33 *
44 * Copyright (c) 2000-2005, PostgreSQL Global Development Group
55 *
6- * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.57 2005/06/09 18:40:06 momjian Exp $
6+ * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.58 2005/06/13 06:36:22 neilc Exp $
77 */
88#include "postgres_fe.h"
99#include "common.h"
2929
3030#include "mbprint.h"
3131
32-
3332/*************************/
3433/* Unaligned text */
3534/*************************/
@@ -1261,6 +1260,7 @@ printTable(const char *title,
12611260 const char * default_footer [] = {NULL };
12621261 unsigned short int border = opt -> border ;
12631262 FILE * output ;
1263+ bool use_expanded ;
12641264
12651265 if (opt -> format == PRINT_NOTHING )
12661266 return ;
@@ -1271,6 +1271,16 @@ printTable(const char *title,
12711271 if (opt -> format != PRINT_HTML && border > 2 )
12721272 border = 2 ;
12731273
1274+ /*
1275+ * We only want to display the results in "expanded" format if
1276+ * this is a normal (user-submitted) query, not a table we're
1277+ * printing for a slash command.
1278+ */
1279+ if (opt -> expanded && opt -> normal_query )
1280+ use_expanded = true;
1281+ else
1282+ use_expanded = false;
1283+
12741284 if (fout == stdout )
12751285 {
12761286 int col_count = 0 ,
@@ -1305,37 +1315,56 @@ printTable(const char *title,
13051315 switch (opt -> format )
13061316 {
13071317 case PRINT_UNALIGNED :
1308- if (opt -> expanded )
1309- print_unaligned_vertical (title , headers , cells , footers , opt -> fieldSep , opt -> recordSep , opt -> tuples_only , output );
1318+ if (use_expanded )
1319+ print_unaligned_vertical (title , headers , cells , footers ,
1320+ opt -> fieldSep , opt -> recordSep ,
1321+ opt -> tuples_only , output );
13101322 else
1311- print_unaligned_text (title , headers , cells , footers , opt -> fieldSep , opt -> recordSep , opt -> tuples_only , output );
1323+ print_unaligned_text (title , headers , cells , footers ,
1324+ opt -> fieldSep , opt -> recordSep ,
1325+ opt -> tuples_only , output );
13121326 break ;
13131327 case PRINT_ALIGNED :
1314- if (opt -> expanded )
1315- print_aligned_vertical (title , headers , cells , footers , opt -> tuples_only , border , opt -> encoding , output );
1328+ if (use_expanded )
1329+ print_aligned_vertical (title , headers , cells , footers ,
1330+ opt -> tuples_only , border ,
1331+ opt -> encoding , output );
13161332 else
1317- print_aligned_text (title , headers , cells , footers , align , opt -> tuples_only , border , opt -> encoding , output );
1333+ print_aligned_text (title , headers , cells , footers ,
1334+ align , opt -> tuples_only ,
1335+ border , opt -> encoding , output );
13181336 break ;
13191337 case PRINT_HTML :
1320- if (opt -> expanded )
1321- print_html_vertical (title , headers , cells , footers , align , opt -> tuples_only , border , opt -> tableAttr , output );
1338+ if (use_expanded )
1339+ print_html_vertical (title , headers , cells , footers ,
1340+ align , opt -> tuples_only ,
1341+ border , opt -> tableAttr , output );
13221342 else
1323- print_html_text (title , headers , cells , footers , align , opt -> tuples_only , border , opt -> tableAttr , output );
1343+ print_html_text (title , headers , cells , footers ,
1344+ align , opt -> tuples_only , border ,
1345+ opt -> tableAttr , output );
13241346 break ;
13251347 case PRINT_LATEX :
1326- if (opt -> expanded )
1327- print_latex_vertical (title , headers , cells , footers , align , opt -> tuples_only , border , output );
1348+ if (use_expanded )
1349+ print_latex_vertical (title , headers , cells , footers , align ,
1350+ opt -> tuples_only , border , output );
13281351 else
1329- print_latex_text (title , headers , cells , footers , align , opt -> tuples_only , border , output );
1352+ print_latex_text (title , headers , cells , footers , align ,
1353+ opt -> tuples_only , border , output );
13301354 break ;
13311355 case PRINT_TROFF_MS :
1332- if (opt -> expanded )
1333- print_troff_ms_vertical (title , headers , cells , footers , align , opt -> tuples_only , border , output );
1356+ if (use_expanded )
1357+ print_troff_ms_vertical (title , headers , cells , footers ,
1358+ align , opt -> tuples_only ,
1359+ border , output );
13341360 else
1335- print_troff_ms_text (title , headers , cells , footers , align , opt -> tuples_only , border , output );
1361+ print_troff_ms_text (title , headers , cells , footers ,
1362+ align , opt -> tuples_only ,
1363+ border , output );
13361364 break ;
13371365 default :
1338- fprintf (stderr , "+ Oops, you shouldn't see this!\n" );
1366+ fprintf (stderr , _ ("illegal output format: %d" ), opt -> format );
1367+ exit (EXIT_FAILURE );
13391368 }
13401369
13411370 /* Only close if we used the pager */
0 commit comments