Ascii null in varchars

From: Thomas Mack <mack(at)ips(dot)cs(dot)tu-bs(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Cc: mack(at)ips(dot)cs(dot)tu-bs(dot)de
Subject: Ascii null in varchars
Date: 1999-07-03 08:36:20
Message-ID: 199907030836.KAA26086@infbsdb7.idb.cs.tu-bs.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

We try to migrate some projects from commercial Ingres to postgres.

One problem we found:

varchars can hold any byte from \000 to \377. In Ingres we could
specify all these characters as a hex-string, e.g. X'4163006341',
meaning a string "Ac\000cA".

Construction of varchars in postgres do obviously not know of
any comparable method, this means, saying:

select char_length(varchar 'ab\000defghi');

will result in 2 and not in 9 as expected. I can somehow understand,
why it works this way, so I came to the thought of saying instead:

select char_length(translate(varchar 'abcdefghi','c','\000'));

which returns '9' as expected.

But this is really not nice...

The documentation does not tell anything about constructions of
varchars (or char / text) beyond this '||', the mentioned functions
do also not give any hint - does it mean, there is no such facility
(in 6.4.2)?

We would like to hear some comments,

Thank you anyway,

Thomas Mack
TU Braunschweig, Abt. Informationssysteme

Browse pgsql-sql by date

  From Date Subject
Next Message Thomas Mack 1999-07-03 10:10:36 plpgsql function problems
Previous Message Chris Bitmead 1999-07-03 02:39:50 Re: [SQL] Tricky SQL (?)