Re: "invalid input syntax for type bytea"

From: Alan Millington <admillington(at)yahoo(dot)co(dot)uk>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Postgres general mailing list <pgsql-general(at)postgresql(dot)org>
Subject: Re: "invalid input syntax for type bytea"
Date: 2011-09-01 16:01:50
Message-ID: 1314892910.84389.YahooMailClassic@web25406.mail.ukl.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thank you for that. Sure enough, at character 36202 I have found "\\ 51". I assume that the space should be a zero. That appears to be the only error. How odd!

--- On Wed, 31/8/11, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [GENERAL] "invalid input syntax for type bytea"
To: "Alan Millington" <admillington(at)yahoo(dot)co(dot)uk>
Cc: "Postgres general mailing list" <pgsql-general(at)postgresql(dot)org>
Date: Wednesday, 31 August, 2011, 18:24

Alan Millington <admillington(at)yahoo(dot)co(dot)uk> writes:
> I recently hit an error when trying to insert into a bytea column. The following is the first part of what appears in the Postgres log:
> 2011-08-25 14:42:40 BST HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.2011-08-25 14:42:40 BST ERROR:  invalid input syntax for type bytea at character 752011-08-25 14:42:40 BST STATEMENT:  insert into FAMILY_DATA (family_id, seq_num, family_pod) values (177, 20,
>  '\\200\\002\\135q\\001\\050cperson\\012Person\\012q\\002\\051\\201q\\003\\175q\\004\\050U\\006\\137namesq\\005cperson\\012\\137Names\\012q\\006\\051\\201q\\007cperson\\012\\137Name\\012q\\010\\051\\201q\\011\\050\\135q\\012X\\003\\000\\000\\00017\\052q\\013a\\135q\\014X\\002\\000\\000\\000ABq\\015ae\\175q\\016U\\006parentq\\017h\\007sba\\175q\\020U\\006personq\\021h\\003sbU\\021nationality\\137eventq\\022cperson\\012Dictof\\137Nationality\\137Event\\012q\\023\\051\\201q\\024X\\004\\000\\000\\000UKBSq\\025\\175q\\026\\051cperson\\012Listof\\137Nationality\\137Event\\012q\\027\\051\\201q\\030\\050cperson\\012Nationality\\137Event\\012q\\031\\051\\201q\\032\\175q\\033\\050U\\015contra\\137eventsq\\034\\051U\\006parentq\\035h\\030U\\004bvosq\\036c\\137\\137builtin\\137\\137\\012set\\012q\\037\\135q U\\002ATq\\041a\\205Rq\\042U\\007cfflagsq\\043\\051U\\006effectq\\044U\\001AU\\005cinfoq\\045ccinfo\\012BCInfo
> (I omit the rest, but there is a close quote and a close parenthesis at the end.)

Well, the part you showed us is perfectly valid bytea data, so the
problem is somewhere in what you omitted.

> If I have counted right, character 75 is the '7' in '\\175', which looks to be a valid octal value.

Unfortunately, that number is just a pointer to the start of the bytea
literal within the statement, so it's not very helpful here :-(.  What
you need to look for is a backslash that's not followed by either a
second backslash or octal digits.

            regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rik Bellens 2011-09-01 16:04:23 Re: strange table disk sizes
Previous Message Robert Treat 2011-09-01 15:44:19 Re: md5 of table