Commit 93df658a authored by Heikki Linnakangas's avatar Heikki Linnakangas

Fix numericlocale psql option when used with a null string and latex and troff

formats; a null string must not be formatted as a numeric. The more exotic
formats latex and troff also incorrectly formatted all strings as numerics
when numericlocale was on.

Backpatch to 8.1 where numericlocale option was added.

This fixes bug #5355 reported by Andy Lester.
parent d6a6f8c6
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* Copyright (c) 2000-2010, PostgreSQL Global Development Group * Copyright (c) 2000-2010, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.238 2010/02/26 02:01:18 momjian Exp $ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.239 2010/03/01 20:55:45 heikki Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -1349,10 +1349,10 @@ describeOneTableDetails(const char *schemaname, ...@@ -1349,10 +1349,10 @@ describeOneTableDetails(const char *schemaname,
for (i = 0; i < numrows; i++) for (i = 0; i < numrows; i++)
{ {
/* Column */ /* Column */
printTableAddCell(&cont, PQgetvalue(res, i, 0), false); printTableAddCell(&cont, PQgetvalue(res, i, 0), false, false);
/* Type */ /* Type */
printTableAddCell(&cont, PQgetvalue(res, i, 1), false); printTableAddCell(&cont, PQgetvalue(res, i, 1), false, false);
/* Modifiers: not null and default */ /* Modifiers: not null and default */
if (show_modifiers) if (show_modifiers)
...@@ -1373,16 +1373,16 @@ describeOneTableDetails(const char *schemaname, ...@@ -1373,16 +1373,16 @@ describeOneTableDetails(const char *schemaname,
} }
modifiers[i] = pg_strdup(tmpbuf.data); modifiers[i] = pg_strdup(tmpbuf.data);
printTableAddCell(&cont, modifiers[i], false); printTableAddCell(&cont, modifiers[i], false, false);
} }
/* Value: for sequences only */ /* Value: for sequences only */
if (tableinfo.relkind == 'S') if (tableinfo.relkind == 'S')
printTableAddCell(&cont, seq_values[i], false); printTableAddCell(&cont, seq_values[i], false, false);
/* Expression for index column */ /* Expression for index column */
if (tableinfo.relkind == 'i') if (tableinfo.relkind == 'i')
printTableAddCell(&cont, PQgetvalue(res, i, 5), false); printTableAddCell(&cont, PQgetvalue(res, i, 5), false, false);
/* Storage and Description */ /* Storage and Description */
if (verbose) if (verbose)
...@@ -1396,8 +1396,9 @@ describeOneTableDetails(const char *schemaname, ...@@ -1396,8 +1396,9 @@ describeOneTableDetails(const char *schemaname,
(storage[0] == 'x' ? "extended" : (storage[0] == 'x' ? "extended" :
(storage[0] == 'e' ? "external" : (storage[0] == 'e' ? "external" :
"???")))), "???")))),
false); false, false);
printTableAddCell(&cont, PQgetvalue(res, i, firstvcol + 1), false); printTableAddCell(&cont, PQgetvalue(res, i, firstvcol + 1),
false, false);
} }
} }
...@@ -2243,7 +2244,7 @@ describeRoles(const char *pattern, bool verbose) ...@@ -2243,7 +2244,7 @@ describeRoles(const char *pattern, bool verbose)
for (i = 0; i < nrows; i++) for (i = 0; i < nrows; i++)
{ {
printTableAddCell(&cont, PQgetvalue(res, i, 0), false); printTableAddCell(&cont, PQgetvalue(res, i, 0), false, false);
resetPQExpBuffer(&buf); resetPQExpBuffer(&buf);
if (strcmp(PQgetvalue(res, i, 1), "t") == 0) if (strcmp(PQgetvalue(res, i, 1), "t") == 0)
...@@ -2278,12 +2279,12 @@ describeRoles(const char *pattern, bool verbose) ...@@ -2278,12 +2279,12 @@ describeRoles(const char *pattern, bool verbose)
attr[i] = pg_strdup(buf.data); attr[i] = pg_strdup(buf.data);
printTableAddCell(&cont, attr[i], false); printTableAddCell(&cont, attr[i], false, false);
printTableAddCell(&cont, PQgetvalue(res, i, 7), false); printTableAddCell(&cont, PQgetvalue(res, i, 7), false, false);
if (verbose && pset.sversion >= 80200) if (verbose && pset.sversion >= 80200)
printTableAddCell(&cont, PQgetvalue(res, i, 8), false); printTableAddCell(&cont, PQgetvalue(res, i, 8), false, false);
} }
termPQExpBuffer(&buf); termPQExpBuffer(&buf);
......
This diff is collapsed.
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2010, PostgreSQL Global Development Group * Copyright (c) 2000-2010, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.44 2010/02/26 02:01:19 momjian Exp $ * $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.45 2010/03/01 20:55:45 heikki Exp $
*/ */
#ifndef PRINT_H #ifndef PRINT_H
#define PRINT_H #define PRINT_H
...@@ -119,6 +119,8 @@ typedef struct printTableContent ...@@ -119,6 +119,8 @@ typedef struct printTableContent
const char **cells; /* NULL-terminated array of cell content const char **cells; /* NULL-terminated array of cell content
* strings */ * strings */
const char **cell; /* Pointer to the last added cell */ const char **cell; /* Pointer to the last added cell */
long cellsadded; /* Number of cells added this far */
bool *cellmustfree; /* true for cells that need to be free()d */
printTableFooter *footers; /* Pointer to the first footer */ printTableFooter *footers; /* Pointer to the first footer */
printTableFooter *footer; /* Pointer to the last added footer */ printTableFooter *footer; /* Pointer to the last added footer */
char *aligns; /* Array of alignment specifiers; 'l' or 'r', char *aligns; /* Array of alignment specifiers; 'l' or 'r',
...@@ -156,7 +158,7 @@ extern void printTableInit(printTableContent *const content, ...@@ -156,7 +158,7 @@ extern void printTableInit(printTableContent *const content,
extern void printTableAddHeader(printTableContent *const content, extern void printTableAddHeader(printTableContent *const content,
const char *header, const bool translate, const char align); const char *header, const bool translate, const char align);
extern void printTableAddCell(printTableContent *const content, extern void printTableAddCell(printTableContent *const content,
const char *cell, const bool translate); const char *cell, const bool translate, const bool mustfree);
extern void printTableAddFooter(printTableContent *const content, extern void printTableAddFooter(printTableContent *const content,
const char *footer); const char *footer);
extern void printTableSetFooter(printTableContent *const content, extern void printTableSetFooter(printTableContent *const content,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment