Thread: [BUGS] BUG #14460: ecpg dynamic describe data types incorrect

[BUGS] BUG #14460: ecpg dynamic describe data types incorrect

From
gary.cowell@gmail.com
Date:
The following bug has been logged on the website:

Bug reference:      14460
Logged by:          gary surname
Email address:      gary.cowell@gmail.com
PostgreSQL version: 9.5.5
Operating system:   Red Hat Linux 7
Description:

If you have a table:

gc=> \d tajsplne
          Table "public.tajsplne"
 Column |         Type          | Modifiers
--------+-----------------------+-----------
 a      | character varying(20) |
 b      | text                  |
 c      | character(10)         |
 d      | integer               |


four different data types.

Insert a row:

gc=> insert into tajsplne values ('var','text','char',1);
INSERT 0 1
gc=> \q

Then run an ecpg program to select and describe the data, the data types
come back as:

a = var (type: 1)
b = text (type: 1)
c = char       (type: 1)
d = 1 (type: 5)

I.e. the sqlda data types for the CHAR , VARCHAR and TEXT columns, is all
type 1.


According to ecpgtype.h

enum ECPGttype
{
        ECPGt_char = 1, ECPGt_unsigned_char, ECPGt_short,
ECPGt_unsigned_short,
        ECPGt_int, ECPGt_unsigned_int, ECPGt_long, ECPGt_unsigned_long,
        ECPGt_long_long, ECPGt_unsigned_long_long,
        ECPGt_bool,
        ECPGt_float, ECPGt_double,
        ECPGt_varchar, ECPGt_varchar2,
        ECPGt_numeric,                          /* this is a decimal that
stores its digits in
                                                                 * a
malloced array */
        ECPGt_decimal,                          /* this is a decimal that
stores its digits in
                                                                 * a fixed
array */
        ECPGt_date,
        ECPGt_timestamp,
        ECPGt_interval,
        ECPGt_array,
        ECPGt_struct,
        ECPGt_union,
        ECPGt_descriptor,                       /* sql descriptor, no C
variable */
        ECPGt_char_variable,
        ECPGt_const,                            /* a constant is needed
sometimes */
        ECPGt_EOIT,                                     /* End of insert
types. */
        ECPGt_EORT,                                     /* End of result
types. */
        ECPGt_NO_INDICATOR,                     /* no indicator */
        ECPGt_string,                           /* trimmed (char *) type
*/
        ECPGt_sqlda                                     /* C struct
descriptor */
};

the varchar at least should be type 14, yes?  Though not much clue what the
TEXT type should be.

Have I a misunderstanding, or is this a bug?

Thanks


--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Re: [BUGS] BUG #14460: ecpg dynamic describe data types incorrect

From
Michael Meskes
Date:
> Then run an ecpg program to select and describe the data, the data
> types
> come back as:
> 
> a = var (type: 1)
> b = text (type: 1)
> c = char       (type: 1)
> d = 1 (type: 5)
> 
> I.e. the sqlda data types for the CHAR , VARCHAR and TEXT columns, is
> all
> type 1.

CHAR and TEXT should be the same. However, varchar should be different
IIRC. There is definitely a case that maps VARCHAROID
to SQL3_CHARACTER_VARYING which equals 12. Does the log file, if you
enable debugging, show the same type information?

> According to ecpgtype.h
> ...

ecpgtype.h is PostgreSQL internal type information, the descriptor is
supposed to handle types as defined by the standard. Those definitions
are in sql3types.h.

Michael
-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs