Thread: Re: BUG #18923: pg_dump 18beta1 fails to process complex table names
PG Bug reporting form <noreply@postgresql.org> writes: > I have just run the E-Maj project regression test suite with PG18 beta1 and > found a pg_dump abort when trying to dump a schema prefixed table having a > complex name including single quote, double quote and space. Thanks for the report! Looks like fetchAttributeStats() is completely misguided about the appropriate quoting rules for array elements. regards, tom lane
My first instinct is that we need to build the array with appendPGArray()
and then append it to the query using appendStringLiteralAH(), as done in
the attached patch.
This patch looks good to me, though I'm wondering if we should add a test case.
On Fri, May 16, 2025 at 3:03 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: > > Yeah, I think so. I was confused for a bit because the one extant > user of appendPGArray is getNamespaces which does an additional layer > of quote-doubling via quoteAclUserName. However, that seems to be because > it's trying to build aclitem[] arrays whose elements will be read by > aclitemin, and that de-dups double quotes. > getNamespaces use appendPGArray for object's initial ACL string getNamespaces `` nsinfo[i].dacl.initprivs = pstrdup(aclarray->data); `` and we seems *only* use it dumpACL->buildACLCommands `` if (!parsePGArray(baseacls, &baseitems, &nbaseitems)) { free(aclitems); free(baseitems); return false; } `` parsePGArray didn't handle single-quotes. I think the above is the reason single-quotes within array elements didn't cause trouble.