BUG #14460: ecpg dynamic describe data types incorrect

From: gary(dot)cowell(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #14460: ecpg dynamic describe data types incorrect
Date: 2016-12-12 15:36:03
Message-ID: 20161212153603.14901.48046@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 14460
Logged by: gary surname
Email address: gary(dot)cowell(at)gmail(dot)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message nwilson5 2016-12-12 22:17:48 BUG #14461: ERROR: index returned tuples in wrong order
Previous Message Tom Lane 2016-12-11 22:18:24 Re: Re: 9.5 / Re: base_yylex undefined in src/interface/ecpg/preproc/parser.c