pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #16912: pg_dump 11 does not respect --quote-all-identifiers within function bodies
5+ messages / 5 participants
[nested] [flat]

* BUG #16912: pg_dump 11 does not respect --quote-all-identifiers within function bodies
@ 2021-03-03 23:39  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 2 replies; 5+ messages in thread

From: PG Bug reporting form @ 2021-03-03 23:39 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: brandon.m.simmons@gmail.com

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.



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

*  Re: BUG #16912: pg_dump 11 does not respect --quote-all-identifiers within function bodies
@ 2021-03-04 12:39  Euler Taveira <euler@eulerto.com>
  parent: PG Bug reporting form <noreply@postgresql.org>
  1 sibling, 0 replies; 5+ messages in thread

From: Euler Taveira @ 2021-03-04 12:39 UTC (permalink / raw)
  To: brandon.m.simmons@gmail.com; pgsql-bugs@lists.postgresql.org

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/

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #16912: pg_dump 11 does not respect --quote-all-identifiers within function bodies
@ 2021-03-04 15:01  David G. Johnston <david.g.johnston@gmail.com>
  parent: PG Bug reporting form <noreply@postgresql.org>
  1 sibling, 1 reply; 5+ messages in thread

From: David G. Johnston @ 2021-03-04 15:01 UTC (permalink / raw)
  To: brandon.m.simmons@gmail.com <brandon.m.simmons@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

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.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #16912: pg_dump 11 does not respect --quote-all-identifiers within function bodies
@ 2021-03-04 15:14  Brandon Simmons <brandon.m.simmons@gmail.com>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Brandon Simmons @ 2021-03-04 15:14 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

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!

>
> David J.
>





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #16912: pg_dump 11 does not respect --quote-all-identifiers within function bodies
@ 2021-03-05 20:17  Alvaro Herrera <alvherre@alvh.no-ip.org>
  parent: Brandon Simmons <brandon.m.simmons@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Alvaro Herrera @ 2021-03-05 20:17 UTC (permalink / raw)
  To: Brandon Simmons <brandon.m.simmons@gmail.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

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 AST
>
> I 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





^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2021-03-05 20:17 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03 23:39 BUG #16912: pg_dump 11 does not respect --quote-all-identifiers within function bodies PG Bug reporting form <noreply@postgresql.org>
2021-03-04 12:39 ` Euler Taveira <euler@eulerto.com>
2021-03-04 15:01 ` David G. Johnston <david.g.johnston@gmail.com>
2021-03-04 15:14   ` Brandon Simmons <brandon.m.simmons@gmail.com>
2021-03-05 20:17     ` Alvaro Herrera <alvherre@alvh.no-ip.org>

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