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

Function printTableAddCell

src/fe_utils/print.c:3137–3174  ·  view source on GitHub ↗

* Add a cell to the table. * * Cells are not duplicated; you must ensure that the cell string is available * for the lifetime of the printTableContent struct. * * If translate is true, the function will pass the cell through gettext. * Otherwise, the cell will not be translated. * * If mustfree is true, the cell string is freed by printTableCleanup(). * Note: Automatic freeing of translat

Source from the content-addressed store, hash-verified

3135 * Note: Automatic freeing of translatable strings is not supported.
3136 */
3137void
3138printTableAddCell(printTableContent *const content, char *cell,
3139 const bool translate, const bool mustfree)
3140{
3141 long total_cells;
3142#ifndef ENABLE_NLS
3143 (void) translate; /* unused parameter */
3144#endif
3145
3146 /* product of cols and rows, using long type to prevent the int overflow */
3147 total_cells = (long)content->ncolumns * (long)content->nrows;
3148 if (content->cellsadded >= total_cells)
3149 {
3150 fprintf(stderr, _("Cannot add cell to table content: "
3151 "total cell count of %ld exceeded, cells added: %ld.\n"),
3152 total_cells, content->cellsadded);
3153 exit(EXIT_FAILURE);
3154 }
3155
3156 *content->cell = (char *) mbvalidate((unsigned char *) cell,
3157 content->opt->encoding);
3158
3159#ifdef ENABLE_NLS
3160 if (translate)
3161 *content->cell = _(*content->cell);
3162#endif
3163
3164 if (mustfree)
3165 {
3166 if (content->cellmustfree == NULL)
3167 content->cellmustfree =
3168 pg_malloc0((total_cells + 1) * sizeof(bool));
3169
3170 content->cellmustfree[content->cellsadded] = true;
3171 }
3172 content->cell++;
3173 content->cellsadded++;
3174}
3175
3176/*
3177 * Add a footer to the table.

Callers 5

printQueryFunction · 0.85
test_printTableAddCellFunction · 0.85
describeOneTableDetailsFunction · 0.85
describeRolesFunction · 0.85
describePublicationsFunction · 0.85

Calls 2

mbvalidateFunction · 0.85
pg_malloc0Function · 0.85

Tested by 1

test_printTableAddCellFunction · 0.68