mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
Fix handling of structure for bytea data type in ECPG
Some code paths dedicated to bytea used the structure for varchar. This did not lead to any actual bugs, as bytea and varchar have the same definition, but it could become a trap if one of these definitions changes for a new feature or a bug fix. Issue introduced by 050710b. Author: Shenhao Wang Reviewed-by: Vignesh C, Michael Paquier Discussion: https://postgr.es/m/07ac7dee1efc44f99d7f53a074420177@G08CNEXMBPEKD06.g08.fujitsu.local Backpatch-through: 12
This commit is contained in:
parent
bdaa84e389
commit
61a4a3a62a
@ -529,8 +529,8 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
|
||||
|
||||
case ECPGt_bytea:
|
||||
{
|
||||
struct ECPGgeneric_varchar *variable =
|
||||
(struct ECPGgeneric_varchar *) (var + offset * act_tuple);
|
||||
struct ECPGgeneric_bytea *variable =
|
||||
(struct ECPGgeneric_bytea *) (var + offset * act_tuple);
|
||||
long dst_size,
|
||||
src_size,
|
||||
dec_size;
|
||||
|
@ -596,8 +596,8 @@ set_desc_attr(struct descriptor_item *desc_item, struct variable *var,
|
||||
|
||||
else
|
||||
{
|
||||
struct ECPGgeneric_varchar *variable =
|
||||
(struct ECPGgeneric_varchar *) (var->value);
|
||||
struct ECPGgeneric_bytea *variable =
|
||||
(struct ECPGgeneric_bytea *) (var->value);
|
||||
|
||||
desc_item->is_binary = true;
|
||||
desc_item->data_len = variable->len;
|
||||
|
@ -825,8 +825,8 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
|
||||
|
||||
case ECPGt_bytea:
|
||||
{
|
||||
struct ECPGgeneric_varchar *variable =
|
||||
(struct ECPGgeneric_varchar *) (var->value);
|
||||
struct ECPGgeneric_bytea *variable =
|
||||
(struct ECPGgeneric_bytea *) (var->value);
|
||||
|
||||
if (!(mallocedval = (char *) ecpg_alloc(variable->len, lineno)))
|
||||
return false;
|
||||
@ -1404,7 +1404,7 @@ ecpg_build_params(struct statement *stmt)
|
||||
|
||||
if (var->type == ECPGt_bytea)
|
||||
{
|
||||
binary_length = ((struct ECPGgeneric_varchar *) (var->value))->len;
|
||||
binary_length = ((struct ECPGgeneric_bytea *) (var->value))->len;
|
||||
binary_format = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user