Обсуждение: Bytea question with \208
Could someone explain why \208 is not a valid syntax for bytea? I am getting the following: test=> select E'\\207'::bytea; bytea ------- \207 (1 row) test=> select E'\\208'::bytea; ERROR: invalid input syntax for type bytea test=> select E'\\209'::bytea; ERROR: invalid input syntax for type bytea test=> select E'\\210'::bytea; bytea ------- \210 (1 row) This all started when our version(older) of bugzilla trying to open a new bug with a word attachment via email: Aug 9 11:43:15 brain01 postgres[8631]: [5-1] ERROR: invalid byte sequence for encoding "UTF8": 0xd0cf The first two bytes of the word document are 0xd0 0xcf and I am assuming they are putting the two together since 0xd0 is invalid 0xd0 == \208 Thanks, Woody ---------------------------------------- iGLASS Networks 211-A S. Salem St Apex NC 27502 (919) 387-3550 x813 www.iglass.net
"Woody Woodring" <george.woodring@iglass.net> writes: > Could someone explain why \208 is not a valid syntax for bytea? Aren't those escapes octal? regards, tom lane
Thanks, My bad, the table I was looking (8.7) at had the first column as the decimal representation and I did notice that the numbers changed as they moved right. Is there a way for bytea to take a hex number, or do I need to convert the bit stream to octal numbers? Thanks again, Woody -----Original Message----- From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Tom Lane Sent: Thursday, August 09, 2007 2:14 PM To: Woody Woodring Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Bytea question with \208 "Woody Woodring" <george.woodring@iglass.net> writes: > Could someone explain why \208 is not a valid syntax for bytea? Aren't those escapes octal? regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings
On Thu, Aug 09, 2007 at 04:16:15PM -0400, Woody Woodring wrote: > My bad, the table I was looking (8.7) at had the first column as the > decimal representation and I did notice that the numbers changed as they > moved right. > > Is there a way for bytea to take a hex number, or do I need to convert the > bit stream to octal numbers? to_hex()? > -----Original Message----- > From: pgsql-general-owner@postgresql.org > [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Tom Lane > Sent: Thursday, August 09, 2007 2:14 PM > To: Woody Woodring > Cc: pgsql-general@postgresql.org > Subject: Re: [GENERAL] Bytea question with \208 > > "Woody Woodring" <george.woodring@iglass.net> writes: > > Could someone explain why \208 is not a valid syntax for bytea? > > Aren't those escapes octal? > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq > -- Decibel!, aka Jim Nasby decibel@decibel.org EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)
Вложения
Decibel! wrote: > On Thu, Aug 09, 2007 at 04:16:15PM -0400, Woody Woodring wrote: >> My bad, the table I was looking (8.7) at had the first column as the >> decimal representation and I did notice that the numbers changed as they >> moved right. >> >> Is there a way for bytea to take a hex number, or do I need to convert the >> bit stream to octal numbers? > > to_hex()? to_hex() produces the text representation of the hex digits, not the actual bytes with those values. What the OP wants is to conveniently represent the bytestream to send to the bytea column. They're looking for an escape sequence to embed into a text representation that will map to the exact byte contents to insert, not a text representation of that representation. Say, > Also supported are \digits, where digits represents an octal byte value, and \xhexdigits, where hexdigits represents ahexadecimal byte value. (It is your responsibility that the byte sequences you create are valid characters in the servercharacter set encoding.) <http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS> Amazing how useful the docs are. -- Lew