Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ticR2-000RC9-K8 for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Feb 2025 16:51:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ticR0-00Aiqt-L5 for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Feb 2025 16:51:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ticR0-00Aiql-B4 for pgsql-hackers@lists.postgresql.org; Thu, 13 Feb 2025 16:51:31 +0000 Received: from charmander.telsasoft.com ([50.244.222.1] helo=pryzbyj2023.telsasoft) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ticQz-000c7t-0Y for pgsql-hackers@lists.postgresql.org; Thu, 13 Feb 2025 16:51:30 +0000 Received: by pryzbyj2023.telsasoft (Postfix, from userid 1000) id 6B9362965; Thu, 13 Feb 2025 10:51:27 -0600 (CST) Date: Thu, 13 Feb 2025 10:51:27 -0600 From: Justin Pryzby To: pgsql-hackers@lists.postgresql.org Subject: pg17.3 PQescapeIdentifier() ignores len Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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