mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +03:00
Add bytea datatype to ECPG.
So far ECPG programs had to treat binary data for bytea column as 'char' type.
But this meant converting from/to escaped format with PQunescapeBytea/
PQescapeBytea() and therefore forcing users to add unnecessary code and cost
for the conversion in runtime. By adding a dedicated datatype for bytea most of
this special handling is no longer needed.
Author: Matsumura-san ("Matsumura, Ryo" <matsumura.ryo@jp.fujitsu.com>)
Discussion: https://postgr.es/m/flat/03040DFF97E6E54E88D3BFEE5F5480F737A141F9@G01JPEXMBYT04
This commit is contained in:
@@ -355,6 +355,9 @@ ECPGset_noind_null(enum ECPGttype type, void *ptr)
|
||||
*(((struct ECPGgeneric_varchar *) ptr)->arr) = 0x00;
|
||||
((struct ECPGgeneric_varchar *) ptr)->len = 0;
|
||||
break;
|
||||
case ECPGt_bytea:
|
||||
((struct ECPGgeneric_bytea *) ptr)->len = 0;
|
||||
break;
|
||||
case ECPGt_decimal:
|
||||
memset((char *) ptr, 0, sizeof(decimal));
|
||||
((decimal *) ptr)->sign = NUMERIC_NULL;
|
||||
@@ -428,6 +431,10 @@ ECPGis_noind_null(enum ECPGttype type, const void *ptr)
|
||||
if (*(((const struct ECPGgeneric_varchar *) ptr)->arr) == 0x00)
|
||||
return true;
|
||||
break;
|
||||
case ECPGt_bytea:
|
||||
if (((struct ECPGgeneric_bytea *) ptr)->len == 0)
|
||||
return true;
|
||||
break;
|
||||
case ECPGt_decimal:
|
||||
if (((const decimal *) ptr)->sign == NUMERIC_NULL)
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user