]> granicus.if.org Git - postgresql/commitdiff
Get rid of scribbling on a const variable in psql's print.c.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 12 Mar 2016 23:16:24 +0000 (18:16 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 12 Mar 2016 23:16:38 +0000 (18:16 -0500)
Commit a2dabf0e1dda93c8 had the bright idea that it could modify a "const"
global variable if it merely casted away const from a pointer.  This does
not work on platforms where the compiler puts "const" variables into
read-only storage.  Depressingly, we evidently have no such platforms in
our buildfarm ... an oversight I have now remedied.  (The one platform
that is known to catch this is recent OS X with -fno-common.)

Per report from Chris Ruprecht.  Back-patch to 9.5 where the bogus
code was introduced.

src/bin/psql/print.c
src/bin/psql/print.h

index 05d4b3162c3441530a8d3cb286a23ba65ed5b827..c08d5af6bbe4aa6e81ce39e71f4db4ce7d9c74be 100644 (file)
@@ -98,7 +98,7 @@ const printTextFormat pg_asciiformat_old =
 };
 
 /* Default unicode linestyle format */
-const printTextFormat pg_utf8format;
+printTextFormat pg_utf8format;
 
 typedef struct unicodeStyleRowFormat
 {
@@ -3410,7 +3410,7 @@ get_line_style(const printTableOpt *opt)
 void
 refresh_utf8format(const printTableOpt *opt)
 {
-       printTextFormat *popt = (printTextFormat *) &pg_utf8format;
+       printTextFormat *popt = &pg_utf8format;
 
        const unicodeStyleBorderFormat *border;
        const unicodeStyleRowFormat *header;
index fd56598426da62390e7428cd6dcba1cbf457bebb..15a365e7d214e8927545b5d76a28d6a4bee3889e 100644 (file)
@@ -164,7 +164,7 @@ typedef struct printQueryOpt
 
 extern const printTextFormat pg_asciiformat;
 extern const printTextFormat pg_asciiformat_old;
-extern const printTextFormat pg_utf8format;
+extern printTextFormat pg_utf8format;  /* ideally would be const, but... */
 
 
 extern void disable_sigpipe_trap(void);