Subject: | Bytea encoding incorrect for bytes 127 through 255 |
The very simple foo.pl program (attached) gives the following results.
You can see it is clearly incorrect for bytes with values 127 through 255.
This may be a good addition for the regression tests.
Byte value 1 quotes to E'\\001'
Byte value 2 quotes to E'\\002'
Byte value 3 quotes to E'\\003'
Byte value 4 quotes to E'\\004'
Byte value 5 quotes to E'\\005'
Byte value 6 quotes to E'\\006'
Byte value 7 quotes to E'\\007'
Byte value 8 quotes to E'\\010'
Byte value 9 quotes to E'\\011'
Byte value 10 quotes to E'\\012'
Byte value 11 quotes to E'\\013'
Byte value 12 quotes to E'\\014'
Byte value 13 quotes to E'\\015'
Byte value 14 quotes to E'\\016'
Byte value 15 quotes to E'\\017'
Byte value 16 quotes to E'\\020'
Byte value 17 quotes to E'\\021'
Byte value 18 quotes to E'\\022'
Byte value 19 quotes to E'\\023'
Byte value 20 quotes to E'\\024'
Byte value 21 quotes to E'\\025'
Byte value 22 quotes to E'\\026'
Byte value 23 quotes to E'\\027'
Byte value 24 quotes to E'\\030'
Byte value 25 quotes to E'\\031'
Byte value 26 quotes to E'\\032'
Byte value 27 quotes to E'\\033'
Byte value 28 quotes to E'\\034'
Byte value 29 quotes to E'\\035'
Byte value 30 quotes to E'\\036'
Byte value 31 quotes to E'\\037'
Byte value 32 quotes to E' '
Byte value 33 quotes to E'!'
Byte value 34 quotes to E'"'
Byte value 35 quotes to E'#'
Byte value 36 quotes to E'$'
Byte value 37 quotes to E'%'
Byte value 38 quotes to E'&'
Byte value 39 quotes to E''''
Byte value 40 quotes to E'('
Byte value 41 quotes to E')'
Byte value 42 quotes to E'*'
Byte value 43 quotes to E'+'
Byte value 44 quotes to E','
Byte value 45 quotes to E'-'
Byte value 46 quotes to E'.'
Byte value 47 quotes to E'/'
Byte value 48 quotes to E'0'
Byte value 49 quotes to E'1'
Byte value 50 quotes to E'2'
Byte value 51 quotes to E'3'
Byte value 52 quotes to E'4'
Byte value 53 quotes to E'5'
Byte value 54 quotes to E'6'
Byte value 55 quotes to E'7'
Byte value 56 quotes to E'8'
Byte value 57 quotes to E'9'
Byte value 58 quotes to E':'
Byte value 59 quotes to E';'
Byte value 60 quotes to E'<'
Byte value 61 quotes to E'='
Byte value 62 quotes to E'>'
Byte value 63 quotes to E'?'
Byte value 64 quotes to E'@'
Byte value 65 quotes to E'A'
Byte value 66 quotes to E'B'
Byte value 67 quotes to E'C'
Byte value 68 quotes to E'D'
Byte value 69 quotes to E'E'
Byte value 70 quotes to E'F'
Byte value 71 quotes to E'G'
Byte value 72 quotes to E'H'
Byte value 73 quotes to E'I'
Byte value 74 quotes to E'J'
Byte value 75 quotes to E'K'
Byte value 76 quotes to E'L'
Byte value 77 quotes to E'M'
Byte value 78 quotes to E'N'
Byte value 79 quotes to E'O'
Byte value 80 quotes to E'P'
Byte value 81 quotes to E'Q'
Byte value 82 quotes to E'R'
Byte value 83 quotes to E'S'
Byte value 84 quotes to E'T'
Byte value 85 quotes to E'U'
Byte value 86 quotes to E'V'
Byte value 87 quotes to E'W'
Byte value 88 quotes to E'X'
Byte value 89 quotes to E'Y'
Byte value 90 quotes to E'Z'
Byte value 91 quotes to E'['
Byte value 92 quotes to E'\\\\'
Byte value 93 quotes to E']'
Byte value 94 quotes to E'^'
Byte value 95 quotes to E'_'
Byte value 96 quotes to E'`'
Byte value 97 quotes to E'a'
Byte value 98 quotes to E'b'
Byte value 99 quotes to E'c'
Byte value 100 quotes to E'd'
Byte value 101 quotes to E'e'
Byte value 102 quotes to E'f'
Byte value 103 quotes to E'g'
Byte value 104 quotes to E'h'
Byte value 105 quotes to E'i'
Byte value 106 quotes to E'j'
Byte value 107 quotes to E'k'
Byte value 108 quotes to E'l'
Byte value 109 quotes to E'm'
Byte value 110 quotes to E'n'
Byte value 111 quotes to E'o'
Byte value 112 quotes to E'p'
Byte value 113 quotes to E'q'
Byte value 114 quotes to E'r'
Byte value 115 quotes to E's'
Byte value 116 quotes to E't'
Byte value 117 quotes to E'u'
Byte value 118 quotes to E'v'
Byte value 119 quotes to E'w'
Byte value 120 quotes to E'x'
Byte value 121 quotes to E'y'
Byte value 122 quotes to E'z'
Byte value 123 quotes to E'{'
Byte value 124 quotes to E'|'
Byte value 125 quotes to E'}'
Byte value 126 quotes to E'~'
Byte value 127 quotes to E'\\177'
Byte value 128 quotes to E'\\377'
Byte value 129 quotes to E'\\377'
Byte value 130 quotes to E'\\377'
Byte value 131 quotes to E'\\377'
Byte value 132 quotes to E'\\377'
Byte value 133 quotes to E'\\377'
Byte value 134 quotes to E'\\377'
Byte value 135 quotes to E'\\377'
Byte value 136 quotes to E'\\377'
Byte value 137 quotes to E'\\377'
Byte value 138 quotes to E'\\377'
Byte value 139 quotes to E'\\377'
Byte value 140 quotes to E'\\377'
Byte value 141 quotes to E'\\377'
Byte value 142 quotes to E'\\377'
Byte value 143 quotes to E'\\377'
Byte value 144 quotes to E'\\377'
Byte value 145 quotes to E'\\377'
Byte value 146 quotes to E'\\377'
Byte value 147 quotes to E'\\377'
Byte value 148 quotes to E'\\377'
Byte value 149 quotes to E'\\377'
Byte value 150 quotes to E'\\377'
Byte value 151 quotes to E'\\377'
Byte value 152 quotes to E'\\377'
Byte value 153 quotes to E'\\377'
Byte value 154 quotes to E'\\377'
Byte value 155 quotes to E'\\377'
Byte value 156 quotes to E'\\377'
Byte value 157 quotes to E'\\377'
Byte value 158 quotes to E'\\377'
Byte value 159 quotes to E'\\377'
Byte value 160 quotes to E'\\377'
Byte value 161 quotes to E'\\377'
Byte value 162 quotes to E'\\377'
Byte value 163 quotes to E'\\377'
Byte value 164 quotes to E'\\377'
Byte value 165 quotes to E'\\377'
Byte value 166 quotes to E'\\377'
Byte value 167 quotes to E'\\377'
Byte value 168 quotes to E'\\377'
Byte value 169 quotes to E'\\377'
Byte value 170 quotes to E'\\377'
Byte value 171 quotes to E'\\377'
Byte value 172 quotes to E'\\377'
Byte value 173 quotes to E'\\377'
Byte value 174 quotes to E'\\377'
Byte value 175 quotes to E'\\377'
Byte value 176 quotes to E'\\377'
Byte value 177 quotes to E'\\377'
Byte value 178 quotes to E'\\377'
Byte value 179 quotes to E'\\377'
Byte value 180 quotes to E'\\377'
Byte value 181 quotes to E'\\377'
Byte value 182 quotes to E'\\377'
Byte value 183 quotes to E'\\377'
Byte value 184 quotes to E'\\377'
Byte value 185 quotes to E'\\377'
Byte value 186 quotes to E'\\377'
Byte value 187 quotes to E'\\377'
Byte value 188 quotes to E'\\377'
Byte value 189 quotes to E'\\377'
Byte value 190 quotes to E'\\377'
Byte value 191 quotes to E'\\377'
Byte value 192 quotes to E'\\377'
Byte value 193 quotes to E'\\377'
Byte value 194 quotes to E'\\377'
Byte value 195 quotes to E'\\377'
Byte value 196 quotes to E'\\377'
Byte value 197 quotes to E'\\377'
Byte value 198 quotes to E'\\377'
Byte value 199 quotes to E'\\377'
Byte value 200 quotes to E'\\377'
Byte value 201 quotes to E'\\377'
Byte value 202 quotes to E'\\377'
Byte value 203 quotes to E'\\377'
Byte value 204 quotes to E'\\377'
Byte value 205 quotes to E'\\377'
Byte value 206 quotes to E'\\377'
Byte value 207 quotes to E'\\377'
Byte value 208 quotes to E'\\377'
Byte value 209 quotes to E'\\377'
Byte value 210 quotes to E'\\377'
Byte value 211 quotes to E'\\377'
Byte value 212 quotes to E'\\377'
Byte value 213 quotes to E'\\377'
Byte value 214 quotes to E'\\377'
Byte value 215 quotes to E'\\377'
Byte value 216 quotes to E'\\377'
Byte value 217 quotes to E'\\377'
Byte value 218 quotes to E'\\377'
Byte value 219 quotes to E'\\377'
Byte value 220 quotes to E'\\377'
Byte value 221 quotes to E'\\377'
Byte value 222 quotes to E'\\377'
Byte value 223 quotes to E'\\377'
Byte value 224 quotes to E'\\377'
Byte value 225 quotes to E'\\377'
Byte value 226 quotes to E'\\377'
Byte value 227 quotes to E'\\377'
Byte value 228 quotes to E'\\377'
Byte value 229 quotes to E'\\377'
Byte value 230 quotes to E'\\377'
Byte value 231 quotes to E'\\377'
Byte value 232 quotes to E'\\377'
Byte value 233 quotes to E'\\377'
Byte value 234 quotes to E'\\377'
Byte value 235 quotes to E'\\377'
Byte value 236 quotes to E'\\377'
Byte value 237 quotes to E'\\377'
Byte value 238 quotes to E'\\377'
Byte value 239 quotes to E'\\377'
Byte value 240 quotes to E'\\377'
Byte value 241 quotes to E'\\377'
Byte value 242 quotes to E'\\377'
Byte value 243 quotes to E'\\377'
Byte value 244 quotes to E'\\377'
Byte value 245 quotes to E'\\377'
Byte value 246 quotes to E'\\377'
Byte value 247 quotes to E'\\377'
Byte value 248 quotes to E'\\377'
Byte value 249 quotes to E'\\377'
Byte value 250 quotes to E'\\377'
Byte value 251 quotes to E'\\377'
Byte value 252 quotes to E'\\377'
Byte value 253 quotes to E'\\377'
Byte value 254 quotes to E'\\377'
Byte value 255 quotes to E'\\377'
[rbt@urbandb ~/work/sk]$ pg_ctl --version
pg_ctl (PostgreSQL) 8.3.3
[rbt@urbandb ~/work/sk]$ perl -e 'use DBD::Pg; print $DBD::Pg::VERSION
."\n"'
2.9.0
[rbt@urbandb ~/work/sk]$ uname -a
FreeBSD urbandb.boughtornot.com 7.0-STABLE FreeBSD 7.0-STABLE #0: Mon
Mar 24 17:49:53 EDT 2008
root@urbandb.boughtornot.com:/usr/obj/usr/src/sys/GENERIC amd64
[rbt@urbandb ~/work/sk]$ perl -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=freebsd, osvers=7.0-beta3, archname=amd64-freebsd
uname='freebsd urbandb.boughtornot.com 7.0-beta3 freebsd 7.0-beta3
#0: fri nov 16 19:12:38 utc 2007
root@myers.cse.buffalo.edu:usrobjusrsrcsysgeneric amd64 '
config_args='-sde -Dprefix=/usr/local
-Darchlib=/usr/local/lib/perl5/5.8.8/mach
-Dprivlib=/usr/local/lib/perl5/5.8.8
-Dman3dir=/usr/local/lib/perl5/5.8.8/perl/man/man3
-Dman1dir=/usr/local/man/man1
-Dsitearch=/usr/local/lib/perl5/site_perl/5.8.8/mach
-Dsitelib=/usr/local/lib/perl5/site_perl/5.8.8
-Dscriptdir=/usr/local/bin
-Dsiteman3dir=/usr/local/lib/perl5/5.8.8/man/man3
-Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv
-Uinstallusrbinperl -Dcc=cc -Duseshrplib
-Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN"
-Doptimize=-O2 -fno-strict-aliasing -pipe -Ud_dosuid -Ui_gdbm
-Dusethreads=n -Dusemymalloc=y -Duse64bitint'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=define use64bitall=define uselongdouble=undef
usemymalloc=y, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN"
-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe
-Wdeclaration-after-statement -I/usr/local/include',
optimize='-O2 -fno-strict-aliasing -pipe ',
cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN"
-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe
-Wdeclaration-after-statement -I/usr/local/include'
ccversion='', gccversion='4.2.1 20070719 [FreeBSD]', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -Wl,-E -L/usr/local/lib'
libpth=/usr/lib /usr/local/lib
libs=-lm -lcrypt -lutil
perllibs=-lm -lcrypt -lutil
libc=, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='
-Wl,-R/usr/local/lib/perl5/5.8.8/mach/CORE'
cccdlflags='-DPIC -fPIC', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: MYMALLOC PERL_MALLOC_WRAP USE_64_BIT_ALL
USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO
Locally applied patches:
defined-or
Built under freebsd
Compiled at Nov 21 2007 19:05:24
@INC:
/usr/local/lib/perl5/5.8.8/BSDPAN
/usr/local/lib/perl5/site_perl/5.8.8/mach
/usr/local/lib/perl5/site_perl/5.8.8
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.8/mach
/usr/local/lib/perl5/5.8.8
.
Subject: | foo.pl |
#!/usr/local/bin/perl
use DBI;
use DBD::Pg qw(:pg_types);
$dbh = DBI->connect( 'DBI:Pg:dbname=sk_test', '', '', );
for my $byteValue (1 .. 255) {
my $byte = chr($byteValue);
my $result = $dbh->quote($byte, { pg_type => PG_BYTEA });
printf("Byte value %s quotes to %s\n", $byteValue, $result);
}