Tom Lane wrote:
> Bruce Momjian <[EMAIL PROTECTED]> writes:
> > OK, the following patch uses UNION and an =ANY() join to the
> > current_schemas() array to suppress non-local temp schemas, but display
> > all other schemas.
>
> Why are you doing any of this? We had agreed to suppress all temp
> schemas, period. The query should be simple.
I know some feel that showing any temporary schemas is wrong, but it
seems that the local temp schema has valuable information. If I do \d
pg_temp_1.*, I see all my temporary tables. I know we have a TODO to
show all existing prepared statements, and giving people a way to see
their temp tables seems important. In fact, it seems more valuable than
the information containted in pg_toast.
The attached patch documents that non-local temp tables are suppressed.
As for people accidentally hardcoding the temp table schema in their
scripts, I don't see how someone would make that mistake with a schema
called pg_temp_##. It is sort of like assuming a file will always exist
in /tmp.
One nifty idea would be for pg_temp.* to alway refer to your local temp
schema. Is that a TODO?
--
Bruce Momjian | http://candle.pha.pa.us
[EMAIL PROTECTED] | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Index: doc/src/sgml/ref/psql-ref.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/ref/psql-ref.sgml,v
retrieving revision 1.101
diff -c -c -r1.101 psql-ref.sgml
*** doc/src/sgml/ref/psql-ref.sgml 1 Dec 2003 22:21:54 -0000 1.101
--- doc/src/sgml/ref/psql-ref.sgml 22 Dec 2003 19:18:16 -0000
***************
*** 957,962 ****
--- 957,963 ----
Lists all available schemas (namespaces). If <replaceable
class="parameter">pattern</replaceable> (a regular expression)
is specified, only schemas whose names match the pattern are listed.
+ Non-local temporary schemas are suppressed.
</para>
</listitem>
</varlistentry>
Index: src/bin/psql/describe.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/psql/describe.c,v
retrieving revision 1.90
diff -c -c -r1.90 describe.c
*** src/bin/psql/describe.c 1 Dec 2003 22:21:54 -0000 1.90
--- src/bin/psql/describe.c 22 Dec 2003 19:18:19 -0000
***************
*** 1626,1639 ****
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
! "SELECT n.nspname AS \"%s\",\n"
! " u.usename AS \"%s\"\n"
"FROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_user u\n"
! " ON n.nspowner=u.usesysid\n",
_("Name"),
_("Owner"));
! processNamePattern(&buf, pattern, false, false,
NULL, "n.nspname", NULL,
NULL);
--- 1626,1654 ----
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
! "SELECT n.nspname AS \"%s\",\n"
! " u.usename AS \"%s\"\n"
"FROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_user u\n"
! " ON n.nspowner=u.usesysid\n"
! "WHERE n.nspname NOT LIKE 'pg_temp_%%'\n",
_("Name"),
_("Owner"));
+ processNamePattern(&buf, pattern, true, false,
+ NULL, "n.nspname", NULL,
+ NULL);
! appendPQExpBuffer(&buf,
! "UNION ALL\n" /* show only local temp schema */
! "SELECT n.nspname AS \"%s\",\n"
! " u.usename AS \"%s\"\n"
! "FROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_user u\n"
! " ON n.nspowner=u.usesysid,\n"
! " (SELECT current_schemas('t'::boolean)) AS
curr_schemas(name)\n"
! "WHERE n.nspname LIKE 'pg_temp_%%' AND\n"
! " n.nspname = ANY(curr_schemas.name)\n",
! _("Name"),
! _("Owner"));
! processNamePattern(&buf, pattern, true, false,
NULL, "n.nspname", NULL,
NULL);
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]