byteain() doesn't parse correctly - Mailing list pgsql-bugs

From Jered Floyd
Subject byteain() doesn't parse correctly
Date
Msg-id 87ofwesyb2.fsf@irregular-apocalypse.permabit.com
Whole thread Raw
Responses Re: byteain() doesn't parse correctly  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name        :    Jered Floyd
Your email address    :    jered@permabit.com


System Configuration
---------------------
  Architecture (example: Intel Pentium)      : x86

  Operating System (example: Linux 2.0.26 ELF)     : Linux 2.2.17

  PostgreSQL version (example: PostgreSQL-7.0):   PostgreSQL-7.0.3

  Compiler used (example:  gcc 2.8.0)        : gcc 2.95.2


Please enter a FULL description of your problem:
------------------------------------------------

byteain() in backend/utils/adt/varlena.c is just wrong. It can't parse
'\\', claiming 'Bad input string for type bytea'. No, really.

More curious is that it can't handle '\134' either, implying that
multiple levels of parsing are going on.  But, it *can* parse
'\\\\' as \\.  This boggles the mind.


Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

SELECT '\\'::bytea;
SELECT '\134'::bytea;
SELECT '\\\\'::bytea;


If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

This routine is cherry fondue; extremely nasty, but we can't prosecute
for that.  It needs a good rewrite, and an audit of the parse chain in
general wouldn't hurt.

As with the previous 2 bugs, I suspect this is something I'll just do
when I port my 7.0.3 routines for making BYTEAs more first-class
citizens to 7.1.  I'd be tickled if you beat me to it, though.

pgsql-bugs by date:

Previous
From: Jered Floyd
Date:
Subject: JDBC driver throws unfriendly exceptions
Next
From: Jered Floyd
Date:
Subject: JDBC driver doesn't allow access to BYTEA types via get/setBytes()