-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Attached is my "backslash consistency" patch which basically makes all the backslash commands behave as \dt does: \d* shows non-system objects, and \d*S shows system objects. See the archives for more discussion on this. I wrote this patch some time ago, and have been meaning to work on enhancing the tab-completion stuff more. However, I'm going to leave it as it is for now[1], and I've updated my patch to the recent cvs. This was done hastily, so it definitely needs a looking over. [1] I'd like to eventually fix psql so that \di [tab] only lists schemas that actually contain possible indexes (or indexes), rather than the current behavior which is to just list all schemas. - -- Greg Sabino Mullane [EMAIL PROTECTED] PGP Key: 0x14964AC8 200505261242 http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 -----BEGIN PGP SIGNATURE----- iD8DBQFClfyjvJuQZxSWSsgRAv4aAJ48KPwfzYGpU80KcjS9/obMqKMK0wCgx+M0 hCAJLpFXpj72anOnb+2E0yg= =ezLT -----END PGP SIGNATURE-----
Index: command.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/command.c,v retrieving revision 1.143 diff -c -r1.143 command.c *** command.c 29 Apr 2005 13:42:20 -0000 1.143 --- command.c 26 May 2005 20:09:37 -0000 *************** *** 298,310 **** else if (cmd[0] == 'd') { char *pattern; ! bool show_verbose; /* We don't do SQLID reduction on the pattern yet */ pattern = psql_scan_slash_option(scan_state, OT_NORMAL, NULL, true); show_verbose = strchr(cmd, '+') ? true : false; switch (cmd[1]) { --- 298,311 ---- else if (cmd[0] == 'd') { char *pattern; ! bool show_verbose, show_system; /* We don't do SQLID reduction on the pattern yet */ pattern = psql_scan_slash_option(scan_state, OT_NORMAL, NULL, true); show_verbose = strchr(cmd, '+') ? true : false; + show_system = strchr(cmd, 'S') ? true: false; switch (cmd[1]) { *************** *** 314,341 **** success = describeTableDetails(pattern, show_verbose); else /* standard listing of interesting things */ ! success = listTables("tvs", NULL, show_verbose); break; case 'a': ! success = describeAggregates(pattern, show_verbose); break; case 'b': success = describeTablespaces(pattern, show_verbose); break; case 'c': ! success = listConversions(pattern); break; case 'C': success = listCasts(pattern); break; case 'd': ! success = objectDescription(pattern); break; case 'D': ! success = listDomains(pattern); break; case 'f': ! success = describeFunctions(pattern, show_verbose); break; case 'g': success = describeGroups(pattern); --- 315,342 ---- success = describeTableDetails(pattern, show_verbose); else /* standard listing of interesting things */ ! success = listTables("tvs", NULL, show_verbose, show_system); break; case 'a': ! success = describeAggregates(pattern, show_verbose, show_system); break; case 'b': success = describeTablespaces(pattern, show_verbose); break; case 'c': ! success = listConversions(pattern, show_system); break; case 'C': success = listCasts(pattern); break; case 'd': ! success = objectDescription(pattern, show_system); break; case 'D': ! success = listDomains(pattern, show_system); break; case 'f': ! success = describeFunctions(pattern, show_verbose, show_system); break; case 'g': success = describeGroups(pattern); *************** *** 347,366 **** success = listSchemas(pattern, show_verbose); break; case 'o': ! success = describeOperators(pattern); break; case 'p': success = permissionsList(pattern); break; case 'T': ! success = describeTypes(pattern, show_verbose); break; case 't': case 'v': case 'i': case 's': case 'S': ! success = listTables(&cmd[1], pattern, show_verbose); break; case 'u': success = describeUsers(pattern); --- 348,367 ---- success = listSchemas(pattern, show_verbose); break; case 'o': ! success = describeOperators(pattern, show_system); break; case 'p': success = permissionsList(pattern); break; case 'T': ! success = describeTypes(pattern, show_verbose, show_system); break; case 't': case 'v': case 'i': case 's': case 'S': ! success = listTables(&cmd[1], pattern, show_verbose, show_system); break; case 'u': success = describeUsers(pattern); Index: describe.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/describe.c,v retrieving revision 1.115 diff -c -r1.115 describe.c *** describe.c 6 Apr 2005 05:23:32 -0000 1.115 --- describe.c 26 May 2005 20:09:37 -0000 *************** *** 53,59 **** * Takes an optional regexp to select particular aggregates */ bool ! describeAggregates(const char *pattern, bool verbose) { PQExpBufferData buf; PGresult *res; --- 53,59 ---- * Takes an optional regexp to select particular aggregates */ bool ! describeAggregates(const char *pattern, bool verbose, bool showSystem) { PQExpBufferData buf; PGresult *res; *************** *** 80,85 **** --- 80,88 ---- _("Schema"), _("Name"), _("(all types)"), _("Data type"), _("Description")); + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname !~ 'pg_catalog'\n"); + processNamePattern(&buf, pattern, true, false, "n.nspname", "p.proname", NULL, "pg_catalog.pg_function_is_visible(p.oid)"); *************** *** 158,164 **** * Takes an optional regexp to select particular functions */ bool ! describeFunctions(const char *pattern, bool verbose) { PQExpBufferData buf; PGresult *res; --- 161,167 ---- * Takes an optional regexp to select particular functions */ bool ! describeFunctions(const char *pattern, bool verbose, bool showSystem) { PQExpBufferData buf; PGresult *res; *************** *** 205,210 **** --- 208,216 ---- " OR p.proargtypes[0] <> 'pg_catalog.cstring'::pg_catalog.regtype)\n" " AND NOT p.proisagg\n"); + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname !~ 'pg_catalog'\n"); + processNamePattern(&buf, pattern, true, false, "n.nspname", "p.proname", NULL, "pg_catalog.pg_function_is_visible(p.oid)"); *************** *** 232,238 **** * describe types */ bool ! describeTypes(const char *pattern, bool verbose) { PQExpBufferData buf; PGresult *res; --- 238,244 ---- * describe types */ bool ! describeTypes(const char *pattern, bool verbose, bool showSystem) { PQExpBufferData buf; PGresult *res; *************** *** 271,276 **** --- 277,285 ---- "WHERE c.oid = t.typrelid)) "); appendPQExpBuffer(&buf, "AND t.typname !~ '^_'\n"); + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname !~ 'pg_catalog'\n"); + /* Match name pattern against either internal or external name */ processNamePattern(&buf, pattern, true, false, "n.nspname", "t.typname", *************** *** 298,304 **** /* \do */ bool ! describeOperators(const char *pattern) { PQExpBufferData buf; PGresult *res; --- 307,313 ---- /* \do */ bool ! describeOperators(const char *pattern, bool showSystem) { PQExpBufferData buf; PGresult *res; *************** *** 320,326 **** _("Left arg type"), _("Right arg type"), _("Result type"), _("Description")); ! processNamePattern(&buf, pattern, false, true, "n.nspname", "o.oprname", NULL, "pg_catalog.pg_operator_is_visible(o.oid)"); --- 329,338 ---- _("Left arg type"), _("Right arg type"), _("Result type"), _("Description")); ! if (!showSystem) ! appendPQExpBuffer(&buf, " AND n.nspname !~ 'pg_catalog'\n"); ! ! processNamePattern(&buf, pattern, !showSystem, true, "n.nspname", "o.oprname", NULL, "pg_catalog.pg_operator_is_visible(o.oid)"); *************** *** 454,460 **** * lists of things, there are other \d? commands. */ bool ! objectDescription(const char *pattern) { PQExpBufferData buf; PGresult *res; --- 466,472 ---- * lists of things, there are other \d? commands. */ bool ! objectDescription(const char *pattern, bool showSystem) { PQExpBufferData buf; PGresult *res; *************** *** 477,482 **** --- 489,498 ---- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" " WHERE p.proisagg\n", _("aggregate")); + + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname !~ 'pg_catalog'\n"); + processNamePattern(&buf, pattern, true, false, "n.nspname", "p.proname", NULL, "pg_catalog.pg_function_is_visible(p.oid)"); *************** *** 496,501 **** --- 512,521 ---- " OR p.proargtypes[0] <> 'pg_catalog.cstring'::pg_catalog.regtype)\n" " AND NOT p.proisagg\n", _("function")); + + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname !~ 'pg_catalog'\n"); + processNamePattern(&buf, pattern, true, false, "n.nspname", "p.proname", NULL, "pg_catalog.pg_function_is_visible(p.oid)"); *************** *** 510,516 **** " FROM pg_catalog.pg_operator o\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n", _("operator")); ! processNamePattern(&buf, pattern, false, false, "n.nspname", "o.oprname", NULL, "pg_catalog.pg_operator_is_visible(o.oid)"); --- 530,540 ---- " FROM pg_catalog.pg_operator o\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n", _("operator")); ! ! if (!showSystem) ! appendPQExpBuffer(&buf, " WHERE n.nspname !~ 'pg_catalog'\n"); ! ! processNamePattern(&buf, pattern, !showSystem, false, "n.nspname", "o.oprname", NULL, "pg_catalog.pg_operator_is_visible(o.oid)"); *************** *** 524,530 **** " FROM pg_catalog.pg_type t\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n", _("data type")); ! processNamePattern(&buf, pattern, false, false, "n.nspname", "pg_catalog.format_type(t.oid, NULL)", NULL, "pg_catalog.pg_type_is_visible(t.oid)"); --- 548,558 ---- " FROM pg_catalog.pg_type t\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n", _("data type")); ! ! if (!showSystem) ! appendPQExpBuffer(&buf, " WHERE n.nspname !~ 'pg_catalog'\n"); ! ! processNamePattern(&buf, pattern, !showSystem, false, "n.nspname", "pg_catalog.format_type(t.oid, NULL)", NULL, "pg_catalog.pg_type_is_visible(t.oid)"); *************** *** 541,546 **** --- 569,578 ---- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n" " WHERE c.relkind IN ('r', 'v', 'i', 'S')\n", _("table"), _("view"), _("index"), _("sequence")); + + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname !~ 'pg_catalog'\n"); + processNamePattern(&buf, pattern, true, false, "n.nspname", "c.relname", NULL, "pg_catalog.pg_table_is_visible(c.oid)"); *************** *** 557,562 **** --- 589,598 ---- " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n" " WHERE r.rulename != '_RETURN'\n", _("rule")); + + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname !~ 'pg_catalog'\n"); + /* XXX not sure what to do about visibility rule here? */ processNamePattern(&buf, pattern, true, false, "n.nspname", "r.rulename", NULL, *************** *** 573,580 **** " JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n", _("trigger")); /* XXX not sure what to do about visibility rule here? */ ! processNamePattern(&buf, pattern, false, false, "n.nspname", "t.tgname", NULL, "pg_catalog.pg_table_is_visible(c.oid)"); --- 609,620 ---- " JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n", _("trigger")); + + if (!showSystem) + appendPQExpBuffer(&buf, " WHERE n.nspname !~ 'pg_catalog'\n"); + /* XXX not sure what to do about visibility rule here? */ ! processNamePattern(&buf, pattern, !showSystem, false, "n.nspname", "t.tgname", NULL, "pg_catalog.pg_table_is_visible(c.oid)"); *************** *** 1452,1464 **** * (any order of the above is fine) */ bool ! listTables(const char *tabtypes, const char *pattern, bool verbose) { bool showTables = strchr(tabtypes, 't') != NULL; bool showIndexes = strchr(tabtypes, 'i') != NULL; bool showViews = strchr(tabtypes, 'v') != NULL; bool showSeq = strchr(tabtypes, 's') != NULL; - bool showSystem = strchr(tabtypes, 'S') != NULL; PQExpBufferData buf; PGresult *res; --- 1492,1503 ---- * (any order of the above is fine) */ bool ! listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSystem) { bool showTables = strchr(tabtypes, 't') != NULL; bool showIndexes = strchr(tabtypes, 'i') != NULL; bool showViews = strchr(tabtypes, 'v') != NULL; bool showSeq = strchr(tabtypes, 's') != NULL; PQExpBufferData buf; PGresult *res; *************** *** 1563,1569 **** * Describes domains. */ bool ! listDomains(const char *pattern) { PQExpBufferData buf; PGresult *res; --- 1602,1608 ---- * Describes domains. */ bool ! listDomains(const char *pattern, bool showSystem) { PQExpBufferData buf; PGresult *res; *************** *** 1591,1596 **** --- 1630,1638 ---- _("Modifier"), _("Check")); + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname !~ 'pg_catalog'\n"); + processNamePattern(&buf, pattern, true, false, "n.nspname", "t.typname", NULL, "pg_catalog.pg_type_is_visible(t.oid)"); *************** *** 1617,1623 **** * Describes conversions. */ bool ! listConversions(const char *pattern) { PQExpBufferData buf; PGresult *res; --- 1659,1665 ---- * Describes conversions. */ bool ! listConversions(const char *pattern, bool showSystem) { PQExpBufferData buf; PGresult *res; *************** *** 1646,1651 **** --- 1688,1696 ---- "n.nspname", "c.conname", NULL, "pg_catalog.pg_conversion_is_visible(c.oid)"); + if (!showSystem) + appendPQExpBuffer(&buf, " AND n.nspname !~ 'pg_catalog'\n"); + appendPQExpBuffer(&buf, "ORDER BY 1, 2;"); res = PSQLexec(buf.data, false); Index: describe.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/describe.h,v retrieving revision 1.28 diff -c -r1.28 describe.h *** describe.h 1 Jan 2005 05:43:08 -0000 1.28 --- describe.h 26 May 2005 20:09:38 -0000 *************** *** 11,29 **** #include "settings.h" /* \da */ ! bool describeAggregates(const char *pattern, bool verbose); /* \db */ bool describeTablespaces(const char *pattern, bool verbose); /* \df */ ! bool describeFunctions(const char *pattern, bool verbose); /* \dT */ ! bool describeTypes(const char *pattern, bool verbose); /* \do */ ! bool describeOperators(const char *pattern); /* \du */ bool describeUsers(const char *pattern); --- 11,29 ---- #include "settings.h" /* \da */ ! bool describeAggregates(const char *pattern, bool verbose, bool showSystem); /* \db */ bool describeTablespaces(const char *pattern, bool verbose); /* \df */ ! bool describeFunctions(const char *pattern, bool verbose, bool showSystem); /* \dT */ ! bool describeTypes(const char *pattern, bool verbose, bool showSystem); /* \do */ ! bool describeOperators(const char *pattern, bool showSystem); /* \du */ bool describeUsers(const char *pattern); *************** *** 35,41 **** bool permissionsList(const char *pattern); /* \dd */ ! bool objectDescription(const char *pattern); /* \d foo */ bool describeTableDetails(const char *pattern, bool verbose); --- 35,41 ---- bool permissionsList(const char *pattern); /* \dd */ ! bool objectDescription(const char *pattern, bool showSystem); /* \d foo */ bool describeTableDetails(const char *pattern, bool verbose); *************** *** 44,56 **** bool listAllDbs(bool verbose); /* \dt, \di, \ds, \dS, etc. */ ! bool listTables(const char *tabtypes, const char *pattern, bool verbose); /* \dD */ ! bool listDomains(const char *pattern); /* \dc */ ! bool listConversions(const char *pattern); /* \dC */ bool listCasts(const char *pattern); --- 44,56 ---- bool listAllDbs(bool verbose); /* \dt, \di, \ds, \dS, etc. */ ! bool listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSystem); /* \dD */ ! bool listDomains(const char *pattern, bool showSystem); /* \dc */ ! bool listConversions(const char *pattern, bool showSystem); /* \dC */ bool listCasts(const char *pattern); Index: help.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/help.c,v retrieving revision 1.101 diff -c -r1.101 help.c *** help.c 22 Feb 2005 04:40:55 -0000 1.101 --- help.c 26 May 2005 20:09:38 -0000 *************** *** 208,231 **** fprintf(output, "\n"); fprintf(output, _("Informational\n")); ! fprintf(output, _(" \\d [NAME] describe table, index, sequence, or view\n")); ! fprintf(output, _(" \\d{t|i|s|v|S} [PATTERN] (add \"+\" for more detail)\n" ! " list tables/indexes/sequences/views/system tables\n")); ! fprintf(output, _(" \\da [PATTERN] list aggregate functions\n")); ! fprintf(output, _(" \\db [PATTERN] list tablespaces (add \"+\" for more detail)\n")); ! fprintf(output, _(" \\dc [PATTERN] list conversions\n")); fprintf(output, _(" \\dC list casts\n")); - fprintf(output, _(" \\dd [PATTERN] show comment for object\n")); - fprintf(output, _(" \\dD [PATTERN] list domains\n")); - fprintf(output, _(" \\df [PATTERN] list functions (add \"+\" for more detail)\n")); fprintf(output, _(" \\dg [PATTERN] list groups\n")); - fprintf(output, _(" \\dn [PATTERN] list schemas (add \"+\" for more detail)\n")); - fprintf(output, _(" \\do [NAME] list operators\n")); fprintf(output, _(" \\dl list large objects, same as \\lo_list\n")); fprintf(output, _(" \\dp [PATTERN] list table, view, and sequence access privileges\n")); - fprintf(output, _(" \\dT [PATTERN] list data types (add \"+\" for more detail)\n")); fprintf(output, _(" \\du [PATTERN] list users\n")); - fprintf(output, _(" \\l list all databases (add \"+\" for more detail)\n")); fprintf(output, _(" \\z [PATTERN] list table, view, and sequence access privileges (same as \\dp)\n")); fprintf(output, "\n"); --- 208,235 ---- fprintf(output, "\n"); fprintf(output, _("Informational\n")); ! fprintf(output, _(" Modifiers: S = show system objects + = Additional detail\n")); ! fprintf(output, _(" \\l[+] list all databases\n")); ! fprintf(output, _(" \\d[S] list tables, views, and sequences\n")); ! fprintf(output, _(" \\d[S] NAME describe table, view, sequence, or index\n")); ! fprintf(output, _(" \\dt[S+] [PATTERN] list tables\n")); ! fprintf(output, _(" \\dv[S+] [PATTERN] list views\n")); ! fprintf(output, _(" \\ds[S+] [PATTERN] list sequences\n")); ! fprintf(output, _(" \\di[S+] [PATTERN] list indexes\n")); ! fprintf(output, _(" \\df[S+] [PATTERN] list functions\n")); ! fprintf(output, _(" \\dT[S+] [PATTERN] list data types\n")); ! fprintf(output, _(" \\dd[S] [PATTERN] list comments on objects\n")); ! fprintf(output, _(" \\dD[S] [PATTERN] list domains\n")); ! fprintf(output, _(" \\do[S] [PATTERN] list operators\n")); ! fprintf(output, _(" \\da[S] [PATTERN] list aggregate functions\n")); ! fprintf(output, _(" \\dc[S] [PATTERN] list conversions\n")); ! fprintf(output, _(" \\db[+] [PATTERN] list tablespaces\n")); ! fprintf(output, _(" \\dn[+] [PATTERN] list schemas\n")); fprintf(output, _(" \\dC list casts\n")); fprintf(output, _(" \\dg [PATTERN] list groups\n")); fprintf(output, _(" \\dl list large objects, same as \\lo_list\n")); fprintf(output, _(" \\dp [PATTERN] list table, view, and sequence access privileges\n")); fprintf(output, _(" \\du [PATTERN] list users\n")); fprintf(output, _(" \\z [PATTERN] list table, view, and sequence access privileges (same as \\dp)\n")); fprintf(output, "\n"); Index: tab-complete.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/tab-complete.c,v retrieving revision 1.130 diff -c -r1.130 tab-complete.c *** tab-complete.c 25 May 2005 22:12:05 -0000 1.130 --- tab-complete.c 26 May 2005 20:09:38 -0000 *************** *** 160,166 **** /* catname */ "pg_catalog.pg_proc p", /* selcondition */ ! "p.proisagg", /* viscondition */ "pg_catalog.pg_function_is_visible(p.oid)", /* namespace */ --- 160,166 ---- /* catname */ "pg_catalog.pg_proc p", /* selcondition */ ! "p.proisagg AND p.pronamespace <> (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')", /* viscondition */ "pg_catalog.pg_function_is_visible(p.oid)", /* namespace */ *************** *** 171,183 **** NULL }; static const SchemaQuery Query_for_list_of_datatypes = { /* catname */ "pg_catalog.pg_type t", /* selcondition --- ignore table rowtypes and array types */ "(t.typrelid = 0 " " OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid)) " ! "AND t.typname !~ '^_'", /* viscondition */ "pg_catalog.pg_type_is_visible(t.oid)", /* namespace */ --- 171,235 ---- NULL }; + static const SchemaQuery Query_for_list_of_comments = { + /* catname */ + "(SELECT c.name, c.namesp FROM ( SELECT * FROM (" + " SELECT oid, relname as name, relnamespace as namesp FROM pg_catalog.pg_class c" + " WHERE pg_catalog.pg_table_is_visible(oid)" + " UNION ALL" + " SELECT oid, proname::pg_catalog.text as name, pronamespace AS namesp FROM pg_catalog.pg_proc" + " WHERE pg_catalog.pg_function_is_visible(oid) AND (proisagg OR proargtypes[0] <> 'pg_catalog.cstring'::pg_catalog.regtype)" + " UNION ALL" + " SELECT oid, pg_catalog.format_type(oid, NULL) as name, typnamespace AS namesp FROM pg_catalog.pg_type" + " WHERE pg_catalog.pg_type_is_visible(oid)" + " UNION ALL" + " SELECT oid, oprname::pg_catalog.text AS name, oprnamespace AS namesp FROM pg_catalog.pg_operator" + " WHERE pg_catalog.pg_operator_is_visible(oid)" + " UNION ALL" + " SELECT r.oid, r.rulename::pg_catalog.text AS name, c.relnamespace AS namesp FROM pg_catalog.pg_rewrite r" + " JOIN pg_catalog.pg_class c ON c.oid = r.ev_class" + " WHERE r.rulename != '_RETURN' AND pg_catalog.pg_table_is_visible(c.oid)" + " UNION ALL" + " SELECT t.oid, t.tgname::pg_catalog.text AS name, c.relnamespace AS namesp FROM pg_catalog.pg_trigger t" + " JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid" + " WHERE pg_catalog.pg_table_is_visible(c.oid)" + ") b WHERE namesp <> (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')" + ") c JOIN pg_catalog.pg_description d ON (c.oid = d.objoid AND d.objsubid = 0)) AS x", + /* selcondition */ + NULL, // "x.namesp <> (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')", + /* viscondition */ + "1=1", /* Always true, since we have to call *_is_visible functions separately above */ + /* namespace */ + "x.namesp", + /* result */ + "pg_catalog.quote_ident(x.name)", + /* qualresult */ + NULL + }; + + static const SchemaQuery Query_for_list_of_conversions = { + /* catname */ + "pg_catalog.pg_conversion c", + /* selcondition */ + "c.connamespace <> (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')", + /* viscondition */ + "pg_catalog.pg_conversion_is_visible(c.oid)", + /* namespace */ + "c.connamespace", + /* result */ + "pg_catalog.quote_ident(c.conname)", + /* qualresult */ + NULL + }; + static const SchemaQuery Query_for_list_of_datatypes = { /* catname */ "pg_catalog.pg_type t", /* selcondition --- ignore table rowtypes and array types */ "(t.typrelid = 0 " " OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid)) " ! "AND t.typname !~ '^_'" ! "AND t.typnamespace <> (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')", /* viscondition */ "pg_catalog.pg_type_is_visible(t.oid)", /* namespace */ *************** *** 192,198 **** /* catname */ "pg_catalog.pg_type t", /* selcondition */ ! "t.typtype = 'd'", /* viscondition */ "pg_catalog.pg_type_is_visible(t.oid)", /* namespace */ --- 244,250 ---- /* catname */ "pg_catalog.pg_type t", /* selcondition */ ! "t.typtype = 'd' AND t.typnamespace <> (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')", /* viscondition */ "pg_catalog.pg_type_is_visible(t.oid)", /* namespace */ *************** *** 207,213 **** /* catname */ "pg_catalog.pg_proc p", /* selcondition */ ! NULL, /* viscondition */ "pg_catalog.pg_function_is_visible(p.oid)", /* namespace */ --- 259,265 ---- /* catname */ "pg_catalog.pg_proc p", /* selcondition */ ! "p.pronamespace <> (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')", /* viscondition */ "pg_catalog.pg_function_is_visible(p.oid)", /* namespace */ *************** *** 233,238 **** --- 285,305 ---- NULL }; + static const SchemaQuery Query_for_list_of_operators = { + /* catname */ + "pg_catalog.pg_operator o", + /* selcondition */ + "p.oprnamespace <> (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')", + /* viscondition */ + "1=1", + /* namespace */ + "o.oprnamespace", + /* result */ + "pg_catalog.quote_ident(o.oprname)", + /* qualresult */ + NULL + }; + static const SchemaQuery Query_for_list_of_sequences = { /* catname */ "pg_catalog.pg_class c", *************** *** 332,359 **** " AND pg_catalog.quote_ident(relname)='%s' "\ " AND pg_catalog.pg_table_is_visible(c.oid)" #define Query_for_list_of_databases \ "SELECT pg_catalog.quote_ident(datname) FROM pg_catalog.pg_database "\ " WHERE substring(pg_catalog.quote_ident(datname),1,%d)='%s'" ! #define Query_for_list_of_tablespaces \ ! "SELECT pg_catalog.quote_ident(spcname) FROM pg_catalog.pg_tablespace "\ ! " WHERE substring(pg_catalog.quote_ident(spcname),1,%d)='%s'" #define Query_for_list_of_encodings \ " SELECT DISTINCT pg_catalog.pg_encoding_to_char(conforencoding) "\ " FROM pg_catalog.pg_conversion "\ " WHERE substring(pg_catalog.pg_encoding_to_char(conforencoding),1,%d)=UPPER('%s')" #define Query_for_list_of_languages \ "SELECT pg_catalog.quote_ident(lanname) "\ " FROM pg_language "\ " WHERE lanname != 'internal' "\ " AND substring(pg_catalog.quote_ident(lanname),1,%d)='%s' " ! #define Query_for_list_of_schemas \ ! "SELECT pg_catalog.quote_ident(nspname) FROM pg_catalog.pg_namespace "\ ! " WHERE substring(pg_catalog.quote_ident(nspname),1,%d)='%s'" #define Query_for_list_of_system_relations \ "SELECT pg_catalog.quote_ident(relname) "\ --- 399,479 ---- " AND pg_catalog.quote_ident(relname)='%s' "\ " AND pg_catalog.pg_table_is_visible(c.oid)" + #define Query_for_list_of_system_aggregates \ + "SELECT pg_catalog.quote_ident(proname) FROM pg_catalog.pg_proc "\ + " WHERE proisagg AND pg_catalog.pg_function_is_visible(oid)"\ + " AND p.pronamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')"\ + " AND substring(pg_catalog.quote_ident(proname),1,%d)='%s'" + + #define Query_for_list_of_system_comments \ + "SELECT pg_catalog.quote_ident(name) FROM "\ + "(SELECT c.name, c.namesp FROM ( SELECT * FROM ("\ + " SELECT oid, relname as name, relnamespace as namesp FROM pg_catalog.pg_class c"\ + " WHERE pg_catalog.pg_table_is_visible(oid)"\ + " UNION ALL"\ + " SELECT oid, proname::pg_catalog.text as name, pronamespace AS namesp FROM pg_catalog.pg_proc"\ + " WHERE pg_catalog.pg_function_is_visible(oid) AND (proisagg OR proargtypes[0] <> 'pg_catalog.cstring'::pg_catalog.regtype)"\ + " UNION ALL"\ + " SELECT oid, pg_catalog.format_type(oid, NULL) as name, typnamespace AS namesp FROM pg_catalog.pg_type"\ + " WHERE pg_catalog.pg_type_is_visible(oid)"\ + " UNION ALL"\ + " SELECT oid, oprname::pg_catalog.text AS name, oprnamespace AS namesp FROM pg_catalog.pg_operator"\ + " WHERE pg_catalog.pg_operator_is_visible(oid)"\ + " UNION ALL"\ + " SELECT r.oid, r.rulename::pg_catalog.text AS name, c.relnamespace AS namesp FROM pg_catalog.pg_rewrite r"\ + " JOIN pg_catalog.pg_class c ON c.oid = r.ev_class"\ + " WHERE r.rulename != '_RETURN' AND pg_catalog.pg_table_is_visible(c.oid)"\ + " UNION ALL"\ + " SELECT t.oid, t.tgname::pg_catalog.text AS name, c.relnamespace AS namesp FROM pg_catalog.pg_trigger t"\ + " JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid"\ + " WHERE pg_catalog.pg_table_is_visible(c.oid)"\ + ") b WHERE namesp = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')"\ + ") c JOIN pg_catalog.pg_description d ON (c.oid = d.objoid AND d.objsubid = 0)) AS x",\ + " WHERE substring(pg_catalog.quote_ident(cname),1,%d)='%s'" + + #define Query_for_list_of_system_conversions \ + "SELECT pg_catalog.quote_ident(conname) FROM pg_catalog.pg_conversion"\ + " WHERE pg_catalog.pg_conversion_is_visible(oid)"\ + " AND connamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')"\ + " AND substring(pg_catalog.quote_ident(conname),1,%d)='%s'" + #define Query_for_list_of_databases \ "SELECT pg_catalog.quote_ident(datname) FROM pg_catalog.pg_database "\ " WHERE substring(pg_catalog.quote_ident(datname),1,%d)='%s'" ! #define Query_for_list_of_system_datatypes \ ! "SELECT pg_catalog.quote_ident(t.typname) FROM pg_catalog.pg_type t"\ ! " WHERE (t.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid)) "\ ! " AND t.typname !~ '^_'"\ ! " AND t.typnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')"\ ! " AND substring(pg_catalog.quote_ident(typname),1,%d)='%s'" ! ! #define Query_for_list_of_system_domains \ ! "SELECT pg_catalog.quote_ident(typname) FROM pg_catalog.pg_type"\ ! " WHERE pg_catalog.pg_domain_is_visible(oid)"\ ! " AND typnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')"\ ! " AND substring(pg_catalog.quote_ident(typname),1,%d)='%s'" #define Query_for_list_of_encodings \ " SELECT DISTINCT pg_catalog.pg_encoding_to_char(conforencoding) "\ " FROM pg_catalog.pg_conversion "\ " WHERE substring(pg_catalog.pg_encoding_to_char(conforencoding),1,%d)=UPPER('%s')" + #define Query_for_list_of_system_functions \ + "SELECT pg_catalog.quote_ident(proname) FROM pg_catalog.pg_proc"\ + " WHERE pg_catalog.pg_function_is_visible(oid)"\ + " AND pronamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')"\ + " AND substring(pg_catalog.quote_ident(proname),1,%d)='%s'" + #define Query_for_list_of_languages \ "SELECT pg_catalog.quote_ident(lanname) "\ " FROM pg_language "\ " WHERE lanname != 'internal' "\ " AND substring(pg_catalog.quote_ident(lanname),1,%d)='%s' " ! #define Query_for_list_of_largeobjects \ ! "SELECT pg_catalog.obj_description(loid, 'pg_largeobject')"\ ! " FROM (SELECT DISTINCT loid FROM pg_catalog.pg_largeobject)" #define Query_for_list_of_system_relations \ "SELECT pg_catalog.quote_ident(relname) "\ *************** *** 363,368 **** --- 483,496 ---- " AND c.relnamespace = n.oid "\ " AND n.nspname = 'pg_catalog'" + #define Query_for_list_of_schemas \ + "SELECT pg_catalog.quote_ident(nspname) FROM pg_catalog.pg_namespace "\ + " WHERE substring(pg_catalog.quote_ident(nspname),1,%d)='%s'" + + #define Query_for_list_of_tablespaces \ + "SELECT pg_catalog.quote_ident(spcname) FROM pg_catalog.pg_tablespace "\ + " WHERE substring(pg_catalog.quote_ident(spcname),1,%d)='%s'" + #define Query_for_list_of_users \ " SELECT pg_catalog.quote_ident(usename) "\ " FROM pg_catalog.pg_user "\ *************** *** 418,424 **** {"CAST", NULL, NULL}, /* Casts have complex structures for * names, so skip it */ /* CREATE CONSTRAINT TRIGGER is not supported here because it is designed to be used only by pg_dump. */ ! {"CONVERSION", "SELECT pg_catalog.quote_ident(conname) FROM pg_catalog.pg_conversion WHERE substring(pg_catalog.quote_ident(conname),1,%d)='%s'"}, {"DATABASE", Query_for_list_of_databases}, {"DOMAIN", NULL, &Query_for_list_of_domains}, {"FUNCTION", NULL, &Query_for_list_of_functions}, --- 546,552 ---- {"CAST", NULL, NULL}, /* Casts have complex structures for * names, so skip it */ /* CREATE CONSTRAINT TRIGGER is not supported here because it is designed to be used only by pg_dump. */ ! {"CONVERSION", NULL, &Query_for_list_of_conversions}, {"DATABASE", Query_for_list_of_databases}, {"DOMAIN", NULL, &Query_for_list_of_domains}, {"FUNCTION", NULL, &Query_for_list_of_functions}, *************** *** 617,625 **** static const char *const backslash_commands[] = { "\\a", "\\connect", "\\C", "\\cd", "\\copy", "\\copyright", ! "\\d", "\\da", "\\db", "\\dc", "\\dC", "\\dd", "\\dD", "\\df", ! "\\dg", "\\di", "\\dl", "\\dn", "\\do", "\\dp", "\\ds", "\\dS", ! "\\dt", "\\dT", "\\dv", "\\du", "\\e", "\\echo", "\\encoding", "\\f", "\\g", "\\h", "\\help", "\\H", "\\i", "\\l", "\\lo_import", "\\lo_export", "\\lo_list", "\\lo_unlink", --- 745,753 ---- static const char *const backslash_commands[] = { "\\a", "\\connect", "\\C", "\\cd", "\\copy", "\\copyright", ! "\\d", "\\da", "\\daS", "\\db", "\\dc", "\\dcS", "\\dC", "\\dd", "\\ddS", "\\dD", "\\dDS", ! "\\df", "\\dfS", "\\dg", "\\di", "\\dl", "\\dn", "\\do", "\\doS", "\\dp", "\\ds", "\\dS", ! "\\dt", "\\dT", "\\dTS", "\\dv", "\\du", "\\e", "\\echo", "\\encoding", "\\f", "\\g", "\\h", "\\help", "\\H", "\\i", "\\l", "\\lo_import", "\\lo_export", "\\lo_list", "\\lo_unlink", *************** *** 1706,1728 **** /* Backslash commands */ - /* TODO: \dc \dd \dl */ else if (strcmp(prev_wd, "\\connect") == 0 || strcmp(prev_wd, "\\c") == 0) COMPLETE_WITH_QUERY(Query_for_list_of_databases); else if (strcmp(prev_wd, "\\d") == 0 || strcmp(prev_wd, "\\d+") == 0) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tisv, NULL); else if (strcmp(prev_wd, "\\da") == 0) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_aggregates, NULL); else if (strcmp(prev_wd, "\\db") == 0) COMPLETE_WITH_QUERY(Query_for_list_of_tablespaces); else if (strcmp(prev_wd, "\\dD") == 0) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_domains, NULL); else if (strcmp(prev_wd, "\\df") == 0 || strcmp(prev_wd, "\\df+") == 0) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_functions, NULL); else if (strcmp(prev_wd, "\\di") == 0 || strcmp(prev_wd, "\\di+") == 0) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL); else if (strcmp(prev_wd, "\\dn") == 0) COMPLETE_WITH_QUERY(Query_for_list_of_schemas); else if (strcmp(prev_wd, "\\dp") == 0 || strcmp(prev_wd, "\\z") == 0) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tsv, NULL); else if (strcmp(prev_wd, "\\ds") == 0 || strcmp(prev_wd, "\\ds+") == 0) --- 1834,1873 ---- /* Backslash commands */ else if (strcmp(prev_wd, "\\connect") == 0 || strcmp(prev_wd, "\\c") == 0) COMPLETE_WITH_QUERY(Query_for_list_of_databases); else if (strcmp(prev_wd, "\\d") == 0 || strcmp(prev_wd, "\\d+") == 0) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tisv, NULL); else if (strcmp(prev_wd, "\\da") == 0) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_aggregates, NULL); + else if (strcmp(prev_wd, "\\daS") == 0) + COMPLETE_WITH_QUERY(Query_for_list_of_system_aggregates); else if (strcmp(prev_wd, "\\db") == 0) COMPLETE_WITH_QUERY(Query_for_list_of_tablespaces); + else if (strcmp(prev_wd, "\\dc") == 0) + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_conversions, NULL); + else if (strcmp(prev_wd, "\\dcS") == 0) + COMPLETE_WITH_QUERY(Query_for_list_of_system_conversions); + else if (strcmp(prev_wd, "\\dd") == 0) + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_comments, NULL); + else if (strcmp(prev_wd, "\\ddS") == 0) + COMPLETE_WITH_QUERY(Query_for_list_of_system_comments); else if (strcmp(prev_wd, "\\dD") == 0) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_domains, NULL); + else if (strcmp(prev_wd, "\\dDS") == 0) + COMPLETE_WITH_QUERY(Query_for_list_of_system_domains); else if (strcmp(prev_wd, "\\df") == 0 || strcmp(prev_wd, "\\df+") == 0) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_functions, NULL); + else if (strcmp(prev_wd, "\\dfS") == 0 || strcmp(prev_wd, "\\dfS+") == 0) + COMPLETE_WITH_QUERY(Query_for_list_of_system_functions); else if (strcmp(prev_wd, "\\di") == 0 || strcmp(prev_wd, "\\di+") == 0) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL); + else if (strcmp(prev_wd, "\\dl") == 0) + COMPLETE_WITH_QUERY(Query_for_list_of_largeobjects); else if (strcmp(prev_wd, "\\dn") == 0) COMPLETE_WITH_QUERY(Query_for_list_of_schemas); + else if (strcmp(prev_wd, "\\do") == 0) + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_operators, NULL); else if (strcmp(prev_wd, "\\dp") == 0 || strcmp(prev_wd, "\\z") == 0) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tsv, NULL); else if (strcmp(prev_wd, "\\ds") == 0 || strcmp(prev_wd, "\\ds+") == 0) *************** *** 1733,1738 **** --- 1878,1885 ---- COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); else if (strcmp(prev_wd, "\\dT") == 0 || strcmp(prev_wd, "\\dT+") == 0) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes, NULL); + else if (strcmp(prev_wd, "\\dTS") == 0 || strcmp(prev_wd, "\\dTS+") == 0) + COMPLETE_WITH_QUERY(Query_for_list_of_system_datatypes); else if (strcmp(prev_wd, "\\du") == 0) COMPLETE_WITH_QUERY(Query_for_list_of_users); else if (strcmp(prev_wd, "\\dv") == 0 || strcmp(prev_wd, "\\dv+") == 0)
---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings