break;
#endif
+ case PHP_PQ_OID_BYTEA:
+ if (!(res->auto_convert & PHP_PQRES_CONV_BYTEA)) {
+ goto noconversion;
+ } else {
+ size_t to_len;
+ char *to_str = (char *) PQunescapeBytea((unsigned char *) str->val, &to_len);
+
+ if (!to_str) {
+ ZVAL_NULL(zv);
+ php_error_docref(NULL, E_WARNING, "Failed to unsescape BYTEA: '%s'", str->val);
+ } else {
+ ZVAL_STRINGL(zv, to_str, to_len);
+ PQfreemem(to_str);
+ }
+ }
+ break;
+
default:
if (!(res->auto_convert & PHP_PQRES_CONV_ARRAY)) {
goto noconversion;
#if PHP_PQ_HAVE_PHP_JSON_H
zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_JSON"), PHP_PQRES_CONV_JSON);
#endif
+ zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_BYTEA"), PHP_PQRES_CONV_BYTEA);
zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_ALL"), PHP_PQRES_CONV_ALL);
return SUCCESS;
#define PHP_PQRES_CONV_BOOL 0x0001
#define PHP_PQRES_CONV_INT 0x0002
#define PHP_PQRES_CONV_FLOAT 0x0004
+#define PHP_PQRES_CONV_BYTEA 0x0008
#define PHP_PQRES_CONV_SCALAR 0x000f
#define PHP_PQRES_CONV_ARRAY 0x0010
#define PHP_PQRES_CONV_DATETIME 0x0020
'2013-01-01 01:01:01 UTC'::timestamptz as timestamptz,
array[array[1,2,3],array[4,5,6],array[NULL::int,NULL::int,NULL::int]] as intarray,
array[box(point(1,2),point(2,3)),box(point(4,5),point(5,6))] as boxarray,
-array[]::text[] as emptyarray
+array[]::text[] as emptyarray,
+'foo\n'::bytea as bytea,
+'foo\n'::bytea::text as bytea_text
");
var_dump($r->fetchRow(pq\Result::FETCH_ASSOC));
?>
DONE
--EXPECTF--
Test
-array(13) {
+array(15) {
["null"]=>
NULL
["bool"]=>
["emptyarray"]=>
array(0) {
}
+ ["bytea"]=>
+ string(4) "foo
+"
+ ["bytea_text"]=>
+ string(10) "\x666f6f0a"
}
-DONE
\ No newline at end of file
+DONE