public inbox for [email protected]  
help / color / mirror / Atom feed
From: Justin Pryzby <[email protected]>
To: [email protected]
Subject: pg17.3 PQescapeIdentifier() ignores len
Date: Thu, 13 Feb 2025 10:51:27 -0600
Message-ID: <Z64jD3u46gObCo1p@pryzbyj2023> (raw)

I found errors in our sql log after upgrading to 17.3.

error_severity | ERROR
message        | schema "rptcache.44e3955c33bb79f55750897da0c5ab1fa2004af1_20250214" does not exist
query          | copy "rptcache.44e3955c33bb79f55750897da0c5ab1fa2004af1_20250214"."44e3955c33bb79f55750897da0c5ab1fa2004af1_20250214" from stdin

The copy command is from pygresql's inserttable(), which does:

    do {
        t = strchr(s, '.');
        if (!t)
            t = s + strlen(s);
        table = PQescapeIdentifier(self->cnx, s, (size_t)(t - s));
        fprintf(stderr, "table %s len %ld => %s\n", s, t-s, table);
        if (bufpt < bufmax)
            bufpt += snprintf(bufpt, (size_t)(bufmax - bufpt), "%s", table);
        PQfreemem(table);
        s = t;
        if (*s && bufpt < bufmax)
            *bufpt++ = *s++;
    } while (*s);

The fprintf suggests that since 5dc1e42b4 PQescapeIdentifier ignores its len.

python3 -c "import pg; db=pg.DB('postgres'); db.inserttable('child.a000000000000', [1])")
table child.a000000000000 len 5 => "child.a000000000000"
table a000000000000 len 13 => "a000000000000"

-- 
Justin






view thread (2+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pg17.3 PQescapeIdentifier() ignores len
  In-Reply-To: <Z64jD3u46gObCo1p@pryzbyj2023>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox