Unix Technical Forum

Re: [HACKERS] expanded \df+ display broken in beta4

This is a discussion on Re: [HACKERS] expanded \df+ display broken in beta4 within the Pgsql Patches forums, part of the PostgreSQL category; --> Michael Paesold wrote: > Bruce Momjian wrote: > > Michael Paesold wrote: > > > >>Tom Lane wrote: > ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 01:00 AM
Bruce Momjian
 
Posts: n/a
Default Re: [HACKERS] expanded \df+ display broken in beta4

Michael Paesold wrote:
> Bruce Momjian wrote:
> > Michael Paesold wrote:
> >
> >>Tom Lane wrote:
> >>
> >>>"Michael Paesold" <mpaesold@gmx.at> writes:
> >>>
> >>>>Robert Treat wrote:
> >>>>
> >>>>>ISTM even a GUC to enable/disable would have been better scheme than
> >>>>>what we have now; we are basically leaving no options for those who
> >>>>>found the old behavior useful, while what we had before would at least
> >>>>>let people switch back and forth.
> >>>
> >>>>I think Robert is right here and the new behaviour is a step backwards.
> >>>
> >>>Should we revert the patch for the time being, and take another go at it
> >>>in 8.2?

>
> > One idea is to hack \d not to honor \x, and let the others honor it.
> > That would probably hit most of the cases people will use in 8.1.
> >
> > In fact, \d is pretty special because it is more of a group of outputs,
> > unlike \df, which is a single table output.

>
> +1 from me. That seems like a workable compromise and should probably
> meet the needs of the author of the patch to change the \x behavior.


OK, here is a patch that disables expanded output only for \d tablename.

--
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: src/bin/psql/common.c
================================================== =================
RCS file: /cvsroot/pgsql/src/bin/psql/common.c,v
retrieving revision 1.108
diff -c -c -r1.108 common.c
*** src/bin/psql/common.c 15 Oct 2005 02:49:40 -0000 1.108
--- src/bin/psql/common.c 27 Oct 2005 05:03:11 -0000
***************
*** 795,802 ****
{
printQueryOpt my_popt = pset.popt;

- my_popt.topt.normal_query = true;
-
/* write output to \g argument, if any */
if (pset.gfname)
{
--- 795,800 ----
Index: src/bin/psql/describe.c
================================================== =================
RCS file: /cvsroot/pgsql/src/bin/psql/describe.c,v
retrieving revision 1.128
diff -c -c -r1.128 describe.c
*** src/bin/psql/describe.c 20 Oct 2005 05:15:09 -0000 1.128
--- src/bin/psql/describe.c 27 Oct 2005 05:03:12 -0000
***************
*** 703,708 ****
--- 703,711 ----

retval = false;

+ /* This output looks confusing in expanded mode. */
+ myopt.disableExpanded = true;
+
initPQExpBuffer(&buf);
initPQExpBuffer(&title);
initPQExpBuffer(&tmpbuf);
Index: src/bin/psql/print.c
================================================== =================
RCS file: /cvsroot/pgsql/src/bin/psql/print.c,v
retrieving revision 1.78
diff -c -c -r1.78 print.c
*** src/bin/psql/print.c 15 Oct 2005 02:49:40 -0000 1.78
--- src/bin/psql/print.c 27 Oct 2005 05:03:12 -0000
***************
*** 1491,1497 ****
* normal (user-submitted) query, not a table we're printing for a slash
* command.
*/
! if (opt->expanded && opt->normal_query)
use_expanded = true;
else
use_expanded = false;
--- 1491,1497 ----
* normal (user-submitted) query, not a table we're printing for a slash
* command.
*/
! if (opt->expanded && !opt->disableExpanded)
use_expanded = true;
else
use_expanded = false;
Index: src/bin/psql/print.h
================================================== =================
RCS file: /cvsroot/pgsql/src/bin/psql/print.h,v
retrieving revision 1.29
diff -c -c -r1.29 print.h
*** src/bin/psql/print.h 15 Oct 2005 02:49:40 -0000 1.29
--- src/bin/psql/print.h 27 Oct 2005 05:03:12 -0000
***************
*** 43,50 ****
* decimal marker */
char *tableAttr; /* attributes for HTML <table ...> */
int encoding; /* character encoding */
! bool normal_query; /* are we presenting the results of a "normal"
! * query, or a slash command? */
} printTableOpt;


--- 43,49 ----
* decimal marker */
char *tableAttr; /* attributes for HTML <table ...> */
int encoding; /* character encoding */
! bool disableExpanded;/* Should we honor \x? Not for \d. */
} printTableOpt;


Index: src/bin/psql/startup.c
================================================== =================
RCS file: /cvsroot/pgsql/src/bin/psql/startup.c,v
retrieving revision 1.125
diff -c -c -r1.125 startup.c
*** src/bin/psql/startup.c 15 Oct 2005 02:49:40 -0000 1.125
--- src/bin/psql/startup.c 27 Oct 2005 05:03:12 -0000
***************
*** 147,153 ****
pset.queryFout = stdout;
pset.popt.topt.border = 1;
pset.popt.topt.pager = 1;
! pset.popt.topt.normal_query = false;
pset.popt.default_footer = true;

SetVariable(pset.vars, "VERSION", PG_VERSION_STR);
--- 147,153 ----
pset.queryFout = stdout;
pset.popt.topt.border = 1;
pset.popt.topt.pager = 1;
! pset.popt.topt.disableExpanded = false;
pset.popt.default_footer = true;

SetVariable(pset.vars, "VERSION", PG_VERSION_STR);


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 01:00 AM
Bruce Momjian
 
Posts: n/a
Default Re: [HACKERS] expanded \df+ display broken in beta4

Bruce Momjian wrote:
> Michael Paesold wrote:
> > Bruce Momjian wrote:
> > > Michael Paesold wrote:
> > >
> > >>Tom Lane wrote:
> > >>
> > >>>"Michael Paesold" <mpaesold@gmx.at> writes:
> > >>>
> > >>>>Robert Treat wrote:
> > >>>>
> > >>>>>ISTM even a GUC to enable/disable would have been better scheme than
> > >>>>>what we have now; we are basically leaving no options for those who
> > >>>>>found the old behavior useful, while what we had before would at least
> > >>>>>let people switch back and forth.
> > >>>
> > >>>>I think Robert is right here and the new behaviour is a step backwards.
> > >>>
> > >>>Should we revert the patch for the time being, and take another go at it
> > >>>in 8.2?

> >
> > > One idea is to hack \d not to honor \x, and let the others honor it.
> > > That would probably hit most of the cases people will use in 8.1.
> > >
> > > In fact, \d is pretty special because it is more of a group of outputs,
> > > unlike \df, which is a single table output.

> >
> > +1 from me. That seems like a workable compromise and should probably
> > meet the needs of the author of the patch to change the \x behavior.

>
> OK, here is a patch that disables expanded output only for \d tablename.


The patch is even easier than the original patch. There was never any
need for "normal_query". Because the structure is a copy of the
session-wide structure, we can just set expanded to true/false as
desired.

I have applied this updated patch which simply turns off expanded mode
for \d tablename. That seemed like the only complex backslash output in
describe.c. I have also updated the release notes.

--
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/release.sgml
================================================== =================
RCS file: /cvsroot/pgsql/doc/src/sgml/release.sgml,v
retrieving revision 1.393
diff -c -c -r1.393 release.sgml
*** doc/src/sgml/release.sgml 25 Oct 2005 17:54:30 -0000 1.393
--- doc/src/sgml/release.sgml 27 Oct 2005 13:05:45 -0000
***************
*** 1690,1696 ****
<listitem>
<para>
Prevent <command>\x</> (expanded mode) from affecting
! backslash-command displays (Neil)
</para>
</listitem>

--- 1690,1696 ----
<listitem>
<para>
Prevent <command>\x</> (expanded mode) from affecting
! the output of <command>\d tablename<\> (Neil)
</para>
</listitem>

Index: src/bin/psql/common.c
================================================== =================
RCS file: /cvsroot/pgsql/src/bin/psql/common.c,v
retrieving revision 1.108
diff -c -c -r1.108 common.c
*** src/bin/psql/common.c 15 Oct 2005 02:49:40 -0000 1.108
--- src/bin/psql/common.c 27 Oct 2005 13:05:48 -0000
***************
*** 795,802 ****
{
printQueryOpt my_popt = pset.popt;

- my_popt.topt.normal_query = true;
-
/* write output to \g argument, if any */
if (pset.gfname)
{
--- 795,800 ----
Index: src/bin/psql/describe.c
================================================== =================
RCS file: /cvsroot/pgsql/src/bin/psql/describe.c,v
retrieving revision 1.128
diff -c -c -r1.128 describe.c
*** src/bin/psql/describe.c 20 Oct 2005 05:15:09 -0000 1.128
--- src/bin/psql/describe.c 27 Oct 2005 13:05:48 -0000
***************
*** 703,708 ****
--- 703,711 ----

retval = false;

+ /* This output looks confusing in expanded mode. */
+ myopt.expanded = false;
+
initPQExpBuffer(&buf);
initPQExpBuffer(&title);
initPQExpBuffer(&tmpbuf);
Index: src/bin/psql/print.c
================================================== =================
RCS file: /cvsroot/pgsql/src/bin/psql/print.c,v
retrieving revision 1.78
diff -c -c -r1.78 print.c
*** src/bin/psql/print.c 15 Oct 2005 02:49:40 -0000 1.78
--- src/bin/psql/print.c 27 Oct 2005 13:05:49 -0000
***************
*** 1491,1497 ****
* normal (user-submitted) query, not a table we're printing for a slash
* command.
*/
! if (opt->expanded && opt->normal_query)
use_expanded = true;
else
use_expanded = false;
--- 1491,1497 ----
* normal (user-submitted) query, not a table we're printing for a slash
* command.
*/
! if (opt->expanded)
use_expanded = true;
else
use_expanded = false;
Index: src/bin/psql/print.h
================================================== =================
RCS file: /cvsroot/pgsql/src/bin/psql/print.h,v
retrieving revision 1.29
diff -c -c -r1.29 print.h
*** src/bin/psql/print.h 15 Oct 2005 02:49:40 -0000 1.29
--- src/bin/psql/print.h 27 Oct 2005 13:05:49 -0000
***************
*** 43,50 ****
* decimal marker */
char *tableAttr; /* attributes for HTML <table ...> */
int encoding; /* character encoding */
- bool normal_query; /* are we presenting the results of a "normal"
- * query, or a slash command? */
} printTableOpt;


--- 43,48 ----
Index: src/bin/psql/startup.c
================================================== =================
RCS file: /cvsroot/pgsql/src/bin/psql/startup.c,v
retrieving revision 1.125
diff -c -c -r1.125 startup.c
*** src/bin/psql/startup.c 15 Oct 2005 02:49:40 -0000 1.125
--- src/bin/psql/startup.c 27 Oct 2005 13:05:49 -0000
***************
*** 147,153 ****
pset.queryFout = stdout;
pset.popt.topt.border = 1;
pset.popt.topt.pager = 1;
- pset.popt.topt.normal_query = false;
pset.popt.default_footer = true;

SetVariable(pset.vars, "VERSION", PG_VERSION_STR);
--- 147,152 ----


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:16 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com