RE: [Bug Fix]ECPG: cancellation of significant digits on ECPG - Mailing list pgsql-hackers

From Higuchi, Daisuke
Subject RE: [Bug Fix]ECPG: cancellation of significant digits on ECPG
Date
Msg-id 1803D792815FC24D871C00D17AE95905C7870E@g01jpexmbkw24
Whole thread Raw
In response to [Bug Fix]ECPG: cancellation of significant digits on ECPG  ("Higuchi, Daisuke" <higuchi.daisuke@jp.fujitsu.com>)
Responses Re: [Bug Fix]ECPG: cancellation of significant digits on ECPG  (Dmitry Dolgov <9erthalion6@gmail.com>)
List 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




pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Portability concerns over pq_sendbyte?
Next
From: Tom Lane
Date:
Subject: Re: Keeping temporary tables in shared buffers