Re: Question on replace function [solved]

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Charles Clavadetscher <clavadetscher(at)swisspug(dot)org>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Question on replace function [solved]
Date: 2016-09-25 16:37:35
Message-ID: f99e932d-0e10-7085-9309-0016e258f687@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 09/25/2016 08:39 AM, Tom Lane wrote:
> Charles Clavadetscher <clavadetscher(at)swisspug(dot)org> writes:
>> Honestly I still don't understand why this happened this way.
>
> I wonder if you have standard_conforming_strings turned off, or
> did when that data was inserted. That would change the behavior
> of backslashes in string literals.

That got me to thinking:

standard_conforming_strings = on

test=# create table test (txt text);
CREATE TABLE

test=# insert into test values ('BEGIN:VCARD\r\\rVERSION:3.0\r\\rN:Halbritter;Ursula;;;\r\\rFN:Ursula Halbritter\r\\rEMAIL;TYPE=INTERNET;TYPE=HOME:ursula(dot)halbritter(at)zweiernet(dot)ch\r\\rADR;TYPE=home:;;strasse;schwerzenbach;;;ooooooooooooooooooooooooooo\r\\rEND:VCARD');
INSERT 0 1

test=# insert into test values (E'BEGIN:VCARD\r\\rVERSION:3.0\r\\rN:Halbritter;Ursula;;;\r\\rFN:Ursula Halbritter\r\\rEMAIL;TYPE=INTERNET;TYPE=HOME:ursula(dot)halbritter(at)zweiernet(dot)ch\r\\rADR;TYPE=home:;;strasse;schwerzenbach;;;ooooooooooooooooooooooooooo\r\\rEND:VCARD');
INSERT 0 1

test=# \copy test to test.txt
COPY 2

cat test.txt

BEGIN:VCARD\\r\\\\rVERSION:3.0\\r\\\\rN:Halbritter;Ursula;;;\\r\\\\rFN:Ursula Halbritter\\r\\\\rEMAIL;TYPE=INTERNET;TYPE=HOME:ursula(dot)halbritter(at)zweiernet(dot)ch\\r\\\\rADR;TYPE=home:;;strasse;schwerzenbach;;;ooooooooooooooooooooooooooo\\r\\\\rEND:VCARD
BEGIN:VCARD\r\\rVERSION:3.0\r\\rN:Halbritter;Ursula;;;\r\\rFN:Ursula Halbritter\r\\rEMAIL;TYPE=INTERNET;TYPE=HOME:ursula(dot)halbritter(at)zweiernet(dot)ch\r\\rADR;TYPE=home:;;strasse;schwerzenbach;;;ooooooooooooooooooooooooooo\r\\rEND:VCARD

standard_conforming_strings = off

test=# truncate test;
TRUNCATE TABLE

test=# insert into test values ('BEGIN:VCARD\r\\rVERSION:3.0\r\\rN:Halbritter;Ursula;;;\r\\rFN:Ursula Halbritter\r\\rEMAIL;TYPE=INTERNET;TYPE=HOME:ursula(dot)halbritter(at)zweiernet(dot)ch\r\\rADR;TYPE=home:;;strasse;schwerzenbach;;;ooooooooooooooooooooooooooo\r\\rEND:VCARD');
WARNING: nonstandard use of escape in a string literal
LINE 1: insert into test values ('BEGIN:VCARD\r\\rVERSION:3.0\r\\rN:...
^
HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
INSERT 0 1

test=# insert into test values (E'BEGIN:VCARD\r\\rVERSION:3.0\r\\rN:Halbritter;Ursula;;;\r\\rFN:Ursula Halbritter\r\\rEMAIL;TYPE=INTERNET;TYPE=HOME:ursula(dot)halbritter(at)zweiernet(dot)ch\r\\rADR;TYPE=home:;;strasse;schwerzenbach;;;ooooooooooooooooooooooooooo\r\\rEND:VCARD');
INSERT 0 1

test=# \copy test to test_off.txt
COPY 2

cat test_off.txt

BEGIN:VCARD\r\\rVERSION:3.0\r\\rN:Halbritter;Ursula;;;\r\\rFN:Ursula Halbritter\r\\rEMAIL;TYPE=INTERNET;TYPE=HOME:ursula(dot)halbritter(at)zweiernet(dot)ch\r\\rADR;TYPE=home:;;strasse;schwerzenbach;;;ooooooooooooooooooooooooooo\r\\rEND:VCARD
BEGIN:VCARD\r\\rVERSION:3.0\r\\rN:Halbritter;Ursula;;;\r\\rFN:Ursula Halbritter\r\\rEMAIL;TYPE=INTERNET;TYPE=HOME:ursula(dot)halbritter(at)zweiernet(dot)ch\r\\rADR;TYPE=home:;;strasse;schwerzenbach;;;ooooooooooooooooooooooooooo\r\\rEND:VCARD

>
> regards, tom lane
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Munro 2016-09-25 21:57:16 Re: [GENERAL] C++ port of Postgres
Previous Message Tom Lane 2016-09-25 15:39:01 Re: Question on replace function [solved]