Commit b30da7ba authored by Michael Meskes's avatar Michael Meskes

Added lots of SoC stuff made by Joachim.

Fixed broken newline on Windows.
Fixed a nasty buffer underrun that only occured when using Informix
no_indicator NULL setting on timestamps and intervals.
parent 58538a0f
......@@ -2082,5 +2082,18 @@ We Aug 9 09:28:56 CEST 2006
- Fixed error handling in numeric conversion (Joachim).
- Fixed some memory bugs that somehow reappeared.
- Also fixed a new Coverity report.
Su Aug 13 11:01:13 CEST 2006
- Applied patch for VPATH builds by Alvaro Herrera
<alvherre@commandprompt.com>
- Merged dyntest.pgc and dyntest2.pgc.
Mo Aug 14 10:39:59 CEST 2006
- Added lots of SoC stuff made by Joachim.
- Fixed broken newline on Windows.
- Fixed a nasty buffer underrun that only occured when using Informix
no_indicator NULL setting on timestamps and intervals.
- Set ecpg library version to 5.2.
- Set ecpg version to 4.2.1.
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.46 2006/06/26 09:20:09 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.47 2006/08/15 06:40:19 meskes Exp $ */
#include <stdlib.h>
#include <string.h>
......@@ -122,12 +122,15 @@ deccall3(decimal *arg1, decimal *arg2, decimal *result, int (*ptr) (numeric *, n
int
decadd(decimal *arg1, decimal *arg2, decimal *sum)
{
errno = 0;
deccall3(arg1, arg2, sum, PGTYPESnumeric_add);
if (errno == PGTYPES_NUM_OVERFLOW)
return ECPG_INFORMIX_NUM_OVERFLOW;
else if (errno != 0)
else if (errno == PGTYPES_NUM_UNDERFLOW)
return ECPG_INFORMIX_NUM_UNDERFLOW;
else if (errno != 0)
return -1;
else
return 0;
}
......@@ -179,6 +182,7 @@ deccvasc(char *cp, int len, decimal *np)
ret = ECPG_INFORMIX_NUM_UNDERFLOW;
else
{
errno = 0;
result = PGTYPESnumeric_from_asc(str, NULL);
if (!result)
{
......@@ -280,6 +284,7 @@ decdiv(decimal *n1, decimal *n2, decimal *result)
int i;
errno = 0;
i = deccall3(n1, n2, result, PGTYPESnumeric_div);
if (i != 0)
......@@ -304,6 +309,7 @@ decmul(decimal *n1, decimal *n2, decimal *result)
{
int i;
errno = 0;
i = deccall3(n1, n2, result, PGTYPESnumeric_mul);
if (i != 0)
......@@ -325,6 +331,7 @@ decsub(decimal *n1, decimal *n2, decimal *result)
{
int i;
errno = 0;
i = deccall3(n1, n2, result, PGTYPESnumeric_sub);
if (i != 0)
......@@ -371,13 +378,25 @@ dectoasc(decimal *np, char *cp, int len, int right)
return -1;
/*
* TODO: have to take care of len here and create exponatial notion if
* necessary
* TODO: have to take care of len here and create exponential notation
* if necessary
*/
strncpy(cp, str, len);
free(str);
return 0;
if ((int) (strlen(str) + 1) > len)
{
if (len > 1)
{
cp[0] = '*';
cp[1] = '\0';
}
free(str);
return -1;
}
else
{
strcpy(cp, str);
free(str);
return 0;
}
}
int
......@@ -474,59 +493,7 @@ rdatestr(date d, char *str)
int
rstrdate(char *str, date * d)
{
date dat;
char strbuf[10];
int i,
j;
rsetnull(CDATETYPE, (char *) &dat);
/*
* we have to flip the year month date around for postgres expects
* yyyymmdd
*
*/
for (i = 0, j = 0; i < 10; i++)
{
/* ignore non-digits */
if (isdigit((unsigned char) str[i]))
{
/* j only increments if it is a digit */
switch (j)
{
/* stick the month into the 4th, 5th position */
case 0:
case 1:
strbuf[j + 4] = str[i];
break;
/* stick the day into the 6th, and 7th position */
case 2:
case 3:
strbuf[j + 4] = str[i];
break;
/* stick the year into the first 4 positions */
case 4:
case 5:
case 6:
case 7:
strbuf[j - 4] = str[i];
break;
}
j++;
}
}
strbuf[8] = '\0';
dat = PGTYPESdate_from_asc(strbuf, NULL);
if (errno && errno != PGTYPES_DATE_BAD_DATE)
return ECPG_INFORMIX_BAD_DATE;
*d = dat;
return 0;
return rdefmtdate(d, "mm/dd/yyyy", str);
}
void
......@@ -554,6 +521,7 @@ rdefmtdate(date * d, char *fmt, char *str)
/* TODO: take care of DBCENTURY environment variable */
/* PGSQL functions allow all centuries */
errno = 0;
if (PGTYPESdate_defmt_asc(d, fmt, str) == 0)
return 0;
......@@ -576,6 +544,7 @@ rdefmtdate(date * d, char *fmt, char *str)
int
rfmtdate(date d, char *fmt, char *str)
{
errno = 0;
if (PGTYPESdate_fmt_asc(d, fmt, str) == 0)
return 0;
......@@ -618,15 +587,18 @@ dtcvasc(char *str, timestamp * ts)
int i;
char **endptr = &str;
errno = 0;
ts_tmp = PGTYPEStimestamp_from_asc(str, endptr);
i = errno;
if (i)
/* TODO: rewrite to Informix error codes */
return i;
if (**endptr)
{
/* extra characters exist at the end */
return ECPG_INFORMIX_EXTRA_CHARS;
}
/* TODO: other Informix error codes missing */
/* everything went fine */
*ts = ts_tmp;
......@@ -634,6 +606,12 @@ dtcvasc(char *str, timestamp * ts)
return 0;
}
int
dtcvfmtasc(char *inbuf, char *fmtstr, timestamp * dtvalue)
{
return PGTYPEStimestamp_defmt_asc(inbuf, fmtstr, dtvalue);
}
int
dtsub(timestamp * ts1, timestamp * ts2, interval * iv)
{
......@@ -659,6 +637,7 @@ dttofmtasc(timestamp * ts, char *output, int str_len, char *fmtstr)
int
intoasc(interval * i, char *str)
{
errno = 0;
str = PGTYPESinterval_to_asc(i);
if (!str)
......@@ -797,17 +776,21 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
/* qualify, where we are in the value_string */
if (k < 0)
{
if (leftalign)
{
/* can't use strncat(,,0) here, Solaris would freek out */
temp[j] = '\0';
break;
}
blank = 1;
if (k == -2)
entity = 1;
else if (k == -1)
sign = 1;
if (leftalign)
{
/* can't use strncat(,,0) here, Solaris would freek out */
if (sign)
if (signdone)
{
temp[j] = '\0';
break;
}
}
}
/* if we're right side of the right-most dot, print '0' */
if (dotpos >= 0 && dotpos <= i)
......@@ -829,6 +812,9 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
fmtchar = lastfmt;
else
fmtchar = fmt[i];
/* waiting for the sign */
if (k < 0 && leftalign && sign && !signdone && fmtchar != '+' && fmtchar != '-')
continue;
/* analyse this format-char */
switch (fmtchar)
{
......@@ -854,9 +840,6 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
else
tmp[0] = value.val_string[k];
break;
case '<':
tmp[0] = value.val_string[k];
break;
case '-':
if (sign && value.sign == '-' && !signdone)
{
......@@ -904,6 +887,9 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
else
tmp[0] = value.val_string[k];
break;
case '<':
tmp[0] = value.val_string[k];
break;
default:
tmp[0] = fmt[i];
}
......@@ -950,8 +936,9 @@ byleng(char *str, int len)
void
ldchar(char *src, int len, char *dest)
{
memmove(dest, src, len);
dest[len] = 0;
int dlen = byleng(src, len);
memmove(dest, src, dlen);
dest[dlen] = '\0';
}
int
......@@ -978,12 +965,6 @@ rtypwidth(int sqltype, int sqllen)
return 0;
}
int
dtcvfmtasc(char *inbuf, char *fmtstr, timestamp * dtvalue)
{
return PGTYPEStimestamp_defmt_asc(inbuf, fmtstr, dtvalue);
}
static struct var_list
{
int number;
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.30 2006/08/08 11:51:24 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.31 2006/08/15 06:40:19 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
......@@ -346,8 +346,8 @@ ECPGset_noind_null(enum ECPGttype type, void *ptr)
static bool
_check(unsigned char *ptr, int length)
{
for (; ptr[--length] == 0xff && length >= 0; length--);
if (length < 0)
for (; length > 0 && ptr[--length] == 0xff;);
if (length <= 0)
return true;
return false;
}
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_error.h,v 1.7 2006/03/11 04:38:39 momjian Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_error.h,v 1.8 2006/08/15 06:40:19 meskes Exp $ */
#define PGTYPES_NUM_OVERFLOW 301
#define PGTYPES_NUM_BAD_NUMERIC 302
#define PGTYPES_NUM_DIVIDE_ZERO 303
#define PGTYPES_NUM_UNDERFLOW 304
#define PGTYPES_DATE_BAD_DATE 310
#define PGTYPES_DATE_ERR_EARGS 311
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.29 2006/06/21 10:24:41 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.30 2006/08/15 06:40:19 meskes Exp $ */
#include "postgres_fe.h"
......@@ -230,7 +230,7 @@ PGTYPESdate_fmt_asc(date dDate, char *fmtstring, char *outbuf)
replace_type = PGTYPES_TYPE_UINT_4_LZ;
break;
case PGTYPES_FMTDATE_YEAR_DIGITS_SHORT:
replace_val.uint_val = tm.tm_year % 1000;
replace_val.uint_val = tm.tm_year % 100;
replace_type = PGTYPES_TYPE_UINT_2_LZ;
break;
default:
......@@ -537,7 +537,7 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
* matches
*/
free(str_copy);
errno = PGTYPES_DATE_ERR_ENOTDMY;
errno = PGTYPES_DATE_ERR_ENOSHORTDATE;
return -1;
}
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.31 2006/08/13 10:18:30 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.32 2006/08/15 06:40:19 meskes Exp $ */
#include "postgres_fe.h"
#include <ctype.h>
......@@ -1512,7 +1512,10 @@ numericvar_to_double(numeric *var, double *dp)
if (errno == ERANGE)
{
free(tmp);
errno = PGTYPES_NUM_OVERFLOW;
if (val == 0)
errno = PGTYPES_NUM_UNDERFLOW;
else
errno = PGTYPES_NUM_OVERFLOW;
return -1;
}
......@@ -1576,7 +1579,10 @@ PGTYPESnumeric_to_long(numeric *nv, long *lp)
return -1;
if (errno == ERANGE)
{
errno = PGTYPES_NUM_OVERFLOW;
if (*lp == LONG_MIN)
errno = PGTYPES_NUM_UNDERFLOW;
else
errno = PGTYPES_NUM_OVERFLOW;
return -1;
}
free(s);
......
......@@ -423,34 +423,47 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
replace_type = PGTYPES_TYPE_NOTHING;
switch (*p)
{
/* the abbreviated name of the day in the week */
/* XXX should be locale aware */
case 'a':
replace_val.str_val = pgtypes_date_weekdays_short[dow];
replace_type = PGTYPES_TYPE_STRING_CONSTANT;
break;
/* the full name of the day in the week */
/* XXX should be locale aware */
case 'A':
replace_val.str_val = days[dow];
replace_type = PGTYPES_TYPE_STRING_CONSTANT;
break;
/* the abbreviated name of the month */
/* XXX should be locale aware */
case 'b':
case 'h':
replace_val.str_val = months[tm->tm_mon];
replace_type = PGTYPES_TYPE_STRING_CONSTANT;
break;
/* the full name name of the month */
/* XXX should be locale aware */
case 'B':
replace_val.str_val = pgtypes_date_months[tm->tm_mon];
replace_type = PGTYPES_TYPE_STRING_CONSTANT;
break;
/* The preferred date and time representation for the
* current locale. */
case 'c':
/* XXX */
break;
/* the century number with leading zeroes */
case 'C':
replace_val.uint_val = tm->tm_year / 100;
replace_type = PGTYPES_TYPE_UINT_2_LZ;
break;
/* day with leading zeroes (01 - 31) */
case 'd':
replace_val.uint_val = tm->tm_mday;
replace_type = PGTYPES_TYPE_UINT_2_LZ;
break;
/* the date in the format mm/dd/yy */
case 'D':
/*
......@@ -467,10 +480,14 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
if (i)
return i;
break;
/* day with leading spaces (01 - 31) */
case 'e':
replace_val.uint_val = tm->tm_mday;
replace_type = PGTYPES_TYPE_UINT_2_LS;
break;
/*
* alternative format modifier
*/
case 'E':
{
char tmp[4] = "%Ex";
......@@ -496,6 +513,10 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
replace_type = PGTYPES_TYPE_NOTHING;
break;
}
/*
* The ISO 8601 year with century as a decimal number. The
* 4-digit year corresponding to the ISO week number.
*/
case 'G':
tm->tm_mon -= 1;
i = strftime(q, *pstr_len, "%G", tm);
......@@ -509,6 +530,10 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
tm->tm_mon += 1;
replace_type = PGTYPES_TYPE_NOTHING;
break;
/*
* Like %G, but without century, i.e., with a 2-digit year
* (00-99).
*/
case 'g':
{
char *fmt = "%g"; /* Keep compiler quiet about
......@@ -527,38 +552,57 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
replace_type = PGTYPES_TYPE_NOTHING;
}
break;
/* hour (24 hour clock) with leading zeroes */
case 'H':
replace_val.uint_val = tm->tm_hour;
replace_type = PGTYPES_TYPE_UINT_2_LZ;
break;
/* hour (12 hour clock) with leading zeroes */
case 'I':
replace_val.uint_val = tm->tm_hour % 12;
replace_type = PGTYPES_TYPE_UINT_2_LZ;
break;
/*
* The day of the year as a decimal number with leading zeroes.
* It ranges from 001 to 366.
*/
case 'j':
replace_val.uint_val = tm->tm_yday;
replace_type = PGTYPES_TYPE_UINT_3_LZ;
break;
/*
* The hour (24 hour clock). Leading zeroes will be turned into
* spaces.
*/
case 'k':
replace_val.uint_val = tm->tm_hour;
replace_type = PGTYPES_TYPE_UINT_2_LS;
break;
/*
* The hour (12 hour clock). Leading zeroes will be turned into
* spaces.
*/
case 'l':
replace_val.uint_val = tm->tm_hour % 12;
replace_type = PGTYPES_TYPE_UINT_2_LS;
break;
/* The month as a decimal number with a leading zero */
case 'm':
replace_val.uint_val = tm->tm_mon;
replace_type = PGTYPES_TYPE_UINT_2_LZ;
break;
/* The minute as a decimal number with a leading zero */
case 'M':
replace_val.uint_val = tm->tm_min;
replace_type = PGTYPES_TYPE_UINT_2_LZ;
break;
/* A newline character */
case 'n':
replace_val.char_val = '\n';
replace_type = PGTYPES_TYPE_CHAR;
break;
/* the AM/PM specifier (uppercase) */
/* XXX should be locale aware */
case 'p':
if (tm->tm_hour < 12)
replace_val.str_val = "AM";
......@@ -566,6 +610,8 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
replace_val.str_val = "PM";
replace_type = PGTYPES_TYPE_STRING_CONSTANT;
break;
/* the AM/PM specifier (lowercase) */
/* XXX should be locale aware */
case 'P':
if (tm->tm_hour < 12)
replace_val.str_val = "am";
......@@ -573,6 +619,8 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
replace_val.str_val = "pm";
replace_type = PGTYPES_TYPE_STRING_CONSTANT;
break;
/* the time in the format %I:%M:%S %p */
/* XXX should be locale aware */
case 'r':
i = dttofmtasc_replace(ts, dDate, dow, tm,
q, pstr_len,
......@@ -580,6 +628,7 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
if (i)
return i;
break;
/* The time in 24 hour notation (%H:%M) */
case 'R':
i = dttofmtasc_replace(ts, dDate, dow, tm,
q, pstr_len,
......@@ -587,6 +636,7 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
if (i)
return i;
break;
/* The number of seconds since the Epoch (1970-01-01) */
case 's':
#ifdef HAVE_INT64_TIMESTAMP
replace_val.int64_val = (*ts - SetEpochTimestamp()) / 1000000.0;
......@@ -596,14 +646,17 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
replace_type = PGTYPES_TYPE_DOUBLE_NF;
#endif
break;
/* seconds as a decimal number with leading zeroes */
case 'S':
replace_val.uint_val = tm->tm_sec;
replace_type = PGTYPES_TYPE_UINT_2_LZ;
break;
/* A tabulator */
case 't':
replace_val.char_val = '\t';
replace_type = PGTYPES_TYPE_CHAR;
break;
/* The time in 24 hour notation (%H:%M:%S) */
case 'T':
i = dttofmtasc_replace(ts, dDate, dow, tm,
q, pstr_len,
......@@ -611,12 +664,14 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
if (i)
return i;
break;
/* The day of the week as a decimal, Monday = 1, Sunday = 7 */
case 'u':
if (dow == 0)
dow = 7;
replace_val.uint_val = dow;
if (replace_val.uint_val == 0)
replace_val.uint_val = 7;
replace_type = PGTYPES_TYPE_UINT;
break;
/* The week number of the year as a decimal number */
case 'U':
tm->tm_mon -= 1;
i = strftime(q, *pstr_len, "%U", tm);
......@@ -630,6 +685,10 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
tm->tm_mon += 1;
replace_type = PGTYPES_TYPE_NOTHING;
break;
/*
* The ISO 8601:1988 week number of the current year as a
* decimal number.
*/
case 'V':
i = strftime(q, *pstr_len, "%V", tm);
if (i == 0)
......@@ -641,10 +700,15 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
}
replace_type = PGTYPES_TYPE_NOTHING;
break;
/*
* The day of the week as a decimal, Sunday being 0 and
* Monday 1.
*/
case 'w':
replace_val.uint_val = dow;
replace_type = PGTYPES_TYPE_UINT;
break;
/* The week number of the year (another definition) */
case 'W':
tm->tm_mon -= 1;
i = strftime(q, *pstr_len, "%U", tm);
......@@ -658,6 +722,10 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
tm->tm_mon += 1;
replace_type = PGTYPES_TYPE_NOTHING;
break;
/*
* The preferred date representation for the current locale
* without the time.
*/
case 'x':
{
char *fmt = "%x"; /* Keep compiler quiet about
......@@ -676,6 +744,10 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
replace_type = PGTYPES_TYPE_NOTHING;
}
break;
/*
* The preferred time representation for the current locale
* without the date.
*/
case 'X':
tm->tm_mon -= 1;
i = strftime(q, *pstr_len, "%X", tm);
......@@ -689,14 +761,17 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
tm->tm_mon += 1;
replace_type = PGTYPES_TYPE_NOTHING;
break;
/* The year without the century (2 digits, leading zeroes) */
case 'y':
replace_val.uint_val = tm->tm_year % 100;
replace_type = PGTYPES_TYPE_UINT_2_LZ;
break;
/* The year with the century (4 digits) */
case 'Y':
replace_val.uint_val = tm->tm_year;
replace_type = PGTYPES_TYPE_UINT;
break;
/* The time zone offset from GMT */
case 'z':
tm->tm_mon -= 1;
i = strftime(q, *pstr_len, "%z", tm);
......@@ -710,6 +785,7 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
tm->tm_mon += 1;
replace_type = PGTYPES_TYPE_NOTHING;
break;
/* The name or abbreviation of the time zone */
case 'Z':
tm->tm_mon -= 1;
i = strftime(q, *pstr_len, "%Z", tm);
......@@ -723,19 +799,18 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
tm->tm_mon += 1;
replace_type = PGTYPES_TYPE_NOTHING;
break;
/* A % sign */
case '%':
replace_val.char_val = '%';
replace_type = PGTYPES_TYPE_CHAR;
break;
case '\0':
/* fmtstr: blabla%' */
/* fmtstr: foo%' - The string ends with a % sign */
/*
* this is not compliant to the specification
*/
return -1;
default:
/*
* if we don't know the pattern, we just copy it
*/
......
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/output.c,v 1.17 2006/03/11 04:38:40 momjian Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/output.c,v 1.18 2006/08/15 06:40:19 meskes Exp $ */
#include "postgres_fe.h"
......@@ -139,6 +139,11 @@ output_escaped_str(char *str)
fputs("\\\"", yyout);
else if (str[i] == '\n')
fputs("\\\n", yyout);
else if (str[i] == '\r' && str[i+1] == '\n')
{
fputs("\\\r\n", yyout);
i++;
}
else
fputc(str[i], yyout);
}
......
......@@ -10,7 +10,11 @@ override LDFLAGS += -L../../compatlib
override LIBS += $(LIBS) -lecpg_compat
TESTS = test_informix test_informix.c \
test_informix2 test_informix2.c
test_informix2 test_informix2.c \
dec_test dec_test.c \
rfmtdate rfmtdate.c \
rfmtlong rfmtlong.c \
charfuncs charfuncs.c
all: $(TESTS)
......@@ -18,5 +22,19 @@ test_informix.c: test_informix.pgc ../regression.h
$(ECPG) -o $@ -I$(srcdir) $<
test_informix2.c: test_informix2.pgc ../regression.h
$(ECPG) -o $@ -I$(srcdir) $<
dec_test.c: dec_test.pgc ../regression.h
$(ECPG) -o $@ -I$(srcdir) $<
rfmtdate.c: rfmtdate.pgc ../regression.h
$(ECPG) -o $@ -I$(srcdir) $<
rfmtlong.c: rfmtlong.pgc ../regression.h
$(ECPG) -o $@ -I$(srcdir) $<
rnull.c: rnull.pgc ../regression.h
$(ECPG_NOIND) -o $@ -I$(srcdir) $<
charfuncs.c: charfuncs.pgc ../regression.h
$(ECPG) -o $@ -I$(srcdir) $<
......@@ -59,10 +59,6 @@ int main(void)
ECPGdebug(1, stderr);
/* if (strlen(REGRESSDB1) > MAXDBLEN) {
exit(1);
}
*/
strcpy(dbname, "regress1");
EXEC SQL connect to :dbname;
sql_check("main", "connect", 0);
......@@ -80,12 +76,6 @@ int main(void)
from history;
sql_check("main", "select max", 100);
if (risnull(CDTIMETYPE, (char *) &maxd))
{
printf("Nothing on the history table\n\n");
exit(0);
}
EXEC SQL select customerid, timestamp
into :c, :d
from history
......
......@@ -170,62 +170,52 @@ int main(void)
ECPGdebug(1, stderr);
/* if (strlen(REGRESSDB1) > MAXDBLEN) {
exit(1);
}
*/
strcpy(dbname, "regress1");
{ ECPGconnect(__LINE__, 1, dbname , NULL,NULL , NULL, 0);
#line 67 "test_informix2.pgc"
#line 63 "test_informix2.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 67 "test_informix2.pgc"
#line 63 "test_informix2.pgc"
sql_check("main", "connect", 0);
{ ECPGdo(__LINE__, 1, 0, NULL, "create table history ( customerid integer , timestamp timestamp without time zone , action_taken char ( 5 ) , narrative varchar ( 100 ) ) ", ECPGt_EOIT, ECPGt_EORT);
#line 70 "test_informix2.pgc"
{ ECPGdo(__LINE__, 1, 1, NULL, "create table history ( customerid integer , timestamp timestamp without time zone , action_taken char ( 5 ) , narrative varchar ( 100 ) ) ", ECPGt_EOIT, ECPGt_EORT);
#line 66 "test_informix2.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 70 "test_informix2.pgc"
#line 66 "test_informix2.pgc"
sql_check("main", "create", 0);
{ ECPGdo(__LINE__, 1, 0, NULL, "insert into history ( customerid , timestamp , action_taken , narrative ) values( 1 , '2003-05-07 13:28:34 CEST' , 'test' , 'test' )", ECPGt_EOIT, ECPGt_EORT);
#line 75 "test_informix2.pgc"
{ ECPGdo(__LINE__, 1, 1, NULL, "insert into history ( customerid , timestamp , action_taken , narrative ) values( 1 , '2003-05-07 13:28:34 CEST' , 'test' , 'test' )", ECPGt_EOIT, ECPGt_EORT);
#line 71 "test_informix2.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 75 "test_informix2.pgc"
#line 71 "test_informix2.pgc"
sql_check("main", "insert", 0);
{ ECPGdo(__LINE__, 1, 0, NULL, "select max ( timestamp ) from history ", ECPGt_EOIT,
{ ECPGdo(__LINE__, 1, 1, NULL, "select max ( timestamp ) from history ", ECPGt_EOIT,
ECPGt_timestamp,&(maxd),(long)1,(long)1,sizeof(timestamp),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 80 "test_informix2.pgc"
#line 76 "test_informix2.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 80 "test_informix2.pgc"
#line 76 "test_informix2.pgc"
sql_check("main", "select max", 100);
if (risnull(CDTIMETYPE, (char *) &maxd))
{
printf("Nothing on the history table\n\n");
exit(0);
}
{ ECPGdo(__LINE__, 1, 0, NULL, "select customerid , timestamp from history where timestamp = ? limit 1 ",
{ ECPGdo(__LINE__, 1, 1, NULL, "select customerid , timestamp from history where timestamp = ? limit 1 ",
ECPGt_timestamp,&(maxd),(long)1,(long)1,sizeof(timestamp),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
ECPGt_int,&(c),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_timestamp,&(d),(long)1,(long)1,sizeof(timestamp),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 93 "test_informix2.pgc"
#line 83 "test_informix2.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 93 "test_informix2.pgc"
#line 83 "test_informix2.pgc"
sql_check("main", "select", 0);
......@@ -236,45 +226,45 @@ if (sqlca.sqlcode < 0) sqlprint();}
c++;
{ ECPGdo(__LINE__, 1, 0, NULL, "insert into history ( customerid , timestamp , action_taken , narrative ) values( ? , ? , 'test' , 'test' )",
{ ECPGdo(__LINE__, 1, 1, NULL, "insert into history ( customerid , timestamp , action_taken , narrative ) values( ? , ? , 'test' , 'test' )",
ECPGt_int,&(c),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_timestamp,&(e),(long)1,(long)1,sizeof(timestamp),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 105 "test_informix2.pgc"
#line 95 "test_informix2.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 105 "test_informix2.pgc"
#line 95 "test_informix2.pgc"
sql_check("main", "update", 0);
{ ECPGtrans(__LINE__, NULL, "commit");
#line 108 "test_informix2.pgc"
#line 98 "test_informix2.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 108 "test_informix2.pgc"
#line 98 "test_informix2.pgc"
{ ECPGdo(__LINE__, 1, 0, NULL, "drop table history ", ECPGt_EOIT, ECPGt_EORT);
#line 110 "test_informix2.pgc"
{ ECPGdo(__LINE__, 1, 1, NULL, "drop table history ", ECPGt_EOIT, ECPGt_EORT);
#line 100 "test_informix2.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 110 "test_informix2.pgc"
#line 100 "test_informix2.pgc"
sql_check("main", "drop", 0);
{ ECPGtrans(__LINE__, NULL, "commit");
#line 113 "test_informix2.pgc"
#line 103 "test_informix2.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 113 "test_informix2.pgc"
#line 103 "test_informix2.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");
#line 115 "test_informix2.pgc"
#line 105 "test_informix2.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 115 "test_informix2.pgc"
#line 105 "test_informix2.pgc"
sql_check("main", "disconnect", 0);
......
......@@ -2,39 +2,39 @@
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 70: QUERY: create table history ( customerid integer , timestamp timestamp without time zone , action_taken char ( 5 ) , narrative varchar ( 100 ) ) on connection regress1
[NO_PID]: ECPGexecute line 66: QUERY: create table history ( customerid integer , timestamp timestamp without time zone , action_taken char ( 5 ) , narrative varchar ( 100 ) ) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 70 Ok: CREATE TABLE
[NO_PID]: ECPGexecute line 66 Ok: CREATE TABLE
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 73: QUERY: insert into history ( customerid , timestamp , action_taken , narrative ) values( 1 , '2003-05-07 13:28:34 CEST' , 'test' , 'test' ) on connection regress1
[NO_PID]: ECPGexecute line 69: QUERY: insert into history ( customerid , timestamp , action_taken , narrative ) values( 1 , '2003-05-07 13:28:34 CEST' , 'test' , 'test' ) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 73 Ok: INSERT 0 1
[NO_PID]: ECPGexecute line 69 Ok: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 78: QUERY: select max ( timestamp ) from history on connection regress1
[NO_PID]: ECPGexecute line 74: QUERY: select max ( timestamp ) from history on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 78: Correctly got 1 tuples with 1 fields
[NO_PID]: ECPGexecute line 74: Correctly got 1 tuples with 1 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 78: RESULT: Wed May 07 13:28:34 2003 offset: -1 array: Yes
[NO_PID]: ECPGget_data line 74: RESULT: Wed May 07 13:28:34 2003 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 89: QUERY: select customerid , timestamp from history where timestamp = timestamp '2003-05-07 13:28:34' limit 1 on connection regress1
[NO_PID]: ECPGexecute line 79: QUERY: select customerid , timestamp from history where timestamp = timestamp '2003-05-07 13:28:34' limit 1 on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 89: Correctly got 1 tuples with 2 fields
[NO_PID]: ECPGexecute line 79: Correctly got 1 tuples with 2 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 89: RESULT: 1 offset: -1 array: Yes
[NO_PID]: ECPGget_data line 79: RESULT: 1 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGget_data line 89: RESULT: Wed May 07 13:28:34 2003 offset: -1 array: Yes
[NO_PID]: ECPGget_data line 79: RESULT: Wed May 07 13:28:34 2003 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 103: QUERY: insert into history ( customerid , timestamp , action_taken , narrative ) values( 2 , timestamp '2003-05-08 15:53:39' , 'test' , 'test' ) on connection regress1
[NO_PID]: ECPGexecute line 93: QUERY: insert into history ( customerid , timestamp , action_taken , narrative ) values( 2 , timestamp '2003-05-08 15:53:39' , 'test' , 'test' ) on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 103 Ok: INSERT 0 1
[NO_PID]: ECPGexecute line 93 Ok: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans line 108 action = commit connection = regress1
[NO_PID]: ECPGtrans line 98 action = commit connection = regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 110: QUERY: drop table history on connection regress1
[NO_PID]: ECPGexecute line 100: QUERY: drop table history on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGexecute line 110 Ok: DROP TABLE
[NO_PID]: ECPGexecute line 100 Ok: DROP TABLE
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGtrans line 113 action = commit connection = regress1
[NO_PID]: ECPGtrans line 103 action = commit connection = regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection regress1 closed.
[NO_PID]: sqlca: code: 0, state: 00000
......@@ -31,6 +31,7 @@ char* nums[] = { "2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4",
into decimal */
"1234567890123456789012345678.921", /* 31 digits should NOT
fit into decimal */
"not a number",
NULL};
......@@ -45,46 +46,52 @@ main(void)
numeric *num, *nin;
decimal *dec;
long l;
int i, q, r, k;
int i, j, k, q, r, count = 0;
double d;
numeric **numarr = (numeric **) malloc(1);
ECPGdebug(1, stderr);
for (i = 0; nums[i]; i++)
{
num = PGTYPESnumeric_from_asc(nums[i], &endptr);
check_errno();
if (!num) check_errno();
if (endptr != NULL)
{
printf("endptr of %d is not NULL\n", i);
if (*endptr != '\0')
printf("*endptr of %d is not \\0\n", i);
}
if (!num) continue;
numarr = realloc(numarr, sizeof(numeric *) * (count + 1));
numarr[count++] = num;
text = PGTYPESnumeric_to_asc(num, -1);
check_errno();
if (!text) check_errno();
printf("num[%d,1]: %s\n", i, text); free(text);
text = PGTYPESnumeric_to_asc(num, 0);
check_errno();
if (!text) check_errno();
printf("num[%d,2]: %s\n", i, text); free(text);
text = PGTYPESnumeric_to_asc(num, 1);
check_errno();
if (!text) check_errno();
printf("num[%d,3]: %s\n", i, text); free(text);
text = PGTYPESnumeric_to_asc(num, 2);
check_errno();
if (!text) check_errno();
printf("num[%d,4]: %s\n", i, text); free(text);
nin = PGTYPESnumeric_new();
text = PGTYPESnumeric_to_asc(nin, 2);
check_errno();
if (!text) check_errno();
printf("num[%d,5]: %s\n", i, text); free(text);
r = PGTYPESnumeric_to_long(num, &l);
check_errno();
if (r) check_errno();
printf("num[%d,6]: %ld (r: %d)\n", i, r?0L:l, r);
if (r == 0)
{
r = PGTYPESnumeric_from_long(l, nin);
check_errno();
if (r) check_errno();
text = PGTYPESnumeric_to_asc(nin, 2);
q = PGTYPESnumeric_cmp(num, nin);
printf("num[%d,7]: %s (r: %d - cmp: %d)\n", i, text, r, q);
......@@ -92,12 +99,12 @@ main(void)
}
r = PGTYPESnumeric_to_int(num, &k);
check_errno();
if (r) check_errno();
printf("num[%d,8]: %d (r: %d)\n", i, r?0:k, r);
if (r == 0)
{
r = PGTYPESnumeric_from_int(k, nin);
check_errno();
if (r) check_errno();
text = PGTYPESnumeric_to_asc(nin, 2);
q = PGTYPESnumeric_cmp(num, nin);
printf("num[%d,9]: %s (r: %d - cmp: %d)\n", i, text, r, q);
......@@ -105,12 +112,12 @@ main(void)
}
r = PGTYPESnumeric_to_double(num, &d);
check_errno();
if (r) check_errno();
printf("num[%d,10]: %2.7f (r: %d)\n", i, r?0.0:d, r);
if (r == 0)
{
r = PGTYPESnumeric_from_double(d, nin);
check_errno();
if (r) check_errno();
text = PGTYPESnumeric_to_asc(nin, 2);
q = PGTYPESnumeric_cmp(num, nin);
printf("num[%d,11]: %s (r: %d - cmp: %d)\n", i, text, r, q);
......@@ -119,14 +126,14 @@ main(void)
dec = PGTYPESdecimal_new();
r = PGTYPESnumeric_to_decimal(num, dec);
check_errno();
if (r) check_errno();
/* we have no special routine for outputting decimal, it would
* convert to a numeric anyway */
printf("num[%d,12]: - (r: %d)\n", i, r);
if (r == 0)
{
r = PGTYPESnumeric_from_decimal(dec, nin);
check_errno();
if (r) check_errno();
text = PGTYPESnumeric_to_asc(nin, 2);
q = PGTYPESnumeric_cmp(num, nin);
printf("num[%d,13]: %s (r: %d - cmp: %d)\n", i, text, r, q);
......@@ -138,6 +145,72 @@ main(void)
printf("\n");
}
for (i = 0; i < count; i++)
{
for (j = 0; j < count; j++)
{
numeric* a = PGTYPESnumeric_new();
numeric* s = PGTYPESnumeric_new();
numeric* m = PGTYPESnumeric_new();
numeric* d = PGTYPESnumeric_new();
r = PGTYPESnumeric_add(numarr[i], numarr[j], a);
if (r)
{
check_errno();
printf("r: %d\n", r);
}
else
{
text = PGTYPESnumeric_to_asc(a, 10);
printf("num[a,%d,%d]: %s\n", i, j, text);
free(text);
}
r = PGTYPESnumeric_sub(numarr[i], numarr[j], s);
if (r)
{
check_errno();
printf("r: %d\n", r);
}
else
{
text = PGTYPESnumeric_to_asc(s, 10);
printf("num[s,%d,%d]: %s\n", i, j, text);
free(text);
}
r = PGTYPESnumeric_mul(numarr[i], numarr[j], m);
if (r)
{
check_errno();
printf("r: %d\n", r);
}
else
{
text = PGTYPESnumeric_to_asc(m, 10);
printf("num[m,%d,%d]: %s\n", i, j, text);
free(text);
}
r = PGTYPESnumeric_div(numarr[i], numarr[j], d);
if (r)
{
check_errno();
printf("r: %d\n", r);
}
else
{
text = PGTYPESnumeric_to_asc(d, 10);
printf("num[d,%d,%d]: %s\n", i, j, text);
free(text);
}
}
}
for (i = 0; i < count; i++)
{
text = PGTYPESnumeric_to_asc(numarr[i], -1);
printf("%d: %s\n", i, text);
free(text);
}
return (0);
}
......@@ -152,9 +225,15 @@ check_errno(void)
case PGTYPES_NUM_OVERFLOW:
printf("(errno == PGTYPES_NUM_OVERFLOW) - ");
break;
case PGTYPES_NUM_UNDERFLOW:
printf("(errno == PGTYPES_NUM_UNDERFLOW) - ");
break;
case PGTYPES_NUM_BAD_NUMERIC:
printf("(errno == PGTYPES_NUM_BAD_NUMERIC) - ");
break;
case PGTYPES_NUM_DIVIDE_ZERO:
printf("(errno == PGTYPES_NUM_DIVIDE_ZERO) - ");
break;
default:
printf("(unknown errno (%d))\n", errno);
printf("(libc: (%s)) ", strerror(errno));
......
......@@ -13,6 +13,7 @@ char* nums[] = { "2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4",
into decimal */
"1234567890123456789012345678.921", /* 31 digits should NOT
fit into decimal */
"not a number",
NULL};
......@@ -27,46 +28,52 @@ main(void)
numeric *num, *nin;
decimal *dec;
long l;
int i, q, r, k;
int i, j, k, q, r, count = 0;
double d;
numeric **numarr = (numeric **) malloc(1);
ECPGdebug(1, stderr);
for (i = 0; nums[i]; i++)
{
num = PGTYPESnumeric_from_asc(nums[i], &endptr);
check_errno();
if (!num) check_errno();
if (endptr != NULL)
{
printf("endptr of %d is not NULL\n", i);
if (*endptr != '\0')
printf("*endptr of %d is not \\0\n", i);
}
if (!num) continue;
numarr = realloc(numarr, sizeof(numeric *) * (count + 1));
numarr[count++] = num;
text = PGTYPESnumeric_to_asc(num, -1);
check_errno();
if (!text) check_errno();
printf("num[%d,1]: %s\n", i, text); free(text);
text = PGTYPESnumeric_to_asc(num, 0);
check_errno();
if (!text) check_errno();
printf("num[%d,2]: %s\n", i, text); free(text);
text = PGTYPESnumeric_to_asc(num, 1);
check_errno();
if (!text) check_errno();
printf("num[%d,3]: %s\n", i, text); free(text);
text = PGTYPESnumeric_to_asc(num, 2);
check_errno();
if (!text) check_errno();
printf("num[%d,4]: %s\n", i, text); free(text);
nin = PGTYPESnumeric_new();
text = PGTYPESnumeric_to_asc(nin, 2);
check_errno();
if (!text) check_errno();
printf("num[%d,5]: %s\n", i, text); free(text);
r = PGTYPESnumeric_to_long(num, &l);
check_errno();
if (r) check_errno();
printf("num[%d,6]: %ld (r: %d)\n", i, r?0L:l, r);
if (r == 0)
{
r = PGTYPESnumeric_from_long(l, nin);
check_errno();
if (r) check_errno();
text = PGTYPESnumeric_to_asc(nin, 2);
q = PGTYPESnumeric_cmp(num, nin);
printf("num[%d,7]: %s (r: %d - cmp: %d)\n", i, text, r, q);
......@@ -74,12 +81,12 @@ main(void)
}
r = PGTYPESnumeric_to_int(num, &k);
check_errno();
if (r) check_errno();
printf("num[%d,8]: %d (r: %d)\n", i, r?0:k, r);
if (r == 0)
{
r = PGTYPESnumeric_from_int(k, nin);
check_errno();
if (r) check_errno();
text = PGTYPESnumeric_to_asc(nin, 2);
q = PGTYPESnumeric_cmp(num, nin);
printf("num[%d,9]: %s (r: %d - cmp: %d)\n", i, text, r, q);
......@@ -87,12 +94,12 @@ main(void)
}
r = PGTYPESnumeric_to_double(num, &d);
check_errno();
if (r) check_errno();
printf("num[%d,10]: %2.7f (r: %d)\n", i, r?0.0:d, r);
if (r == 0)
{
r = PGTYPESnumeric_from_double(d, nin);
check_errno();
if (r) check_errno();
text = PGTYPESnumeric_to_asc(nin, 2);
q = PGTYPESnumeric_cmp(num, nin);
printf("num[%d,11]: %s (r: %d - cmp: %d)\n", i, text, r, q);
......@@ -101,14 +108,14 @@ main(void)
dec = PGTYPESdecimal_new();
r = PGTYPESnumeric_to_decimal(num, dec);
check_errno();
if (r) check_errno();
/* we have no special routine for outputting decimal, it would
* convert to a numeric anyway */
printf("num[%d,12]: - (r: %d)\n", i, r);
if (r == 0)
{
r = PGTYPESnumeric_from_decimal(dec, nin);
check_errno();
if (r) check_errno();
text = PGTYPESnumeric_to_asc(nin, 2);
q = PGTYPESnumeric_cmp(num, nin);
printf("num[%d,13]: %s (r: %d - cmp: %d)\n", i, text, r, q);
......@@ -120,6 +127,72 @@ main(void)
printf("\n");
}
for (i = 0; i < count; i++)
{
for (j = 0; j < count; j++)
{
numeric* a = PGTYPESnumeric_new();
numeric* s = PGTYPESnumeric_new();
numeric* m = PGTYPESnumeric_new();
numeric* d = PGTYPESnumeric_new();
r = PGTYPESnumeric_add(numarr[i], numarr[j], a);
if (r)
{
check_errno();
printf("r: %d\n", r);
}
else
{
text = PGTYPESnumeric_to_asc(a, 10);
printf("num[a,%d,%d]: %s\n", i, j, text);
free(text);
}
r = PGTYPESnumeric_sub(numarr[i], numarr[j], s);
if (r)
{
check_errno();
printf("r: %d\n", r);
}
else
{
text = PGTYPESnumeric_to_asc(s, 10);
printf("num[s,%d,%d]: %s\n", i, j, text);
free(text);
}
r = PGTYPESnumeric_mul(numarr[i], numarr[j], m);
if (r)
{
check_errno();
printf("r: %d\n", r);
}
else
{
text = PGTYPESnumeric_to_asc(m, 10);
printf("num[m,%d,%d]: %s\n", i, j, text);
free(text);
}
r = PGTYPESnumeric_div(numarr[i], numarr[j], d);
if (r)
{
check_errno();
printf("r: %d\n", r);
}
else
{
text = PGTYPESnumeric_to_asc(d, 10);
printf("num[d,%d,%d]: %s\n", i, j, text);
free(text);
}
}
}
for (i = 0; i < count; i++)
{
text = PGTYPESnumeric_to_asc(numarr[i], -1);
printf("%d: %s\n", i, text);
free(text);
}
return (0);
}
......@@ -134,9 +207,15 @@ check_errno(void)
case PGTYPES_NUM_OVERFLOW:
printf("(errno == PGTYPES_NUM_OVERFLOW) - ");
break;
case PGTYPES_NUM_UNDERFLOW:
printf("(errno == PGTYPES_NUM_UNDERFLOW) - ");
break;
case PGTYPES_NUM_BAD_NUMERIC:
printf("(errno == PGTYPES_NUM_BAD_NUMERIC) - ");
break;
case PGTYPES_NUM_DIVIDE_ZERO:
printf("(errno == PGTYPES_NUM_DIVIDE_ZERO) - ");
break;
default:
printf("(unknown errno (%d))\n", errno);
printf("(libc: (%s)) ", strerror(errno));
......
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