Re: small psql patch - show Schema name for \dt \dv \dS - Mailing list pgsql-patches

Tom Lane wrote:
> It seems rather odd and confusing that the sort order takes the second
> column as the major key.

Maybe I'm a rather odd and confused kind of guy ;-)

> I think that the sort ordering should be
> column 1 then 2.  That means either putting the schema column first,
> or keeping this column ordering and sorting on relname before schema.
> I lean towards the first choice but can see a case for the second.

Here's another small patch, to implement Tom's first choice above. I
looked at re-adding your own "pg_temp_n" schema back into the results.
But I don't see a way to determine your own BackendId unless we add a
builtin function to expose MyBackendId as a user callable function.
Should we do this, or did I just miss something?

If there are no objections, please apply.

Thanks,

Joe
Index: src/bin/psql/describe.c
===================================================================
RCS file: /opt/src/cvs/pgsql/src/bin/psql/describe.c,v
retrieving revision 1.56
diff -c -r1.56 describe.c
*** src/bin/psql/describe.c    20 Jul 2002 05:57:31 -0000    1.56
--- src/bin/psql/describe.c    20 Jul 2002 20:57:16 -0000
***************
*** 1021,1031 ****
      initPQExpBuffer(&buf);

      printfPQExpBuffer(&buf,
!              "SELECT c.relname as \"%s\",\n"
!              "  n.nspname 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"), _("Schema"), _("table"), _("view"), _("index"), _("sequence"),
               _("special"), _("Type"), _("Owner"));

      if (desc)
--- 1021,1031 ----
      initPQExpBuffer(&buf);

      printfPQExpBuffer(&buf,
!              "SELECT n.nspname as \"%s\",\n"
!              "  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\"",
!              _("Schema"), _("Name"), _("table"), _("view"), _("index"), _("sequence"),
               _("special"), _("Type"), _("Owner"));

      if (desc)
***************
*** 1068,1074 ****
      if (name)
          appendPQExpBuffer(&buf, "  AND c.relname ~ '^%s'\n", name);

!     appendPQExpBuffer(&buf, "ORDER BY 2,1;");

      res = PSQLexec(buf.data);
      termPQExpBuffer(&buf);
--- 1068,1074 ----
      if (name)
          appendPQExpBuffer(&buf, "  AND c.relname ~ '^%s'\n", name);

!     appendPQExpBuffer(&buf, "ORDER BY 1,2;");

      res = PSQLexec(buf.data);
      termPQExpBuffer(&buf);

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: Demo patch for DROP COLUMN
Next
From: Tom Lane
Date:
Subject: Re: show() function - updated patch