MCPcopy Create free account
hub / github.com/apache/cloudberry / printTable

Function printTable

src/fe_utils/print.c:3321–3416  ·  view source on GitHub ↗

* Use this to print any table in the supported formats. * * cont: table data and formatting options * fout: where to print to * is_pager: true if caller has already redirected fout to be a pager pipe * flog: if not null, also print the table there (for --log-file option) */

Source from the content-addressed store, hash-verified

3319 * flog: if not null, also print the table there (for --log-file option)
3320 */
3321void
3322printTable(const printTableContent *cont,
3323 FILE *fout, bool is_pager, FILE *flog)
3324{
3325 bool is_local_pager = false;
3326
3327 if (cancel_pressed)
3328 return;
3329
3330 if (cont->opt->format == PRINT_NOTHING)
3331 return;
3332
3333 /* print_aligned_*() handle the pager themselves */
3334 if (!is_pager &&
3335 cont->opt->format != PRINT_ALIGNED &&
3336 cont->opt->format != PRINT_WRAPPED)
3337 {
3338 IsPagerNeeded(cont, 0, (cont->opt->expanded == 1), &fout, &is_pager);
3339 is_local_pager = is_pager;
3340 }
3341
3342 /* clear any pre-existing error indication on the output stream */
3343 clearerr(fout);
3344
3345 /* print the stuff */
3346
3347 if (flog)
3348 print_aligned_text(cont, flog, false);
3349
3350 switch (cont->opt->format)
3351 {
3352 case PRINT_UNALIGNED:
3353 if (cont->opt->expanded == 1)
3354 print_unaligned_vertical(cont, fout);
3355 else
3356 print_unaligned_text(cont, fout);
3357 break;
3358 case PRINT_ALIGNED:
3359 case PRINT_WRAPPED:
3360
3361 /*
3362 * In expanded-auto mode, force vertical if a pager is passed in;
3363 * else we may make different decisions for different hunks of the
3364 * query result.
3365 */
3366 if (cont->opt->expanded == 1 ||
3367 (cont->opt->expanded == 2 && is_pager))
3368 print_aligned_vertical(cont, fout, is_pager);
3369 else
3370 print_aligned_text(cont, fout, is_pager);
3371 break;
3372 case PRINT_CSV:
3373 if (cont->opt->expanded == 1)
3374 print_csv_vertical(cont, fout);
3375 else
3376 print_csv_text(cont, fout);
3377 break;
3378 case PRINT_HTML:

Callers 5

printQueryFunction · 0.85
printCrosstabFunction · 0.85
describeOneTableDetailsFunction · 0.85
describeRolesFunction · 0.85
describePublicationsFunction · 0.85

Calls 15

IsPagerNeededFunction · 0.85
print_aligned_textFunction · 0.85
print_unaligned_verticalFunction · 0.85
print_unaligned_textFunction · 0.85
print_aligned_verticalFunction · 0.85
print_csv_verticalFunction · 0.85
print_csv_textFunction · 0.85
print_html_verticalFunction · 0.85
print_html_textFunction · 0.85
print_asciidoc_verticalFunction · 0.85
print_asciidoc_textFunction · 0.85
print_latex_verticalFunction · 0.85

Tested by

no test coverage detected