Thread: Fix for \dn and temp schemas

Fix for \dn and temp schemas

From
Bruce Momjian
Date:
I have applied this patch to suppress non-local temp schemas from psql
\dn.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (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    23 Dec 2003 23:12:07 -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    23 Dec 2003 23:12:09 -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,1640 ----

      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\\\\_%%' OR\n"
!         "         n.nspname = (pg_catalog.current_schemas(true))[1])\n",    /* temp schema is first */
                        _("Name"),
                        _("Owner"));
!     processNamePattern(&buf, pattern, true, false,
                         NULL, "n.nspname", NULL,
                         NULL);