Skip to content

Commit 1598dc1

Browse files
committed
Get rid of scribbling on a const variable in psql's print.c.
Commit a2dabf0 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.
1 parent c84c87c commit 1598dc1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/bin/psql/print.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const printTextFormat pg_asciiformat_old =
9898
};
9999

100100
/* Default unicode linestyle format */
101-
const printTextFormat pg_utf8format;
101+
printTextFormat pg_utf8format;
102102

103103
typedef struct unicodeStyleRowFormat
104104
{
@@ -3410,7 +3410,7 @@ get_line_style(const printTableOpt *opt)
34103410
void
34113411
refresh_utf8format(const printTableOpt *opt)
34123412
{
3413-
printTextFormat *popt = (printTextFormat *) &pg_utf8format;
3413+
printTextFormat *popt = &pg_utf8format;
34143414

34153415
const unicodeStyleBorderFormat *border;
34163416
const unicodeStyleRowFormat *header;

src/bin/psql/print.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ typedef struct printQueryOpt
164164

165165
extern const printTextFormat pg_asciiformat;
166166
extern const printTextFormat pg_asciiformat_old;
167-
extern const printTextFormat pg_utf8format;
167+
extern printTextFormat pg_utf8format; /* ideally would be const, but... */
168168

169169

170170
extern void disable_sigpipe_trap(void);

0 commit comments

Comments
 (0)