Re: pgsql: Allow multiple xacts during table sync in logical replication. - Mailing list pgsql-committers

From Tom Lane
Subject Re: pgsql: Allow multiple xacts during table sync in logical replication.
Date
Msg-id 1610789.1613170207@sss.pgh.pa.us
Whole thread Raw
In response to Re: pgsql: Allow multiple xacts during table sync in logical replication.  (Amit Kapila <amit.kapila16@gmail.com>)
Responses Re: pgsql: Allow multiple xacts during table sync in logical replication.  (Amit Kapila <amit.kapila16@gmail.com>)
List pgsql-committers
Various buildfarm members are complaining about this patch, eg

 caiman        | 2021-02-12 15:00:19 | tablesync.c:885:70: warning: argument 3 of type 'char[64]' with mismatched bound
[-Warray-parameter=]
 caiman        | 2021-02-12 15:00:19 | tablesync.c:904:72: warning: argument 3 of type 'char[64]' with mismatched bound
[-Warray-parameter=]

That's because of the inconsistency between

extern void ReplicationOriginNameForTablesync(Oid suboid, Oid relid, char *originname);

and

void
ReplicationOriginNameForTablesync(Oid suboid, Oid relid,
                                  char originname[NAMEDATALEN])

Don't do that.  Quite aside from the inconsistency, this is pretty
darn unsafe coding technique, because there is exactly nothing
guaranteeing that the caller passes a buffer of the length the
function expects.

I'm not real sure that you could expect a compiler warning for that
even if you'd put the length declaration where callers could see it.
So personally I'd avoid hard-wiring NAMEDATALEN into this API at all,
and have the caller pass sizeof(its buffer) instead.

            regards, tom lane



pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Tweak compiler version cutoff for no_sanitize("alignment") suppo
Next
From: Amit Kapila
Date:
Subject: Re: pgsql: Allow multiple xacts during table sync in logical replication.