1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-10 14:22:35 +03:00

COMMENT ON casts, conversions, languages, operator classes, and

large objects.  Dump all these in pg_dump; also add code to pg_dump
user-defined conversions.  Make psql's large object code rely on
the backend for inserting/deleting LOB comments, instead of trying to
hack pg_description directly.  Documentation and regression tests added.

Christopher Kings-Lynne, code reviewed by Tom
This commit is contained in:
Tom Lane
2003-11-21 22:32:49 +00:00
parent 0a97cb37fc
commit 42ce74bf17
37 changed files with 879 additions and 55 deletions

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.29 2003/08/04 23:59:40 tgl Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.30 2003/11/21 22:32:49 tgl Exp $
*/
#include "postgres_fe.h"
#include "large_obj.h"
@@ -165,9 +165,7 @@ do_lo_import(const char *filename_arg, const char *comment_arg)
}
/* insert description if given */
/* XXX don't try to hack pg_description if not superuser */
/* XXX ought to replace this with some kind of COMMENT command */
if (comment_arg && is_superuser())
if (comment_arg)
{
char *cmdbuf;
char *bufptr;
@@ -177,9 +175,7 @@ do_lo_import(const char *filename_arg, const char *comment_arg)
if (!cmdbuf)
return fail_lo_xact("\\lo_import", own_transaction);
sprintf(cmdbuf,
"INSERT INTO pg_catalog.pg_description VALUES ('%u', "
"'pg_catalog.pg_largeobject'::regclass, "
"0, '",
"COMMENT ON LARGE OBJECT %u IS '",
loid);
bufptr = cmdbuf + strlen(cmdbuf);
for (i = 0; i < slen; i++)
@@ -188,7 +184,7 @@ do_lo_import(const char *filename_arg, const char *comment_arg)
*bufptr++ = '\\';
*bufptr++ = comment_arg[i];
}
strcpy(bufptr, "')");
strcpy(bufptr, "'");
if (!(res = PSQLexec(cmdbuf, false)))
{
@@ -219,10 +215,8 @@ do_lo_import(const char *filename_arg, const char *comment_arg)
bool
do_lo_unlink(const char *loid_arg)
{
PGresult *res;
int status;
Oid loid = atooid(loid_arg);
char buf[256];
bool own_transaction;
if (!start_lo_xact("\\lo_unlink", &own_transaction))
@@ -235,20 +229,6 @@ do_lo_unlink(const char *loid_arg)
return fail_lo_xact("\\lo_unlink", own_transaction);
}
/* remove the comment as well */
/* XXX don't try to hack pg_description if not superuser */
/* XXX ought to replace this with some kind of COMMENT command */
if (is_superuser())
{
snprintf(buf, sizeof(buf),
"DELETE FROM pg_catalog.pg_description WHERE objoid = '%u' "
"AND classoid = 'pg_catalog.pg_largeobject'::regclass",
loid);
if (!(res = PSQLexec(buf, false)))
return fail_lo_xact("\\lo_unlink", own_transaction);
PQclear(res);
}
if (!finish_lo_xact("\\lo_unlink", own_transaction))
return false;