pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
show value of backslashes in string array argument
6+ messages / 3 participants
[nested] [flat]

* show value of backslashes in string array argument
@ 2007-11-12 09:15  Sabin Coanda <sabin.coanda@deuromedia.ro>
  0 siblings, 3 replies; 6+ messages in thread

From: Sabin Coanda @ 2007-11-12 09:15 UTC (permalink / raw)
  To: pgsql-sql

Hi there,

I have a problem using backslash character as part of a string array item.

I use "PostgreSQL 8.2.4 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC) 
3.4.2 (mingw-special)" version, with standard_conforming_strings = 'on'.

I found that, is that in spite of using standard_conforming_strings = 'on', 
the string array items are shown in C escape sequences conventions.

Use the following scenario:
    - create a table with
        CREATE TABLE test
        (
          "colVarchar" character varying,
          "colVarcharArray" character varying[]
        )
    - insert a row with a string composed by just one character backslash, 
and an array with just one item, with the same value of one backslash, with:
        INSERT INTO test VALUES ( '\', ARRAY[ '\' ] );
    - show the values with:
        SELECT * FROM test

And the result is:

 colVarchar | colVarcharArray
------------+-----------------
 \          | {"\\"}

The question is why the two strings are shown different in spite they are 
the same, and standard_conforming_strings = 'on' ?

Sabin





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: show value of backslashes in string array argument
@ 2007-11-12 09:51  Sabin Coanda <sabin.coanda@deuromedia.ro>
  parent: Sabin Coanda <sabin.coanda@deuromedia.ro>
  2 siblings, 1 reply; 6+ messages in thread

From: Sabin Coanda @ 2007-11-12 09:51 UTC (permalink / raw)
  To: pgsql-sql

I fond another collateral problem, because there are the different 
convention to describe a varchar array item which contains backslashes, when 
standard_conforming_strings = 'on'

For instance, to get a string composed by just one character backslash I can 
use any of the two forms:

    SELECT ARRAY[ '\' ]::varchar[];

or

    SELECT '{\\}'::varchar[];

On the other hand, standard_conforming_strings = 'on' let me use varchar 
items with '\' format. So the first format seems to be aware of 
standard_conforming_strings = 'on', but the second is not.

My problem is that the java driver build arrays using the second format, but 
the driver seems to be aware of standard_conforming_strings = 'on'. This 
make inconsistence using the statement parameters, because to get the same 
thing in the database I have to initialize a varchar parameter with a string 
of one backslashes, but a varchar array item has to be initialized with a 
string of two backslashes.

Sabin 





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: show value of backslashes in string array argument
@ 2007-11-12 09:58  Achilleas Mantzios <achill@matrix.gatewaynet.com>
  parent: Sabin Coanda <sabin.coanda@deuromedia.ro>
  2 siblings, 0 replies; 6+ messages in thread

From: Achilleas Mantzios @ 2007-11-12 09:58 UTC (permalink / raw)
  To: pgsql-sql; +Cc: Sabin Coanda <sabin.coanda@deuromedia.ro>

If you do 

 SELECT "colVarchar","colVarcharArray"[1] FROM test;
you will see that you get identical values.


-- 
Achilleas Mantzios 



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: show value of backslashes in string array argument
@ 2007-11-12 10:20  Achilleas Mantzios <achill@matrix.gatewaynet.com>
  parent: Sabin Coanda <sabin.coanda@deuromedia.ro>
  0 siblings, 0 replies; 6+ messages in thread

From: Achilleas Mantzios @ 2007-11-12 10:20 UTC (permalink / raw)
  To: pgsql-sql; +Cc: Sabin Coanda <sabin.coanda@deuromedia.ro>

Óôéò ÄåõôÝñá 12 ÍïÝìâñéïò 2007 11:51, ï/ç Sabin Coanda Ýãñáøå:
> I fond another collateral problem, because there are the different
> convention to describe a varchar array item which contains backslashes,
> when standard_conforming_strings = 'on'
>
> For instance, to get a string composed by just one character backslash I
> can use any of the two forms:
>
>     SELECT ARRAY[ '\' ]::varchar[];
>
> or
>
>     SELECT '{\\}'::varchar[];
>
> On the other hand, standard_conforming_strings = 'on' let me use varchar
> items with '\' format. So the first format seems to be aware of
> standard_conforming_strings = 'on', but the second is not.
>
> My problem is that the java driver build arrays using the second format,
> but the driver seems to be aware of standard_conforming_strings = 'on'.
> This make inconsistence using the statement parameters, because to get the
> same thing in the database I have to initialize a varchar parameter with a
> string of one backslashes, but a varchar array item has to be initialized
> with a string of two backslashes.
>
> Sabin

I would recommend:

a) Move to Unix
b) Subscribe to pgsql-jdbc@postgresql.org

>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
>
>                 http://www.postgresql.org/about/donate

-- 
Achilleas Mantzios



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: show value of backslashes in string array argument
@ 2007-11-12 16:05  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Sabin Coanda <sabin.coanda@deuromedia.ro>
  2 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2007-11-12 16:05 UTC (permalink / raw)
  To: Sabin Coanda <sabin.coanda@deuromedia.ro>; +Cc: pgsql-sql

"Sabin Coanda" <sabin.coanda@deuromedia.ro> writes:
> I found that, is that in spite of using standard_conforming_strings = 'on', 
> the string array items are shown in C escape sequences conventions.

That's how it's supposed to be.  See
http://www.postgresql.org/docs/8.2/static/arrays.html#AEN5876

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: show value of backslashes in string array argument
@ 2007-11-12 17:12  Sabin Coanda <sabin.coanda@deuromedia.ro>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Sabin Coanda @ 2007-11-12 17:12 UTC (permalink / raw)
  To: pgsql-sql


"Tom Lane" <tgl@sss.pgh.pa.us> wrote in message 
news:6268.1194883527@sss.pgh.pa.us...
> That's how it's supposed to be.  See
> http://www.postgresql.org/docs/8.2/static/arrays.html#AEN5876

Hi Tom,

I read it and I understood there are 2 cascaded parsers, but I didn't find 
an explicit reference to the behavior related to 
standard_conforming_strings.

But after some tests, I found the following behaviors:
- the 1st parser is the SQL interpreter which is aware of 
standard_conforming_strings (on or off)
- the 2nd parser which is an array interpreter, doesn't care of 
standard_conforming_strings, using every time C escape conventions

Please confirm me whether I understand it correctly or not.

TIA,
Sabin 





^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2007-11-12 17:12 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-11-12 09:15 show value of backslashes in string array argument Sabin Coanda <sabin.coanda@deuromedia.ro>
2007-11-12 09:51 ` Sabin Coanda <sabin.coanda@deuromedia.ro>
2007-11-12 10:20   ` Achilleas Mantzios <achill@matrix.gatewaynet.com>
2007-11-12 09:58 ` Achilleas Mantzios <achill@matrix.gatewaynet.com>
2007-11-12 16:05 ` Tom Lane <tgl@sss.pgh.pa.us>
2007-11-12 17:12   ` Sabin Coanda <sabin.coanda@deuromedia.ro>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox