Commit 22c0b1f0 authored by Michael Meskes's avatar Michael Meskes

- Fixed order mismatch in processing "using" arguments.

- Fixed some minor things in test cases.
- Use defines for Informix error codes.
parent 8839b85e
......@@ -1645,6 +1645,12 @@ Sat Sep 20 11:06:13 CEST 2003
- Applied some bug fixing patches by Dave Cramer <dave@fastcrypt.com>.
- Added protecting defines to include files.
- Renamed my own strndup() function because of a name clash.
Mon Sep 22 15:13:02 CEST 2003
- Fixed order mismatch in processing "using" arguments.
- Fixed some minor things in test cases.
- Use defines for Informix error codes.
- Set ecpg version to 3.0.0
- Set ecpg library to 4.0.0
- Set pgtypes library to 1.0.0
......
......@@ -20,26 +20,26 @@ deccall2(decimal * arg1, decimal * arg2, int (*ptr) (numeric *, numeric *))
int i;
if ((a1 = PGTYPESnumeric_new()) == NULL)
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
if ((a2 = PGTYPESnumeric_new()) == NULL)
{
PGTYPESnumeric_free(a1);
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
}
if (PGTYPESnumeric_from_decimal(arg1, a1) != 0)
{
PGTYPESnumeric_free(a1);
PGTYPESnumeric_free(a2);
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
}
if (PGTYPESnumeric_from_decimal(arg2, a2) != 0)
{
PGTYPESnumeric_free(a1);
PGTYPESnumeric_free(a2);
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
}
i = (*ptr) (a1, a2);
......@@ -65,19 +65,19 @@ deccall3(decimal * arg1, decimal * arg2, decimal * result, int (*ptr) (numeric *
}
if ((a1 = PGTYPESnumeric_new()) == NULL)
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
if ((a2 = PGTYPESnumeric_new()) == NULL)
{
PGTYPESnumeric_free(a1);
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
}
if ((nres = PGTYPESnumeric_new()) == NULL)
{
PGTYPESnumeric_free(a1);
PGTYPESnumeric_free(a2);
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
}
if (PGTYPESnumeric_from_decimal(arg1, a1) != 0)
......@@ -85,7 +85,7 @@ deccall3(decimal * arg1, decimal * arg2, decimal * result, int (*ptr) (numeric *
PGTYPESnumeric_free(a1);
PGTYPESnumeric_free(a2);
PGTYPESnumeric_free(nres);
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
}
if (PGTYPESnumeric_from_decimal(arg2, a2) != 0)
......@@ -93,7 +93,7 @@ deccall3(decimal * arg1, decimal * arg2, decimal * result, int (*ptr) (numeric *
PGTYPESnumeric_free(a1);
PGTYPESnumeric_free(a2);
PGTYPESnumeric_free(nres);
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
}
i = (*ptr) (a1, a2, nres);
......@@ -115,9 +115,9 @@ decadd(decimal * arg1, decimal * arg2, decimal * sum)
deccall3(arg1, arg2, sum, PGTYPESnumeric_add);
if (errno == PGTYPES_NUM_OVERFLOW)
return -1200;
return ECPG_INFORMIX_NUM_OVERFLOW;
else if (errno != 0)
return -1201;
return ECPG_INFORMIX_NUM_UNDERFLOW;
else
return 0;
}
......@@ -166,7 +166,7 @@ deccvasc(char *cp, int len, decimal * np)
return 0;
if (!str)
ret = -1201;
ret = ECPG_INFORMIX_NUM_UNDERFLOW;
else
{
result = PGTYPESnumeric_from_asc(str, NULL);
......@@ -175,20 +175,20 @@ deccvasc(char *cp, int len, decimal * np)
switch (errno)
{
case PGTYPES_NUM_OVERFLOW:
ret = -1200;
ret = ECPG_INFORMIX_NUM_OVERFLOW;
break;
case PGTYPES_NUM_BAD_NUMERIC:
ret = -1213;
ret = ECPG_INFORMIX_BAD_NUMERIC;
break;
default:
ret = -1216;
ret = ECPG_INFORMIX_BAD_EXPONENT;
break;
}
}
else
{
if (PGTYPESnumeric_to_decimal(result, np) != 0)
ret = -1200;
ret = ECPG_INFORMIX_NUM_OVERFLOW;
free(result);
}
......@@ -209,7 +209,7 @@ deccvdbl(double dbl, decimal * np)
return 0;
if (nres == NULL)
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
result = PGTYPESnumeric_from_double(dbl, nres);
if (result == 0)
......@@ -230,7 +230,7 @@ deccvint(int in, decimal * np)
return 0;
if (nres == NULL)
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
result = PGTYPESnumeric_from_int(in, nres);
if (result == 0)
......@@ -251,7 +251,7 @@ deccvlong(long lng, decimal * np)
return 0;
if (nres == NULL)
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
result = PGTYPESnumeric_from_long(lng, nres);
if (result == 0)
......@@ -270,13 +270,13 @@ decdiv(decimal * n1, decimal * n2, decimal * n3)
switch (errno)
{
case PGTYPES_NUM_DIVIDE_ZERO:
return -1202;
return ECPG_INFORMIX_DIVIDE_ZERO;
break;
case PGTYPES_NUM_OVERFLOW:
return -1200;
return ECPG_INFORMIX_NUM_OVERFLOW;
break;
default:
return -1201;
return ECPG_INFORMIX_NUM_UNDERFLOW;
break;
}
......@@ -292,10 +292,10 @@ decmul(decimal * n1, decimal * n2, decimal * n3)
switch (errno)
{
case PGTYPES_NUM_OVERFLOW:
return -1200;
return ECPG_INFORMIX_NUM_OVERFLOW;
break;
default:
return -1201;
return ECPG_INFORMIX_NUM_UNDERFLOW;
break;
}
......@@ -311,10 +311,10 @@ decsub(decimal * n1, decimal * n2, decimal * n3)
switch (errno)
{
case PGTYPES_NUM_OVERFLOW:
return -1200;
return ECPG_INFORMIX_NUM_OVERFLOW;
break;
default:
return -1201;
return ECPG_INFORMIX_NUM_UNDERFLOW;
break;
}
......@@ -328,14 +328,14 @@ dectoasc(decimal * np, char *cp, int len, int right)
numeric *nres = PGTYPESnumeric_new();
if (nres == NULL)
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
rsetnull(CSTRINGTYPE, (char *) cp);
if (risnull(CDECIMALTYPE, (char *) np))
return 0;
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
if (right >= 0)
str = PGTYPESnumeric_to_asc(nres, right);
......@@ -363,10 +363,10 @@ dectodbl(decimal * np, double *dblp)
int i;
if (nres == NULL)
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
i = PGTYPESnumeric_to_double(nres, dblp);
PGTYPESnumeric_free(nres);
......@@ -381,15 +381,15 @@ dectoint(decimal * np, int *ip)
numeric *nres = PGTYPESnumeric_new();
if (nres == NULL)
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
ret = PGTYPESnumeric_to_int(nres, ip);
if (ret == PGTYPES_NUM_OVERFLOW)
ret = -1200;
ret = ECPG_INFORMIX_NUM_OVERFLOW;
return ret;
}
......@@ -401,15 +401,15 @@ dectolong(decimal * np, long *lngp)
numeric *nres = PGTYPESnumeric_new();;
if (nres == NULL)
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
ret = PGTYPESnumeric_to_long(nres, lngp);
if (ret == PGTYPES_NUM_OVERFLOW)
ret = -1200;
ret = ECPG_INFORMIX_NUM_OVERFLOW;
return ret;
}
......@@ -421,7 +421,7 @@ rdatestr(date d, char *str)
char *tmp = PGTYPESdate_to_asc(d);
if (!tmp)
return -1210;
return ECPG_INFORMIX_DATE_CONVERT;
/* move to user allocated buffer */
strcpy(str, tmp);
......@@ -436,7 +436,7 @@ rstrdate(char *str, date * d)
date dat = PGTYPESdate_from_asc(str, NULL);
if (errno != PGTYPES_DATE_BAD_DATE && dat == 0)
return -1218;
return ECPG_INFORMIX_BAD_DATE;
*d = dat;
return 0;
......@@ -473,16 +473,16 @@ rdefmtdate(date * d, char *fmt, char *str)
switch (errno)
{
case PGTYPES_DATE_ERR_ENOSHORTDATE:
return -1209;
return ECPG_INFORMIX_ENOSHORTDATE;
case PGTYPES_DATE_ERR_EARGS:
case PGTYPES_DATE_ERR_ENOTDMY:
return -1212;
return ECPG_INFORMIX_ENOTDMY;
case PGTYPES_DATE_BAD_DAY:
return -1204;
return ECPG_INFORMIX_BAD_DAY;
case PGTYPES_DATE_BAD_MONTH:
return -1205;
return ECPG_INFORMIX_BAD_MONTH;
default:
return -1206;
return ECPG_INFORMIX_BAD_YEAR;
}
}
......@@ -493,9 +493,9 @@ rfmtdate(date d, char *fmt, char *str)
return 0;
if (errno == ENOMEM)
return -1211;
return ECPG_INFORMIX_OUT_OF_MEMORY;
return -1210;
return ECPG_INFORMIX_DATE_CONVERT;
}
int
......@@ -538,7 +538,7 @@ dtcvasc(char *str, timestamp *ts)
if (**endptr)
{
/* extra characters exist at the end */
return -1264;
return ECPG_INFORMIX_EXTRA_CHARS;
}
/* everything went fine */
......
......@@ -11,6 +11,21 @@
#define SQLNOTFOUND 100
#define ECPG_INFORMIX_NUM_OVERFLOW -1200
#define ECPG_INFORMIX_NUM_UNDERFLOW -1201
#define ECPG_INFORMIX_DIVIDE_ZERO -1202
#define ECPG_INFORMIX_BAD_YEAR -1204
#define ECPG_INFORMIX_BAD_MONTH -1205
#define ECPG_INFORMIX_BAD_DAY -1206
#define ECPG_INFORMIX_ENOSHORTDATE -1209
#define ECPG_INFORMIX_DATE_CONVERT -1210
#define ECPG_INFORMIX_OUT_OF_MEMORY -1211
#define ECPG_INFORMIX_ENOTDMY -1212
#define ECPG_INFORMIX_BAD_NUMERIC -1213
#define ECPG_INFORMIX_BAD_EXPONENT -1216
#define ECPG_INFORMIX_BAD_DATE -1218
#define ECPG_INFORMIX_EXTRA_CHARS -1264
extern int rdatestr(date, char *);
extern void rtoday(date *);
extern int rjulmdy(date, short *);
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.257 2003/09/19 14:13:16 meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.258 2003/09/22 13:19:39 meskes Exp $ */
/* Copyright comment */
%{
......@@ -268,16 +268,16 @@ add_additional_variables(char *name, bool insert)
}
if (insert)
{
/* add all those input variables that were given earlier */
/* add all those input variables that were given earlier
* note that we have to append here but have to keep the existing order */
for (p = ptr->argsinsert; p; p = p->next)
add_variable(&argsinsert, p->variable, p->indicator);
append_variable(&argsinsert, p->variable, p->indicator);
}
else
{
/* add all those output variables that were given earlier */
for (p = ptr->argsresult; p; p = p->next)
add_variable(&argsresult, p->variable, p->indicator);
}
return ptr;
}
%}
......@@ -5320,7 +5320,7 @@ UsingConst: AllConst
char *length = mm_alloc(32);
sprintf(length, "%d", (int) strlen($1));
add_variable(&argsinsert, new_variable($1, ECPGmake_simple_type(ECPGt_const, length), 0), &no_indicator);
append_variable(&argsinsert, new_variable($1, ECPGmake_simple_type(ECPGt_const, length), 0), &no_indicator);
}
}
;
......
......@@ -345,7 +345,9 @@ reset_variables(void)
argsresult = NULL;
}
/* Insert a new variable into our request list. */
/* Insert a new variable into our request list.
* Note: The list is dumped from the end,
* so we have to add new entries at the beginning */
void
add_variable(struct arguments ** list, struct variable * var, struct variable * ind)
{
......
......@@ -22,18 +22,18 @@ main()
value1 = PGTYPESnumeric_new();
PGTYPESnumeric_from_int(1407, value1);
text = PGTYPESnumeric_to_asc(value1, 0);
text = PGTYPESnumeric_to_asc(value1, -1);
printf("long = %s\n", text);
value1 = PGTYPESnumeric_from_asc("2369.7", NULL);
value2 = PGTYPESnumeric_from_asc("10.0", NULL);
res = PGTYPESnumeric_new();
PGTYPESnumeric_add(value1, value2, res);
text = PGTYPESnumeric_to_asc(res, 0);
text = PGTYPESnumeric_to_asc(res, -1);
printf("add = %s\n", text);
PGTYPESnumeric_sub(res, value2, res);
text = PGTYPESnumeric_to_asc(res, 0);
text = PGTYPESnumeric_to_asc(res, -1);
printf("sub = %s\n", text);
PGTYPESnumeric_copy(res, &des);
......@@ -45,12 +45,12 @@ main()
exec sql select num into :des from test where text = 'test';
PGTYPESnumeric_mul(res, &des, res);
text = PGTYPESnumeric_to_asc(res, 0);
text = PGTYPESnumeric_to_asc(res, -1);
printf("mul = %s\n", text);
value2 = PGTYPESnumeric_from_asc("10000", NULL);
PGTYPESnumeric_div(res, value2, res);
text = PGTYPESnumeric_to_asc(res, 0);
text = PGTYPESnumeric_to_asc(res, -1);
PGTYPESnumeric_to_double(res, &d);
printf("div = %s %e\n", text, d);
......
......@@ -20,13 +20,13 @@ int main()
$commit;
$insert into test (i, j) values (7, 2);
printf("%ld: %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
printf("INSERT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
if (sqlca.sqlcode != 0) $rollback;
$insert into test (i, j) values (:i, 1);
$select i from test where j=(select j from test);
printf("%ld: %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
printf("SELECT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
if (sqlca.sqlcode != 0) $rollback;
$declare c cursor for select * from test where i <= :i;
......@@ -55,7 +55,7 @@ int main()
deccvint(14, &m);
decadd(&j, &m, &n);
$delete from test where i=:n;
printf("delete: %ld\n", sqlca.sqlcode);
printf("DELETE: %ld\n", sqlca.sqlcode);
$select 1 from test where i=14;
printf("Exists: %ld\n", sqlca.sqlcode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment