psql wrapped format default for backslash-d commands

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема psql wrapped format default for backslash-d commands
Дата
Msg-id 200805091752.m49HqOO14516@momjian.us
обсуждение исходный текст
Ответы Re: psql wrapped format default for backslash-d commands  ("Brendan Jurd" <direvus@gmail.com>)
Re: psql wrapped format default for backslash-d commands  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Now that psql '\pset format wrapped' is in CVS, we should consider when
we want to use 'wrapped' format by default.  I think psql \df and \dT
certainly can benefit from wrapped mode.  \df+ even displays, though
there is quite a bit of wrapping.

The attached patch uses wrapped format for \d* output if the current
output format is 'aligned'.  It certainly helps the \df and \dT because
those outputs have normally narrow values with a few wide values that
cause aligned output to be much too wide.  The downside of the patch is
that you can no longer get 'aligned' output for \d* commands anymore
because there is no way to know if the user specified 'aligned' or if
they are just using the default.

This opens the larger question that if 'wrapped' helps with \df and \dT,
wouldn't it help with other wide user query output.

Now, we can discard this patch and tell people to set their output to
'wrapped' when they issue \d commands, but it is unlikely they will do
so.  We can also tell people to just default to 'wrapped' in their
.psqlrc and then their \d commands and user queries will be in
'wrapped', or we can just default 'format' to 'wrapped' for psql.

I have heard a few people say they never way to see 'wrapped' output so
perhaps we should do nothing, but I then question whether we want \df
and \dT to be hard to read by default.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/bin/psql/command.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/command.c,v
retrieving revision 1.188
diff -c -c -r1.188 command.c
*** src/bin/psql/command.c    8 May 2008 17:04:26 -0000    1.188
--- src/bin/psql/command.c    9 May 2008 17:36:38 -0000
***************
*** 314,319 ****
--- 314,324 ----
      {
          char       *pattern;
          bool        show_verbose;
+         enum printFormat saved_format = pset.popt.topt.format;
+
+         /* Use wrapped mode in hopes of displaying output cleanly. */
+         if (pset.popt.topt.format == PRINT_ALIGNED)
+             pset.popt.topt.format = PRINT_WRAPPED;

          /* We don't do SQLID reduction on the pattern yet */
          pattern = psql_scan_slash_option(scan_state,
***************
*** 407,412 ****
--- 412,419 ----
                  status = PSQL_CMD_UNKNOWN;
          }

+         pset.popt.topt.format = saved_format;    /* restore */
+
          if (pattern)
              free(pattern);
      }

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Re: [COMMITTERS] pgsql: Improve logic for finding object files on OBJS lines in contrib
Следующее
От: Jan Urbański
Дата:
Сообщение: gsoc08, text search selectivity, pg_statistics holding an array of a different type