diff options
Diffstat (limited to 'src/interfaces/ecpg/lib')
| -rw-r--r-- | src/interfaces/ecpg/lib/Makefile | 4 | ||||
| -rw-r--r-- | src/interfaces/ecpg/lib/data.c | 39 | ||||
| -rw-r--r-- | src/interfaces/ecpg/lib/descriptor.c | 24 | ||||
| -rw-r--r-- | src/interfaces/ecpg/lib/execute.c | 45 | ||||
| -rw-r--r-- | src/interfaces/ecpg/lib/typename.c | 4 |
5 files changed, 102 insertions, 14 deletions
diff --git a/src/interfaces/ecpg/lib/Makefile b/src/interfaces/ecpg/lib/Makefile index 2706060e5e..591a286f0e 100644 --- a/src/interfaces/ecpg/lib/Makefile +++ b/src/interfaces/ecpg/lib/Makefile @@ -4,7 +4,7 @@ # # Copyright (c) 1994, Regents of the University of California # -# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile,v 1.8 2000/09/17 13:02:46 petere Exp $ +# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile,v 1.9 2000/09/19 11:47:13 meskes Exp $ # #------------------------------------------------------------------------- @@ -14,7 +14,7 @@ include $(top_builddir)/src/Makefile.global NAME= ecpg SO_MAJOR_VERSION= 3 -SO_MINOR_VERSION= 1.1 +SO_MINOR_VERSION= 2.0 CPPFLAGS += -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) diff --git a/src/interfaces/ecpg/lib/data.c b/src/interfaces/ecpg/lib/data.c index 054966f9cf..1c85de0350 100644 --- a/src/interfaces/ecpg/lib/data.c +++ b/src/interfaces/ecpg/lib/data.c @@ -60,6 +60,12 @@ get_data(PGresult *results, int act_tuple, int act_field, int lineno, case ECPGt_unsigned_long: ((long *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field); break; + case ECPGt_long_long: + ((long long int*) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field); + break; + case ECPGt_unsigned_long_long: + ((unsigned long long int*) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field); + break; case ECPGt_NO_INDICATOR: if (PQgetisnull(results, act_tuple, act_field)) { @@ -93,7 +99,6 @@ get_data(PGresult *results, int act_tuple, int act_field, int lineno, { ECPGraise(lineno, ECPG_INT_FORMAT, pval); return (false); - res = 0L; } } else @@ -127,7 +132,6 @@ get_data(PGresult *results, int act_tuple, int act_field, int lineno, { ECPGraise(lineno, ECPG_UINT_FORMAT, pval); return (false); - ures = 0L; } } else @@ -150,7 +154,38 @@ get_data(PGresult *results, int act_tuple, int act_field, int lineno, } break; + case ECPGt_long_long: + if (pval) + { + ((long long int *) var)[act_tuple] = strtoull(pval, &scan_length, 10); + if ((isarray && *scan_length != ',' && *scan_length != '}') + || (!isarray && *scan_length != '\0')) /* Garbage left */ + { + ECPGraise(lineno, ECPG_INT_FORMAT, pval); + return (false); + } + } + else + ((long long int *) var)[act_tuple] = 0LL; + + break; + case ECPGt_unsigned_long_long: + if (pval) + { + ((unsigned long long int *) var)[act_tuple] = strtoull(pval, &scan_length, 10); + if ((isarray && *scan_length != ',' && *scan_length != '}') + || (!isarray && *scan_length != '\0')) /* Garbage left */ + { + ECPGraise(lineno, ECPG_UINT_FORMAT, pval); + return (false); + } + } + else + ((unsigned long long int *) var)[act_tuple] = 0LL; + + break; + case ECPGt_float: case ECPGt_double: if (pval) diff --git a/src/interfaces/ecpg/lib/descriptor.c b/src/interfaces/ecpg/lib/descriptor.c index fe4a04d2e0..3742325533 100644 --- a/src/interfaces/ecpg/lib/descriptor.c +++ b/src/interfaces/ecpg/lib/descriptor.c @@ -63,29 +63,35 @@ get_int_item(int lineno, void *var, enum ECPGdtype vartype, int value) { switch (vartype) { - case ECPGt_short: - *(short *) var = value; + case ECPGt_short: + *(short *) var = (short) value; break; case ECPGt_int: - *(int *) var = value; + *(int *) var = (int) value; break; case ECPGt_long: - *(long *) var = value; + *(long *) var = (long) value; break; case ECPGt_unsigned_short: - *(unsigned short *) var = value; + *(unsigned short *) var = (unsigned short) value; break; case ECPGt_unsigned_int: - *(unsigned int *) var = value; + *(unsigned int *) var = (unsigned int) value; break; case ECPGt_unsigned_long: - *(unsigned long *) var = value; + *(unsigned long *) var = (unsigned long) value; + break; + case ECPGt_long_long: + *(long long int *) var = (long long int) value; + break; + case ECPGt_unsigned_long_long: + *(unsigned long long int *) var = (unsigned long long int) value; break; case ECPGt_float: - *(float *) var = value; + *(float *) var = (float) value; break; case ECPGt_double: - *(double *) var = value; + *(double *) var = (double) value; break; default: ECPGraise(lineno, ECPG_VAR_NOT_NUMERIC, NULL); diff --git a/src/interfaces/ecpg/lib/execute.c b/src/interfaces/ecpg/lib/execute.c index f606a88e84..0741db622a 100644 --- a/src/interfaces/ecpg/lib/execute.c +++ b/src/interfaces/ecpg/lib/execute.c @@ -305,6 +305,11 @@ ECPGexecute(struct statement * stmt) if (*(long *) var->ind_value < 0L) strcpy(buff, "null"); break; + case ECPGt_long_long: + case ECPGt_unsigned_long_long: + if (*(long long int*) var->ind_value < 0LL) + strcpy(buff, "null"); + break; default: break; } @@ -428,6 +433,44 @@ ECPGexecute(struct statement * stmt) tobeinserted = mallocedval; break; + + case ECPGt_long_long: + if (!(mallocedval = ecpg_alloc(var->arrsize * 25, stmt->lineno))) + return false; + + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); + + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%lld,", ((long long *) var->value)[element]); + + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%lld", *((long long *) var->value)); + + tobeinserted = mallocedval; + break; + + case ECPGt_unsigned_long_long: + if (!(mallocedval = ecpg_alloc(var->arrsize * 25, stmt->lineno))) + return false; + + if (var->arrsize > 1) + { + strncpy(mallocedval, "'{", sizeof("'{")); + + for (element = 0; element < var->arrsize; element++) + sprintf(mallocedval + strlen(mallocedval), "%llu,", ((unsigned long long *) var->value)[element]); + + strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); + } + else + sprintf(mallocedval, "%llu", *((unsigned long long*) var->value)); + + tobeinserted = mallocedval; + break; case ECPGt_float: if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno))) @@ -868,7 +911,7 @@ ECPGdo(int lineno, const char *connection_name, char *query,...) * * Copyright (c) 2000, Christof Petig <christof.petig@wtal.de> * - * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.7 2000/05/29 21:25:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.8 2000/09/19 11:47:13 meskes Exp $ */ PGconn *ECPG_internal_get_connection(char *name); diff --git a/src/interfaces/ecpg/lib/typename.c b/src/interfaces/ecpg/lib/typename.c index 18f9aef57e..c66ed7709d 100644 --- a/src/interfaces/ecpg/lib/typename.c +++ b/src/interfaces/ecpg/lib/typename.c @@ -28,6 +28,10 @@ ECPGtype_name(enum ECPGttype typ) return "long"; case ECPGt_unsigned_long: return "unsigned long"; + case ECPGt_long_long: + return "long long"; + case ECPGt_unsigned_long_long: + return "unsigned long long"; case ECPGt_float: return "float"; case ECPGt_double: |
