Re: dollar quoting and pg_dump

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема Re: dollar quoting and pg_dump
Дата
Msg-id 40605FB9.4010306@dunslane.net
обсуждение исходный текст
Ответ на Re: dollar quoting and pg_dump  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: dollar quoting and pg_dump  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Tom Lane wrote:

>Andrew Dunstan <andrew@dunslane.net> writes:
>  
>
>>... using it in dumping function bodies and comments on all objects, 
>>with a prefix argument of "function" and "comment" respectively. There 
>>might be other places where we want to use dollar quoting, but this 
>>would be a good start, ISTM.
>>    
>>
>
>Do we really need to be that verbose?  Why not start with the minimal $$
>and extend only if needed?  On the KISS principle, trying "$$", "$X$",
>"$XX$", "$XXX$", etc seems sufficient.
>  
>

It's a matter of taste, I guess. I'm certainly not dogmatic about it. 
The function design in my head is flexible enough for either.

>For that matter, I'm not convinced we should use $$ for comments.  They
>don't have nearly the problem that functions do with embedded quotes.
>  
>

Well, I keep a master schema file and I like to decorate it with fairly 
verbose comments, so users can see what the object is for and how it 
works. I've been caught a few times with forgetting to double quotes 
inside the comments. But again, Maybe you are right, and we should at 
least start with just the obvious case.

>A thought: maybe just put this logic into the regular
>appendStringLiteral routine, and trigger it when the string contains any
>quotes or backslashes; if it has none, you can just use quotes ...
>  
>

I did think of fallback, but rejected it on the KISS principle :-)  I 
also prefer consistency in style - I want all my functions dollar quoted 
even if they don't currently contain characters in need of escape.

>BTW, I've been holding off making this change myself, realizing that it
>will completely break backwards compatibility of pg_dump output to 7.4
>and earlier.  Not sure if anyone is trying to use CVS tip pg_dump with
>older releases, but it seems possible given that the dump ordering issue
>is finally solved.  Might be a good idea to make it disablable with a
>fallback to regular quoting.
>  
>

Makes sense. "-X disable-dollar-quoting"? Or we could have it turned off 
by default and require it to be specifically turned on - that might 
conform to the principle of least surprise, at least for now.

For that matter, we could also have a "verbose-dollar-quoting" feature, 
and/or a "dollar-quote-objects=functions,comments,......" feature

But let's walk before we start to run ;-)

cheers

andrew





В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Treat
Дата:
Сообщение: Re: postgres on windows page update
Следующее
От: Tom Lane
Дата:
Сообщение: Re: dollar quoting and pg_dump