Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit cf883ea

Browse files
author
Michael Meskes
committed
- Made sure Informix style decimal vars are initialized. They use a
fixed amount of digits and not an allocated one. So we have to work around. PostgreSQL numeric type remains the same. - In INFORMIX_SE mode with autcommit set, make all cursors be "with hold". Is this really they way SE behaves?
1 parent 4355d4f commit cf883ea

File tree

5 files changed

+41
-11
lines changed

5 files changed

+41
-11
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,11 @@ Thu Jun 26 13:26:13 CEST 2003
15281528
Sun Jun 29 11:22:48 CEST 2003
15291529

15301530
- Just another sync.
1531+
- Made sure Informix style decimal vars are initialized. They use a
1532+
fixed amount of digits and not an allocated one. So we have to work
1533+
around. PostgreSQL numeric type remains the same.
1534+
- In INFORMIX_SE mode with autcommit set, make all cursors be "with
1535+
hold". Is this really they way SE behaves?
15311536
- Set ecpg version to 3.0.0
15321537
- Set ecpg library to 4.0.0
15331538
- Set pgtypes library to 1.0.0

src/interfaces/ecpg/include/ecpgtype.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ enum ECPGttype
4545
ECPGt_float, ECPGt_double,
4646
ECPGt_varchar, ECPGt_varchar2,
4747
ECPGt_numeric,
48+
ECPGt_decimal, /* only used internally */
4849
ECPGt_date,
4950
ECPGt_timestamp,
5051
ECPGt_interval,

src/interfaces/ecpg/preproc/preproc.y

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.242 2003/06/29 09:25:19 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.243 2003/06/29 16:52:58 meskes Exp $ */
22

33
/* Copyright comment */
44
%{
@@ -2706,7 +2706,10 @@ cursor_options: /* EMPTY */ { $$ = EMPTY; }
27062706
| cursor_options NO SCROLL { $$ = cat2_str($1, make_str("no scroll")); }
27072707
;
27082708

2709-
opt_hold: /* EMPTY */ { $$ = EMPTY; }
2709+
opt_hold: /* EMPTY */ { if (compat == ECPG_COMPAT_INFORMIX_SE && autocommit == true)
2710+
$$ = make_str("with hold");
2711+
else
2712+
$$ = EMPTY; }
27102713
| WITH HOLD { $$ = make_str("with hold"); }
27112714
| WITHOUT HOLD { $$ = make_str("without hold"); }
27122715
;
@@ -4449,7 +4452,7 @@ single_vt_type: common_type
44494452
}
44504453
else if (strcmp($1, "decimal") == 0)
44514454
{
4452-
$$.type_enum = ECPGt_numeric;
4455+
$$.type_enum = ECPGt_decimal;
44534456
$$.type_str = make_str("Numeric");
44544457
$$.type_dimension = make_str("-1");
44554458
$$.type_index = make_str("-1");
@@ -4751,7 +4754,7 @@ common_type: simple_type
47514754
if (strcmp($1, "numeric") != 0 && strcmp($1, "decimal") != 0)
47524755
mmerror(PARSE_ERROR, ET_ERROR, "Only numeric/decimal have precision/scale argument");
47534756

4754-
$$.type_enum = ECPGt_numeric;
4757+
$$.type_enum = (strcmp($1, "numeric") != 0) ? ECPGt_decimal : ECPGt_numeric;
47554758
$$.type_str = make_str("Numeric");
47564759
$$.type_dimension = make_str("-1");
47574760
$$.type_index = make_str("-1");
@@ -4803,7 +4806,7 @@ var_type: common_type
48034806
}
48044807
else if (strcmp($1, "decimal") == 0)
48054808
{
4806-
$$.type_enum = ECPGt_numeric;
4809+
$$.type_enum = ECPGt_decimal;
48074810
$$.type_str = make_str("Numeric");
48084811
$$.type_dimension = make_str("-1");
48094812
$$.type_index = make_str("-1");
@@ -5073,6 +5076,21 @@ variable: opt_pointer ECPGColLabelCommon opt_array_bounds opt_initializer
50735076
$$ = cat_str(4, $1, mm_strdup($2), $3.str, $4);
50745077
break;
50755078

5079+
case ECPGt_decimal: /* this is used by informix and need to be initialized */
5080+
if (atoi(dimension) < 0)
5081+
type = ECPGmake_simple_type(ECPGt_numeric, make_str("1"));
5082+
else
5083+
type = ECPGmake_array_type(ECPGmake_simple_type(ECPGt_numeric, make_str("1")), dimension);
5084+
5085+
if (strlen($4) == 0)
5086+
{
5087+
$4 = mm_alloc(sizeof(" = {0, 0, 0, 0, 0, NULL, NULL}"));
5088+
strcpy($4, " = {0, 0, 0, 0, 0, NULL, NULL}");
5089+
}
5090+
5091+
$$ = cat_str(4, $1, mm_strdup($2), $3.str, $4);
5092+
5093+
break;
50765094
default:
50775095
if (atoi(dimension) < 0)
50785096
type = ECPGmake_simple_type(actual_type[struct_level].type_enum, make_str("1"));

src/interfaces/ecpg/test/num_test.pgc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ main()
88
char *text="error\n";
99
Numeric *value1, *value2, *res;
1010
exec sql begin declare section;
11-
decimal(14,7) des = {0, 0, 0, 0, 0, NULL, NULL} ;
11+
numeric(14,7) des = {0, 0, 0, 0, 0, NULL, NULL} ;
1212
exec sql end declare section;
1313
double d;
1414
FILE *dbgs;

src/interfaces/ecpg/test/test_informix.pgc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ void openit(void);
55
int main()
66
{
77
$int i = 14;
8-
$int j;
8+
$decimal j;
99
FILE *dbgs;
1010

1111
if ((dbgs = fopen("log", "w")) != NULL)
@@ -15,24 +15,30 @@ int main()
1515

1616
$create table test(i int primary key, j int);
1717

18-
rsetnull(CINTTYPE, (char *)&j);
18+
rsetnull(CDECIMALTYPE, (char *)&j);
1919
$insert into test (i, j) values (7, :j);
2020
$insert into test (i, j) values (:i, 1);
2121

2222
$declare c cursor for select * from test where i <= :i;
2323
openit();
2424

25-
j=0;
25+
deccvint(0, &j);
26+
2627
while (1)
2728
{
2829
$fetch in c into :i, :j;
2930
if (sqlca.sqlcode == 100) break;
3031
else if (sqlca.sqlcode != 0) printf ("Error: %ld\n", sqlca.sqlcode);
3132

32-
if (risnull(CINTTYPE, (char *)&j))
33+
if (risnull(CDECIMALTYPE, (char *)&j))
3334
printf("%d\n", i);
3435
else
35-
printf("%d %d\n", i, j);
36+
{
37+
int a;
38+
39+
dectoint(&j, &a);
40+
printf("%d %d\n", i, a);
41+
}
3642
}
3743

3844
$delete from test where i=87;

0 commit comments

Comments
 (0)