PostgreSQL Source Code git master
fe-print.c
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * fe-print.c
4 * functions for pretty-printing query results
5 *
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 * These functions were formerly part of fe-exec.c, but they
10 * didn't really belong there.
11 *
12 * IDENTIFICATION
13 * src/interfaces/libpq/fe-print.c
14 *
15 *-------------------------------------------------------------------------
16 */
17#include "postgres_fe.h"
18
19#include <signal.h>
20
21#ifdef WIN32
22#include "win32.h"
23#else
24#include <unistd.h>
25#include <sys/ioctl.h>
26#endif
27
28#ifdef HAVE_TERMIOS_H
29#include <termios.h>
30#else
31#ifndef WIN32
32#include <sys/termios.h>
33#endif
34#endif
35
36#include "libpq-fe.h"
37#include "libpq-int.h"
38
39
40static bool do_field(const PQprintOpt *po, const PGresult *res,
41 const int i, const int j, const int fs_len,
42 char **fields,
43 const int nFields, const char **fieldNames,
44 unsigned char *fieldNotNum, int *fieldMax,
45 const int fieldMaxLen, FILE *fout);
46static char *do_header(FILE *fout, const PQprintOpt *po, const int nFields,
47 int *fieldMax, const char **fieldNames, unsigned char *fieldNotNum,
48 const int fs_len, const PGresult *res);
49static void output_row(FILE *fout, const PQprintOpt *po, const int nFields, char **fields,
50 unsigned char *fieldNotNum, int *fieldMax, char *border,
51 const int row_index);
52static void fill(int length, int max, char filler, FILE *fp);
53
54/*
55 * PQprint()
56 *
57 * Format results of a query for printing.
58 *
59 * PQprintOpt is a typedef (structure) that contains
60 * various flags and options. consult libpq-fe.h for
61 * details
62 *
63 * This function should probably be removed sometime since psql
64 * doesn't use it anymore. It is unclear to what extent this is used
65 * by external clients, however.
66 */
67void
68PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
69{
70 int nFields;
71
72 nFields = PQnfields(res);
73
74 if (nFields > 0)
75 { /* only print rows with at least 1 field. */
76 int i,
77 j;
78 int nTups;
79 int *fieldMax = NULL; /* in case we don't use them */
80 unsigned char *fieldNotNum = NULL;
81 char *border = NULL;
82 char **fields = NULL;
83 const char **fieldNames = NULL;
84 int fieldMaxLen = 0;
85 int numFieldName;
86 int fs_len = strlen(po->fieldSep);
87 int total_line_length = 0;
88 bool usePipe = false;
89 char *pagerenv;
90
91#if !defined(WIN32)
92 sigset_t osigset;
93 bool sigpipe_masked = false;
94 bool sigpipe_pending;
95#endif
96
97#ifdef TIOCGWINSZ
98 struct winsize screen_size;
99#else
100 struct winsize
101 {
102 int ws_row;
103 int ws_col;
104 } screen_size;
105#endif
106
107 /*
108 * Quick sanity check on po->fieldSep, since we make heavy use of int
109 * math throughout.
110 */
111 if (fs_len < strlen(po->fieldSep))
112 {
113 fprintf(stderr, libpq_gettext("overlong field separator\n"));
114 goto exit;
115 }
116
117 nTups = PQntuples(res);
118 fieldNames = (const char **) calloc(nFields, sizeof(char *));
119 fieldNotNum = (unsigned char *) calloc(nFields, 1);
120 fieldMax = (int *) calloc(nFields, sizeof(int));
121 if (!fieldNames || !fieldNotNum || !fieldMax)
122 {
123 fprintf(stderr, libpq_gettext("out of memory\n"));
124 goto exit;
125 }
126 for (numFieldName = 0;
127 po->fieldName && po->fieldName[numFieldName];
128 numFieldName++)
129 ;
130 for (j = 0; j < nFields; j++)
131 {
132 int len;
133 const char *s = (j < numFieldName && po->fieldName[j][0]) ?
134 po->fieldName[j] : PQfname(res, j);
135
136 fieldNames[j] = s;
137 len = s ? strlen(s) : 0;
138 fieldMax[j] = len;
139 len += fs_len;
140 if (len > fieldMaxLen)
141 fieldMaxLen = len;
142 total_line_length += len;
143 }
144
145 total_line_length += nFields * strlen(po->fieldSep) + 1;
146
147 if (fout == NULL)
148 fout = stdout;
149 if (po->pager && fout == stdout && isatty(fileno(stdin)) &&
150 isatty(fileno(stdout)))
151 {
152 /*
153 * If we think there'll be more than one screen of output, try to
154 * pipe to the pager program.
155 */
156#ifdef TIOCGWINSZ
157 if (ioctl(fileno(stdout), TIOCGWINSZ, &screen_size) == -1 ||
158 screen_size.ws_col == 0 ||
159 screen_size.ws_row == 0)
160 {
161 screen_size.ws_row = 24;
162 screen_size.ws_col = 80;
163 }
164#else
165 screen_size.ws_row = 24;
166 screen_size.ws_col = 80;
167#endif
168
169 /*
170 * Since this function is no longer used by psql, we don't examine
171 * PSQL_PAGER. It's possible that the hypothetical external users
172 * of the function would like that to happen, but in the name of
173 * backwards compatibility, we'll stick to just examining PAGER.
174 */
175 pagerenv = getenv("PAGER");
176 /* if PAGER is unset, empty or all-white-space, don't use pager */
177 if (pagerenv != NULL &&
178 strspn(pagerenv, " \t\r\n") != strlen(pagerenv) &&
179 !po->html3 &&
180 ((po->expanded &&
181 nTups * (nFields + 1) >= screen_size.ws_row) ||
182 (!po->expanded &&
183 nTups * (total_line_length / screen_size.ws_col + 1) *
184 (1 + (po->standard != 0)) >= screen_size.ws_row -
185 (po->header != 0) *
186 (total_line_length / screen_size.ws_col + 1) * 2
187 - (po->header != 0) * 2 /* row count and newline */
188 )))
189 {
190 fflush(NULL);
191 fout = popen(pagerenv, "w");
192 if (fout)
193 {
194 usePipe = true;
195#ifndef WIN32
196 if (pq_block_sigpipe(&osigset, &sigpipe_pending) == 0)
197 sigpipe_masked = true;
198#endif /* WIN32 */
199 }
200 else
201 fout = stdout;
202 }
203 }
204
205 if (!po->expanded && (po->align || po->html3))
206 {
207 fields = (char **) calloc((size_t) nTups + 1,
208 nFields * sizeof(char *));
209 if (!fields)
210 {
211 fprintf(stderr, libpq_gettext("out of memory\n"));
212 goto exit;
213 }
214 }
215 else if (po->header && !po->html3)
216 {
217 if (po->expanded)
218 {
219 if (po->align)
220 fprintf(fout, libpq_gettext("%-*s%s Value\n"),
221 fieldMaxLen - fs_len, libpq_gettext("Field"), po->fieldSep);
222 else
223 fprintf(fout, libpq_gettext("%s%sValue\n"), libpq_gettext("Field"), po->fieldSep);
224 }
225 else
226 {
227 int len = 0;
228
229 for (j = 0; j < nFields; j++)
230 {
231 const char *s = fieldNames[j];
232
233 fputs(s, fout);
234 len += strlen(s) + fs_len;
235 if ((j + 1) < nFields)
236 fputs(po->fieldSep, fout);
237 }
238 fputc('\n', fout);
239 for (len -= fs_len; len--; fputc('-', fout));
240 fputc('\n', fout);
241 }
242 }
243 if (po->expanded && po->html3)
244 {
245 if (po->caption)
246 fprintf(fout, "<center><h2>%s</h2></center>\n", po->caption);
247 else
248 fprintf(fout,
249 "<center><h2>"
250 "Query retrieved %d rows * %d fields"
251 "</h2></center>\n",
252 nTups, nFields);
253 }
254 for (i = 0; i < nTups; i++)
255 {
256 if (po->expanded)
257 {
258 if (po->html3)
259 fprintf(fout,
260 "<table %s><caption align=\"top\">%d</caption>\n",
261 po->tableOpt ? po->tableOpt : "", i);
262 else
263 fprintf(fout, libpq_gettext("-- RECORD %d --\n"), i);
264 }
265 for (j = 0; j < nFields; j++)
266 {
267 if (!do_field(po, res, i, j, fs_len, fields, nFields,
268 fieldNames, fieldNotNum,
269 fieldMax, fieldMaxLen, fout))
270 goto exit;
271 }
272 if (po->html3 && po->expanded)
273 fputs("</table>\n", fout);
274 }
275 if (!po->expanded && (po->align || po->html3))
276 {
277 if (po->html3)
278 {
279 if (po->header)
280 {
281 if (po->caption)
282 fprintf(fout,
283 "<table %s><caption align=\"top\">%s</caption>\n",
284 po->tableOpt ? po->tableOpt : "",
285 po->caption);
286 else
287 fprintf(fout,
288 "<table %s><caption align=\"top\">"
289 "Retrieved %d rows * %d fields"
290 "</caption>\n",
291 po->tableOpt ? po->tableOpt : "", nTups, nFields);
292 }
293 else
294 fprintf(fout, "<table %s>", po->tableOpt ? po->tableOpt : "");
295 }
296 if (po->header)
297 border = do_header(fout, po, nFields, fieldMax, fieldNames,
298 fieldNotNum, fs_len, res);
299 for (i = 0; i < nTups; i++)
300 output_row(fout, po, nFields, fields,
301 fieldNotNum, fieldMax, border, i);
302 }
303 if (po->header && !po->html3)
304 fprintf(fout, "(%d row%s)\n\n", PQntuples(res),
305 (PQntuples(res) == 1) ? "" : "s");
306 if (po->html3 && !po->expanded)
307 fputs("</table>\n", fout);
308
309exit:
310 free(fieldMax);
311 free(fieldNotNum);
312 free(border);
313 if (fields)
314 {
315 /* if calloc succeeded, this shouldn't overflow size_t */
316 size_t numfields = ((size_t) nTups + 1) * (size_t) nFields;
317
318 while (numfields-- > 0)
319 free(fields[numfields]);
320 free(fields);
321 }
322 free(fieldNames);
323 if (usePipe)
324 {
325#ifdef WIN32
326 _pclose(fout);
327#else
328 pclose(fout);
329
330 /* we can't easily verify if EPIPE occurred, so say it did */
331 if (sigpipe_masked)
332 pq_reset_sigpipe(&osigset, sigpipe_pending, true);
333#endif /* WIN32 */
334 }
335 }
336}
337
338
339static bool
340do_field(const PQprintOpt *po, const PGresult *res,
341 const int i, const int j, const int fs_len,
342 char **fields,
343 const int nFields, char const **fieldNames,
344 unsigned char *fieldNotNum, int *fieldMax,
345 const int fieldMaxLen, FILE *fout)
346{
347 const char *pval,
348 *p;
349 int plen;
350 bool skipit;
351
352 plen = PQgetlength(res, i, j);
353 pval = PQgetvalue(res, i, j);
354
355 if (plen < 1 || !pval || !*pval)
356 {
357 if (po->align || po->expanded)
358 skipit = true;
359 else
360 {
361 skipit = false;
362 goto efield;
363 }
364 }
365 else
366 skipit = false;
367
368 if (!skipit)
369 {
370 if (po->align && !fieldNotNum[j])
371 {
372 /* Detect whether field contains non-numeric data */
373 char ch = '0';
374
375 for (p = pval; *p; p += PQmblenBounded(p, res->client_encoding))
376 {
377 ch = *p;
378 if (!((ch >= '0' && ch <= '9') ||
379 ch == '.' ||
380 ch == 'E' ||
381 ch == 'e' ||
382 ch == ' ' ||
383 ch == '-'))
384 {
385 fieldNotNum[j] = 1;
386 break;
387 }
388 }
389
390 /*
391 * Above loop will believe E in first column is numeric; also, we
392 * insist on a digit in the last column for a numeric. This test
393 * is still not bulletproof but it handles most cases.
394 */
395 if (*pval == 'E' || *pval == 'e' ||
396 !(ch >= '0' && ch <= '9'))
397 fieldNotNum[j] = 1;
398 }
399
400 if (!po->expanded && (po->align || po->html3))
401 {
402 if (plen > fieldMax[j])
403 fieldMax[j] = plen;
404 if (!(fields[i * nFields + j] = (char *) malloc((size_t) plen + 1)))
405 {
406 fprintf(stderr, libpq_gettext("out of memory\n"));
407 return false;
408 }
409 strcpy(fields[i * nFields + j], pval);
410 }
411 else
412 {
413 if (po->expanded)
414 {
415 if (po->html3)
416 fprintf(fout,
417 "<tr><td align=\"left\"><b>%s</b></td>"
418 "<td align=\"%s\">%s</td></tr>\n",
419 fieldNames[j],
420 fieldNotNum[j] ? "left" : "right",
421 pval);
422 else
423 {
424 if (po->align)
425 fprintf(fout,
426 "%-*s%s %s\n",
427 fieldMaxLen - fs_len, fieldNames[j],
428 po->fieldSep,
429 pval);
430 else
431 fprintf(fout,
432 "%s%s%s\n",
433 fieldNames[j], po->fieldSep, pval);
434 }
435 }
436 else
437 {
438 if (!po->html3)
439 {
440 fputs(pval, fout);
441 efield:
442 if ((j + 1) < nFields)
443 fputs(po->fieldSep, fout);
444 else
445 fputc('\n', fout);
446 }
447 }
448 }
449 }
450 return true;
451}
452
453
454/*
455 * Frontend version of the backend's add_size(), intended to be API-compatible
456 * with the pg_add_*_overflow() helpers. Stores the result into *dst on success.
457 * Returns true instead if the addition overflows.
458 *
459 * TODO: move to common/int.h
460 */
461static bool
462add_size_overflow(size_t s1, size_t s2, size_t *dst)
463{
464 size_t result;
465
466 result = s1 + s2;
467 if (result < s1 || result < s2)
468 return true;
469
470 *dst = result;
471 return false;
472}
473
474
475static char *
476do_header(FILE *fout, const PQprintOpt *po, const int nFields, int *fieldMax,
477 const char **fieldNames, unsigned char *fieldNotNum,
478 const int fs_len, const PGresult *res)
479{
480 int j; /* for loop index */
481 char *border = NULL;
482
483 if (po->html3)
484 fputs("<tr>", fout);
485 else
486 {
487 size_t tot = 0;
488 int n = 0;
489 char *p = NULL;
490
491 /* Calculate the border size, checking for overflow. */
492 for (; n < nFields; n++)
493 {
494 /* Field plus separator, plus 2 extra '-' in standard format. */
495 if (add_size_overflow(tot, fieldMax[n], &tot) ||
496 add_size_overflow(tot, fs_len, &tot) ||
497 (po->standard && add_size_overflow(tot, 2, &tot)))
498 goto overflow;
499 }
500 if (po->standard)
501 {
502 /* An extra separator at the front and back. */
503 if (add_size_overflow(tot, fs_len, &tot) ||
504 add_size_overflow(tot, fs_len, &tot) ||
505 add_size_overflow(tot, 2, &tot))
506 goto overflow;
507 }
508 if (add_size_overflow(tot, 1, &tot)) /* terminator */
509 goto overflow;
510
511 border = malloc(tot);
512 if (!border)
513 {
514 fprintf(stderr, libpq_gettext("out of memory\n"));
515 return NULL;
516 }
517 p = border;
518 if (po->standard)
519 {
520 char *fs = po->fieldSep;
521
522 while (*fs++)
523 *p++ = '+';
524 }
525 for (j = 0; j < nFields; j++)
526 {
527 int len;
528
529 for (len = fieldMax[j] + (po->standard ? 2 : 0); len--; *p++ = '-');
530 if (po->standard || (j + 1) < nFields)
531 {
532 char *fs = po->fieldSep;
533
534 while (*fs++)
535 *p++ = '+';
536 }
537 }
538 *p = '\0';
539 if (po->standard)
540 fprintf(fout, "%s\n", border);
541 }
542 if (po->standard)
543 fputs(po->fieldSep, fout);
544 for (j = 0; j < nFields; j++)
545 {
546 const char *s = PQfname(res, j);
547
548 if (po->html3)
549 {
550 fprintf(fout, "<th align=\"%s\">%s</th>",
551 fieldNotNum[j] ? "left" : "right", fieldNames[j]);
552 }
553 else
554 {
555 int n = strlen(s);
556
557 if (n > fieldMax[j])
558 fieldMax[j] = n;
559 if (po->standard)
560 fprintf(fout,
561 fieldNotNum[j] ? " %-*s " : " %*s ",
562 fieldMax[j], s);
563 else
564 fprintf(fout, fieldNotNum[j] ? "%-*s" : "%*s", fieldMax[j], s);
565 if (po->standard || (j + 1) < nFields)
566 fputs(po->fieldSep, fout);
567 }
568 }
569 if (po->html3)
570 fputs("</tr>\n", fout);
571 else
572 fprintf(fout, "\n%s\n", border);
573 return border;
574
575overflow:
576 fprintf(stderr, libpq_gettext("header size exceeds the maximum allowed\n"));
577 return NULL;
578}
579
580
581static void
582output_row(FILE *fout, const PQprintOpt *po, const int nFields, char **fields,
583 unsigned char *fieldNotNum, int *fieldMax, char *border,
584 const int row_index)
585{
586 int field_index; /* for loop index */
587
588 if (po->html3)
589 fputs("<tr>", fout);
590 else if (po->standard)
591 fputs(po->fieldSep, fout);
592 for (field_index = 0; field_index < nFields; field_index++)
593 {
594 char *p = fields[row_index * nFields + field_index];
595
596 if (po->html3)
597 fprintf(fout, "<td align=\"%s\">%s</td>",
598 fieldNotNum[field_index] ? "left" : "right", p ? p : "");
599 else
600 {
601 fprintf(fout,
602 fieldNotNum[field_index] ?
603 (po->standard ? " %-*s " : "%-*s") :
604 (po->standard ? " %*s " : "%*s"),
605 fieldMax[field_index],
606 p ? p : "");
607 if (po->standard || field_index + 1 < nFields)
608 fputs(po->fieldSep, fout);
609 }
610 }
611 if (po->html3)
612 fputs("</tr>", fout);
613 else if (po->standard)
614 fprintf(fout, "\n%s", border);
615 fputc('\n', fout);
616}
617
618
619
620/*
621 * really old printing routines
622 */
623
624void
626 FILE *fp, /* where to send the output */
627 int fillAlign, /* pad the fields with spaces */
628 const char *fieldSep, /* field separator */
629 int printHeader, /* display headers? */
630 int quiet
631)
632{
633#define DEFAULT_FIELD_SEP " "
634
635 int i,
636 j;
637 int nFields;
638 int nTuples;
639 int *fLength = NULL;
640
641 if (fieldSep == NULL)
642 fieldSep = DEFAULT_FIELD_SEP;
643
644 /* Get some useful info about the results */
645 nFields = PQnfields(res);
646 nTuples = PQntuples(res);
647
648 if (fp == NULL)
649 fp = stdout;
650
651 /* Figure the field lengths to align to */
652 /* will be somewhat time consuming for very large results */
653 if (fillAlign)
654 {
655 fLength = (int *) malloc(nFields * sizeof(int));
656 if (!fLength)
657 {
658 fprintf(stderr, libpq_gettext("out of memory\n"));
659 return;
660 }
661
662 for (j = 0; j < nFields; j++)
663 {
664 fLength[j] = strlen(PQfname(res, j));
665 for (i = 0; i < nTuples; i++)
666 {
667 int flen = PQgetlength(res, i, j);
668
669 if (flen > fLength[j])
670 fLength[j] = flen;
671 }
672 }
673 }
674
675 if (printHeader)
676 {
677 /* first, print out the attribute names */
678 for (i = 0; i < nFields; i++)
679 {
680 fputs(PQfname(res, i), fp);
681 if (fillAlign)
682 fill(strlen(PQfname(res, i)), fLength[i], ' ', fp);
683 fputs(fieldSep, fp);
684 }
685 fprintf(fp, "\n");
686
687 /* Underline the attribute names */
688 for (i = 0; i < nFields; i++)
689 {
690 if (fillAlign)
691 fill(0, fLength[i], '-', fp);
692 fputs(fieldSep, fp);
693 }
694 fprintf(fp, "\n");
695 }
696
697 /* next, print out the instances */
698 for (i = 0; i < nTuples; i++)
699 {
700 for (j = 0; j < nFields; j++)
701 {
702 fprintf(fp, "%s", PQgetvalue(res, i, j));
703 if (fillAlign)
704 fill(strlen(PQgetvalue(res, i, j)), fLength[j], ' ', fp);
705 fputs(fieldSep, fp);
706 }
707 fprintf(fp, "\n");
708 }
709
710 if (!quiet)
711 fprintf(fp, "\nQuery returned %d row%s.\n", PQntuples(res),
712 (PQntuples(res) == 1) ? "" : "s");
713
714 fflush(fp);
715
716 free(fLength);
717}
718
719
720
721void
723 FILE *fout, /* output stream */
724 int PrintAttNames, /* print attribute names or not */
725 int TerseOutput, /* delimiter bars or not? */
726 int colWidth /* width of column, if 0, use variable width */
727)
728{
729 int nFields;
730 int nTups;
731 int i,
732 j;
733 char formatString[80];
734 char *tborder = NULL;
735
736 nFields = PQnfields(res);
737 nTups = PQntuples(res);
738
739 if (colWidth > 0)
740 sprintf(formatString, "%%s %%-%ds", colWidth);
741 else
742 sprintf(formatString, "%%s %%s");
743
744 if (nFields > 0)
745 { /* only print rows with at least 1 field. */
746
747 if (!TerseOutput)
748 {
749 int width;
750
751 width = nFields * 14;
752 tborder = (char *) malloc(width + 1);
753 if (!tborder)
754 {
755 fprintf(stderr, libpq_gettext("out of memory\n"));
756 return;
757 }
758 for (i = 0; i < width; i++)
759 tborder[i] = '-';
760 tborder[width] = '\0';
761 fprintf(fout, "%s\n", tborder);
762 }
763
764 for (i = 0; i < nFields; i++)
765 {
766 if (PrintAttNames)
767 {
768 fprintf(fout, formatString,
769 TerseOutput ? "" : "|",
770 PQfname(res, i));
771 }
772 }
773
774 if (PrintAttNames)
775 {
776 if (TerseOutput)
777 fprintf(fout, "\n");
778 else
779 fprintf(fout, "|\n%s\n", tborder);
780 }
781
782 for (i = 0; i < nTups; i++)
783 {
784 for (j = 0; j < nFields; j++)
785 {
786 const char *pval = PQgetvalue(res, i, j);
787
788 fprintf(fout, formatString,
789 TerseOutput ? "" : "|",
790 pval ? pval : "");
791 }
792 if (TerseOutput)
793 fprintf(fout, "\n");
794 else
795 fprintf(fout, "|\n%s\n", tborder);
796 }
797 }
798
799 free(tborder);
800}
801
802
803/* simply send out max-length number of filler characters to fp */
804
805static void
806fill(int length, int max, char filler, FILE *fp)
807{
808 int count;
809
810 count = max - length;
811 while (count-- >= 0)
812 putc(filler, fp);
813}
#define fprintf(file, fmt, msg)
Definition: cubescan.l:21
int PQmblenBounded(const char *s, int encoding)
Definition: fe-misc.c:1266
void PQdisplayTuples(const PGresult *res, FILE *fp, int fillAlign, const char *fieldSep, int printHeader, int quiet)
Definition: fe-print.c:625
static void fill(int length, int max, char filler, FILE *fp)
Definition: fe-print.c:806
#define DEFAULT_FIELD_SEP
void PQprintTuples(const PGresult *res, FILE *fout, int PrintAttNames, int TerseOutput, int colWidth)
Definition: fe-print.c:722
void PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
Definition: fe-print.c:68
static char * do_header(FILE *fout, const PQprintOpt *po, const int nFields, int *fieldMax, const char **fieldNames, unsigned char *fieldNotNum, const int fs_len, const PGresult *res)
Definition: fe-print.c:476
static bool do_field(const PQprintOpt *po, const PGresult *res, const int i, const int j, const int fs_len, char **fields, const int nFields, const char **fieldNames, unsigned char *fieldNotNum, int *fieldMax, const int fieldMaxLen, FILE *fout)
Definition: fe-print.c:340
static void output_row(FILE *fout, const PQprintOpt *po, const int nFields, char **fields, unsigned char *fieldNotNum, int *fieldMax, char *border, const int row_index)
Definition: fe-print.c:582
static bool add_size_overflow(size_t s1, size_t s2, size_t *dst)
Definition: fe-print.c:462
#define calloc(a, b)
Definition: header.h:55
#define free(a)
Definition: header.h:65
#define malloc(a)
Definition: header.h:50
int j
Definition: isn.c:78
int i
Definition: isn.c:77
#define PQgetvalue
Definition: libpq-be-fe.h:253
#define PQgetlength
Definition: libpq-be-fe.h:254
#define PQnfields
Definition: libpq-be-fe.h:252
#define PQfname
Definition: libpq-be-fe.h:256
#define PQntuples
Definition: libpq-be-fe.h:251
void pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending, bool got_epipe)
Definition: oauth-utils.c:208
int pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending)
Definition: oauth-utils.c:172
#define libpq_gettext(x)
Definition: oauth-utils.h:86
const void size_t len
#define sprintf
Definition: port.h:241
char * s1
char * s2
pqbool align
Definition: libpq-fe.h:250
pqbool pager
Definition: libpq-fe.h:254
pqbool standard
Definition: libpq-fe.h:251
pqbool html3
Definition: libpq-fe.h:252
char * caption
Definition: libpq-fe.h:257
pqbool header
Definition: libpq-fe.h:249
pqbool expanded
Definition: libpq-fe.h:253
char * fieldSep
Definition: libpq-fe.h:255
char ** fieldName
Definition: libpq-fe.h:258
char * tableOpt
Definition: libpq-fe.h:256
int client_encoding
Definition: libpq-int.h:186