Thread: Re: [BUGS] BUG #4007: chr(0) doesn't work anymore

Re: [BUGS] BUG #4007: chr(0) doesn't work anymore

From
Bruce Momjian
Date:
Tom Lane wrote:
> Steve Clark <sclark@netwolves.com> writes:
> > I'm not sure I understand what you mean about TEXT being null-safe.
> > What are the issues, and why was
> > it supported for years and now abruptly changed.
>
> It never was supported, we are simply plugging a hole that let you
> create a text value that would be likely to malfunction in subsequent
> use.

Seems we never documented that chr(0) is not supported.  I have applied
the following doc patch to CVS HEAD and 8.3.X.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://postgres.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/func.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/func.sgml,v
retrieving revision 1.420
diff -c -c -r1.420 func.sgml
*** doc/src/sgml/func.sgml    26 Feb 2008 15:32:30 -0000    1.420
--- doc/src/sgml/func.sgml    3 Mar 2008 17:07:22 -0000
***************
*** 1340,1346 ****
          Character with the given code. For <acronym>UTF8</acronym> the
          argument is treated as a Unicode code point. For other multibyte
          encodings the argument must designate a strictly
!         <acronym>ASCII</acronym> character.
         </entry>
         <entry><literal>chr(65)</literal></entry>
         <entry><literal>A</literal></entry>
--- 1340,1347 ----
          Character with the given code. For <acronym>UTF8</acronym> the
          argument is treated as a Unicode code point. For other multibyte
          encodings the argument must designate a strictly
!         <acronym>ASCII</acronym> character.  The NULL (0) character is not
!         allowed because text data types cannot reliably store such bytes.
         </entry>
         <entry><literal>chr(65)</literal></entry>
         <entry><literal>A</literal></entry>

Re: [BUGS] BUG #4007: chr(0) doesn't work anymore

From
Andrew Dunstan
Date:

Bruce Momjian wrote:
> Tom Lane wrote:
>
>> Steve Clark <sclark@netwolves.com> writes:
>>
>>> I'm not sure I understand what you mean about TEXT being null-safe.
>>> What are the issues, and why was
>>> it supported for years and now abruptly changed.
>>>
>> It never was supported, we are simply plugging a hole that let you
>> create a text value that would be likely to malfunction in subsequent
>> use.
>>
>
> Seems we never documented that chr(0) is not supported.  I have applied
> the following doc patch to CVS HEAD and 8.3.X.
>
>
>   The NULL (0) character is not
>   allowed because text data types cannot reliably store such bytes.
>
>



"Reliably" is arguably misleading here.

cheers

andrew

Re: [BUGS] BUG #4007: chr(0) doesn't work anymore

From
Bruce Momjian
Date:
BAndrew Dunstan wrote:
>
>
> Bruce Momjian wrote:
> > Tom Lane wrote:
> >
> >> Steve Clark <sclark@netwolves.com> writes:
> >>
> >>> I'm not sure I understand what you mean about TEXT being null-safe.
> >>> What are the issues, and why was
> >>> it supported for years and now abruptly changed.
> >>>
> >> It never was supported, we are simply plugging a hole that let you
> >> create a text value that would be likely to malfunction in subsequent
> >> use.
> >>
> >
> > Seems we never documented that chr(0) is not supported.  I have applied
> > the following doc patch to CVS HEAD and 8.3.X.
> >
> >
> >   The NULL (0) character is not
> >   allowed because text data types cannot reliably store such bytes.
> >
> >
>
>
>
> "Reliably" is arguably misleading here.

Agreed.  "Reliably" word removed.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://postgres.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +