Re: small psql patch - show Schema name for \dt \dv \dS

Поиск
Список
Период
Сортировка
От Joe Conway
Тема Re: small psql patch - show Schema name for \dt \dv \dS
Дата
Msg-id 3D39DB5E.7080003@joeconway.com
обсуждение исходный текст
Ответ на small psql patch - show Schema name for \dt \dv \dS  (Joe Conway <mail@joeconway.com>)
Ответы Re: small psql patch - show Schema name for \dt \dv \dS  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: small psql patch - show Schema name for \dt \dv \dS  (Bruce Momjian <pgman@candle.pha.pa.us>)
Re: small psql patch - show Schema name for \dt \dv \dS  (Bruce Momjian <pgman@candle.pha.pa.us>)
Re: small psql patch - show Schema name for \dt \dv \dS  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Demo patch for DROP COLUMN
Следующее
От: Tom Lane
Дата:
Сообщение: Re: show() function - updated patch