how do i store \0 inside a text attribute? - Mailing list pgsql-hackers

From Paul A Vixie
Subject how do i store \0 inside a text attribute?
Date
Msg-id 200012231859.KAA87062@redpaul.mfnx.net
Whole thread Raw
Responses Re: how do i store \0 inside a text attribute?
List pgsql-hackers
for my pgcat utility i now know i have to use \nnn octal quoting for
nonprintables in the generated INSERT commands.  but in testing, i
found the following oddity.  this is in 7.1-b1 (cvs-current).
vixie=> create table foo ( bar text );CREATEvixie=> insert into foo values ( 'a\033b' );INSERT 728084 1vixie=> select
length(bar)from foo;length------     3(1 row)
 

great!  it stored the escape.  and since SELECT's front/back end protocol
is counted-string rather than quoted text, it comes back reliably (though
i still intend to try a binary cursor at some point, just to do it.)  BUT:
vixie=> delete from foo;DELETE 1vixie=> insert into foo values ( 'a\0b' );INSERT 728085 1vixie=> select length(bar)
fromfoo;length------     1(1 row)
 
vixie=> drop table foo;DROPvixie=> \q

this is not what i was hoping for at ALL.  evidently the implementation of
text assumes NUL-termination in other places than the parser.  ultimately
this means that pgsql will need a "blob" type whose presentation format is
uuencode or some such.  but is there a workaround for this using "text"?

how would someone be expected to store, say, a GIF image in a TOAST text?


pgsql-hackers by date:

Previous
From: "Mike S. Avelar"
Date:
Subject: Java and Postgresql
Next
From: Tom Lane
Date:
Subject: Regress-test failure in current sources