diff options
author | Michael Meskes <meskes@postgresql.org> | 2019-02-18 10:20:31 +0100 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2019-02-18 10:20:31 +0100 |
commit | 050710b36964dee7e1b2bf6b5ef00041fd5d2787 (patch) | |
tree | 888139b986d5d65660bd26d11c3c69d3b1d7e513 /src/interfaces/ecpg/ecpglib/misc.c | |
parent | 3fdc374b5d24b08119a91555ca2fae427af0b085 (diff) |
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
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/misc.c')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/misc.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c index ee0d3e98fb9..02338a41eae 100644 --- a/src/interfaces/ecpg/ecpglib/misc.c +++ b/src/interfaces/ecpg/ecpglib/misc.c @@ -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; |