RE: [Bug Fix]ECPG: cancellation of significant digits on ECPG

From: "Higuchi, Daisuke" <higuchi(dot)daisuke(at)jp(dot)fujitsu(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: [Bug Fix]ECPG: cancellation of significant digits on ECPG
Date: 2018-05-25 02:11:05
Message-ID: 1803D792815FC24D871C00D17AE95905C7870E@g01jpexmbkw24
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
I have a question which is related to numeric data type bugs on ECPG sqlda.

Currently, I think following functions have a problem when using numeric data type on sqlda.
Please see the details of problem from the mail I sent before.
[src/ecpg/ecpglib/sqlda.c]
- ecpg_set_native_sqlda()
- sqlda_common_total_size()
- ecpg_set_compat_sqlda()

However, I think some codes which have problem in ecpg_set_compat_sqlda() are not used.

On ecpg_set_compat_sqlda(), there are own cases for numeric and decimal data type.
-------------
ecpg_set_compat_sqlda(int lineno, struct sqlda_compat **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
{
for (i = 0; i < sqlda->sqld; i++)
{
switch (sqlda->sqlvar[i].sqltype)
{
case ECPGt_decimal:
ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);

case ECPGt_numeric:
ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);

-------------

ecpg_set_compat_sqlda() is used only when INFORMIX_MODE(stmt->compat) is true.
-------------
bool
ecpg_process_output(struct statement *stmt, bool clear_result)
{

if (INFORMIX_MODE(stmt->compat))
{
sqlda_new = ecpg_build_compat_sqlda(stmt->lineno, stmt->results, i, stmt->compat);

ecpg_set_compat_sqlda(stmt->lineno, _sqlda, stmt->results, i, stmt->compat);

}
-------------

However, numeric data type could be changed to decimal by ecpg_build_compat_sqlda() in this case.
-------------
ecpg_build_compat_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
{
sqlda->sqlvar[i].sqltype = sqlda_dynamic_type(PQftype(res, i), compat);

sqlda_dynamic_type(Oid type, enum COMPAT_MODE compat)
{
switch (type)
{
case NUMERICOID:
return INFORMIX_MODE(compat) ? ECPGt_decimal : ECPGt_numeric;
-------------

Could we remove some codes for numeric in ecpg_set_compat_sqlda()?

Regards,
Daisuke, Higuchi

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-05-25 03:19:02 Re: Keeping temporary tables in shared buffers
Previous Message Tatsuo Ishii 2018-05-25 02:09:20 Re: Add PostgreSQL 11 to feature matrix page?