Skip site navigation (1) Skip section navigation (2)

Re: Making TEXT NUL-transparent

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Florian Weimer <fweimer(at)bfk(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Making TEXT NUL-transparent
Date: 2011-11-24 09:41:08
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
2011/11/24 Florian Weimer <fweimer(at)bfk(dot)de>:
> * Pavel Stehule:
>> Hello
>> 2011/11/24 Florian Weimer <fweimer(at)bfk(dot)de>:
>>> Occasionally, we get bitten by embedded NUL bytes in TEXT values.  We
>>> take care of generating proper UTF-8, but this additional restriction
>>> sometimes slips by.  It would be really helpful if PostgreSQL could
>>> store such TEXT fields as-is (at least if they are computed internally,
>>> or come from query parameters).
>> and why you don't use bytea ? Text should be correct literal.
> It's actually UTF-8 text, and some PostgreSQL functions are only
> available for TEXT, but not BYTEA, e.g.:
> bfk_int=> SELECT '\x006500'::bytea ~ 'A';
> ERROR:  operator does not exist: bytea ~ unknown
> LINE 1: SELECT '\x006500'::bytea ~ 'A';
>                                 ^
> HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

then you can prepare some custom function that can filter zeroes and
prepare valid text functions - some postgresql's functions (based on
external libs) cannot to work with string containing zeroes too.
Probably you can do it in plperl.

I don't think so this functionality is generally requested. If you
have broken strings, then you have to clean it before storing to



> --
> Florian Weimer                <fweimer(at)bfk(dot)de>
> BFK edv-consulting GmbH
> Kriegsstraße 100              tel: +49-721-96201-1
> D-76133 Karlsruhe             fax: +49-721-96201-99

In response to

pgsql-hackers by date

Next:From: Florian WeimerDate: 2011-11-24 09:54:09
Subject: Re: Making TEXT NUL-transparent
Previous:From: Lars KanisDate: 2011-11-24 09:39:07
Subject: Re: [PATCH] PostgreSQL fails to build with 32bit MinGW-w64

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group