Thread: Quoting "
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
Andy Anderson <aanderson@amherst.edu> 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
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
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 <aanderson@amherst.edu> 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
On Wed, Apr 30, 2008 at 7:10 AM, Andy Anderson <aanderson@amherst.edu> 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?
> On Wed, Apr 30, 2008 at 9:10 AM, Andy Anderson > <aanderson@amherst.edu> 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