public inbox for [email protected]
help / color / mirror / Atom feedQuoting "
11+ messages / 6 participants
[nested] [flat]
* Quoting "
@ 2008-04-30 13:10 Andy Anderson <[email protected]>
2008-04-30 14:28 ` Re: Quoting " Craig Ringer <[email protected]>
2008-04-30 14:28 ` Re: Quoting " Tom Lane <[email protected]>
2008-04-30 15:52 ` Re: Quoting " Scott Marlowe <[email protected]>
0 siblings, 3 replies; 11+ messages in thread
From: Andy Anderson @ 2008-04-30 13:10 UTC (permalink / raw)
To: [email protected]
In a test I just did, the sequence \" (backslash double-quote) is
interpreted as just a " inside of the E'...' string constant
expression. This is great, since PHP's addslashes() sticks them in
along with the other stuff I really need to quote like ' and \. But I
see that \" isn't documented in the manual in section 4.1.2.1. I
assume this is, in fact, standard behavior for Postgres? (Perhaps a
comprehensive table might be a good idea at this point in the manual.)
Thanks,
-- Andy
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Quoting "
2008-04-30 13:10 Quoting " Andy Anderson <[email protected]>
@ 2008-04-30 14:28 ` Craig Ringer <[email protected]>
2 siblings, 0 replies; 11+ messages in thread
From: Craig Ringer @ 2008-04-30 14:28 UTC (permalink / raw)
To: Andy Anderson <[email protected]>; +Cc: [email protected]
Andy Anderson wrote:
> In a test I just did, the sequence \" (backslash double-quote) is
> interpreted as just a " inside of the E'...' string constant expression.
> This is great, since PHP's addslashes() sticks them in along with the
> other stuff I really need to quote like ' and \. But I see that \" isn't
> documented in the manual in section 4.1.2.1. I assume this is, in fact,
> standard behavior for Postgres? (Perhaps a comprehensive table might be
> a good idea at this point in the manual.)
craig=# SELECT E'\z\v\k\-';
?column?
----------
zvk-
(1 row)
From 4.1.2.1:
... "Any other character following a backslash is taken literally."
I didn't see any escape sequences being interpreted other than those
that're already documented in the section of 4.1.2.1 that describes E''
strings.
--
Craig Ringer
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Quoting "
2008-04-30 13:10 Quoting " Andy Anderson <[email protected]>
@ 2008-04-30 14:28 ` Tom Lane <[email protected]>
2008-04-30 14:33 ` Re: Quoting " Andy Anderson <[email protected]>
2 siblings, 1 reply; 11+ messages in thread
From: Tom Lane @ 2008-04-30 14:28 UTC (permalink / raw)
To: Andy Anderson <[email protected]>; +Cc: [email protected]
Andy Anderson <[email protected]> writes:
> In a test I just did, the sequence \" (backslash double-quote) is
> interpreted as just a " inside of the E'...' string constant
> expression. This is great, since PHP's addslashes() sticks them in
> along with the other stuff I really need to quote like ' and \. But I
> see that \" isn't documented in the manual in section 4.1.2.1.
Huh? It says
Any other character following a backslash is taken literally.
regards, tom lane
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Quoting "
2008-04-30 13:10 Quoting " Andy Anderson <[email protected]>
2008-04-30 14:28 ` Re: Quoting " Tom Lane <[email protected]>
@ 2008-04-30 14:33 ` Andy Anderson <[email protected]>
2008-04-30 18:26 ` Backslash Escape Sequences Andy Anderson <[email protected]>
0 siblings, 1 reply; 11+ messages in thread
From: Andy Anderson @ 2008-04-30 14:33 UTC (permalink / raw)
To: [email protected]
Ah, slight ambiguity here. Perhaps this might best say "Any other
character following a backslash is taken literally, and the backslash
is removed."
Thanks,
-- Andy
On Apr 30, 2008, at 10:28 AM, Tom Lane wrote:
> Andy Anderson <[email protected]> writes:
>> In a test I just did, the sequence \" (backslash double-quote) is
>> interpreted as just a " inside of the E'...' string constant
>> expression. This is great, since PHP's addslashes() sticks them in
>> along with the other stuff I really need to quote like ' and \. But I
>> see that \" isn't documented in the manual in section 4.1.2.1.
>
> Huh? It says
>
> Any other character following a backslash is taken literally.
>
> regards, tom lane
^ permalink raw reply [nested|flat] 11+ messages in thread
* Backslash Escape Sequences
2008-04-30 13:10 Quoting " Andy Anderson <[email protected]>
2008-04-30 14:28 ` Re: Quoting " Tom Lane <[email protected]>
2008-04-30 14:33 ` Re: Quoting " Andy Anderson <[email protected]>
@ 2008-04-30 18:26 ` Andy Anderson <[email protected]>
2008-04-30 22:04 ` Re: Backslash Escape Sequences Alvaro Herrera <[email protected]>
0 siblings, 1 reply; 11+ messages in thread
From: Andy Anderson @ 2008-04-30 18:26 UTC (permalink / raw)
To: pgsql-docs
On the list pgsql-general, I had this exchange:
>>> Andy Anderson <[email protected]> writes:
>>>> In a test I just did, the sequence \" (backslash double-quote) is
>>>> interpreted as just a " inside of the E'...' string constant
>>>> expression. This is great, since PHP's addslashes() sticks them
>>>> in along with the other stuff I really need to quote like ' and
>>>> \. But I see that \" isn't documented in the manual in section
>>>> 4.1.2.1. I assume this is, in fact, standard behavior for
>>>> Postgres? (Perhaps a comprehensive table might be a good idea at
>>>> this point in the manual.)
>>
>> Tom Lane wrote:
>>> Huh? It says
>>>
>>> Any other character following a backslash is taken literally.
>>>
>>>
>
> Andy Anderson wrote:
>> Ah, slight ambiguity here. Perhaps this might best say "Any other
>> character following a backslash is taken literally, and the
>> backslash is removed."
In any case, here's a contribution to the manual, a short table with
this information, in a format that might help make the subject
clearer. Modify at will!
-- Andy
<!--<TABLE BORDER="1" CLASS="CALSTABLE"> <COL><COL><COL> <THEAD> <TR>
<TH>Backslash Escape Sequence</TH> <TH>Interpretation</TH> <TH>Notes</
TH> </TR> </THEAD> <TBODY> <TR> <TD><TT CLASS="TOKEN">\b</TT></TD>
<TD>backspace</TD> <TD></TD> </TR> <TR> <TD><TT CLASS="TOKEN">\f</TT></
TD> <TD>form feed</TD> <TD></TD> </TR> <TR> <TD><TT CLASS="TOKEN">\n</
TT></TD> <TD>newline</TD> <TD></TD> </TR> <TR> <TD><TT CLASS="TOKEN">
\r</TT></TD> <TD>carriage return</TD> <TD></TD> </TR> <TR> <TD><TT
CLASS="TOKEN">\t</TT></TD> <TD>tab</TD> <TD></TD> </TR> <TR> <TD> <TT
CLASS="TOKEN">\<var>o</var></TT><br> <TT CLASS="TOKEN">\<var>oo</var></
TT><br> <TT CLASS="TOKEN">\<var>ooo</var></TT><br> </TD> <TD> octal
byte value </TD> <TD> <var>o</var> = 0 - 7 </TD> </TR> <TR> <TD> <TT
CLASS="TOKEN">\x<var>h</var></TT><br> <TT CLASS="TOKEN">\x<var>hh</
var></TT><br> </TD> <TD> hexadecimal byte value </TD> <TD> <var>h</
var> = 0 - F </TD> </TR> <TR> <TD><TT CLASS="TOKEN">\</TT><var>a</
var></TD> <TD><var>a</var></TD> <TD><var>a</var> = any other
character. Commonly used to include \ and '</TD> </TR> </TBODY> </
TABLE>-->
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Backslash Escape Sequences
2008-04-30 13:10 Quoting " Andy Anderson <[email protected]>
2008-04-30 14:28 ` Re: Quoting " Tom Lane <[email protected]>
2008-04-30 14:33 ` Re: Quoting " Andy Anderson <[email protected]>
2008-04-30 18:26 ` Backslash Escape Sequences Andy Anderson <[email protected]>
@ 2008-04-30 22:04 ` Alvaro Herrera <[email protected]>
2008-05-01 15:29 ` Re: Backslash Escape Sequences Andy Anderson <[email protected]>
0 siblings, 1 reply; 11+ messages in thread
From: Alvaro Herrera @ 2008-04-30 22:04 UTC (permalink / raw)
To: Andy Anderson <[email protected]>; +Cc: pgsql-docs
Andy Anderson wrote:
> In any case, here's a contribution to the manual, a short table with
> this information, in a format that might help make the subject clearer.
> Modify at will!
FWIW if you really want to make a contribution to the docs, please see
the SGML sources instead of the HTML output (which is machine-generated).
http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Backslash Escape Sequences
2008-04-30 13:10 Quoting " Andy Anderson <[email protected]>
2008-04-30 14:28 ` Re: Quoting " Tom Lane <[email protected]>
2008-04-30 14:33 ` Re: Quoting " Andy Anderson <[email protected]>
2008-04-30 18:26 ` Backslash Escape Sequences Andy Anderson <[email protected]>
2008-04-30 22:04 ` Re: Backslash Escape Sequences Alvaro Herrera <[email protected]>
@ 2008-05-01 15:29 ` Andy Anderson <[email protected]>
2008-06-26 22:25 ` Re: Backslash Escape Sequences Bruce Momjian <[email protected]>
0 siblings, 1 reply; 11+ messages in thread
From: Andy Anderson @ 2008-05-01 15:29 UTC (permalink / raw)
To: pgsql-docs
>> Andy Anderson wrote:
>>
>>> In any case, here's a contribution to the manual, a short table with
>>> this information, in a format that might help make the subject
>>> clearer.
>> Modify at will!
> On Apr 30, 2008, at 6:04 PM, Alvaro Herrera wrote:
>> FWIW if you really want to make a contribution to the docs, please
>> see
>> the SGML sources instead of the HTML output (which is machine-
>> generated).
OK, then, I hope the following is accurate enough SGML to be more
useful. Submitted here per the instructions on <http://www.postgresql.org/docs/8.3/interactive/bug-reporting.html
>.
-- Andy
********************************************************************
<table id="sql-backslash-table">
<title>Backslash Escape Sequences</title>
<tgroup cols="2">
<thead>
<row>
<entry>Backslash Escape Sequence</>
<entry>Interpretation</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>\b</literal></entry>
<entry>backspace</entry>
</row>
<row>
<entry><literal>\f</literal></entry>
<entry>form feed</entry>
</row>
<row>
<entry><literal>\n</literal></entry>
<entry>newline</entry>
</row>
<row>
<entry><literal>\r</literal></entry>
<entry>carriage return</entry>
</row>
<row>
<entry><literal>\t</literal></entry>
<entry>tab</entry>
</row>
<row>
<entry>
<literallayout>
<literal>\<replaceable>o</replaceable></literal>
<literal>\<replaceable>oo</replaceable></literal>
<literal>\<replaceable>ooo</replaceable></literal>
(<replaceable>o</replaceable> = 0 - 7)
</literallayout>
</entry>
<entry>octal byte value</entry>
</row>
<row>
<entry>
<literallayout>
<literal>\x<replaceable>h</replaceable></literal>
<literal>\x<replaceable>hh</replaceable></literal>
(<replaceable>h</replaceable> = 0 - F)
</literallayout>
</entry>
<entry>hexadecimal byte value</entry>
</row>
<row>
<entry>
<literallayout>
<literal>\<replaceable>a</replaceable></literal>
(<replaceable>a</replaceable> = any other character than the
above,
e.g. <literal>\</literal> and <literal>'</literal>.)
</literallayout>
</entry>
<entry><replaceable>a</replaceable></entry>
</row>
</tbody>
</tgroup>
</table>
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Backslash Escape Sequences
2008-04-30 13:10 Quoting " Andy Anderson <[email protected]>
2008-04-30 14:28 ` Re: Quoting " Tom Lane <[email protected]>
2008-04-30 14:33 ` Re: Quoting " Andy Anderson <[email protected]>
2008-04-30 18:26 ` Backslash Escape Sequences Andy Anderson <[email protected]>
2008-04-30 22:04 ` Re: Backslash Escape Sequences Alvaro Herrera <[email protected]>
2008-05-01 15:29 ` Re: Backslash Escape Sequences Andy Anderson <[email protected]>
@ 2008-06-26 22:25 ` Bruce Momjian <[email protected]>
2008-09-03 16:59 ` Re: Backslash Escape Sequences Alvaro Herrera <[email protected]>
0 siblings, 1 reply; 11+ messages in thread
From: Bruce Momjian @ 2008-06-26 22:25 UTC (permalink / raw)
To: Andy Anderson <[email protected]>; +Cc: pgsql-docs
Andy Anderson wrote:
> >> Andy Anderson wrote:
> >>
> >>> In any case, here's a contribution to the manual, a short table with
> >>> this information, in a format that might help make the subject
> >>> clearer.
> >> Modify at will!
>
> > On Apr 30, 2008, at 6:04 PM, Alvaro Herrera wrote:
> >> FWIW if you really want to make a contribution to the docs, please
> >> see
> >> the SGML sources instead of the HTML output (which is machine-
> >> generated).
>
> OK, then, I hope the following is accurate enough SGML to be more
> useful. Submitted here per the instructions on <http://www.postgresql.org/docs/8.3/interactive/bug-reporting.html
Good idea --- a table is certainly clearer. I modified your patch and
applied the attached version. Thanks much.
Your documentation changes can be viewed in five minutes at:
http://developer.postgresql.org/pgdocs/postgres/index.html
--
Bruce Momjian <[email protected]> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
Attachments:
[text/x-diff] /rtmp/diff (3.6K, 2-%2Frtmp%2Fdiff)
download | inline diff:
Index: doc/src/sgml/syntax.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v
retrieving revision 1.122
diff -c -c -r1.122 syntax.sgml
*** doc/src/sgml/syntax.sgml 20 Mar 2008 21:42:47 -0000 1.122
--- doc/src/sgml/syntax.sgml 26 Jun 2008 22:24:11 -0000
***************
*** 286,304 ****
quote.)
Within an escape string, a backslash character (<literal>\</>) begins a
C-like <firstterm>backslash escape</> sequence, in which the combination
! of backslash and following character(s) represents a special byte value.
! <literal>\b</literal> is a backspace,
! <literal>\f</literal> is a form feed,
! <literal>\n</literal> is a newline,
! <literal>\r</literal> is a carriage return,
! <literal>\t</literal> is a tab.
! Also supported are
! <literal>\<replaceable>digits</replaceable></literal>, where
! <replaceable>digits</replaceable> represents an octal byte value, and
! <literal>\x<replaceable>hexdigits</replaceable></literal>, where
! <replaceable>hexdigits</replaceable> represents a hexadecimal byte value.
! (It is your responsibility that the byte sequences you create are
! valid characters in the server character set encoding.) Any other
character following a backslash is taken literally. Thus, to
include a backslash character, write two backslashes (<literal>\\</>).
Also, a single quote can be included in an escape string by writing
--- 286,348 ----
quote.)
Within an escape string, a backslash character (<literal>\</>) begins a
C-like <firstterm>backslash escape</> sequence, in which the combination
! of backslash and following character(s) represent a special byte
! value:
!
! <table id="sql-backslash-table">
! <title>Backslash Escape Sequences</title>
! <tgroup cols="2">
! <thead>
! <row>
! <entry>Backslash Escape Sequence</>
! <entry>Interpretation</entry>
! </row>
! </thead>
!
! <tbody>
! <row>
! <entry><literal>\b</literal></entry>
! <entry>backspace</entry>
! </row>
! <row>
! <entry><literal>\f</literal></entry>
! <entry>form feed</entry>
! </row>
! <row>
! <entry><literal>\n</literal></entry>
! <entry>newline</entry>
! </row>
! <row>
! <entry><literal>\r</literal></entry>
! <entry>carriage return</entry>
! </row>
! <row>
! <entry><literal>\t</literal></entry>
! <entry>tab</entry>
! </row>
! <row>
! <entry>
! <literal>\<replaceable>o</replaceable></literal>,
! <literal>\<replaceable>oo</replaceable></literal>,
! <literal>\<replaceable>ooo</replaceable></literal>
! (<replaceable>o</replaceable> = 0 - 7)
! </entry>
! <entry>octal byte value</entry>
! </row>
! <row>
! <entry>
! <literal>\x<replaceable>h</replaceable></literal>,
! <literal>\x<replaceable>hh</replaceable></literal>
! (<replaceable>h</replaceable> = 0 - 9, A - F)
! </entry>
! <entry>hexadecimal byte value</entry>
! </row>
! </tbody>
! </tgroup>
! </table>
!
! It is your responsibility that the byte sequences you create are
! valid characters in the server character set encoding. Any other
character following a backslash is taken literally. Thus, to
include a backslash character, write two backslashes (<literal>\\</>).
Also, a single quote can be included in an escape string by writing
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Backslash Escape Sequences
2008-04-30 13:10 Quoting " Andy Anderson <[email protected]>
2008-04-30 14:28 ` Re: Quoting " Tom Lane <[email protected]>
2008-04-30 14:33 ` Re: Quoting " Andy Anderson <[email protected]>
2008-04-30 18:26 ` Backslash Escape Sequences Andy Anderson <[email protected]>
2008-04-30 22:04 ` Re: Backslash Escape Sequences Alvaro Herrera <[email protected]>
2008-05-01 15:29 ` Re: Backslash Escape Sequences Andy Anderson <[email protected]>
2008-06-26 22:25 ` Re: Backslash Escape Sequences Bruce Momjian <[email protected]>
@ 2008-09-03 16:59 ` Alvaro Herrera <[email protected]>
0 siblings, 0 replies; 11+ messages in thread
From: Alvaro Herrera @ 2008-09-03 16:59 UTC (permalink / raw)
To: Bruce Momjian <[email protected]>; +Cc: Andy Anderson <[email protected]>; pgsql-docs
Bruce Momjian wrote:
> > OK, then, I hope the following is accurate enough SGML to be more
> > useful. Submitted here per the instructions on
> > <http://www.postgresql.org/docs/8.3/interactive/bug-reporting.html
>
> Good idea --- a table is certainly clearer. I modified your patch and
> applied the attached version. Thanks much.
Hmm, I think the \\ and \' stuff should be part of that table too -- the
\<replaceable>a</> as in the patch seemed fine.
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Quoting "
2008-04-30 13:10 Quoting " Andy Anderson <[email protected]>
@ 2008-04-30 15:52 ` Scott Marlowe <[email protected]>
2008-04-30 16:51 ` Re: Quoting " Andy Anderson <[email protected]>
2 siblings, 1 reply; 11+ messages in thread
From: Scott Marlowe @ 2008-04-30 15:52 UTC (permalink / raw)
To: Andy Anderson <[email protected]>; +Cc: [email protected]
On Wed, Apr 30, 2008 at 7:10 AM, Andy Anderson <[email protected]> wrote:
> In a test I just did, the sequence \" (backslash double-quote) is
> interpreted as just a " inside of the E'...' string constant expression.
> This is great, since PHP's addslashes() sticks them in along with the other
> stuff I really need to quote like ' and \. But I see that \" isn't
> documented in the manual in section 4.1.2.1. I assume this is, in fact,
> standard behavior for Postgres? (Perhaps a comprehensive table might be a
> good idea at this point in the manual.)
Why are you using php's addslashes() function? Is there something
missing from pg_escape_string()??? Or are you doing something else
I'm not thinking of?
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Quoting "
2008-04-30 13:10 Quoting " Andy Anderson <[email protected]>
2008-04-30 15:52 ` Re: Quoting " Scott Marlowe <[email protected]>
@ 2008-04-30 16:51 ` Andy Anderson <[email protected]>
0 siblings, 0 replies; 11+ messages in thread
From: Andy Anderson @ 2008-04-30 16:51 UTC (permalink / raw)
To: [email protected]
> On Wed, Apr 30, 2008 at 9:10 AM, Andy Anderson
> <[email protected]> wrote:
>> In a test I just did, the sequence \" (backslash double-quote) is
>> interpreted as just a " inside of the E'...' string constant
>> expression.
>> This is great, since PHP's addslashes() sticks them in along with
>> the other
>> stuff I really need to quote like ' and \.
On Apr 30, 2008, at 11:52 AM, Scott Marlowe wrote:
> Why are you using php's addslashes() function? Is there something
> missing from pg_escape_string()??? Or are you doing something else
> I'm not thinking of?
Yep, relying on what I already know to move forward on my project,
rather than browsing the manual for things I didn't know I needed :-).
Thanks for the tip.
-- Andy
^ permalink raw reply [nested|flat] 11+ messages in thread
end of thread, other threads:[~2008-09-03 16:59 UTC | newest]
Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-04-30 13:10 Quoting " Andy Anderson <[email protected]>
2008-04-30 14:28 ` Craig Ringer <[email protected]>
2008-04-30 14:28 ` Tom Lane <[email protected]>
2008-04-30 14:33 ` Andy Anderson <[email protected]>
2008-04-30 18:26 ` Backslash Escape Sequences Andy Anderson <[email protected]>
2008-04-30 22:04 ` Re: Backslash Escape Sequences Alvaro Herrera <[email protected]>
2008-05-01 15:29 ` Re: Backslash Escape Sequences Andy Anderson <[email protected]>
2008-06-26 22:25 ` Re: Backslash Escape Sequences Bruce Momjian <[email protected]>
2008-09-03 16:59 ` Re: Backslash Escape Sequences Alvaro Herrera <[email protected]>
2008-04-30 15:52 ` Scott Marlowe <[email protected]>
2008-04-30 16:51 ` Andy Anderson <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox