3
3
*
4
4
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
5
5
*
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 $
7
7
*/
8
8
#include "postgres_fe.h"
9
9
#include "common.h"
29
29
30
30
#include "mbprint.h"
31
31
32
-
33
32
/*************************/
34
33
/* Unaligned text */
35
34
/*************************/
@@ -1261,6 +1260,7 @@ printTable(const char *title,
1261
1260
const char * default_footer [] = {NULL };
1262
1261
unsigned short int border = opt -> border ;
1263
1262
FILE * output ;
1263
+ bool use_expanded ;
1264
1264
1265
1265
if (opt -> format == PRINT_NOTHING )
1266
1266
return ;
@@ -1271,6 +1271,16 @@ printTable(const char *title,
1271
1271
if (opt -> format != PRINT_HTML && border > 2 )
1272
1272
border = 2 ;
1273
1273
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
+
1274
1284
if (fout == stdout )
1275
1285
{
1276
1286
int col_count = 0 ,
@@ -1305,37 +1315,56 @@ printTable(const char *title,
1305
1315
switch (opt -> format )
1306
1316
{
1307
1317
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 );
1310
1322
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 );
1312
1326
break ;
1313
1327
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 );
1316
1332
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 );
1318
1336
break ;
1319
1337
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 );
1322
1342
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 );
1324
1346
break ;
1325
1347
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 );
1328
1351
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 );
1330
1354
break ;
1331
1355
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 );
1334
1360
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 );
1336
1364
break ;
1337
1365
default :
1338
- fprintf (stderr , "+ Oops, you shouldn't see this!\n" );
1366
+ fprintf (stderr , _ ("illegal output format: %d" ), opt -> format );
1367
+ exit (EXIT_FAILURE );
1339
1368
}
1340
1369
1341
1370
/* Only close if we used the pager */
0 commit comments