BUG #16912: pg_dump 11 does not respect --quote-all-identifiers within function bodies
The following bug has been logged on the website:
Bug reference: 16912
Logged by: Brandon Simmons
Email address: brandon.m.simmons@gmail.com
PostgreSQL version: 11.11
Operating system: Linux
Description:
I'm using regex to rewrite identifiers in a SQL dump and rely on the
double-quotes.
Within plpgsql `CREATE FUNCTION` statements in the resulting dump,
identifiers are not quoted as I would expect.
On Wed, Mar 3, 2021, at 8:39 PM, PG Bug reporting form wrote:
I'm using regex to rewrite identifiers in a SQL dump and rely on the
double-quotes.
Within plpgsql `CREATE FUNCTION` statements in the resulting dump,
identifiers are not quoted as I would expect.
IIUC this is not a bug. You don't provide enough detail to show the issue. Are
you generating dynamic commands inside your PL/pgSQL function? If so, Postgres
doesn't manipulate function body. You should use quote_ident (that adds quotes
if necessary) or a similar user-defined function.
--
Euler Taveira
EDB https://www.enterprisedb.com/
On Wednesday, March 3, 2021, PG Bug reporting form <noreply@postgresql.org>
wrote:
The following bug has been logged on the website:
Bug reference: 16912
Logged by: Brandon Simmons
Email address: brandon.m.simmons@gmail.com
PostgreSQL version: 11.11
Operating system: Linux
Description:I'm using regex to rewrite identifiers in a SQL dump and rely on the
double-quotes.
Within plpgsql `CREATE FUNCTION` statements in the resulting dump,
identifiers are not quoted as I would expect.
PostgreSQL will not do anything to the text values in your database. A
function body is just plain text - that is why it gets surrounded with
single quotes or, more commonly, dollar-quoting, when written. It only has
meaning when interpreted during its execution.
David J.
On Thu, Mar 4, 2021 at 10:01 AM David G. Johnston
<david.g.johnston@gmail.com> wrote:
On Wednesday, March 3, 2021, PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:
Bug reference: 16912
Logged by: Brandon Simmons
Email address: brandon.m.simmons@gmail.com
PostgreSQL version: 11.11
Operating system: Linux
Description:I'm using regex to rewrite identifiers in a SQL dump and rely on the
double-quotes.
Within plpgsql `CREATE FUNCTION` statements in the resulting dump,
identifiers are not quoted as I would expect.PostgreSQL will not do anything to the text values in your database. A function body is just plain text - that is why it gets surrounded with single quotes or, more commonly, dollar-quoting, when written. It only has meaning when interpreted during its execution.
My understanding:
- As far as pg_dump is concerned, function bodies are just text
- this is somewhat desirable too, since comments/formatting (AFAIU)
are preserved in dumps
- It might even be that function bodies are malformed (if `SET
check_function_bodies = false`) and these end up in dump
So I guess this is really a feature request:
- add a mode that dumps function bodies from their AST
- --quote-all-identifiers should apply to the function body AST
I can see why this might never happen. Thanks all!
Show quoted text
David J.
On 2021-Mar-04, Brandon Simmons wrote:
So I guess this is really a feature request:
- add a mode that dumps function bodies from their AST
- --quote-all-identifiers should apply to the function body ASTI can see why this might never happen. Thanks all!
Yeah, I doubt this (producing source code from a plpgsql function's AST)
would ever happen. And what would you think should happen with
functions in other languages?
--
�lvaro Herrera 39�49'30"S 73�17'W