Re: pgsql: dblink: Replace some macros by static functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: dblink: Replace some macros by static functions
Date: 2017-03-13 19:58:06
Message-ID: 30881.1489435086@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> writes:
> On 3/12/17 17:44, David Rowley wrote:
>> Please accept a small patch which fixes a new compiler warning which
>> started as a result of this commit.

> Done.

> Which compiler is that?

Any compiler that didn't support pg_attribute_noreturn() could be expected
to whine about the original coding.

In the same vein, I think this bit in dblink_open is pretty poor coding
practice:

if (!rconn || !rconn->conn)
dblink_conn_not_avail(conname);
else
conn = rconn->conn;

as it expects both the compiler and the reader to understand that
we will not proceed without "conn" getting a value. I see that
that was band-aided around by initializing conn to NULL, but that's a
crummy way of suppressing uninitialized-variable warnings, because it
will mask even actual errors. Far better would be to remove the dummy
initialization and write

if (!rconn || !rconn->conn)
dblink_conn_not_avail(conname);
conn = rconn->conn;

regards, tom lane

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Meskes 2017-03-13 20:03:31 pgsql: Ecpg should support COMMIT PREPARED and ROLLBACK PREPARED.
Previous Message Heikki Linnakangas 2017-03-13 19:54:46 pgsql: Include array size in forward declaration.