*** ./src/bin/psql/command.c.orig Sat Jun 22 08:51:05 2002 --- ./src/bin/psql/command.c Mon Jun 24 11:59:12 2002 *************** *** 39,44 **** --- 39,46 ---- #include "settings.h" #include "variables.h" + #define _(x) gettext((x)) + #ifdef MULTIBYTE #include "mb/pg_wchar.h" #else *************** *** 134,139 **** --- 136,145 ---- my_line[blank_loc] = '\0'; } + /* \z is an alias to \dp */ + if (my_line[0] == 'z') + my_line = xstrdup("dp"); + status = exec_command(my_line, options_string, &continue_parse, query_buf, paren_level); if (status == CMD_UNKNOWN) *************** *** 155,161 **** * continue_parse must be relative to my_line for calculation * below */ ! continue_parse += my_line - line; #if 0 /* turned out to be too annoying */ if (status != CMD_UNKNOWN && isalpha((unsigned char) new_cmd[0])) --- 161,169 ---- * continue_parse must be relative to my_line for calculation * below */ ! ! if (continue_parse) ! continue_parse += my_line - line; #if 0 /* turned out to be too annoying */ if (status != CMD_UNKNOWN && isalpha((unsigned char) new_cmd[0])) *************** *** 171,177 **** psql_error("invalid command \\%s\n", my_line); status = CMD_ERROR; } - if (continue_parse && *continue_parse && *(continue_parse + 1) == '\\') continue_parse += 2; --- 179,184 ---- *************** *** 201,206 **** --- 208,215 ---- * failed */ bool quiet = QUIET(); backslashResult status = CMD_SKIP_LINE; + PQExpBufferData buf; + PGresult *res; char *string, *string_cpy, *val; *************** *** 214,220 **** string = string_cpy = xstrdup(options_string); else string = string_cpy = NULL; - /* * \a -- toggle field alignment This makes little sense but we keep it * around. --- 223,228 ---- *************** *** 332,356 **** else if (strcmp(cmd, "copyright") == 0) print_copyright(); ! /* \d* commands */ else if (cmd[0] == 'd') { char *name; bool show_verbose; name = scan_option(&string, OT_SQLID, NULL, true); show_verbose = strchr(cmd, '+') ? true : false; switch (cmd[1]) { case '\0': case '+': if (name) ! success = describeTableDetails(name, show_verbose); else /* standard listing of interesting things */ ! success = listTables("tvs", NULL, show_verbose); break; case 'a': success = describeAggregates(name); --- 340,470 ---- else if (strcmp(cmd, "copyright") == 0) print_copyright(); ! /* \d* commands (also \z, which is the same as \dp) */ else if (cmd[0] == 'd') { char *name; + char *schema = NULL; + char *relation = NULL; bool show_verbose; + bool wildcard; + unsigned short int i; + unsigned short int ii; + unsigned short int dots; + char *aa; name = scan_option(&string, OT_SQLID, NULL, true); show_verbose = strchr(cmd, '+') ? true : false; + /* Wildcards: dp dt dv di ds dS */ + + wildcard = strpbrk(&cmd[1],"ptvisS") ? true : false; + + /* No schema lookup: da dD dd df dl do dT du */ + + if (name && !strpbrk(&cmd[1],"aDdfloTu")) + { + if (strchr(name,'.')==NULL) + relation = xstrdup(name); + else /* Got some dots in the name */ + { + for(i=ii=dots=0,aa=name;*aa;aa++) { + if (*aa=='.') + { + if (++dots>1 || (!(*(aa+1)) && !wildcard)) + { + if (!quiet) + fprintf(stderr, + _("\"%s\" is not a valid relation name.\n" + "Relation names must be either be " + "\"name\" or \"schema.name\"\n"), + name); + free(name); free(schema); free(relation); + return true; + } + else if (!(*(aa+1)) && wildcard) + { + if (schema) + schema[i]='\0'; + } + else + { + if (schema) + schema[i] = '\0'; + relation = malloc(NAMEDATALEN+1); + } + } + else if (dots) + { + relation[ii++]=*aa; + if (ii>NAMEDATALEN) + { + if (!quiet) + fprintf(stderr, _("Relation names must be %d characters or less.\n"), NAMEDATALEN); + free(name); free(schema); free(relation); + return true; + } + } + else + { + if (!schema) + schema = malloc(NAMEDATALEN+1); + schema[i++]=*aa; + if (i>NAMEDATALEN) + { + if (!quiet) + fprintf(stderr, _("Schema names must be %d characters or less.\n"), NAMEDATALEN); + free(name); free(schema); + return true; + } + } + } + if (relation) + relation[ii] = '\0'; + } + } /* end if name */ + + /* Find the schema if necessary */ + if (!wildcard && !schema && relation) + { + initPQExpBuffer(&buf); + printfPQExpBuffer(&buf, + "SELECT n.nspname\n" + "FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n\n" + "WHERE c.relname = '%s'\n" + " AND c.relnamespace=n.oid\n" + "ORDER BY (CASE WHEN n.nspname ~ '^pg_temp_' THEN 0\n" + " WHEN n.nspname = 'public' THEN 1\n" + " WHEN n.nspname !~ '^pg_' THEN 2 ELSE 3 END),\n" + " c.oid DESC LIMIT 1", + relation); + + res = PSQLexec(buf.data); + termPQExpBuffer(&buf); + + if (!res || PQntuples(res)==0) + { + if (!quiet) + fprintf(stderr, + _("No relation named \"%s\" was found in any schema.\n"), + relation); + PQclear(res); free(name); free(relation); + return true; + } + PQclear(res); + schema = xstrdup(PQgetvalue(res,0,0)); + } + switch (cmd[1]) { case '\0': case '+': if (name) ! success = describeTableDetails(schema, relation, show_verbose); else /* standard listing of interesting things */ ! success = listTables("tvs", NULL, NULL, show_verbose); break; case 'a': success = describeAggregates(name); *************** *** 368,374 **** success = describeOperators(name); break; case 'p': ! success = permissionsList(name); break; case 'T': success = describeTypes(name, show_verbose); --- 482,488 ---- success = describeOperators(name); break; case 'p': ! success = permissionsList(schema,relation); break; case 'T': success = describeTypes(name, show_verbose); *************** *** 378,384 **** case 'i': case 's': case 'S': ! success = listTables(&cmd[1], name, show_verbose); break; case 'u': success = describeUsers(name); --- 492,498 ---- case 'i': case 's': case 'S': ! success = listTables(&cmd[1], relation, schema, show_verbose); break; case 'u': success = describeUsers(name); *************** *** 390,396 **** default: status = CMD_UNKNOWN; } ! free(name); } --- 504,510 ---- default: status = CMD_UNKNOWN; } ! free(name); free(relation); free(schema); } *************** *** 825,840 **** else if (strcmp(cmd, "x") == 0) success = do_pset("expanded", NULL, &pset.popt, quiet); - - /* \z -- list table rights (grant/revoke) */ - else if (strcmp(cmd, "z") == 0) - { - char *opt = scan_option(&string, OT_SQLID, NULL, true); - - success = permissionsList(opt); - free(opt); - } - /* \! -- shell escape */ else if (strcmp(cmd, "!") == 0) { --- 939,944 ---- *************** *** 950,956 **** * If this is expected to be an SQL identifier like option * then we strip out the double quotes */ ! if (type == OT_SQLID || type == OT_SQLIDHACK) { unsigned int k, --- 1054,1060 ---- * If this is expected to be an SQL identifier like option * then we strip out the double quotes */ ! if (type == OT_SQLID || type == OT_SQLIDHACK) { unsigned int k, *************** *** 1440,1446 **** return false; initPQExpBuffer(&buf); ! printfPQExpBuffer(&buf, "SELECT usesuper FROM pg_user WHERE usename = '%s'", username); res = PSQLexec(buf.data); termPQExpBuffer(&buf); --- 1544,1550 ---- return false; initPQExpBuffer(&buf); ! printfPQExpBuffer(&buf, "SELECT usesuper FROM pg_catalog.pg_user WHERE usename = '%s'", username); res = PSQLexec(buf.data); termPQExpBuffer(&buf); *** ./src/bin/psql/describe.c.orig Sat Jun 22 08:50:52 2002 --- ./src/bin/psql/describe.c Mon Jun 24 11:59:13 2002 *************** *** 45,65 **** * types and ones that work on all (denoted by input type = 0) */ printfPQExpBuffer(&buf, ! "SELECT p.proname AS \"%s\",\n" " CASE p.proargtypes[0]\n" " WHEN 0 THEN CAST('%s' AS text)\n" " ELSE format_type(p.proargtypes[0], NULL)\n" " END AS \"%s\",\n" " obj_description(p.oid, 'pg_proc') as \"%s\"\n" ! "FROM pg_proc p\n" ! "WHERE p.proisagg\n", ! _("Name"), _("(all types)"), _("Data type"), _("Description")); if (name) appendPQExpBuffer(&buf, " AND p.proname ~ '^%s'\n", name); ! appendPQExpBuffer(&buf, "ORDER BY 1, 2;"); res = PSQLexec(buf.data); termPQExpBuffer(&buf); --- 45,66 ---- * types and ones that work on all (denoted by input type = 0) */ printfPQExpBuffer(&buf, ! "SELECT n.nspname AS \"%s\", p.proname AS \"%s\",\n" " CASE p.proargtypes[0]\n" " WHEN 0 THEN CAST('%s' AS text)\n" " ELSE format_type(p.proargtypes[0], NULL)\n" " END AS \"%s\",\n" " obj_description(p.oid, 'pg_proc') as \"%s\"\n" ! "FROM pg_catalog.pg_proc p, pg_namespace n\n" ! "WHERE p.proisagg\n" ! " AND p.pronamespace = n.oid\n", ! _("Schema"), _("Name"), _("(all types)"), _("Data type"), _("Description")); if (name) appendPQExpBuffer(&buf, " AND p.proname ~ '^%s'\n", name); ! appendPQExpBuffer(&buf, "ORDER BY 1, 2, 3;"); res = PSQLexec(buf.data); termPQExpBuffer(&buf); *************** *** 93,126 **** * arguments, but have no types defined for those arguments */ printfPQExpBuffer(&buf, ! "SELECT format_type(p.prorettype, NULL) as \"%s\",\n" ! " p.proname as \"%s\",\n" ! " oidvectortypes(p.proargtypes) as \"%s\"", ! _("Result data type"), _("Name"), _("Argument data types")); if (verbose) appendPQExpBuffer(&buf, ! ",\n u.usename as \"%s\",\n" ! " l.lanname as \"%s\",\n" ! " p.prosrc as \"%s\",\n" ! " obj_description(p.oid, 'pg_proc') as \"%s\"", _("Owner"), _("Language"), _("Source code"), _("Description")); if (!verbose) appendPQExpBuffer(&buf, ! "\nFROM pg_proc p\n" ! "WHERE p.prorettype <> 0 AND (pronargs = 0 OR oidvectortypes(p.proargtypes) <> '') AND NOT p.proisagg\n"); else appendPQExpBuffer(&buf, ! "\nFROM pg_proc p, pg_language l, pg_user u\n" "WHERE p.prolang = l.oid AND p.proowner = u.usesysid\n" ! " AND p.prorettype <> 0 AND (pronargs = 0 OR oidvectortypes(p.proargtypes) <> '') AND NOT p.proisagg\n"); if (name) appendPQExpBuffer(&buf, " AND p.proname ~ '^%s'\n", name); ! appendPQExpBuffer(&buf, "ORDER BY 2, 1, 3;"); res = PSQLexec(buf.data); termPQExpBuffer(&buf); --- 94,135 ---- * arguments, but have no types defined for those arguments */ printfPQExpBuffer(&buf, ! "SELECT format_type(p.prorettype, NULL) AS \"%s\",\n" ! " n.nspname AS \"%s\", p.proname AS \"%s\",\n" ! " oidvectortypes(p.proargtypes) AS \"%s\"", ! _("Result data type"), _("Schema"), _("Name"), _("Argument data types")); if (verbose) appendPQExpBuffer(&buf, ! ",\n u.usename AS \"%s\",\n" ! " l.lanname AS \"%s\",\n" ! " p.prosrc AS \"%s\",\n" ! " obj_description(p.oid, 'pg_proc') AS \"%s\"", _("Owner"), _("Language"), _("Source code"), _("Description")); if (!verbose) appendPQExpBuffer(&buf, ! "\nFROM pg_catalog.pg_proc p, pg_namespace n\n" ! "WHERE p.prorettype <> 0\n" ! " AND (pronargs = 0 OR oidvectortypes(p.proargtypes) <> '')\n" ! " AND NOT p.proisagg\n"); else appendPQExpBuffer(&buf, ! "\nFROM pg_catalog.pg_proc p, pg_catalog.pg_language l,\n" ! " pg_catalog.pg_user u, pg_namespace n\n" "WHERE p.prolang = l.oid AND p.proowner = u.usesysid\n" ! " AND p.prorettype <> 0\n" ! " AND (pronargs = 0 OR oidvectortypes(p.proargtypes) <> '')\n" ! " AND NOT p.proisagg\n"); if (name) appendPQExpBuffer(&buf, " AND p.proname ~ '^%s'\n", name); ! appendPQExpBuffer(&buf, ! " AND p.pronamespace = n.oid\n" ! "ORDER BY (CASE WHEN n.nspname ~ '^pg_temp_' THEN 0\n" ! " WHEN n.nspname !~ '^pg_' THEN 1 ELSE 2 END), 2, 3, 1, 4"); res = PSQLexec(buf.data); termPQExpBuffer(&buf); *************** *** 170,176 **** * do not include array types (start with underscore), do not include * user relations (typrelid!=0) */ ! appendPQExpBuffer(&buf, "FROM pg_type t\nWHERE t.typrelid = 0 AND t.typname !~ '^_.*'\n"); if (name) /* accept either internal or external type name */ --- 179,185 ---- * do not include array types (start with underscore), do not include * user relations (typrelid!=0) */ ! appendPQExpBuffer(&buf, "FROM pg_catalog.pg_type t\nWHERE t.typrelid = 0 AND t.typname !~ '^_.*'\n"); if (name) /* accept either internal or external type name */ *************** *** 207,217 **** printfPQExpBuffer(&buf, "SELECT o.oprname AS \"%s\",\n" ! " CASE WHEN o.oprkind='l' THEN NULL ELSE format_type(o.oprleft, NULL) END AS \"%s\",\n" ! " CASE WHEN o.oprkind='r' THEN NULL ELSE format_type(o.oprright, NULL) END AS \"%s\",\n" " format_type(o.oprresult, NULL) AS \"%s\",\n" " obj_description(o.oprcode, 'pg_proc') AS \"%s\"\n" ! "FROM pg_operator o\n", _("Name"), _("Left arg type"), _("Right arg type"), _("Result type"), _("Description")); if (name) --- 216,230 ---- printfPQExpBuffer(&buf, "SELECT o.oprname AS \"%s\",\n" ! " CASE\n" ! " WHEN o.oprkind='l' THEN NULL ELSE format_type(o.oprleft, NULL)\n" ! " END AS \"%s\",\n" ! " CASE\n" ! " WHEN o.oprkind='r' THEN NULL ELSE format_type(o.oprright, NULL)\n" ! " END AS \"%s\",\n" " format_type(o.oprresult, NULL) AS \"%s\",\n" " obj_description(o.oprcode, 'pg_proc') AS \"%s\"\n" ! "FROM pg_catalog.pg_operator o\n", _("Name"), _("Left arg type"), _("Right arg type"), _("Result type"), _("Description")); if (name) *************** *** 254,260 **** _("Name"), _("Owner")); #ifdef MULTIBYTE appendPQExpBuffer(&buf, ! ",\n pg_encoding_to_char(d.encoding) as \"%s\"", _("Encoding")); #endif if (desc) --- 267,273 ---- _("Name"), _("Owner")); #ifdef MULTIBYTE appendPQExpBuffer(&buf, ! ",\n pg_catalog.pg_encoding_to_char(d.encoding) as \"%s\"", _("Encoding")); #endif if (desc) *************** *** 262,268 **** ",\n obj_description(d.oid, 'pg_database') as \"%s\"", _("Description")); appendPQExpBuffer(&buf, ! "\nFROM pg_database d LEFT JOIN pg_user u ON d.datdba = u.usesysid\n" "ORDER BY 1;"); res = PSQLexec(buf.data); --- 275,282 ---- ",\n obj_description(d.oid, 'pg_database') as \"%s\"", _("Description")); appendPQExpBuffer(&buf, ! "\nFROM pg_catalog.pg_database d\n" ! " LEFT JOIN pg_catalog.pg_user u ON d.datdba = u.usesysid\n" "ORDER BY 1;"); res = PSQLexec(buf.data); *************** *** 285,291 **** * \z (now also \dp -- perhaps more mnemonic) */ bool ! permissionsList(const char *name) { PQExpBufferData buf; PGresult *res; --- 299,305 ---- * \z (now also \dp -- perhaps more mnemonic) */ bool ! permissionsList(const char *schema, const char *relation) { PQExpBufferData buf; PGresult *res; *************** *** 294,309 **** initPQExpBuffer(&buf); /* Currently, we ignore indexes since they have no meaningful rights */ ! printfPQExpBuffer(&buf, ! "SELECT relname as \"%s\",\n" ! " relacl as \"%s\"\n" ! "FROM pg_class\n" ! "WHERE relkind in ('r', 'v', 'S') AND\n" ! " relname NOT LIKE 'pg$_%%' ESCAPE '$'\n", ! _("Table"), _("Access privileges")); ! if (name) ! appendPQExpBuffer(&buf, " AND relname ~ '^%s'\n", name); ! appendPQExpBuffer(&buf, "ORDER BY 1;"); res = PSQLexec(buf.data); if (!res) --- 308,326 ---- initPQExpBuffer(&buf); /* Currently, we ignore indexes since they have no meaningful rights */ ! printfPQExpBuffer(&buf, "SELECT n.nspname as \"%s\",\n" ! " c.relname as \"%s\",\n" ! " c.relacl as \"%s\"\n" ! "FROM pg_catalog.pg_namespace n, pg_catalog.pg_class c\n" ! "WHERE c.relkind in ('r', 'v', 'S')\n" ! " AND n.nspname != 'pg_catalog'\n" ! " AND c.relnamespace = n.oid\n", ! _("Schema"), _("Table"), _("Access privileges")); ! if (relation) ! appendPQExpBuffer(&buf, " AND c.relname ~ '^%s'\n", relation); ! if (schema) ! appendPQExpBuffer(&buf, " AND n.nspname ~ '^%s'\n", schema); ! appendPQExpBuffer(&buf, "ORDER BY (CASE WHEN n.nspname ~ '^pg_temp_' THEN 0 ELSE 1 END), 1,2"); res = PSQLexec(buf.data); if (!res) *************** *** 349,376 **** /* Aggregate descriptions */ " SELECT p.oid as oid, p.tableoid as tableoid,\n" " CAST(p.proname AS text) as name, CAST('%s' AS text) as object\n" ! " FROM pg_proc p\n" " WHERE p.proisagg\n" /* Function descriptions (except in/outs for datatypes) */ "UNION ALL\n" " SELECT p.oid as oid, p.tableoid as tableoid,\n" " CAST(p.proname AS text) as name, CAST('%s' AS text) as object\n" ! " FROM pg_proc p\n" " WHERE (p.pronargs = 0 or oidvectortypes(p.proargtypes) <> '') AND NOT p.proisagg\n" /* Operator descriptions (must get comment via associated function) */ "UNION ALL\n" " SELECT CAST(o.oprcode AS oid) as oid,\n" ! " (SELECT oid FROM pg_class WHERE relname = 'pg_proc') as tableoid,\n" " CAST(o.oprname AS text) as name, CAST('%s' AS text) as object\n" ! " FROM pg_operator o\n" /* Type description */ "UNION ALL\n" " SELECT t.oid as oid, t.tableoid as tableoid,\n" " format_type(t.oid, NULL) as name, CAST('%s' AS text) as object\n" ! " FROM pg_type t\n" /* Relation (tables, views, indexes, sequences) descriptions */ "UNION ALL\n" --- 366,393 ---- /* Aggregate descriptions */ " SELECT p.oid as oid, p.tableoid as tableoid,\n" " CAST(p.proname AS text) as name, CAST('%s' AS text) as object\n" ! " FROM pg_catalog.pg_proc p\n" " WHERE p.proisagg\n" /* Function descriptions (except in/outs for datatypes) */ "UNION ALL\n" " SELECT p.oid as oid, p.tableoid as tableoid,\n" " CAST(p.proname AS text) as name, CAST('%s' AS text) as object\n" ! " FROM pg_catalog.pg_proc p\n" " WHERE (p.pronargs = 0 or oidvectortypes(p.proargtypes) <> '') AND NOT p.proisagg\n" /* Operator descriptions (must get comment via associated function) */ "UNION ALL\n" " SELECT CAST(o.oprcode AS oid) as oid,\n" ! " (SELECT oid FROM pg_catalog.pg_class WHERE relname = 'pg_proc') as tableoid,\n" " CAST(o.oprname AS text) as name, CAST('%s' AS text) as object\n" ! " FROM pg_catalog.pg_operator o\n" /* Type description */ "UNION ALL\n" " SELECT t.oid as oid, t.tableoid as tableoid,\n" " format_type(t.oid, NULL) as name, CAST('%s' AS text) as object\n" ! " FROM pg_catalog.pg_type t\n" /* Relation (tables, views, indexes, sequences) descriptions */ "UNION ALL\n" *************** *** 379,401 **** " CAST(\n" " CASE c.relkind WHEN 'r' THEN '%s' WHEN 'v' THEN '%s' WHEN 'i' THEN '%s' WHEN 'S' THEN '%s' END" " AS text) as object\n" ! " FROM pg_class c\n" /* Rule description (ignore rules for views) */ "UNION ALL\n" " SELECT r.oid as oid, r.tableoid as tableoid,\n" " CAST(r.rulename AS text) as name, CAST('%s' AS text) as object\n" ! " FROM pg_rewrite r\n" " WHERE r.rulename != '_RETURN'\n" /* Trigger description */ "UNION ALL\n" " SELECT t.oid as oid, t.tableoid as tableoid,\n" " CAST(t.tgname AS text) as name, CAST('%s' AS text) as object\n" ! " FROM pg_trigger t\n" ") AS tt,\n" ! "pg_description d\n" "WHERE tt.oid = d.objoid and tt.tableoid = d.classoid and d.objsubid = 0\n", _("Name"), _("Object"), _("Description"), --- 396,418 ---- " CAST(\n" " CASE c.relkind WHEN 'r' THEN '%s' WHEN 'v' THEN '%s' WHEN 'i' THEN '%s' WHEN 'S' THEN '%s' END" " AS text) as object\n" ! " FROM pg_catalog.pg_class c\n" /* Rule description (ignore rules for views) */ "UNION ALL\n" " SELECT r.oid as oid, r.tableoid as tableoid,\n" " CAST(r.rulename AS text) as name, CAST('%s' AS text) as object\n" ! " FROM pg_catalog.pg_rewrite r\n" " WHERE r.rulename != '_RETURN'\n" /* Trigger description */ "UNION ALL\n" " SELECT t.oid as oid, t.tableoid as tableoid,\n" " CAST(t.tgname AS text) as name, CAST('%s' AS text) as object\n" ! " FROM pg_catalog.pg_trigger t\n" ") AS tt,\n" ! "pg_catalog.pg_description d\n" "WHERE tt.oid = d.objoid and tt.tableoid = d.classoid and d.objsubid = 0\n", _("Name"), _("Object"), _("Description"), *************** *** 407,413 **** if (object) appendPQExpBuffer(&buf, " AND tt.name ~ '^%s'\n", object); ! appendPQExpBuffer(&buf, "ORDER BY 1;"); res = PSQLexec(buf.data); termPQExpBuffer(&buf); --- 424,430 ---- if (object) appendPQExpBuffer(&buf, " AND tt.name ~ '^%s'\n", object); ! appendPQExpBuffer(&buf, "ORDER BY 1, 2, 3;"); res = PSQLexec(buf.data); termPQExpBuffer(&buf); *************** *** 450,456 **** bool ! describeTableDetails(const char *name, bool desc) { PQExpBufferData buf; PGresult *res = NULL; --- 467,473 ---- bool ! describeTableDetails(const char *schema, const char *relation, bool desc) { PQExpBufferData buf; PGresult *res = NULL; *************** *** 472,488 **** bool hasrules; } tableinfo; bool retval; - retval = false; initPQExpBuffer(&buf); initPQExpBuffer(&title); ! /* Get general table info */ printfPQExpBuffer(&buf, ! "SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules\n" ! "FROM pg_class WHERE relname='%s'", ! name); res = PSQLexec(buf.data); if (!res) goto error_return; --- 489,507 ---- bool hasrules; } tableinfo; bool retval; retval = false; initPQExpBuffer(&buf); initPQExpBuffer(&title); ! /* Get general table info (and the schema name) */ printfPQExpBuffer(&buf, ! "SELECT c.relhasindex, c.relkind, c.relchecks, c.reltriggers, c.relhasrules\n" ! "FROM pg_catalog.pg_namespace n, pg_catalog.pg_class c\n" ! "WHERE n.nspname = '%s' AND c.relname = '%s'\n" ! " AND c.relnamespace = n.oid", ! schema, relation); ! res = PSQLexec(buf.data); if (!res) goto error_return; *************** *** 491,497 **** if (PQntuples(res) == 0) { if (!QUIET()) ! fprintf(stderr, _("Did not find any relation named \"%s\".\n"), name); PQclear(res); res = NULL; goto error_return; --- 510,516 ---- if (PQntuples(res) == 0) { if (!QUIET()) ! fprintf(stderr, _("Did not find any relation named \"%s.%s\".\n"), schema, relation); PQclear(res); res = NULL; goto error_return; *************** *** 505,511 **** tableinfo.hasrules = strcmp(PQgetvalue(res, 0, 4), "t") == 0; PQclear(res); - headers[0] = _("Column"); headers[1] = _("Type"); cols = 2; --- 524,529 ---- *************** *** 524,545 **** headers[cols] = NULL; - /* Get column info (index requires additional checks) */ if (tableinfo.relkind == 'i') ! printfPQExpBuffer(&buf, "SELECT\n CASE i.indproc WHEN ('-'::regproc) THEN a.attname\n ELSE SUBSTR(pg_get_indexdef(attrelid),\n POSITION('(' in pg_get_indexdef(attrelid)))\n END, "); else printfPQExpBuffer(&buf, "SELECT a.attname, "); ! appendPQExpBuffer(&buf, "format_type(a.atttypid, a.atttypmod), a.attnotnull, a.atthasdef, a.attnum"); if (desc) appendPQExpBuffer(&buf, ", col_description(a.attrelid, a.attnum)"); ! appendPQExpBuffer(&buf, "\nFROM pg_class c, pg_attribute a"); if (tableinfo.relkind == 'i') ! appendPQExpBuffer(&buf, ", pg_index i"); ! appendPQExpBuffer(&buf, "\nWHERE c.relname = '%s'\n AND a.attnum > 0 AND a.attrelid = c.oid", name); if (tableinfo.relkind == 'i') ! appendPQExpBuffer(&buf, " AND a.attrelid = i.indexrelid"); ! appendPQExpBuffer(&buf, "\nORDER BY a.attnum"); res = PSQLexec(buf.data); if (!res) --- 542,575 ---- headers[cols] = NULL; /* Get column info (index requires additional checks) */ if (tableinfo.relkind == 'i') ! printfPQExpBuffer(&buf, "SELECT\n" ! " CASE i.indproc\n" ! " WHEN ('-'::regproc) THEN a.attname\n" ! " ELSE SUBSTR(pg_catalog.pg_get_indexdef(attrelid),\n" ! " POSITION('(' in pg_catalog.pg_get_indexdef(attrelid)))\n" ! " END, "); else printfPQExpBuffer(&buf, "SELECT a.attname, "); ! appendPQExpBuffer(&buf, ! "format_type(a.atttypid, a.atttypmod), a.attnotnull,\n" ! " a.atthasdef, a.attnum"); if (desc) appendPQExpBuffer(&buf, ", col_description(a.attrelid, a.attnum)"); ! appendPQExpBuffer(&buf, ! "\nFROM pg_catalog.pg_attribute a,\n" ! " pg_catalog.pg_namespace n, pg_catalog.pg_class c\n"); if (tableinfo.relkind == 'i') ! appendPQExpBuffer(&buf, ", pg_catalog.pg_index i"); ! appendPQExpBuffer(&buf, ! "\nWHERE n.nspname = '%s' AND c.relname = '%s'\n" ! " AND c.relnamespace = n.oid\n" ! " AND a.attnum > 0 AND a.attrelid = c.oid\n", ! schema, relation); if (tableinfo.relkind == 'i') ! appendPQExpBuffer(&buf, " AND a.attrelid = i.indexrelid\n"); ! appendPQExpBuffer(&buf, "ORDER BY a.attnum"); res = PSQLexec(buf.data); if (!res) *************** *** 550,556 **** { PGresult *result; ! printfPQExpBuffer(&buf, "SELECT definition FROM pg_views WHERE viewname = '%s'", name); result = PSQLexec(buf.data); if (!result) { --- 580,590 ---- { PGresult *result; ! printfPQExpBuffer(&buf, ! "SELECT definition FROM pg_catalog.pg_views\n" ! "WHERE schemaname='%s'\n" ! " AND viewname = '%s'", ! schema, relation); result = PSQLexec(buf.data); if (!result) { *************** *** 593,601 **** PGresult *result; printfPQExpBuffer(&buf, ! "SELECT substring(d.adsrc for 128) FROM pg_attrdef d, pg_class c\n" ! "WHERE c.relname = '%s' AND c.oid = d.adrelid AND d.adnum = %s", ! name, PQgetvalue(res, i, 4)); result = PSQLexec(buf.data); --- 627,639 ---- PGresult *result; printfPQExpBuffer(&buf, ! "SELECT substring(d.adsrc for 128)\n" ! "FROM pg_catalog.pg_attrdef d, pg_catalog.pg_namespace n, pg_catalog.pg_class c n\n" ! "WHERE n.nspname = '%s' AND c.relname = '%s'\n" ! " AND c.relnamespace = n.oid\n" ! " AND c.oid = d.adrelid\n" ! " AND d.adnum = %s", ! schema, relation, PQgetvalue(res, i, 4)); result = PSQLexec(buf.data); *************** *** 617,641 **** switch (tableinfo.relkind) { case 'r': ! printfPQExpBuffer(&title, _("Table \"%s\""), name); break; case 'v': ! printfPQExpBuffer(&title, _("View \"%s\""), name); break; case 'S': ! printfPQExpBuffer(&title, _("Sequence \"%s\""), name); break; case 'i': ! printfPQExpBuffer(&title, _("Index \"%s\""), name); break; case 's': ! printfPQExpBuffer(&title, _("Special relation \"%s\""), name); break; case 't': ! printfPQExpBuffer(&title, _("TOAST table \"%s\""), name); break; default: ! printfPQExpBuffer(&title, _("?%c? \"%s\""), tableinfo.relkind, name); break; } --- 655,679 ---- switch (tableinfo.relkind) { case 'r': ! printfPQExpBuffer(&title, _("Table \"%s.%s\""), schema,relation); break; case 'v': ! printfPQExpBuffer(&title, _("View \"%s.%s\""), schema,relation); break; case 'S': ! printfPQExpBuffer(&title, _("Sequence \"%s.%s\""), schema,relation); break; case 'i': ! printfPQExpBuffer(&title, _("Index \"%s.%s\""), schema,relation); break; case 's': ! printfPQExpBuffer(&title, _("Special relation \"%s.%s\""), schema,relation); break; case 't': ! printfPQExpBuffer(&title, _("TOAST table \"%s.%s\""), schema,relation); break; default: ! printfPQExpBuffer(&title, _("?%c? \"%s.%s\""), tableinfo.relkind, schema,relation); break; } *************** *** 645,657 **** /* Footer information about an index */ PGresult *result; printfPQExpBuffer(&buf, ! "SELECT i.indisunique, i.indisprimary, a.amname, c2.relname,\n" ! "pg_get_expr(i.indpred,i.indrelid)\n" ! "FROM pg_index i, pg_class c, pg_class c2, pg_am a\n" ! "WHERE i.indexrelid = c.oid AND c.relname = '%s' AND c.relam = a.oid\n" ! "AND i.indrelid = c2.oid", ! name); ! result = PSQLexec(buf.data); if (!result) goto error_return; --- 683,700 ---- /* Footer information about an index */ PGresult *result; printfPQExpBuffer(&buf, ! "SELECT i.indisunique, i.indisprimary, a.amname,\n" ! " n2.nspname ||'.'|| c2.relname,\n" ! " pg_catalog.pg_get_expr(i.indpred,i.indrelid)\n" ! "FROM pg_catalog.pg_am a, pg_catalog.pg_index i, pg_catalog.pg_namespace n,\n" ! " pg_catalog.pg_namespace n2, pg_catalog.pg_class c, pg_catalog.pg_class c2\n" ! "WHERE n.nspname = '%s' AND c.relname = '%s'\n" ! " AND c.relnamespace = n.oid\n" ! " AND c.relam = a.oid\n" ! " AND i.indexrelid = c.oid\n" ! " AND i.indrelid = c2.oid\n" ! " AND c2.relnamespace = n2.oid\n", ! schema, relation); result = PSQLexec(buf.data); if (!result) goto error_return; *************** *** 679,684 **** --- 722,728 ---- resetPQExpBuffer(&tmpbuf); appendPQExpBuffer(&tmpbuf, "%s, ", indamname); + /* indtable is actually schema.relation */ appendPQExpBuffer(&tmpbuf, _("for table \"%s\""), indtable); if (strlen(indpred)) appendPQExpBuffer(&tmpbuf, ", predicate %s", indpred); *************** *** 701,711 **** if (tableinfo.hasrules) { printfPQExpBuffer(&buf, ! "SELECT r.rulename\n" ! "FROM pg_rewrite r, pg_class c\n" ! "WHERE c.relname = '%s' AND c.oid = r.ev_class\n" ! "AND r.rulename != '_RETURN'", ! name); result = PSQLexec(buf.data); if (!result) goto error_return; --- 745,757 ---- if (tableinfo.hasrules) { printfPQExpBuffer(&buf, ! "SELECT r.rulename\n" ! "FROM pg_catalog.pg_rewrite r, pg_catalog.pg_namespace n, pg_catalog.pg_class c\n" ! "WHERE n.nspname = '%s' AND c.relname = '%s'\n" ! " AND c.relnamespace = n.oid\n" ! " AND c.oid = r.ev_class\n" ! " AND r.rulename != '_RETURN'", ! schema, relation); result = PSQLexec(buf.data); if (!result) goto error_return; *************** *** 756,768 **** if (tableinfo.hasindex) { printfPQExpBuffer(&buf, ! "SELECT c2.relname, i.indisprimary, i.indisunique,\n" ! "SUBSTR(pg_get_indexdef(i.indexrelid),\n" ! "POSITION('USING ' IN pg_get_indexdef(i.indexrelid))+5)\n" ! "FROM pg_class c, pg_class c2, pg_index i\n" ! "WHERE c.relname = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n" "ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname", ! name); result1 = PSQLexec(buf.data); if (!result1) goto error_return; --- 802,819 ---- if (tableinfo.hasindex) { printfPQExpBuffer(&buf, ! "SELECT n2.nspname ||'.'|| c2.relname, i.indisprimary, i.indisunique,\n" ! " SUBSTR(pg_catalog.pg_get_indexdef(i.indexrelid),\n" ! " POSITION('USING ' IN pg_catalog.pg_get_indexdef(i.indexrelid))+5)\n" ! "FROM pg_catalog.pg_index i, pg_catalog.pg_namespace n,\n" ! "pg_catalog.pg_namespace n2, pg_catalog.pg_class c, pg_catalog.pg_class c2\n" ! "WHERE n.nspname = '%s' AND c.relname = '%s'\n" ! " AND c.relnamespace = n.oid\n" ! " AND c.oid = i.indrelid\n" ! " AND i.indexrelid = c2.oid\n" ! " AND c2.relnamespace = n2.oid\n" "ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname", ! schema,relation); result1 = PSQLexec(buf.data); if (!result1) goto error_return; *************** *** 774,783 **** if (tableinfo.checks) { printfPQExpBuffer(&buf, ! "SELECT rcsrc, rcname\n" ! "FROM pg_relcheck r, pg_class c\n" ! "WHERE c.relname='%s' AND c.oid = r.rcrelid", ! name); result2 = PSQLexec(buf.data); if (!result2) goto error_return; --- 825,836 ---- if (tableinfo.checks) { printfPQExpBuffer(&buf, ! "SELECT r.rcsrc, r.rcname\n" ! "FROM pg_catalog.pg_relcheck r, pg_catalog.pg_namespace n, pg_catalog.pg_class c\n" ! "WHERE n.nspname = '%s' AND c.relname = '%s'\n" ! " AND c.relnamespace = n.oid\n" ! " AND c.oid = r.rcrelid", ! schema, relation); result2 = PSQLexec(buf.data); if (!result2) goto error_return; *************** *** 790,798 **** { printfPQExpBuffer(&buf, "SELECT r.rulename\n" ! "FROM pg_rewrite r, pg_class c\n" ! "WHERE c.relname='%s' AND c.oid = r.ev_class", ! name); result3 = PSQLexec(buf.data); if (!result3) goto error_return; --- 843,853 ---- { printfPQExpBuffer(&buf, "SELECT r.rulename\n" ! "FROM pg_catalog.pg_rewrite r, pg_catalog.pg_namespace n, pg_class c\n" ! "WHERE n.nspname = '%s' AND c.relname = '%s'\n" ! " AND c.relnamespace = n.oid\n" ! " AND c.oid = r.ev_class", ! schema, relation); result3 = PSQLexec(buf.data); if (!result3) goto error_return; *************** *** 805,813 **** { printfPQExpBuffer(&buf, "SELECT t.tgname\n" ! "FROM pg_trigger t, pg_class c\n" ! "WHERE c.relname='%s' AND c.oid = t.tgrelid", ! name); result4 = PSQLexec(buf.data); if (!result4) goto error_return; --- 860,870 ---- { printfPQExpBuffer(&buf, "SELECT t.tgname\n" ! "FROM pg_catalog.pg_trigger t, pg_catalog.pg_namespace n, pg_catalog.pg_class c\n" ! "WHERE n.nspname='%s' AND c.relname = '%s'\n" ! " AND c.relnamespace = n.oid\n" ! " AND c.oid = t.tgrelid", ! schema, relation); result4 = PSQLexec(buf.data); if (!result4) goto error_return; *************** *** 960,966 **** " WHEN u.usecreatedb THEN CAST('%s' AS text)\n" " ELSE CAST('' AS text)\n" " END AS \"%s\"\n" ! "FROM pg_user u\n", _("User name"), _("User ID"), _("superuser, create database"), _("superuser"), _("create database"), --- 1017,1023 ---- " WHEN u.usecreatedb THEN CAST('%s' AS text)\n" " ELSE CAST('' AS text)\n" " END AS \"%s\"\n" ! "FROM pg_catalog.pg_user u\n", _("User name"), _("User ID"), _("superuser, create database"), _("superuser"), _("create database"), *************** *** 994,1008 **** * i - indexes * v - views * s - sequences ! * S - systems tables (~ '^pg_') * (any order of the above is fine) * * Note: For some reason it always happens to people that their tables have owners ! * that are no longer in pg_user; consequently they wouldn't show up here. The code * tries to fix this the painful way, hopefully outer joins will be done sometime. */ bool ! listTables(const char *infotype, const char *name, bool desc) { bool showTables = strchr(infotype, 't') != NULL; bool showIndexes = strchr(infotype, 'i') != NULL; --- 1051,1065 ---- * i - indexes * v - views * s - sequences ! * S - systems tables (~ '^pg_' AND !~ '^pg_temp_') * (any order of the above is fine) * * Note: For some reason it always happens to people that their tables have owners ! * that are no longer in pg_catalog.pg_user; consequently they wouldn't show up here. The code * tries to fix this the painful way, hopefully outer joins will be done sometime. */ bool ! listTables(const char *infotype, const char *relation, const char *schema, bool desc) { bool showTables = strchr(infotype, 't') != NULL; bool showIndexes = strchr(infotype, 'i') != NULL; *************** *** 1020,1030 **** initPQExpBuffer(&buf); printfPQExpBuffer(&buf, ! "SELECT c.relname as \"%s\",\n" ! " CASE c.relkind WHEN 'r' THEN '%s' WHEN 'v' THEN '%s' WHEN 'i' THEN '%s' WHEN 'S' THEN '%s' WHEN 's' THEN '%s' END as \"%s\",\n" " u.usename as \"%s\"", ! _("Name"), _("table"), _("view"), _("index"), _("sequence"), ! _("special"), _("Type"), _("Owner")); if (desc) appendPQExpBuffer(&buf, --- 1077,1090 ---- initPQExpBuffer(&buf); printfPQExpBuffer(&buf, ! "SELECT n.nspname as \"%s\", c.relname as \"%s\",\n" ! " CASE c.relkind\n" ! " WHEN 'r' THEN '%s' WHEN 'v' THEN '%s' WHEN 'i' THEN '%s'\n" ! " WHEN 'S' THEN '%s' WHEN 's' THEN '%s'\n" ! " END as \"%s\",\n" " u.usename as \"%s\"", ! _("Schema"), _("Name"), _("table"), _("view"), _("index"), ! _("sequence"), _("special"), _("Type"), _("Owner")); if (desc) appendPQExpBuffer(&buf, *************** *** 1032,1048 **** _("Description")); if (showIndexes) appendPQExpBuffer(&buf, ! ",\n c2.relname as \"%s\"" ! "\nFROM pg_class c, pg_class c2, pg_index i, pg_user u\n" "WHERE c.relowner = u.usesysid\n" ! "AND i.indrelid = c2.oid AND i.indexrelid = c.oid\n", _("Table")); else appendPQExpBuffer(&buf, ! "\nFROM pg_class c, pg_user u\n" "WHERE c.relowner = u.usesysid\n"); ! appendPQExpBuffer(&buf, "AND c.relkind IN ("); if (showTables) appendPQExpBuffer(&buf, "'r',"); if (showViews) --- 1092,1111 ---- _("Description")); if (showIndexes) appendPQExpBuffer(&buf, ! ",\n n2.nspname||'.'||c2.relname as \"%s\"\n" ! "FROM pg_catalog.pg_index i, pg_catalog.pg_user u,\n" ! " pg_catalog.pg_namespace n, pg_catalog.pg_namespace n2,\n" ! " pg_catalog.pg_class c, pg_catalog.pg_class c2\n" "WHERE c.relowner = u.usesysid\n" ! " AND i.indrelid = c2.oid AND c2.relnamespace = n2.oid\n" ! " AND i.indexrelid = c.oid\n", _("Table")); else appendPQExpBuffer(&buf, ! "\nFROM pg_catalog.pg_class c, pg_catalog.pg_user u, pg_catalog.pg_namespace n\n" "WHERE c.relowner = u.usesysid\n"); ! appendPQExpBuffer(&buf, " AND c.relkind IN ("); if (showTables) appendPQExpBuffer(&buf, "'r',"); if (showViews) *************** *** 1057,1070 **** appendPQExpBuffer(&buf, ")\n"); if (showSystem) ! appendPQExpBuffer(&buf, " AND c.relname ~ '^pg_'\n"); else ! appendPQExpBuffer(&buf, " AND c.relname !~ '^pg_'\n"); ! if (name) ! appendPQExpBuffer(&buf, " AND c.relname ~ '^%s'\n", name); ! appendPQExpBuffer(&buf, "ORDER BY 1;"); res = PSQLexec(buf.data); termPQExpBuffer(&buf); --- 1120,1137 ---- appendPQExpBuffer(&buf, ")\n"); if (showSystem) ! appendPQExpBuffer(&buf, " AND (n.nspname !~ '^pg_temp_' AND n.nspname ~ '^pg_')\n"); else ! appendPQExpBuffer(&buf, " AND (n.nspname ~ '^pg_temp_' OR n.nspname !~ '^pg_')\n"); ! if (relation) ! appendPQExpBuffer(&buf, " AND c.relname ~ '^%s'\n", relation); ! if (schema) ! appendPQExpBuffer(&buf, " AND n.nspname ~ '^%s'\n", schema); ! appendPQExpBuffer(&buf, ! " AND c.relnamespace = n.oid\n" ! "ORDER BY (CASE WHEN n.nspname ~ '^pg_temp_' THEN 0 ELSE 1 END), 1, 2, 3"); res = PSQLexec(buf.data); termPQExpBuffer(&buf); *************** *** 1073,1079 **** if (PQntuples(res) == 0 && !QUIET()) { ! if (name) fprintf(pset.queryFout, _("No matching relations found.\n")); else fprintf(pset.queryFout, _("No relations found.\n")); --- 1140,1146 ---- if (PQntuples(res) == 0 && !QUIET()) { ! if (relation) fprintf(pset.queryFout, _("No matching relations found.\n")); else fprintf(pset.queryFout, _("No relations found.\n")); *************** *** 1108,1126 **** printfPQExpBuffer(&buf, "SELECT t.typname as \"%s\",\n" ! " format_type(t.typbasetype, t.typtypmod) as \"%s\",\n" ! " CASE WHEN t.typnotnull AND t.typdefault IS NOT NULL THEN 'not null default '||t.typdefault\n" ! " WHEN t.typnotnull AND t.typdefault IS NULL THEN 'not null'\n" ! " WHEN NOT t.typnotnull AND t.typdefault IS NOT NULL THEN 'default '||t.typdefault\n" ! " ELSE ''\n" ! " END as \"%s\"\n" ! "FROM pg_type t\n" "WHERE t.typtype = 'd'\n", _("Name"), _("Type"), _("Modifier")); if (name) ! appendPQExpBuffer(&buf, "AND t.typname ~ '^%s'\n", name); appendPQExpBuffer(&buf, "ORDER BY 1;"); res = PSQLexec(buf.data); --- 1175,1194 ---- printfPQExpBuffer(&buf, "SELECT t.typname as \"%s\",\n" ! " format_type(t.typbasetype, t.typtypmod) as \"%s\",\n" ! " CASE WHEN t.typnotnull AND t.typdefault IS NOT NULL\n" ! " THEN 'not null default '||t.typdefault\n" ! " WHEN t.typnotnull AND t.typdefault IS NULL THEN 'not null'\n" ! " WHEN NOT t.typnotnull AND t.typdefault IS NOT NULL\n" ! " THEN 'default '||t.typdefault ELSE ''\n" ! " END as \"%s\"\n" ! "FROM pg_catalog.pg_type t\n" "WHERE t.typtype = 'd'\n", _("Name"), _("Type"), _("Modifier")); if (name) ! appendPQExpBuffer(&buf, " AND t.typname ~ '^%s'\n", name); appendPQExpBuffer(&buf, "ORDER BY 1;"); res = PSQLexec(buf.data); *** ./src/bin/psql/describe.h.orig Sat Jun 22 08:51:14 2002 --- ./src/bin/psql/describe.h Mon Jun 24 11:59:13 2002 *************** *** 26,44 **** bool describeUsers(const char *name); /* \z (or \dp) */ ! bool permissionsList(const char *name); /* \dd */ bool objectDescription(const char *object); /* \d foo */ ! bool describeTableDetails(const char *name, bool desc); /* \l */ bool listAllDbs(bool desc); /* \dt, \di, \ds, \dS, etc. */ ! bool listTables(const char *infotype, const char *name, bool desc); /* \dD */ bool listDomains(const char *name); --- 26,44 ---- bool describeUsers(const char *name); /* \z (or \dp) */ ! bool permissionsList(const char *schema, const char *name); /* \dd */ bool objectDescription(const char *object); /* \d foo */ ! bool describeTableDetails(const char *schema, const char *relation, bool desc); /* \l */ bool listAllDbs(bool desc); /* \dt, \di, \ds, \dS, etc. */ ! bool listTables(const char *infotype, const char *relation, const char *schema, bool desc); /* \dD */ bool listDomains(const char *name); *** ./src/bin/psql/help.c.orig Mon Jun 24 11:39:07 2002 --- ./src/bin/psql/help.c Mon Jun 24 11:45:37 2002 *************** *** 321,327 **** { puts( "PostgreSQL Data Base Management System\n\n" ! "Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group\n\n" "This software is based on Postgres95, formerly known as Postgres, which\n" "contains the following notice:\n\n" "Portions Copyright(c) 1994 - 7 Regents of the University of California\n\n" --- 321,327 ---- { puts( "PostgreSQL Data Base Management System\n\n" ! "Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group\n\n" "This software is based on Postgres95, formerly known as Postgres, which\n" "contains the following notice:\n\n" "Portions Copyright(c) 1994 - 7 Regents of the University of California\n\n" *** ./src/bin/psql/large_obj.c.orig Sun Jun 23 15:03:39 2002 --- ./src/bin/psql/large_obj.c Sun Jun 23 16:24:01 2002 *************** *** 209,216 **** return false; } sprintf(cmdbuf, ! "INSERT INTO pg_description VALUES ('%u', " ! "(SELECT oid FROM pg_class WHERE relname = 'pg_largeobject')," " 0, '", loid); bufptr = cmdbuf + strlen(cmdbuf); for (i = 0; i < slen; i++) --- 209,216 ---- return false; } sprintf(cmdbuf, ! "INSERT INTO pg_catalog.pg_description VALUES ('%u', " ! "(SELECT oid FROM pg_catalog.pg_class WHERE relname = 'pg_largeobject')," " 0, '", loid); bufptr = cmdbuf + strlen(cmdbuf); for (i = 0; i < slen; i++) *************** *** 310,317 **** /* XXX ought to replace this with some kind of COMMENT command */ if (pset.issuper) { ! sprintf(buf, "DELETE FROM pg_description WHERE objoid = '%u' " ! "AND classoid = (SELECT oid FROM pg_class WHERE relname = 'pg_largeobject')", loid); if (!(res = PSQLexec(buf))) { --- 310,317 ---- /* XXX ought to replace this with some kind of COMMENT command */ if (pset.issuper) { ! sprintf(buf, "DELETE FROM pg_catalog.pg_description WHERE objoid = '%u' " ! "AND classoid = (SELECT oid FROM pg_catalog.pg_class WHERE relname = 'pg_largeobject')", loid); if (!(res = PSQLexec(buf))) { *************** *** 357,363 **** snprintf(buf, sizeof(buf), "SELECT loid as \"ID\", obj_description(loid, 'pg_largeobject') as \"%s\"\n" ! "FROM (SELECT DISTINCT loid FROM pg_largeobject) x\n" "ORDER BY \"ID\"", gettext("Description")); --- 357,363 ---- snprintf(buf, sizeof(buf), "SELECT loid as \"ID\", obj_description(loid, 'pg_largeobject') as \"%s\"\n" ! "FROM (SELECT DISTINCT loid FROM pg_catalog.pg_largeobject) x\n" "ORDER BY \"ID\"", gettext("Description"));