Em 12 de novembro de 2012 17:43, Alexsander Rosa
<[email protected]>escreveu:

> O ideal então é ligar o "standard_conforming_strings" no PG8, não?
>
>
Sim, esse comportamento foi introduzido na 8.2 [1]. Veja a nota abaixo:

"Enable 
standard_conforming_strings<http://www.postgresql.org/docs/8.2/static/runtime-config-compatible.html#GUC-STANDARD-CONFORMING-STRINGS>
to
be turned on (Kevin Grittner)

This allows backslash escaping in strings to be disabled, making
PostgreSQL more
standards-compliant. The default is off for backwards compatibility, but
future releases will default this to on."
Vc terá que ter alguns cuidados ao escrever SQL com escapes utilizando o
'E' no inicio da string, para dizer ao banco que a mesma contém escapes,
tipo:

postgres=# SHOW standard_conforming_strings ;
 standard_conforming_strings
-----------------------------
 on
(1 row)

postgres=# SELECT 'Marca D\'Água';
postgres'# ';
ERROR:  syntax error at or near "';
'"
LINE 1: select 'Marca D\'Água';
                             ^
postgres=#
postgres=#
postgres=# SELECT E'Marca D\'Água';
   ?column?
--------------
 Marca D'Água
(1 row)


Com ele desligado sempre irá considerar o escape:

postgres=# set standard_conforming_strings to off;
SET
postgres=# select 'Marca D\'Água';
   ?column?
--------------
 Marca D'Água
(1 row)


Att,

[1] http://www.postgresql.org/docs/8.2/static/release-8-2.html#AEN80530

-- 
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
>> Blog sobre TI: http://fabriziomello.blogspot.com
>> Perfil Linkedin: http://br.linkedin.com/in/fabriziomello
>> Twitter: http://twitter.com/fabriziomello
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a