@@ -59,14 +59,16 @@ const hex = (rng) => `\\x${bytes(rng, 8).toString('hex')}`
5959
6060// one entry per type family. `literal` is a SQL expression, `param` a JS value pg sends for it,
6161// `binary` says whether the binary result format gives the same JS value as the text one, which
62- // is only true for the types pg-types has a binary parser for, or decodes as utf8 anyway
62+ // is only true for the types pg-types has a binary parser for, or decodes as utf8 anyway. The
63+ // parser decodes a binary value as utf8 before pg-types sees it (#3496), so a type whose bytes
64+ // can be invalid utf8 (numbers, oid, an array header) is false too
6365const TYPES = [
64- { type : 'int2' , binary : true , literal : ( rng ) => `${ ints ( rng , 16 ) } ::int2` , param : ( rng ) => ints ( rng , 16 ) } ,
65- { type : 'int4' , binary : true , literal : ( rng ) => `${ ints ( rng , 32 ) } ::int4` , param : ( rng ) => ints ( rng , 32 ) } ,
66- { type : 'int8' , binary : true , literal : ( rng ) => `${ ints ( rng , 53 ) } ::int8` , param : ( rng ) => String ( ints ( rng , 53 ) ) } ,
66+ { type : 'int2' , binary : false , literal : ( rng ) => `${ ints ( rng , 16 ) } ::int2` , param : ( rng ) => ints ( rng , 16 ) } ,
67+ { type : 'int4' , binary : false , literal : ( rng ) => `${ ints ( rng , 32 ) } ::int4` , param : ( rng ) => ints ( rng , 32 ) } ,
68+ { type : 'int8' , binary : false , literal : ( rng ) => `${ ints ( rng , 53 ) } ::int8` , param : ( rng ) => String ( ints ( rng , 53 ) ) } ,
6769 {
6870 type : 'float8' ,
69- binary : true ,
71+ binary : false ,
7072 literal : ( rng ) => `${ quote ( String ( floats ( rng ) ) ) } ::float8` ,
7173 param : ( rng ) => floats ( rng ) ,
7274 } ,
@@ -136,7 +138,7 @@ const TYPES = [
136138 { type : 'uuid' , binary : false , literal : ( ) => `${ quote ( uuid ( ) ) } ::uuid` , param : ( ) => uuid ( ) } ,
137139 {
138140 type : 'oid' ,
139- binary : true ,
141+ binary : false ,
140142 literal : ( rng ) => `${ int ( rng , 0 , 2147483647 ) } ::oid` ,
141143 param : ( rng ) => int ( rng , 0 , 2147483647 ) ,
142144 } ,
@@ -160,7 +162,7 @@ const TYPES = [
160162 } ,
161163 {
162164 type : 'text[]' ,
163- binary : true ,
165+ binary : false ,
164166 literal : ( rng ) => `${ quote ( arrayLiteral ( arrayOf ( rng , texts ) ) ) } ::text[]` ,
165167 param : ( rng ) => arrayOf ( rng , texts ) ,
166168 } ,
@@ -199,7 +201,7 @@ const TYPES = [
199201 { type : 'unknown' , binary : true , literal : ( rng ) => quote ( texts ( rng ) ) } ,
200202 { type : 'null' , binary : true , literal : ( ) => 'NULL' , param : ( ) => null } ,
201203 // something that changes with the row, so a result is not one value repeated
202- { type : 'row' , binary : true , literal : ( ) => 'g' } ,
204+ { type : 'row' , binary : false , literal : ( ) => 'g' } ,
203205 { type : 'rowtext' , binary : true , literal : ( ) => `'r' || g::text` } ,
204206]
205207
0 commit comments