1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-09 22:41:56 +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:
Michael Meskes
2019-02-18 10:20:31 +01:00
parent 3fdc374b5d
commit 050710b369
18 changed files with 985 additions and 51 deletions

View File

@ -40,6 +40,13 @@ struct ECPGgeneric_varchar
char arr[FLEXIBLE_ARRAY_MEMBER];
};
/* A generic bytea type. */
struct ECPGgeneric_bytea
{
int len;
char arr[FLEXIBLE_ARRAY_MEMBER];
};
/*
* type information cache
*/
@ -75,6 +82,8 @@ struct statement
#endif
int nparams;
char **paramvalues;
int *paramlengths;
int *paramformats;
PGresult *results;
};
@ -133,6 +142,8 @@ struct descriptor_item
int precision;
int scale;
int type;
bool is_binary;
int data_len;
struct descriptor_item *next;
};
@ -226,6 +237,9 @@ struct sqlda_compat *ecpg_build_compat_sqlda(int, PGresult *, int, enum COMPAT_M
void ecpg_set_compat_sqlda(int, struct sqlda_compat **, const PGresult *, int, enum COMPAT_MODE);
struct sqlda_struct *ecpg_build_native_sqlda(int, PGresult *, int, enum COMPAT_MODE);
void ecpg_set_native_sqlda(int, struct sqlda_struct **, const PGresult *, int, enum COMPAT_MODE);
unsigned ecpg_hex_dec_len(unsigned srclen);
unsigned ecpg_hex_enc_len(unsigned srclen);
unsigned ecpg_hex_encode(const char *src, unsigned len, char *dst);
/* SQLSTATE values generated or processed by ecpglib (intentionally
* not exported -- users should refer to the codes directly) */