Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fvNrC-0000hl-Qb for pgsql-docs@arkaria.postgresql.org; Thu, 30 Aug 2018 14:23:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fvNrB-0002vH-6B for pgsql-docs@arkaria.postgresql.org; Thu, 30 Aug 2018 14:23:33 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fvNrA-0002vA-RV for pgsql-docs@lists.postgresql.org; Thu, 30 Aug 2018 14:23:33 +0000 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fvNr7-0005S6-Vo for pgsql-docs@postgresql.org; Thu, 30 Aug 2018 14:23:31 +0000 Received: by mail-ed1-x543.google.com with SMTP id u1-v6so6505448eds.1 for ; Thu, 30 Aug 2018 07:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2aUJFTAtSC/Zmj1Ldb30eSKNNNtLMqUN0U+bAU0FtpE=; b=IX8rmjKt+TA5nJkFhsqR5C9JZQaLT/3vHpsGa+2s/jwNbp9xhocNyPhdGedMIiZnfg TjIMbAeV3QDxMK4+1JTwPwyDZonQLzHtsr0Aj+afuo6KFWeKCNVv+kghG+LRJ6vKDWPC 9hBPdkv4Yd1ScKVL1KpDuN0upJ3reD5L+MNyZZulPkvcccr6fSGV/Q0qgCIb9lFQm/Gm NgHM2K7JxYTqk6DqOZseEjzYVL3PrUVB2RB47fsKqxUTBaLIPtoWREnFfH097tzsfXOh 9fE/i1CORlkzwaP7t3shvOqrzbeB8y87qdEZLj2FEOimrN0xD+bNMZQ3y1sO0p1UezKg dXFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2aUJFTAtSC/Zmj1Ldb30eSKNNNtLMqUN0U+bAU0FtpE=; b=kgtmh1ZERTzUfH5+Y9jn2ocZNnQ81/JOsbYiZL7YsFm9d4H7ouc6evk0bBGDjBktDw 5gvUE2m5WsdAU9tpFUJwkrgW+TL0Xbtv09dh4KFBrJUlbaKjq8WcVdMYAsFZqzE3zkoS bF/Qpt7OF6U4JASiOmkdSrpqCGNbWvThK8hLsCyZmsQTKGPagvpSvg1VYkRvJPST1bKW hwJOCWaHzIgIywH00MVCm+DeYrZWtBVWl9Nrkv08xqYwemayuqIcgBVx+JI2oqw2AYM+ YKU5fzq1HzC3m274w7tsGnNkZO49rFoHQBzy8h8/OBiVifRpgm+x/956pY9AeG46hqIq Hi8A== X-Gm-Message-State: APzg51BRV3O3nq7nQA472vNAhsv8HvFSJ3qeINC5Q3B5VqV+d5M9LlhQ bTgeeZ4Qlv5bdsf0ZOOcUdQ3VmFiKtZmis3ehkc= X-Google-Smtp-Source: ANB0VdZxN5yeudifiigYaouP16T3rzNPzOCGvOfKoFAdV56kDmc3JrARZbvkPcuFZItcH3W9QeBYFg3lcuBaKwRUPrk= X-Received: by 2002:a50:81c6:: with SMTP id 64-v6mr13256928ede.93.1535639008257; Thu, 30 Aug 2018 07:23:28 -0700 (PDT) MIME-Version: 1.0 References: <28416.1535473275@sss.pgh.pa.us> In-Reply-To: <28416.1535473275@sss.pgh.pa.us> From: Flavio Henrique Araque Gurgel Date: Thu, 30 Aug 2018 16:23:14 +0200 Message-ID: Subject: Re: Limitation of prepared statement name To: Tom Lane Cc: pgsql-docs@postgresql.org Content-Type: multipart/alternative; boundary="000000000000972a0a0574a7d105" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000972a0a0574a7d105 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Em ter, 28 de ago de 2018 =C3=A0s 18:21, Tom Lane escre= veu: > Flavio Henrique Araque Gurgel writes: > > It seems that naming prepared statements is limited to 63 characters as > per > > > https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQ= L-SYNTAX-IDENTIFIERS > > Yeah, just like every other SQL identifier in Postgres... > > > The dangerous situation is that PostgreSQL seems to ignore rigthmost > > overflowed characters silently. > > It's hardly silent: > > regression=3D# prepare > foo1234567890123456789012345678901234567890123456789012345678901234567890 > as select 1; > NOTICE: identifier > "foo123456789012345678901234567890123456789012345678901234567890123456789= 0" > will be truncated to > "foo123456789012345678901234567890123456789012345678901234567890" > PREPARE > Sorry, when I said silently I should've say that the message level is too low. A human would easily understand the NOTICE message but an application code doesn't. And that was the case here. I don't know how an application could follow what the NOTICE says here and most NOTICE are harmless. I think most drivers just ignore NOTICE messages at runtime or throw it on logs and that will never be caught by automated alert systems since they're just NOTICE. In my case, it goes down to the level of the library used to talk to PostgreSQL, it's the pgx library largely used in Go projects. Developers in my company will submit a patch there to avoid the situation but I would like improve things at the PostgreSQL side since I'm a DBA. I know this is not the right list to discuss this but maybe an ERROR level would be better, completely aborting the command and the transaction would completely avoid the situation and handling at the application side would be complete. > > Wouldn't it be good to include that information on the prepared stateme= nt > > doc page? > > You could as well argue that every single page that describes creating > any sort of object ought to repeat this information. I doubt that people > would find that to be an improvement. > I'll never argue repeating the same information everywhere in the docs but a good solution would be to link the identifiers section everytime an identifier is used in the docs. That would ease the task for developers that are used to read PostgreSQL docs in a daily basis. If that is a good thing, I can propose a doc patch at least for the SQL language pages. Flavio Gurgel --000000000000972a0a0574a7d105 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Em ter= , 28 de ago de 2018 =C3=A0s 18:21, Tom Lane <tgl@sss.pgh.pa.us> escreveu:
Flavio Henrique Araque Gurgel <fhagur@gmail.com> writes:
> It seems that naming prepared statements is limited to 63 characters a= s per
> ht= tps://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SY= NTAX-IDENTIFIERS

Yeah, just like every other SQL identifier in Postgres...

> The dangerous situation is that PostgreSQL seems to ignore rigthmost > overflowed characters silently.

It's hardly silent:

regression=3D# prepare foo1234567890123456789012345678901234567890123456789= 012345678901234567890 as select 1;
NOTICE:=C2=A0 identifier "foo12345678901234567890123456789012345678901= 23456789012345678901234567890" will be truncated to "foo123456789= 012345678901234567890123456789012345678901234567890"
PREPARE

Sorry, when I said silently I s= hould've say that the message level is too low. A human would easily un= derstand the NOTICE message but an application code doesn't. And that w= as the case here.

I don't know how an applicat= ion could follow what the NOTICE says here and most NOTICE are harmless. I = think most drivers just ignore NOTICE messages at runtime or throw it on lo= gs and that will never be caught by automated alert systems since they'= re just NOTICE.

In my case, it goes down to th= e level of the library used to talk to PostgreSQL, it's the pgx library= largely used in Go projects. Developers in my company will submit a patch = there to avoid the situation but I would like improve things at the Postgre= SQL side since I'm a DBA.
=C2=A0
I know this is= not the right list to discuss this but maybe an ERROR level would be bette= r, completely aborting the command and the transaction would completely avo= id the situation and handling at the application side would be complete.


> Wouldn't it be good to include that information on the prepared st= atement
> doc page?

You could as well argue that every single page that describes creating
any sort of object ought to repeat this information.=C2=A0 I doubt that peo= ple
would find that to be an improvement.

I'= ll never argue repeating the same information everywhere in the docs but a = good solution would be to link the identifiers section everytime an identif= ier is used in the docs. That would ease the task for developers that are u= sed to read PostgreSQL docs in a daily basis.

If that is a good thing, I can prop= ose a doc patch at least for the SQL language pages.

Flavio Gurgel
<= /div> --000000000000972a0a0574a7d105--