handle a ECPG_bytea typo
Hi, hackers
The source looks like:
case ECPGt_bytea:
{
struct ECPGgeneric_varchar *variable =
(struct ECPGgeneric_varchar *) (var->value);
......
}
I think the developer intend to use struct ECPGgeneric_bytea instead of struct ECPGgeneric_varchar
Is this thoughts right?
I have wrote a patch to fix this typo
Attachments:
0001-Fix-ECPGt_bytea-typo.patchapplication/octet-stream; name=0001-Fix-ECPGt_bytea-typo.patchDownload
From d00df50fcf7e7a46536fd496c42522cb617d217b Mon Sep 17 00:00:00 2001
From: Shenhao Wang <wangsh.fnst@cn.fujitsu.com>
Date: Fri, 24 Jul 2020 15:39:42 +0800
Subject: [PATCH] Fix ECPGt_bytea typo
Using struct ECPGgeneric_bytea when type is ECPGt_bytea
---
src/interfaces/ecpg/ecpglib/data.c | 4 ++--
src/interfaces/ecpg/ecpglib/descriptor.c | 4 ++--
src/interfaces/ecpg/ecpglib/execute.c | 6 +++---
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/interfaces/ecpg/ecpglib/data.c b/src/interfaces/ecpg/ecpglib/data.c
index d3db5094cf..6bc91ef7eb 100644
--- a/src/interfaces/ecpg/ecpglib/data.c
+++ b/src/interfaces/ecpg/ecpglib/data.c
@@ -523,8 +523,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;
diff --git a/src/interfaces/ecpg/ecpglib/descriptor.c b/src/interfaces/ecpg/ecpglib/descriptor.c
index f71f539bef..369c2f0867 100644
--- a/src/interfaces/ecpg/ecpglib/descriptor.c
+++ b/src/interfaces/ecpg/ecpglib/descriptor.c
@@ -591,8 +591,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;
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index 6961d7c75b..9d61ae7250 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -822,8 +822,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;
@@ -1401,7 +1401,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;
}
}
--
2.21.0
On Fri, Jul 24, 2020 at 1:35 PM Wang, Shenhao
<wangsh.fnst@cn.fujitsu.com> wrote:
Hi, hackers
The source looks like:
case ECPGt_bytea:
{
struct ECPGgeneric_varchar *variable =
(struct ECPGgeneric_varchar *) (var->value);......
}I think the developer intend to use struct ECPGgeneric_bytea instead of struct ECPGgeneric_varchar
Is this thoughts right?
I have wrote a patch to fix this typo
I felt the changes look correct. The reason it might be working
earlier is because the structure members are the same for both the
data structures ECPGgeneric_bytea & ECPGgeneric_varchar.
Regards,
Vignesh
EnterpriseDB: http://www.enterprisedb.com
On Sat, Jul 25, 2020 at 07:22:15AM +0530, vignesh C wrote:
I felt the changes look correct. The reason it might be working
earlier is because the structure members are the same for both the
data structures ECPGgeneric_bytea & ECPGgeneric_varchar.
ECPGset_noind_null() and ECPGis_noind_null() in misc.c show that
ECPGgeneric_bytea is attached to ECPGt_bytea. The two structures may
be the same now, but if a bug fix or a code change involves a change
in the structure definition we could run into problems. So let's fix
and back-patch this change. I am not spotting other areas impacted,
and I'll try to take care at the beginning of next week.
--
Michael
On Sat, Jul 25, 2020 at 06:17:42PM +0900, Michael Paquier wrote:
ECPGset_noind_null() and ECPGis_noind_null() in misc.c show that
ECPGgeneric_bytea is attached to ECPGt_bytea. The two structures may
be the same now, but if a bug fix or a code change involves a change
in the structure definition we could run into problems. So let's fix
and back-patch this change. I am not spotting other areas impacted,
and I'll try to take care at the beginning of next week.
Okay, fixed as e971357. The issue came from 050710b, so this fix was
only needed in 12~.
--
Michael