pgbench is broken on strict-C89 compilers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: pgbench is broken on strict-C89 compilers
Date: 2014-05-17 23:15:15
Message-ID: 6687.1400368515@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I got around to trying to build PG with the HP-supplied compiler on my
ancient HPUX box, something I do about once a release cycle to see if
we've finally broken that trailing-edge toolchain. Things still seem
to work except for this:

cc: "pgbench.c", line 1579: error 1521: Incorrect initialization.
cc: "pgbench.c", line 1591: error 1521: Incorrect initialization.

What it's complaining about is these nonconstant initializers:

struct ddlinfo DDLs[] = {
{
"pgbench_history",
scale >= SCALE_32BIT_THRESHOLD
? "tid int,bid int,aid bigint,delta int,mtime timestamp,filler char(22)"
: "tid int,bid int,aid int,delta int,mtime timestamp,filler char(22)",
0
},

which were apparently added in commit 89d00cbe. It appears to me that
the compiler is within its rights to refuse a nonconstant expression
for an inner initializer according to C89, though I don't see any such
restriction in C99.

We shipped this code in 9.3, and nobody's complained yet, so maybe
it's time to forget about C89 compliance. On the other hand, minor
notational convenience seems like a pretty poor reason to move the
goalposts for C language compliance, so I'm inclined to fix this.

I'm not entirely sure what the least ugly substitute code would be.
One idea is to replace the bigint/int column types with %s and fill
in the correct type with a snprintf operation, but that's not real
attractive because it would only work for a single such column,
and the compiler could not catch any format-spec-mismatch problems.

Thoughts?

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2014-05-17 23:30:31 Re: pgbench is broken on strict-C89 compilers
Previous Message Christoph Berg 2014-05-17 22:40:42 Re: 9.4 beta1 crash on Debian sid/i386