diff options
Diffstat (limited to 'src/interfaces')
68 files changed, 4972 insertions, 3292 deletions
diff --git a/src/interfaces/ecpg/compatlib/informix.c b/src/interfaces/ecpg/compatlib/informix.c index a8a95f4e437..cfde8be5aa1 100644 --- a/src/interfaces/ecpg/compatlib/informix.c +++ b/src/interfaces/ecpg/compatlib/informix.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.47 2006/08/15 06:40:19 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.48 2006/10/04 00:30:11 momjian Exp $ */ #include <stdlib.h> #include <string.h> @@ -169,15 +169,16 @@ ecpg_strndup(const char *str, size_t len) int deccvasc(char *cp, int len, decimal *np) { - char *str; - int ret = 0; - numeric *result; + char *str; + int ret = 0; + numeric *result; rsetnull(CDECIMALTYPE, (char *) np); if (risnull(CSTRINGTYPE, cp)) return 0; - str = ecpg_strndup(cp, len); /* decimal_in always converts the complete string */ + str = ecpg_strndup(cp, len);/* decimal_in always converts the complete + * string */ if (!str) ret = ECPG_INFORMIX_NUM_UNDERFLOW; else @@ -378,8 +379,8 @@ dectoasc(decimal *np, char *cp, int len, int right) return -1; /* - * TODO: have to take care of len here and create exponential notation - * if necessary + * TODO: have to take care of len here and create exponential notation if + * necessary */ if ((int) (strlen(str) + 1) > len) { @@ -647,7 +648,7 @@ intoasc(interval * i, char *str) } /* - * rfmt.c - description + * rfmt.c - description * by Carsten Wolff <[email protected]>, Wed Apr 2 2003 */ @@ -936,7 +937,8 @@ byleng(char *str, int len) void ldchar(char *src, int len, char *dest) { - int dlen = byleng(src, len); + int dlen = byleng(src, len); + memmove(dest, src, dlen); dest[dlen] = '\0'; } diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c index b07a8bbeb65..9636c91a363 100644 --- a/src/interfaces/ecpg/ecpglib/connect.c +++ b/src/interfaces/ecpg/ecpglib/connect.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.35 2006/08/29 12:24:51 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.36 2006/10/04 00:30:11 momjian Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -27,7 +27,8 @@ ecpg_actual_connection_init(void) pthread_key_create(&actual_connection_key, NULL); } -void ecpg_pthreads_init(void) +void +ecpg_pthreads_init(void) { pthread_once(&actual_connection_key_once, ecpg_actual_connection_init); } @@ -226,7 +227,7 @@ ECPGnoticeReceiver(void *arg, const PGresult *result) if (sqlstate == NULL) sqlstate = ECPG_SQLSTATE_ECPG_INTERNAL_ERROR; - if (message == NULL) /* Shouldn't happen, but need to be sure */ + if (message == NULL) /* Shouldn't happen, but need to be sure */ message = "No message received"; /* these are not warnings */ @@ -369,9 +370,10 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p ECPGraise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, realname ? realname : "<DEFAULT>"); if (host) ECPGfree(host); - /* port not set yet - * if (port) - * ECPGfree(port); */ + + /* + * port not set yet if (port) ECPGfree(port); + */ if (options) ECPGfree(options); if (realname) diff --git a/src/interfaces/ecpg/ecpglib/data.c b/src/interfaces/ecpg/ecpglib/data.c index 4f474d3bcf1..ab1f2554ce5 100644 --- a/src/interfaces/ecpg/ecpglib/data.c +++ b/src/interfaces/ecpg/ecpglib/data.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.34 2006/08/24 10:35:58 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.35 2006/10/04 00:30:11 momjian Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -16,7 +16,10 @@ #include "pgtypes_timestamp.h" #include "pgtypes_interval.h" -static enum { NOT_CHECKED, REGRESS, NORMAL } ECPG_regression_mode = NOT_CHECKED; +static enum +{ + NOT_CHECKED, REGRESS, NORMAL +} ECPG_regression_mode = NOT_CHECKED; static bool garbage_left(enum ARRAY_TYPE isarray, char *scan_length, enum COMPAT_MODE compat) @@ -47,11 +50,11 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, long ind_offset, enum ARRAY_TYPE isarray, enum COMPAT_MODE compat, bool force_indicator) { struct sqlca_t *sqlca = ECPGget_sqlca(); - char *pval = (char *) PQgetvalue(results, act_tuple, act_field); - int binary = PQfformat(results, act_field); - int size = PQgetlength(results, act_tuple, act_field); - int value_for_indicator = 0; - long log_offset; + char *pval = (char *) PQgetvalue(results, act_tuple, act_field); + int binary = PQfformat(results, act_field); + int size = PQgetlength(results, act_tuple, act_field); + int value_for_indicator = 0; + long log_offset; /* * use a global variable to see if the environment variable @@ -62,13 +65,13 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, { if (getenv("ECPG_REGRESSION")) ECPG_regression_mode = REGRESS; - else + else ECPG_regression_mode = NORMAL; } /* - * If we are running in a regression test, do not log the offset - * variable, it depends on the machine's alignment. + * If we are running in a regression test, do not log the offset variable, + * it depends on the machine's alignment. */ if (ECPG_regression_mode == REGRESS) log_offset = -1; @@ -167,15 +170,15 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, { if (pval) { - if (varcharsize == 0 || varcharsize*offset >= size) + if (varcharsize == 0 || varcharsize * offset >= size) memcpy((char *) ((long) var + offset * act_tuple), pval, size); else { memcpy((char *) ((long) var + offset * act_tuple), - pval, varcharsize*offset); + pval, varcharsize * offset); - if (varcharsize*offset < size) + if (varcharsize * offset < size) { /* truncation */ switch (ind_type) @@ -206,533 +209,533 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, } pval += size; } - } + } else { - switch (type) - { - long res; - unsigned long ures; - double dres; - char *scan_length; - numeric *nres; - date ddres; - timestamp tres; - interval *ires; - - case ECPGt_short: - case ECPGt_int: - case ECPGt_long: - if (pval) - { - res = strtol(pval, &scan_length, 10); - if (garbage_left(isarray, scan_length, compat)) + switch (type) + { + long res; + unsigned long ures; + double dres; + char *scan_length; + numeric *nres; + date ddres; + timestamp tres; + interval *ires; + + case ECPGt_short: + case ECPGt_int: + case ECPGt_long: + if (pval) { - ECPGraise(lineno, ECPG_INT_FORMAT, - ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); - return (false); + res = strtol(pval, &scan_length, 10); + if (garbage_left(isarray, scan_length, compat)) + { + ECPGraise(lineno, ECPG_INT_FORMAT, + ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); + return (false); + } + pval = scan_length; } - pval = scan_length; - } - else - res = 0L; + else + res = 0L; - switch (type) - { - case ECPGt_short: - *((short *) (var + offset * act_tuple)) = (short) res; - break; - case ECPGt_int: - *((int *) (var + offset * act_tuple)) = (int) res; - break; - case ECPGt_long: - *((long *) (var + offset * act_tuple)) = (long) res; - break; - default: - /* Cannot happen */ - break; - } - break; + switch (type) + { + case ECPGt_short: + *((short *) (var + offset * act_tuple)) = (short) res; + break; + case ECPGt_int: + *((int *) (var + offset * act_tuple)) = (int) res; + break; + case ECPGt_long: + *((long *) (var + offset * act_tuple)) = (long) res; + break; + default: + /* Cannot happen */ + break; + } + break; - case ECPGt_unsigned_short: - case ECPGt_unsigned_int: - case ECPGt_unsigned_long: - if (pval) - { - ures = strtoul(pval, &scan_length, 10); - if (garbage_left(isarray, scan_length, compat)) + case ECPGt_unsigned_short: + case ECPGt_unsigned_int: + case ECPGt_unsigned_long: + if (pval) { - ECPGraise(lineno, ECPG_UINT_FORMAT, - ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); - return (false); + ures = strtoul(pval, &scan_length, 10); + if (garbage_left(isarray, scan_length, compat)) + { + ECPGraise(lineno, ECPG_UINT_FORMAT, + ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); + return (false); + } + pval = scan_length; } - pval = scan_length; - } - else - ures = 0L; + else + ures = 0L; - switch (type) - { - case ECPGt_unsigned_short: - *((unsigned short *) (var + offset * act_tuple)) = (unsigned short) ures; - break; - case ECPGt_unsigned_int: - *((unsigned int *) (var + offset * act_tuple)) = (unsigned int) ures; - break; - case ECPGt_unsigned_long: - *((unsigned long *) (var + offset * act_tuple)) = (unsigned long) ures; - break; - default: - /* Cannot happen */ - break; - } - break; + switch (type) + { + case ECPGt_unsigned_short: + *((unsigned short *) (var + offset * act_tuple)) = (unsigned short) ures; + break; + case ECPGt_unsigned_int: + *((unsigned int *) (var + offset * act_tuple)) = (unsigned int) ures; + break; + case ECPGt_unsigned_long: + *((unsigned long *) (var + offset * act_tuple)) = (unsigned long) ures; + break; + default: + /* Cannot happen */ + break; + } + break; #ifdef HAVE_LONG_LONG_INT_64 #ifdef HAVE_STRTOLL - case ECPGt_long_long: - if (pval) - { - *((long long int *) (var + offset * act_tuple)) = strtoll(pval, &scan_length, 10); - if (garbage_left(isarray, scan_length, compat)) + case ECPGt_long_long: + if (pval) { - ECPGraise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); - return (false); + *((long long int *) (var + offset * act_tuple)) = strtoll(pval, &scan_length, 10); + if (garbage_left(isarray, scan_length, compat)) + { + ECPGraise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); + return (false); + } + pval = scan_length; } - pval = scan_length; - } - else - *((long long int *) (var + offset * act_tuple)) = (long long) 0; + else + *((long long int *) (var + offset * act_tuple)) = (long long) 0; - break; + break; #endif /* HAVE_STRTOLL */ #ifdef HAVE_STRTOULL - case ECPGt_unsigned_long_long: - if (pval) - { - *((unsigned long long int *) (var + offset * act_tuple)) = strtoull(pval, &scan_length, 10); - if ((isarray && *scan_length != ',' && *scan_length != '}') - || (!isarray && !(INFORMIX_MODE(compat) && *scan_length == '.') && *scan_length != '\0' && *scan_length != ' ')) /* Garbage left */ + case ECPGt_unsigned_long_long: + if (pval) { - ECPGraise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); - return (false); + *((unsigned long long int *) (var + offset * act_tuple)) = strtoull(pval, &scan_length, 10); + if ((isarray && *scan_length != ',' && *scan_length != '}') + || (!isarray && !(INFORMIX_MODE(compat) && *scan_length == '.') && *scan_length != '\0' && *scan_length != ' ')) /* Garbage left */ + { + ECPGraise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); + return (false); + } + pval = scan_length; } - pval = scan_length; - } - else - *((unsigned long long int *) (var + offset * act_tuple)) = (long long) 0; + else + *((unsigned long long int *) (var + offset * act_tuple)) = (long long) 0; - break; + break; #endif /* HAVE_STRTOULL */ #endif /* HAVE_LONG_LONG_INT_64 */ - case ECPGt_float: - case ECPGt_double: - if (pval) - { - if (isarray && *pval == '"') - dres = strtod(pval + 1, &scan_length); - else - dres = strtod(pval, &scan_length); - - if (isarray && *scan_length == '"') - scan_length++; - - if (garbage_left(isarray, scan_length, compat)) + case ECPGt_float: + case ECPGt_double: + if (pval) { - ECPGraise(lineno, ECPG_FLOAT_FORMAT, - ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); - return (false); - } - pval = scan_length; - } - else - dres = 0.0; + if (isarray && *pval == '"') + dres = strtod(pval + 1, &scan_length); + else + dres = strtod(pval, &scan_length); - switch (type) - { - case ECPGt_float: - *((float *) (var + offset * act_tuple)) = dres; - break; - case ECPGt_double: - *((double *) (var + offset * act_tuple)) = dres; - break; - default: - /* Cannot happen */ - break; - } - break; + if (isarray && *scan_length == '"') + scan_length++; - case ECPGt_bool: - if (pval) - { - if (pval[0] == 'f' && pval[1] == '\0') - { - if (offset == sizeof(char)) - *((char *) (var + offset * act_tuple)) = false; - else if (offset == sizeof(int)) - *((int *) (var + offset * act_tuple)) = false; - else - ECPGraise(lineno, ECPG_CONVERT_BOOL, - ECPG_SQLSTATE_DATATYPE_MISMATCH, - "different size"); - break; + if (garbage_left(isarray, scan_length, compat)) + { + ECPGraise(lineno, ECPG_FLOAT_FORMAT, + ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); + return (false); + } + pval = scan_length; } - else if (pval[0] == 't' && pval[1] == '\0') + else + dres = 0.0; + + switch (type) { - if (offset == sizeof(char)) - *((char *) (var + offset * act_tuple)) = true; - else if (offset == sizeof(int)) - *((int *) (var + offset * act_tuple)) = true; - else - ECPGraise(lineno, ECPG_CONVERT_BOOL, - ECPG_SQLSTATE_DATATYPE_MISMATCH, - "different size"); - break; + case ECPGt_float: + *((float *) (var + offset * act_tuple)) = dres; + break; + case ECPGt_double: + *((double *) (var + offset * act_tuple)) = dres; + break; + default: + /* Cannot happen */ + break; } - else if (pval[0] == '\0' && PQgetisnull(results, act_tuple, act_field)) + break; + + case ECPGt_bool: + if (pval) { - /* NULL is valid */ - break; + if (pval[0] == 'f' && pval[1] == '\0') + { + if (offset == sizeof(char)) + *((char *) (var + offset * act_tuple)) = false; + else if (offset == sizeof(int)) + *((int *) (var + offset * act_tuple)) = false; + else + ECPGraise(lineno, ECPG_CONVERT_BOOL, + ECPG_SQLSTATE_DATATYPE_MISMATCH, + "different size"); + break; + } + else if (pval[0] == 't' && pval[1] == '\0') + { + if (offset == sizeof(char)) + *((char *) (var + offset * act_tuple)) = true; + else if (offset == sizeof(int)) + *((int *) (var + offset * act_tuple)) = true; + else + ECPGraise(lineno, ECPG_CONVERT_BOOL, + ECPG_SQLSTATE_DATATYPE_MISMATCH, + "different size"); + break; + } + else if (pval[0] == '\0' && PQgetisnull(results, act_tuple, act_field)) + { + /* NULL is valid */ + break; + } } - } - ECPGraise(lineno, ECPG_CONVERT_BOOL, - ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); - return (false); - break; + ECPGraise(lineno, ECPG_CONVERT_BOOL, + ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); + return (false); + break; - case ECPGt_char: - case ECPGt_unsigned_char: - if (pval) - { - if (varcharsize == 0 || varcharsize > size) - strncpy((char *) ((long) var + offset * act_tuple), pval, size + 1); - else + case ECPGt_char: + case ECPGt_unsigned_char: + if (pval) { - strncpy((char *) ((long) var + offset * act_tuple), pval, varcharsize); - - if (varcharsize < size) + if (varcharsize == 0 || varcharsize > size) + strncpy((char *) ((long) var + offset * act_tuple), pval, size + 1); + else { - /* truncation */ - switch (ind_type) + strncpy((char *) ((long) var + offset * act_tuple), pval, varcharsize); + + if (varcharsize < size) { - case ECPGt_short: - case ECPGt_unsigned_short: - *((short *) (ind + ind_offset * act_tuple)) = size; - break; - case ECPGt_int: - case ECPGt_unsigned_int: - *((int *) (ind + ind_offset * act_tuple)) = size; - break; - case ECPGt_long: - case ECPGt_unsigned_long: - *((long *) (ind + ind_offset * act_tuple)) = size; - break; + /* truncation */ + switch (ind_type) + { + case ECPGt_short: + case ECPGt_unsigned_short: + *((short *) (ind + ind_offset * act_tuple)) = size; + break; + case ECPGt_int: + case ECPGt_unsigned_int: + *((int *) (ind + ind_offset * act_tuple)) = size; + break; + case ECPGt_long: + case ECPGt_unsigned_long: + *((long *) (ind + ind_offset * act_tuple)) = size; + break; #ifdef HAVE_LONG_LONG_INT_64 - case ECPGt_long_long: - case ECPGt_unsigned_long_long: - *((long long int *) (ind + ind_offset * act_tuple)) = size; - break; + case ECPGt_long_long: + case ECPGt_unsigned_long_long: + *((long long int *) (ind + ind_offset * act_tuple)) = size; + break; #endif /* HAVE_LONG_LONG_INT_64 */ - default: - break; + default: + break; + } + sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W'; } - sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W'; } + pval += size; } - pval += size; - } - break; + break; - case ECPGt_varchar: - if (pval) - { - struct ECPGgeneric_varchar *variable = - (struct ECPGgeneric_varchar *) ((long) var + offset * act_tuple); - - variable->len = size; - if (varcharsize == 0) - strncpy(variable->arr, pval, variable->len); - else + case ECPGt_varchar: + if (pval) { - strncpy(variable->arr, pval, varcharsize); + struct ECPGgeneric_varchar *variable = + (struct ECPGgeneric_varchar *) ((long) var + offset * act_tuple); - if (variable->len > varcharsize) + variable->len = size; + if (varcharsize == 0) + strncpy(variable->arr, pval, variable->len); + else { - /* truncation */ - switch (ind_type) + strncpy(variable->arr, pval, varcharsize); + + if (variable->len > varcharsize) { - case ECPGt_short: - case ECPGt_unsigned_short: - *((short *) (ind + offset * act_tuple)) = variable->len; - break; - case ECPGt_int: - case ECPGt_unsigned_int: - *((int *) (ind + offset * act_tuple)) = variable->len; - break; - case ECPGt_long: - case ECPGt_unsigned_long: - *((long *) (ind + offset * act_tuple)) = variable->len; - break; + /* truncation */ + switch (ind_type) + { + case ECPGt_short: + case ECPGt_unsigned_short: + *((short *) (ind + offset * act_tuple)) = variable->len; + break; + case ECPGt_int: + case ECPGt_unsigned_int: + *((int *) (ind + offset * act_tuple)) = variable->len; + break; + case ECPGt_long: + case ECPGt_unsigned_long: + *((long *) (ind + offset * act_tuple)) = variable->len; + break; #ifdef HAVE_LONG_LONG_INT_64 - case ECPGt_long_long: - case ECPGt_unsigned_long_long: - *((long long int *) (ind + ind_offset * act_tuple)) = variable->len; - break; + case ECPGt_long_long: + case ECPGt_unsigned_long_long: + *((long long int *) (ind + ind_offset * act_tuple)) = variable->len; + break; #endif /* HAVE_LONG_LONG_INT_64 */ - default: - break; - } - sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W'; + default: + break; + } + sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W'; - variable->len = varcharsize; + variable->len = varcharsize; + } } + pval += size; } - pval += size; - } - break; + break; - case ECPGt_decimal: - case ECPGt_numeric: - if (pval) - { - if (isarray && *pval == '"') - nres = PGTYPESnumeric_from_asc(pval + 1, &scan_length); - else - nres = PGTYPESnumeric_from_asc(pval, &scan_length); - - /* did we get an error? */ - if (nres == NULL) + case ECPGt_decimal: + case ECPGt_numeric: + if (pval) { - ECPGlog("ECPGget_data line %d: RESULT: %s errno %d\n", - lineno, pval ? pval : "", errno); + if (isarray && *pval == '"') + nres = PGTYPESnumeric_from_asc(pval + 1, &scan_length); + else + nres = PGTYPESnumeric_from_asc(pval, &scan_length); - if (INFORMIX_MODE(compat)) + /* did we get an error? */ + if (nres == NULL) { - /* - * Informix wants its own NULL value here instead - * of an error - */ - nres = PGTYPESnumeric_new(); - if (nres) - ECPGset_noind_null(ECPGt_numeric, nres); + ECPGlog("ECPGget_data line %d: RESULT: %s errno %d\n", + lineno, pval ? pval : "", errno); + + if (INFORMIX_MODE(compat)) + { + /* + * Informix wants its own NULL value here + * instead of an error + */ + nres = PGTYPESnumeric_new(); + if (nres) + ECPGset_noind_null(ECPGt_numeric, nres); + else + { + ECPGraise(lineno, ECPG_OUT_OF_MEMORY, + ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL); + return (false); + } + } else { - ECPGraise(lineno, ECPG_OUT_OF_MEMORY, - ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL); + ECPGraise(lineno, ECPG_NUMERIC_FORMAT, + ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); return (false); } } else { - ECPGraise(lineno, ECPG_NUMERIC_FORMAT, - ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); - return (false); - } - } - else - { - if (isarray && *scan_length == '"') - scan_length++; + if (isarray && *scan_length == '"') + scan_length++; - if (garbage_left(isarray, scan_length, compat)) - { - free(nres); - ECPGraise(lineno, ECPG_NUMERIC_FORMAT, + if (garbage_left(isarray, scan_length, compat)) + { + free(nres); + ECPGraise(lineno, ECPG_NUMERIC_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); - return (false); + return (false); + } } + pval = scan_length; } - pval = scan_length; - } - else - nres = PGTYPESnumeric_from_asc("0.0", &scan_length); - - if (type == ECPGt_numeric) - PGTYPESnumeric_copy(nres, (numeric *) (var + offset * act_tuple)); - else - PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * act_tuple)); - - free(nres); - break; + else + nres = PGTYPESnumeric_from_asc("0.0", &scan_length); - case ECPGt_interval: - if (pval) - { - if (isarray && *pval == '"') - ires = PGTYPESinterval_from_asc(pval + 1, &scan_length); + if (type == ECPGt_numeric) + PGTYPESnumeric_copy(nres, (numeric *) (var + offset * act_tuple)); else - ires = PGTYPESinterval_from_asc(pval, &scan_length); + PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * act_tuple)); + + free(nres); + break; - /* did we get an error? */ - if (ires == NULL) + case ECPGt_interval: + if (pval) { - if (INFORMIX_MODE(compat)) + if (isarray && *pval == '"') + ires = PGTYPESinterval_from_asc(pval + 1, &scan_length); + else + ires = PGTYPESinterval_from_asc(pval, &scan_length); + + /* did we get an error? */ + if (ires == NULL) { - /* - * Informix wants its own NULL value here instead - * of an error - */ - ires = (interval *) ECPGalloc(sizeof(interval), lineno); - if (!ires) + if (INFORMIX_MODE(compat)) + { + /* + * Informix wants its own NULL value here + * instead of an error + */ + ires = (interval *) ECPGalloc(sizeof(interval), lineno); + if (!ires) + return (false); + + ECPGset_noind_null(ECPGt_interval, ires); + } + else + { + ECPGraise(lineno, ECPG_INTERVAL_FORMAT, + ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); return (false); - - ECPGset_noind_null(ECPGt_interval, ires); + } } else { - ECPGraise(lineno, ECPG_INTERVAL_FORMAT, - ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); - return (false); - } - } - else - { - if (isarray && *scan_length == '"') - scan_length++; + if (isarray && *scan_length == '"') + scan_length++; - if (garbage_left(isarray, scan_length, compat)) - { - free(ires); - ECPGraise(lineno, ECPG_INTERVAL_FORMAT, + if (garbage_left(isarray, scan_length, compat)) + { + free(ires); + ECPGraise(lineno, ECPG_INTERVAL_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); - return (false); + return (false); + } } + pval = scan_length; } - pval = scan_length; - } - else - ires = PGTYPESinterval_from_asc("0 seconds", NULL); - - PGTYPESinterval_copy(ires, (interval *) (var + offset * act_tuple)); - free(ires); - break; - case ECPGt_date: - if (pval) - { - if (isarray && *pval == '"') - ddres = PGTYPESdate_from_asc(pval + 1, &scan_length); else - ddres = PGTYPESdate_from_asc(pval, &scan_length); + ires = PGTYPESinterval_from_asc("0 seconds", NULL); - /* did we get an error? */ - if (errno != 0) + PGTYPESinterval_copy(ires, (interval *) (var + offset * act_tuple)); + free(ires); + break; + case ECPGt_date: + if (pval) { - if (INFORMIX_MODE(compat)) - { - /* - * Informix wants its own NULL value here instead - * of an error - */ - ECPGset_noind_null(ECPGt_date, &ddres); - } + if (isarray && *pval == '"') + ddres = PGTYPESdate_from_asc(pval + 1, &scan_length); else + ddres = PGTYPESdate_from_asc(pval, &scan_length); + + /* did we get an error? */ + if (errno != 0) { - ECPGraise(lineno, ECPG_DATE_FORMAT, + if (INFORMIX_MODE(compat)) + { + /* + * Informix wants its own NULL value here + * instead of an error + */ + ECPGset_noind_null(ECPGt_date, &ddres); + } + else + { + ECPGraise(lineno, ECPG_DATE_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); - return (false); + return (false); + } } - } - else - { - if (isarray && *scan_length == '"') - scan_length++; - - if (garbage_left(isarray, scan_length, compat)) + else { - ECPGraise(lineno, ECPG_DATE_FORMAT, + if (isarray && *scan_length == '"') + scan_length++; + + if (garbage_left(isarray, scan_length, compat)) + { + ECPGraise(lineno, ECPG_DATE_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); - return (false); + return (false); + } } - } - - *((date *) (var + offset * act_tuple)) = ddres; - pval = scan_length; - } - break; - case ECPGt_timestamp: - if (pval) - { - if (isarray && *pval == '"') - tres = PGTYPEStimestamp_from_asc(pval + 1, &scan_length); - else - tres = PGTYPEStimestamp_from_asc(pval, &scan_length); + *((date *) (var + offset * act_tuple)) = ddres; + pval = scan_length; + } + break; - /* did we get an error? */ - if (errno != 0) + case ECPGt_timestamp: + if (pval) { - if (INFORMIX_MODE(compat)) - { - /* - * Informix wants its own NULL value here instead - * of an error - */ - ECPGset_noind_null(ECPGt_timestamp, &tres); - } + if (isarray && *pval == '"') + tres = PGTYPEStimestamp_from_asc(pval + 1, &scan_length); else + tres = PGTYPEStimestamp_from_asc(pval, &scan_length); + + /* did we get an error? */ + if (errno != 0) { - ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT, + if (INFORMIX_MODE(compat)) + { + /* + * Informix wants its own NULL value here + * instead of an error + */ + ECPGset_noind_null(ECPGt_timestamp, &tres); + } + else + { + ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); - return (false); + return (false); + } } - } - else - { - if (isarray && *scan_length == '"') - scan_length++; - - if (garbage_left(isarray, scan_length, compat)) + else { - ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT, + if (isarray && *scan_length == '"') + scan_length++; + + if (garbage_left(isarray, scan_length, compat)) + { + ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval); - return (false); + return (false); + } } - } - *((timestamp *) (var + offset * act_tuple)) = tres; - pval = scan_length; - } - break; + *((timestamp *) (var + offset * act_tuple)) = tres; + pval = scan_length; + } + break; - default: - ECPGraise(lineno, ECPG_UNSUPPORTED, - ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, - ECPGtype_name(type)); - return (false); - break; - } - if (isarray == ECPG_ARRAY_ARRAY) - { - bool string = false; + default: + ECPGraise(lineno, ECPG_UNSUPPORTED, + ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, + ECPGtype_name(type)); + return (false); + break; + } + if (isarray == ECPG_ARRAY_ARRAY) + { + bool string = false; - /* set array to next entry */ - ++act_tuple; + /* set array to next entry */ + ++act_tuple; - /* set pval to the next entry */ - for (; string || (*pval != ',' && *pval != '}' && *pval != '\0'); ++pval) - if (*pval == '"') - string = string ? false : true; + /* set pval to the next entry */ + for (; string || (*pval != ',' && *pval != '}' && *pval != '\0'); ++pval) + if (*pval == '"') + string = string ? false : true; - if (*pval == ',') - ++pval; - } - else if (isarray == ECPG_ARRAY_VECTOR) - { - bool string = false; + if (*pval == ',') + ++pval; + } + else if (isarray == ECPG_ARRAY_VECTOR) + { + bool string = false; - /* set array to next entry */ - ++act_tuple; + /* set array to next entry */ + ++act_tuple; - /* set pval to the next entry */ - for (; string || (*pval != ' ' && *pval != '\0'); ++pval) - if (*pval == '"') - string = string ? false : true; + /* set pval to the next entry */ + for (; string || (*pval != ' ' && *pval != '\0'); ++pval) + if (*pval == '"') + string = string ? false : true; - if (*pval == ' ') - ++pval; - } + if (*pval == ' ') + ++pval; + } } } while (*pval != '\0' && ((isarray == ECPG_ARRAY_ARRAY && *pval != '}') || isarray == ECPG_ARRAY_VECTOR)); diff --git a/src/interfaces/ecpg/ecpglib/descriptor.c b/src/interfaces/ecpg/ecpglib/descriptor.c index 58d7b5bf6f1..d73b7d6e80e 100644 --- a/src/interfaces/ecpg/ecpglib/descriptor.c +++ b/src/interfaces/ecpg/ecpglib/descriptor.c @@ -1,6 +1,6 @@ /* dynamic SQL support routines * - * $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.19 2006/08/23 13:57:27 meskes Exp $ + * $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.20 2006/10/04 00:30:11 momjian Exp $ */ #define POSTGRES_ECPG_INTERNAL @@ -351,7 +351,8 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...) /* allocate storage if needed */ if (arrsize == 0 && *(void **) var == NULL) { - void *mem = (void *) ECPGalloc(offset * ntuples, lineno); + void *mem = (void *) ECPGalloc(offset * ntuples, lineno); + if (!mem) return false; *(void **) var = mem; @@ -398,7 +399,12 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...) ECPGfree(oldlocale); } else if (data_var.ind_type != ECPGt_NO_INDICATOR && data_var.ind_pointer != NULL) - /* ind_type != NO_INDICATOR should always have ind_pointer != NULL but since this might be changed manually in the .c file let's play it safe */ + + /* + * ind_type != NO_INDICATOR should always have ind_pointer != NULL but + * since this might be changed manually in the .c file let's play it + * safe + */ { /* * this is like ECPGstore_result but since we don't have a data @@ -415,7 +421,8 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...) /* allocate storage if needed */ if (data_var.ind_arrsize == 0 && data_var.ind_value == NULL) { - void *mem = (void *) ECPGalloc(data_var.ind_offset * ntuples, lineno); + void *mem = (void *) ECPGalloc(data_var.ind_offset * ntuples, lineno); + if (!mem) return false; *(void **) data_var.ind_pointer = mem; diff --git a/src/interfaces/ecpg/ecpglib/error.c b/src/interfaces/ecpg/ecpglib/error.c index 5e65c0df8d4..3f811377bdb 100644 --- a/src/interfaces/ecpg/ecpglib/error.c +++ b/src/interfaces/ecpg/ecpglib/error.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.14 2006/08/02 13:43:23 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.15 2006/10/04 00:30:11 momjian Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -190,7 +190,7 @@ ECPGraise_backend(int line, PGresult *result, PGconn *conn, int compat) sqlca->sqlcode = ECPG_PGSQL; ECPGlog("raising sqlstate %.*s (sqlcode: %d) in line %d, '%s'.\n", - sizeof(sqlca->sqlstate), sqlca->sqlstate, sqlca->sqlcode, line, sqlca->sqlerrm.sqlerrmc); + sizeof(sqlca->sqlstate), sqlca->sqlstate, sqlca->sqlcode, line, sqlca->sqlerrm.sqlerrmc); /* free all memory we have allocated for the user */ ECPGfree_auto_mem(); diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index 7cd23cfc15e..15edddcea21 100644 --- a/src/interfaces/ecpg/ecpglib/execute.c +++ b/src/interfaces/ecpg/ecpglib/execute.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.61 2006/08/23 12:01:52 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.62 2006/10/04 00:30:11 momjian Exp $ */ /* * The aim is to get a simpler inteface to the database routines. @@ -39,10 +39,13 @@ static char * quote_postgres(char *arg, bool quote, int lineno) { char *res; - int i, ri = 0; + int i, + ri = 0; - /* if quote is false we just need to store things in a descriptor - * they will be quoted once they are inserted in a statement */ + /* + * if quote is false we just need to store things in a descriptor they + * will be quoted once they are inserted in a statement + */ if (!quote) return res = ECPGstrdup(arg, lineno); else @@ -52,9 +55,9 @@ quote_postgres(char *arg, bool quote, int lineno) return (res); /* - * We don't know if the target database is using - * standard_conforming_strings, so we always use E'' strings. - */ + * We don't know if the target database is using + * standard_conforming_strings, so we always use E'' strings. + */ if (strchr(arg, '\\') != NULL) res[ri++] = ESCAPE_STRING_SYNTAX; @@ -270,7 +273,7 @@ ECPGtypeinfocache_push(struct ECPGtype_information_cache ** cache, int oid, bool new_entry->isarray = isarray; new_entry->next = *cache; *cache = new_entry; - return(true); + return (true); } static enum ARRAY_TYPE @@ -290,48 +293,90 @@ ECPGis_type_an_array(int type, const struct statement * stmt, const struct varia #define not_an_array_in_ecpg ECPG_ARRAY_NONE /* populate cache with well known types to speed things up */ - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BOOLOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BYTEAOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CHAROID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), NAMEOID, not_an_array_in_ecpg, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT8OID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT2OID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT2VECTOROID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT4OID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), REGPROCOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TEXTOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), OIDOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIDOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), XIDOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIDOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), OIDVECTOROID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), POINTOID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), LSEGOID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), PATHOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BOXOID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), POLYGONOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), LINEOID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), FLOAT4OID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), FLOAT8OID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), ABSTIMEOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), RELTIMEOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TINTERVALOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), UNKNOWNOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIRCLEOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CASHOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INETOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIDROID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BPCHAROID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), VARCHAROID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), DATEOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMEOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMESTAMPOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMESTAMPTZOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INTERVALOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMETZOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), ZPBITOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), VARBITOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); - if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), NUMERICOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BOOLOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BYTEAOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CHAROID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), NAMEOID, not_an_array_in_ecpg, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT8OID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT2OID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT2VECTOROID, ECPG_ARRAY_VECTOR, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT4OID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), REGPROCOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TEXTOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), OIDOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIDOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), XIDOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIDOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), OIDVECTOROID, ECPG_ARRAY_VECTOR, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), POINTOID, ECPG_ARRAY_VECTOR, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), LSEGOID, ECPG_ARRAY_VECTOR, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), PATHOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BOXOID, ECPG_ARRAY_VECTOR, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), POLYGONOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), LINEOID, ECPG_ARRAY_VECTOR, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), FLOAT4OID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), FLOAT8OID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), ABSTIMEOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), RELTIMEOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TINTERVALOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), UNKNOWNOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIRCLEOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CASHOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INETOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIDROID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BPCHAROID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), VARCHAROID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), DATEOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMEOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMESTAMPOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMESTAMPTZOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INTERVALOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMETZOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), ZPBITOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), VARBITOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); + if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), NUMERICOID, ECPG_ARRAY_NONE, stmt->lineno)) + return (ECPG_ARRAY_ERROR); } for (cache_entry = (stmt->connection->cache_head); cache_entry != NULL; cache_entry = cache_entry->next) @@ -580,7 +625,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia } if (**tobeinserted_p == '\0') { - int asize = var->arrsize? var->arrsize : 1; + int asize = var->arrsize ? var->arrsize : 1; switch (var->type) { @@ -882,7 +927,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia case ECPGt_numeric: { char *str = NULL; - int slen; + int slen; numeric *nval; if (var->arrsize > 1) @@ -892,7 +937,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia nval = PGTYPESnumeric_new(); if (!nval) return false; - + if (var->type == ECPGt_numeric) PGTYPESnumeric_copy((numeric *) ((var + var->offset * element)->value), nval); else @@ -1237,8 +1282,8 @@ ECPGexecute(struct statement * stmt) * the first %s */ if (!(newcopy = (char *) ECPGalloc(strlen(copiedquery) - + strlen(tobeinserted) - + 1, stmt->lineno))) + + strlen(tobeinserted) + + 1, stmt->lineno))) { ECPGfree(copiedquery); return false; @@ -1252,7 +1297,7 @@ ECPGexecute(struct statement * stmt) * in the string */ ECPGraise(stmt->lineno, ECPG_TOO_MANY_ARGUMENTS, - ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS, + ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS, NULL); ECPGfree(copiedquery); ECPGfree(newcopy); @@ -1422,11 +1467,12 @@ ECPGexecute(struct statement * stmt) break; case PGRES_COPY_OUT: { - char *buffer; - int res; + char *buffer; + int res; + ECPGlog("ECPGexecute line %d: Got PGRES_COPY_OUT\n", stmt->lineno); while ((res = PQgetCopyData(stmt->connection->connection, - &buffer, 0)) > 0) + &buffer, 0)) > 0) { printf("%s", buffer); PQfreemem(buffer); diff --git a/src/interfaces/ecpg/ecpglib/extern.h b/src/interfaces/ecpg/ecpglib/extern.h index 62f8cf34da7..8759fac4fdb 100644 --- a/src/interfaces/ecpg/ecpglib/extern.h +++ b/src/interfaces/ecpg/ecpglib/extern.h @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.19 2006/08/23 12:01:52 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.20 2006/10/04 00:30:11 momjian Exp $ */ #ifndef _ECPG_LIB_EXTERN_H #define _ECPG_LIB_EXTERN_H @@ -27,6 +27,7 @@ void ECPGadd_mem(void *ptr, int lineno); bool ECPGget_data(const PGresult *, int, int, int, enum ECPGttype type, enum ECPGttype, char *, char *, long, long, long, enum ARRAY_TYPE, enum COMPAT_MODE, bool); + #ifdef ENABLE_THREAD_SAFETY void ecpg_pthreads_init(void); #endif diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c index 3c84cfd4f75..0bd850d36d9 100644 --- a/src/interfaces/ecpg/ecpglib/misc.c +++ b/src/interfaces/ecpg/ecpglib/misc.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.31 2006/08/15 06:40:19 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.32 2006/10/04 00:30:11 momjian Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -247,8 +247,8 @@ ECPGlog(const char *format,...) if (simple_debug) { - int bufsize = strlen(format) + 100; - char *f = (char *) malloc(bufsize); + int bufsize = strlen(format) + 100; + char *f = (char *) malloc(bufsize); if (f == NULL) { diff --git a/src/interfaces/ecpg/ecpglib/prepare.c b/src/interfaces/ecpg/ecpglib/prepare.c index 19b771afea2..f1a9db0729f 100644 --- a/src/interfaces/ecpg/ecpglib/prepare.c +++ b/src/interfaces/ecpg/ecpglib/prepare.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.17 2006/09/05 10:00:52 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.18 2006/10/04 00:30:11 momjian Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -53,8 +53,9 @@ replace_variables(char *text) *ptr = '?'; for (++ptr; *ptr && isvarchar(*ptr); ptr++) *ptr = ' '; - if (*ptr == '\0') /* we reached the end */ - ptr--; /* since we will ptr++ in the top level for loop */ + if (*ptr == '\0') /* we reached the end */ + ptr--; /* since we will ptr++ in the top level for + * loop */ } } } @@ -103,7 +104,7 @@ ECPGprepare(int lineno, const char *name, const char *variable) this->name = ECPGstrdup(name, lineno); this->stmt = stmt; ECPGlog("ECPGprepare line %d: QUERY: %s\n", stmt->lineno, stmt->command); - + if (prep_stmts == NULL) this->next = NULL; diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h index ced6da563d0..ab18b7e5f98 100644 --- a/src/interfaces/ecpg/include/ecpglib.h +++ b/src/interfaces/ecpg/include/ecpglib.h @@ -1,7 +1,7 @@ /* * this is a small part of c.h since we don't want to leak all postgres * definitions into ecpg programs - * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.69 2006/08/04 16:54:05 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.70 2006/10/04 00:30:11 momjian Exp $ */ #ifndef _ECPGLIB_H @@ -38,7 +38,7 @@ extern "C" { #endif -void ECPGinit_sqlca(struct sqlca_t *sqlca); +void ECPGinit_sqlca(struct sqlca_t * sqlca); void ECPGdebug(int, FILE *); bool ECPGstatus(int, const char *); bool ECPGsetcommit(int, const char *, const char *); diff --git a/src/interfaces/ecpg/include/pgtypes_date.h b/src/interfaces/ecpg/include/pgtypes_date.h index 2afc97198e2..9cc4233ee0f 100644 --- a/src/interfaces/ecpg/include/pgtypes_date.h +++ b/src/interfaces/ecpg/include/pgtypes_date.h @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_date.h,v 1.10 2006/09/14 08:02:38 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_date.h,v 1.11 2006/10/04 00:30:11 momjian Exp $ */ #ifndef PGTYPES_DATETIME #define PGTYPES_DATETIME @@ -13,7 +13,7 @@ extern "C" #endif extern date *PGTYPESdate_new(void); -extern void PGTYPESdate_free(date *); +extern void PGTYPESdate_free(date *); extern date PGTYPESdate_from_asc(char *, char **); extern char *PGTYPESdate_to_asc(date); extern date PGTYPESdate_from_timestamp(timestamp); diff --git a/src/interfaces/ecpg/include/pgtypes_interval.h b/src/interfaces/ecpg/include/pgtypes_interval.h index b2ab1a871ed..bb4f269ead3 100644 --- a/src/interfaces/ecpg/include/pgtypes_interval.h +++ b/src/interfaces/ecpg/include/pgtypes_interval.h @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_interval.h,v 1.12 2006/09/14 08:02:38 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_interval.h,v 1.13 2006/10/04 00:30:11 momjian Exp $ */ #ifndef PGTYPES_INTERVAL #define PGTYPES_INTERVAL @@ -17,8 +17,8 @@ typedef long int int64; #ifndef HAVE_INT64 typedef long long int int64; #endif -#else /* not HAVE_LONG_INT_64 and not - * HAVE_LONG_LONG_INT_64 */ +#else /* not HAVE_LONG_INT_64 and not + * HAVE_LONG_LONG_INT_64 */ /* Won't actually work, but fall back to long int so that code compiles */ #ifndef HAVE_INT64 @@ -26,13 +26,13 @@ typedef long int int64; #endif #define INT64_IS_BUSTED -#endif /* not HAVE_LONG_INT_64 and not HAVE_LONG_LONG_INT_64 */ +#endif /* not HAVE_LONG_INT_64 and not + * HAVE_LONG_LONG_INT_64 */ #if defined(USE_INTEGER_DATETIMES) && !defined(INT64_IS_BUSTED) #define HAVE_INT64_TIMESTAMP #endif - -#endif /* C_H */ +#endif /* C_H */ typedef struct { diff --git a/src/interfaces/ecpg/pgtypeslib/datetime.c b/src/interfaces/ecpg/pgtypeslib/datetime.c index e323d579e78..87b62c0b105 100644 --- a/src/interfaces/ecpg/pgtypeslib/datetime.c +++ b/src/interfaces/ecpg/pgtypeslib/datetime.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.31 2006/09/14 08:02:38 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.32 2006/10/04 00:30:11 momjian Exp $ */ #include "postgres_fe.h" @@ -15,14 +15,15 @@ date * PGTYPESdate_new(void) { - date *result; + date *result; + result = (date *) pgtypes_alloc(sizeof(date)); /* result can be NULL if we run out of memory */ return result; } void -PGTYPESdate_free(date *d) +PGTYPESdate_free(date * d) { free(d); } diff --git a/src/interfaces/ecpg/pgtypeslib/interval.c b/src/interfaces/ecpg/pgtypeslib/interval.c index b49267eb62c..534acdcc5fd 100644 --- a/src/interfaces/ecpg/pgtypeslib/interval.c +++ b/src/interfaces/ecpg/pgtypeslib/interval.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.35 2006/09/14 08:02:38 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.36 2006/10/04 00:30:11 momjian Exp $ */ #include "postgres_fe.h" #include <time.h> @@ -307,7 +307,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse tm->tm_mday += val * 7; if (fval != 0) { - int extra_days; + int extra_days; + fval *= 7; extra_days = (int32) fval; tm->tm_mday += extra_days; @@ -315,6 +316,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse if (fval != 0) { int sec; + fval *= SECS_PER_DAY; sec = fval; tm->tm_sec += sec; @@ -332,7 +334,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse tm->tm_mon += val; if (fval != 0) { - int day; + int day; + fval *= DAYS_PER_MONTH; day = fval; tm->tm_mday += day; @@ -340,6 +343,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse if (fval != 0) { int sec; + fval *= SECS_PER_DAY; sec = fval; tm->tm_sec += sec; @@ -756,14 +760,15 @@ tm2interval(struct tm * tm, fsec_t fsec, interval * span) interval * PGTYPESinterval_new(void) { - interval *result; + interval *result; + result = (interval *) pgtypes_alloc(sizeof(interval)); /* result can be NULL if we run out of memory */ return result; } void -PGTYPESinterval_free(interval *intvl) +PGTYPESinterval_free(interval * intvl) { free(intvl); } diff --git a/src/interfaces/ecpg/pgtypeslib/numeric.c b/src/interfaces/ecpg/pgtypeslib/numeric.c index c462d21673b..93505eaab18 100644 --- a/src/interfaces/ecpg/pgtypeslib/numeric.c +++ b/src/interfaces/ecpg/pgtypeslib/numeric.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.32 2006/08/15 06:40:19 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.33 2006/10/04 00:30:12 momjian Exp $ */ #include "postgres_fe.h" #include <ctype.h> @@ -143,6 +143,7 @@ decimal * PGTYPESdecimal_new(void) { decimal *var; + if ((var = (decimal *) pgtypes_alloc(sizeof(decimal))) == NULL) return NULL; @@ -382,7 +383,7 @@ PGTYPESnumeric_from_asc(char *str, char **endptr) char *realptr; char **ptr = (endptr != NULL) ? endptr : &realptr; - if (!value) + if (!value) return (NULL); ret = set_var_from_str(str, ptr, value); @@ -398,8 +399,8 @@ PGTYPESnumeric_from_asc(char *str, char **endptr) char * PGTYPESnumeric_to_asc(numeric *num, int dscale) { - numeric *numcopy = PGTYPESnumeric_new(); - char *s; + numeric *numcopy = PGTYPESnumeric_new(); + char *s; if (dscale < 0) dscale = num->dscale; @@ -1468,7 +1469,7 @@ PGTYPESnumeric_from_double(double d, numeric *dst) { char buffer[100]; numeric *tmp; - int i; + int i; if (sprintf(buffer, "%f", d) == 0) return -1; @@ -1490,7 +1491,7 @@ numericvar_to_double(numeric *var, double *dp) char *tmp; double val; char *endptr; - numeric *varcopy = PGTYPESnumeric_new(); + numeric *varcopy = PGTYPESnumeric_new(); if (PGTYPESnumeric_copy(var, varcopy) < 0) { @@ -1566,8 +1567,8 @@ PGTYPESnumeric_to_int(numeric *nv, int *ip) int PGTYPESnumeric_to_long(numeric *nv, long *lp) { - char *s = PGTYPESnumeric_to_asc(nv, 0); - char *endptr; + char *s = PGTYPESnumeric_to_asc(nv, 0); + char *endptr; if (s == NULL) return -1; diff --git a/src/interfaces/ecpg/pgtypeslib/timestamp.c b/src/interfaces/ecpg/pgtypeslib/timestamp.c index d7011243857..19c6bb80de6 100644 --- a/src/interfaces/ecpg/pgtypeslib/timestamp.c +++ b/src/interfaces/ecpg/pgtypeslib/timestamp.c @@ -423,47 +423,50 @@ 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 */ + /* 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 */ + /* 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 */ + /* 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 */ + /* 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. */ + + /* + * The preferred date and time representation for + * the current locale. + */ case 'c': /* XXX */ break; - /* the century number with leading zeroes */ + /* 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) */ + /* 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 */ + /* the date in the format mm/dd/yy */ case 'D': /* @@ -480,14 +483,15 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm, if (i) return i; break; - /* day with leading spaces (01 - 31) */ + /* 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 - */ + + /* + * alternative format modifier + */ case 'E': { char tmp[4] = "%Ex"; @@ -496,7 +500,7 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm, if (*p == '\0') return -1; tmp[2] = *p; - + /* * strftime's month is 0 based, ours is 1 based */ @@ -513,10 +517,11 @@ 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. - */ + + /* + * 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); @@ -530,10 +535,11 @@ 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). - */ + + /* + * Like %G, but without century, i.e., with a 2-digit year + * (00-99). + */ case 'g': { char *fmt = "%g"; /* Keep compiler quiet about @@ -552,57 +558,60 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm, replace_type = PGTYPES_TYPE_NOTHING; } break; - /* hour (24 hour clock) with leading zeroes */ + /* 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 */ + /* 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. - */ + + /* + * 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. - */ + + /* + * 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. - */ + + /* + * 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 */ + /* 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 */ + /* 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 */ + /* 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 */ + /* the AM/PM specifier (uppercase) */ + /* XXX should be locale aware */ case 'p': if (tm->tm_hour < 12) replace_val.str_val = "AM"; @@ -610,8 +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 AM/PM specifier (lowercase) */ - /* XXX should be locale aware */ + /* the AM/PM specifier (lowercase) */ + /* XXX should be locale aware */ case 'P': if (tm->tm_hour < 12) replace_val.str_val = "am"; @@ -619,8 +628,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 */ + /* 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, @@ -628,7 +637,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) */ + /* The time in 24 hour notation (%H:%M) */ case 'R': i = dttofmtasc_replace(ts, dDate, dow, tm, q, pstr_len, @@ -636,7 +645,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) */ + /* The number of seconds since the Epoch (1970-01-01) */ case 's': #ifdef HAVE_INT64_TIMESTAMP replace_val.int64_val = (*ts - SetEpochTimestamp()) / 1000000.0; @@ -646,17 +655,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 */ + /* 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 */ + /* A tabulator */ case 't': replace_val.char_val = '\t'; replace_type = PGTYPES_TYPE_CHAR; break; - /* The time in 24 hour notation (%H:%M:%S) */ + /* The time in 24 hour notation (%H:%M:%S) */ case 'T': i = dttofmtasc_replace(ts, dDate, dow, tm, q, pstr_len, @@ -664,14 +673,18 @@ 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 */ + + /* + * The day of the week as a decimal, Monday = 1, Sunday = + * 7 + */ case 'u': 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 */ + /* The week number of the year as a decimal number */ case 'U': tm->tm_mon -= 1; i = strftime(q, *pstr_len, "%U", tm); @@ -685,10 +698,11 @@ 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. - */ + + /* + * 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) @@ -700,15 +714,16 @@ 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. - */ + + /* + * 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) */ + /* The week number of the year (another definition) */ case 'W': tm->tm_mon -= 1; i = strftime(q, *pstr_len, "%U", tm); @@ -722,10 +737,11 @@ 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. - */ + + /* + * The preferred date representation for the current + * locale without the time. + */ case 'x': { char *fmt = "%x"; /* Keep compiler quiet about @@ -744,10 +760,11 @@ 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. - */ + + /* + * The preferred time representation for the current + * locale without the date. + */ case 'X': tm->tm_mon -= 1; i = strftime(q, *pstr_len, "%X", tm); @@ -761,17 +778,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) */ + /* 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) */ + /* 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 */ + /* The time zone offset from GMT */ case 'z': tm->tm_mon -= 1; i = strftime(q, *pstr_len, "%z", tm); @@ -785,7 +802,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 */ + /* The name or abbreviation of the time zone */ case 'Z': tm->tm_mon -= 1; i = strftime(q, *pstr_len, "%Z", tm); @@ -799,18 +816,20 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm, tm->tm_mon += 1; replace_type = PGTYPES_TYPE_NOTHING; break; - /* A % sign */ + /* A % sign */ case '%': replace_val.char_val = '%'; replace_type = PGTYPES_TYPE_CHAR; break; case '\0': /* 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 */ diff --git a/src/interfaces/ecpg/preproc/output.c b/src/interfaces/ecpg/preproc/output.c index 910d1750a4c..23469fca860 100644 --- a/src/interfaces/ecpg/preproc/output.c +++ b/src/interfaces/ecpg/preproc/output.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/output.c,v 1.18 2006/08/15 06:40:19 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/output.c,v 1.19 2006/10/04 00:30:12 momjian Exp $ */ #include "postgres_fe.h" @@ -9,8 +9,8 @@ static void output_escaped_str(char *cmd); void output_line_number(void) { - char *line = hashline_number(); - + char *line = hashline_number(); + /* output_escaped_str(line); */ fprintf(yyout, "%s", line); free(line); @@ -130,7 +130,8 @@ output_statement(char *stmt, int mode, char *con) static void output_escaped_str(char *str) { - int i, len = strlen(str); + int i, + len = strlen(str); /* output this char by char as we have to filter " and \n */ for (i = 0; i < len; i++) @@ -139,7 +140,7 @@ output_escaped_str(char *str) fputs("\\\"", yyout); else if (str[i] == '\n') fputs("\\\n", yyout); - else if (str[i] == '\r' && str[i+1] == '\n') + else if (str[i] == '\r' && str[i + 1] == '\n') { fputs("\\\r\n", yyout); i++; diff --git a/src/interfaces/ecpg/test/expected/compat_informix-charfuncs.c b/src/interfaces/ecpg/test/expected/compat_informix-charfuncs.c index eddd580e542..7ed4de17eda 100644 --- a/src/interfaces/ecpg/test/expected/compat_informix-charfuncs.c +++ b/src/interfaces/ecpg/test/expected/compat_informix-charfuncs.c @@ -13,12 +13,14 @@ #include <stdlib.h> #include <sqltypes.h> -int main(void) +int +main(void) { - char t1[] = "abc def ghi "; - /* 123456789012345 */ - char buf[50]; - int k; + char t1[] = "abc def ghi "; + + /* 123456789012345 */ + char buf[50]; + int k; printf("t1: _%s_\n", t1); rupshift(t1); diff --git a/src/interfaces/ecpg/test/expected/compat_informix-dec_test.c b/src/interfaces/ecpg/test/expected/compat_informix-dec_test.c index a130aa17c90..bde792c4000 100644 --- a/src/interfaces/ecpg/test/expected/compat_informix-dec_test.c +++ b/src/interfaces/ecpg/test/expected/compat_informix-dec_test.c @@ -44,31 +44,36 @@ TODO: ECPG_INFORMIX_BAD_EXPONENT ? */ -char* decs[] = { "2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4", - "2E-394", ".1E-2", "+.0", "-592.49E-07", "+32.84e-4", - ".500001", "-.5000001", - "1234567890123456789012345678.91", /* 30 digits should fit - into decimal */ - "1234567890123456789012345678.921", /* 31 digits should NOT - fit into decimal */ - "not a number", - NULL}; +char *decs[] = {"2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4", + "2E-394", ".1E-2", "+.0", "-592.49E-07", "+32.84e-4", + ".500001", "-.5000001", + "1234567890123456789012345678.91", /* 30 digits should fit into decimal */ + "1234567890123456789012345678.921", /* 31 digits should NOT fit into + * decimal */ + "not a number", +NULL}; static void -check_errno(void); + check_errno(void); #define BUFSIZE 200 int main(void) { - decimal *dec, *din; - char buf[BUFSIZE]; - long l; - int i, j, k, q, r, count = 0; - double dbl; - decimal **decarr = (decimal **) calloc(1, sizeof(decimal)); + decimal *dec, + *din; + char buf[BUFSIZE]; + long l; + int i, + j, + k, + q, + r, + count = 0; + double dbl; + decimal **decarr = (decimal **) calloc(1, sizeof(decimal)); ECPGdebug(1, stderr); @@ -85,52 +90,62 @@ main(void) decarr = realloc(decarr, sizeof(decimal *) * (count + 1)); decarr[count++] = dec; - r = dectoasc(dec, buf, BUFSIZE-1, -1); - if (r < 0) check_errno(); + r = dectoasc(dec, buf, BUFSIZE - 1, -1); + if (r < 0) + check_errno(); printf("dec[%d,1]: r: %d, %s\n", i, r, buf); - r = dectoasc(dec, buf, BUFSIZE-1, 0); - if (r < 0) check_errno(); + r = dectoasc(dec, buf, BUFSIZE - 1, 0); + if (r < 0) + check_errno(); printf("dec[%d,2]: r: %d, %s\n", i, r, buf); - r = dectoasc(dec, buf, BUFSIZE-1, 1); - if (r < 0) check_errno(); + r = dectoasc(dec, buf, BUFSIZE - 1, 1); + if (r < 0) + check_errno(); printf("dec[%d,3]: r: %d, %s\n", i, r, buf); - r = dectoasc(dec, buf, BUFSIZE-1, 2); - if (r < 0) check_errno(); + r = dectoasc(dec, buf, BUFSIZE - 1, 2); + if (r < 0) + check_errno(); printf("dec[%d,4]: r: %d, %s\n", i, r, buf); din = PGTYPESdecimal_new(); - r = dectoasc(din, buf, BUFSIZE-1, 2); - if (r < 0) check_errno(); + r = dectoasc(din, buf, BUFSIZE - 1, 2); + if (r < 0) + check_errno(); printf("dec[%d,5]: r: %d, %s\n", i, r, buf); r = dectolong(dec, &l); - if (r) check_errno(); - printf("dec[%d,6]: %ld (r: %d)\n", i, r?0L:l, r); + if (r) + check_errno(); + printf("dec[%d,6]: %ld (r: %d)\n", i, r ? 0L : l, r); if (r == 0) { r = deccvlong(l, din); - if (r) check_errno(); - dectoasc(din, buf, BUFSIZE-1, 2); + if (r) + check_errno(); + dectoasc(din, buf, BUFSIZE - 1, 2); q = deccmp(dec, din); printf("dec[%d,7]: %s (r: %d - cmp: %d)\n", i, buf, r, q); } r = dectoint(dec, &k); - if (r) check_errno(); - printf("dec[%d,8]: %d (r: %d)\n", i, r?0:k, r); + if (r) + check_errno(); + printf("dec[%d,8]: %d (r: %d)\n", i, r ? 0 : k, r); if (r == 0) { r = deccvint(k, din); - if (r) check_errno(); - dectoasc(din, buf, BUFSIZE-1, 2); + if (r) + check_errno(); + dectoasc(din, buf, BUFSIZE - 1, 2); q = deccmp(dec, din); printf("dec[%d,9]: %s (r: %d - cmp: %d)\n", i, buf, r, q); } r = dectodbl(dec, &dbl); - if (r) check_errno(); - printf("dec[%d,10]: %g (r: %d)\n", i, r?0.0:dbl, r); + if (r) + check_errno(); + printf("dec[%d,10]: %g (r: %d)\n", i, r ? 0.0 : dbl, r); PGTYPESdecimal_free(din); printf("\n"); @@ -141,23 +156,29 @@ main(void) decarr = realloc(decarr, sizeof(decimal *) * (count + 1)); decarr[count++] = dec; - rsetnull(CDECIMALTYPE, (char *) decarr[count-1]); - printf("dec[%d]: %sNULL\n", count-1, - risnull(CDECIMALTYPE, (char *) decarr[count-1]) ? "" : "NOT "); + rsetnull(CDECIMALTYPE, (char *) decarr[count - 1]); + printf("dec[%d]: %sNULL\n", count - 1, + risnull(CDECIMALTYPE, (char *) decarr[count - 1]) ? "" : "NOT "); printf("dec[0]: %sNULL\n", - risnull(CDECIMALTYPE, (char *) decarr[0]) ? "" : "NOT "); + risnull(CDECIMALTYPE, (char *) decarr[0]) ? "" : "NOT "); r = dectoasc(decarr[3], buf, -1, -1); - check_errno(); printf("dectoasc with len == -1: r: %d\n", r); + check_errno(); + printf("dectoasc with len == -1: r: %d\n", r); r = dectoasc(decarr[3], buf, 0, -1); - check_errno(); printf("dectoasc with len == 0: r: %d\n", r); + check_errno(); + printf("dectoasc with len == 0: r: %d\n", r); for (i = 0; i < count; i++) { for (j = 0; j < count; j++) { - decimal a, s, m, d; - int c; + decimal a, + s, + m, + d; + int c; + c = deccmp(decarr[i], decarr[j]); printf("dec[c,%d,%d]: %d\n", i, j, c); @@ -169,7 +190,7 @@ main(void) } else { - dectoasc(&a, buf, BUFSIZE-1, -1); + dectoasc(&a, buf, BUFSIZE - 1, -1); printf("dec[a,%d,%d]: %s\n", i, j, buf); } @@ -181,7 +202,7 @@ main(void) } else { - dectoasc(&s, buf, BUFSIZE-1, -1); + dectoasc(&s, buf, BUFSIZE - 1, -1); printf("dec[s,%d,%d]: %s\n", i, j, buf); } @@ -193,7 +214,7 @@ main(void) } else { - dectoasc(&m, buf, BUFSIZE-1, -1); + dectoasc(&m, buf, BUFSIZE - 1, -1); printf("dec[m,%d,%d]: %s\n", i, j, buf); } @@ -205,7 +226,7 @@ main(void) } else { - dectoasc(&d, buf, BUFSIZE-1, -1); + dectoasc(&d, buf, BUFSIZE - 1, -1); printf("dec[d,%d,%d]: %s\n", i, j, buf); } } @@ -213,7 +234,7 @@ main(void) for (i = 0; i < count; i++) { - dectoasc(decarr[i], buf, BUFSIZE-1, -1); + dectoasc(decarr[i], buf, BUFSIZE - 1, -1); printf("%d: %s\n", i, buf); } @@ -223,7 +244,7 @@ main(void) static void check_errno(void) { - switch(errno) + switch (errno) { case 0: printf("(no errno set) - "); diff --git a/src/interfaces/ecpg/test/expected/compat_informix-rfmtdate.c b/src/interfaces/ecpg/test/expected/compat_informix-rfmtdate.c index 49de0b660b1..7add41eb8ee 100644 --- a/src/interfaces/ecpg/test/expected/compat_informix-rfmtdate.c +++ b/src/interfaces/ecpg/test/expected/compat_informix-rfmtdate.c @@ -21,15 +21,16 @@ static void -check_return(int ret); + check_return(int ret); static void date_test_strdate(char *input) { - static int i; - date d; - int r, q; - char dbuf[11]; + static int i; + date d; + int r, + q; + char dbuf[11]; r = rstrdate(input, &d); printf("r: %d ", r); @@ -51,10 +52,11 @@ date_test_strdate(char *input) static void date_test_defmt(char *fmt, char *input) { - static int i; - char dbuf[11]; - date d; - int q, r; + static int i; + char dbuf[11]; + date d; + int q, + r; r = rdefmtdate(&d, fmt, input); printf("r: %d ", r); @@ -76,9 +78,9 @@ date_test_defmt(char *fmt, char *input) static void date_test_fmt(date d, char *fmt) { - static int i; - char buf[200]; - int r; + static int i; + char buf[200]; + int r; r = rfmtdate(d, fmt, buf); printf("r: %d ", r); @@ -92,10 +94,10 @@ date_test_fmt(date d, char *fmt) int main(void) { - short mdy[3] = { 11, 23, 1959 }; - char dbuf[11]; - date d; - int r; + short mdy[3] = {11, 23, 1959}; + char dbuf[11]; + date d; + int r; ECPGdebug(1, stderr); @@ -164,7 +166,7 @@ main(void) static void check_return(int ret) { - switch(ret) + switch (ret) { case ECPG_INFORMIX_ENOTDMY: printf("(ECPG_INFORMIX_ENOTDMY)"); diff --git a/src/interfaces/ecpg/test/expected/compat_informix-rfmtlong.c b/src/interfaces/ecpg/test/expected/compat_informix-rfmtlong.c index d000054abb7..8c9d76986c2 100644 --- a/src/interfaces/ecpg/test/expected/compat_informix-rfmtlong.c +++ b/src/interfaces/ecpg/test/expected/compat_informix-rfmtlong.c @@ -21,14 +21,14 @@ static void -check_return(int ret); + check_return(int ret); static void fmtlong(long lng, char *fmt) { - static int i; - int r; - char buf[30]; + static int i; + int r; + char buf[30]; r = rfmtlong(lng, fmt, buf); printf("r: %d ", r); @@ -62,7 +62,7 @@ main(void) static void check_return(int ret) { - switch(ret) + switch (ret) { case ECPG_INFORMIX_ENOTDMY: printf("(ECPG_INFORMIX_ENOTDMY)"); diff --git a/src/interfaces/ecpg/test/expected/compat_informix-rnull.c b/src/interfaces/ecpg/test/expected/compat_informix-rnull.c index 9ee19ace763..7cfa6a80d12 100644 --- a/src/interfaces/ecpg/test/expected/compat_informix-rnull.c +++ b/src/interfaces/ecpg/test/expected/compat_informix-rnull.c @@ -30,65 +30,66 @@ test_null(int type, char *ptr) printf("null: %d\n", risnull(type, ptr)); } -int main(void) +int +main(void) { - + #line 15 "rnull.pgc" - char c [] = "abc " ; + char c[] = "abc "; #line 15 "rnull.pgc" - + #line 16 "rnull.pgc" - short s = 17 ; + short s = 17; #line 16 "rnull.pgc" - + #line 17 "rnull.pgc" - int i = - 74874 ; + int i = -74874; #line 17 "rnull.pgc" - + #line 18 "rnull.pgc" - bool b = 1 ; + bool b = 1; #line 18 "rnull.pgc" - + #line 19 "rnull.pgc" - float f = 3.71 ; + float f = 3.71; #line 19 "rnull.pgc" - + #line 20 "rnull.pgc" - long l = 487444 ; + long l = 487444; #line 20 "rnull.pgc" - + #line 21 "rnull.pgc" - double dbl = 404.404 ; + double dbl = 404.404; #line 21 "rnull.pgc" - + #line 22 "rnull.pgc" - decimal dec ; + decimal dec; #line 22 "rnull.pgc" - + #line 23 "rnull.pgc" - date dat ; + date dat; #line 23 "rnull.pgc" - + #line 24 "rnull.pgc" - timestamp tmp ; + timestamp tmp; #line 24 "rnull.pgc" @@ -98,50 +99,65 @@ int main(void) #line 27 "rnull.pgc" - { ECPGconnect(__LINE__, 1, "regress1" , NULL,NULL , NULL, 0); + { + ECPGconnect(__LINE__, 1, "regress1", NULL, NULL, NULL, 0); #line 29 "rnull.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 29 "rnull.pgc" - { ECPGdo(__LINE__, 1, 0, NULL, "create table test ( id int , c char ( 10 ) , s smallint , i int , b bool , f float , l bigint , dbl double precision , dec decimal , dat date , tmp timestamptz ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 0, NULL, "create table test ( id int , c char ( 10 ) , s smallint , i int , b bool , f float , l bigint , dbl double precision , dec decimal , dat date , tmp timestamptz ) ", ECPGt_EOIT, ECPGt_EORT); #line 33 "rnull.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 33 "rnull.pgc" - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 34 "rnull.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 34 "rnull.pgc" - { ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id , c , s , i , b , f , l , dbl ) values( 1 , ? , ? , ? , ? , ? , ? , ? ) ", - ECPGt_char,(c),(long)sizeof("abc "),(long)1,(sizeof("abc "))*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_short,&(s),(long)1,(long)1,sizeof(short), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_int,&(i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_float,&(f),(long)1,(long)1,sizeof(float), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_long,&(l),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id , c , s , i , b , f , l , dbl ) values( 1 , ? , ? , ? , ? , ? , ? , ? ) ", + ECPGt_char, (c), (long) sizeof("abc "), (long) 1, (sizeof("abc ")) *sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_short, &(s), (long) 1, (long) 1, sizeof(short), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_bool, &(b), (long) 1, (long) 1, sizeof(bool), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_float, &(f), (long) 1, (long) 1, sizeof(float), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_long, &(l), (long) 1, (long) 1, sizeof(long), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_double, &(dbl), (long) 1, (long) 1, sizeof(double), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 38 "rnull.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 38 "rnull.pgc" - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 39 "rnull.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 39 "rnull.pgc" @@ -156,65 +172,74 @@ if (sqlca.sqlcode < 0) sqlprint ( );} rsetnull(CDATETYPE, (char *) &dat); rsetnull(CDTIMETYPE, (char *) &tmp); - { ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id , c , s , i , b , f , l , dbl , dec , dat , tmp ) values( 2 , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ", - ECPGt_char,(c),(long)sizeof("abc "),(long)1,(sizeof("abc "))*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_short,&(s),(long)1,(long)1,sizeof(short), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_int,&(i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_float,&(f),(long)1,(long)1,sizeof(float), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_long,&(l),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_date,&(dat),(long)1,(long)1,sizeof(date), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id , c , s , i , b , f , l , dbl , dec , dat , tmp ) values( 2 , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ", + ECPGt_char, (c), (long) sizeof("abc "), (long) 1, (sizeof("abc ")) *sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_short, &(s), (long) 1, (long) 1, sizeof(short), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_bool, &(b), (long) 1, (long) 1, sizeof(bool), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_float, &(f), (long) 1, (long) 1, sizeof(float), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_long, &(l), (long) 1, (long) 1, sizeof(long), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_double, &(dbl), (long) 1, (long) 1, sizeof(double), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_decimal, &(dec), (long) 1, (long) 1, sizeof(decimal), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_date, &(dat), (long) 1, (long) 1, sizeof(date), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_timestamp, &(tmp), (long) 1, (long) 1, sizeof(timestamp), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 54 "rnull.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 54 "rnull.pgc" - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 55 "rnull.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 55 "rnull.pgc" printf("first select\n"); - { ECPGdo(__LINE__, 1, 0, NULL, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 1 ", ECPGt_EOIT, - ECPGt_char,(c),(long)sizeof("abc "),(long)1,(sizeof("abc "))*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_short,&(s),(long)1,(long)1,sizeof(short), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_int,&(i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_float,&(f),(long)1,(long)1,sizeof(float), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_long,&(l),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_date,&(dat),(long)1,(long)1,sizeof(date), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 0, NULL, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 1 ", ECPGt_EOIT, + ECPGt_char, (c), (long) sizeof("abc "), (long) 1, (sizeof("abc ")) *sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_short, &(s), (long) 1, (long) 1, sizeof(short), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_bool, &(b), (long) 1, (long) 1, sizeof(bool), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_float, &(f), (long) 1, (long) 1, sizeof(float), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_long, &(l), (long) 1, (long) 1, sizeof(long), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_double, &(dbl), (long) 1, (long) 1, sizeof(double), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_decimal, &(dec), (long) 1, (long) 1, sizeof(decimal), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_date, &(dat), (long) 1, (long) 1, sizeof(date), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_timestamp, &(tmp), (long) 1, (long) 1, sizeof(timestamp), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 61 "rnull.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 61 "rnull.pgc" @@ -231,30 +256,33 @@ if (sqlca.sqlcode < 0) sqlprint ( );} printf("second select\n"); - { ECPGdo(__LINE__, 1, 0, NULL, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 2 ", ECPGt_EOIT, - ECPGt_char,(c),(long)sizeof("abc "),(long)1,(sizeof("abc "))*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_short,&(s),(long)1,(long)1,sizeof(short), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_int,&(i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_float,&(f),(long)1,(long)1,sizeof(float), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_long,&(l),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_date,&(dat),(long)1,(long)1,sizeof(date), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 0, NULL, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 2 ", ECPGt_EOIT, + ECPGt_char, (c), (long) sizeof("abc "), (long) 1, (sizeof("abc ")) *sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_short, &(s), (long) 1, (long) 1, sizeof(short), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_bool, &(b), (long) 1, (long) 1, sizeof(bool), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_float, &(f), (long) 1, (long) 1, sizeof(float), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_long, &(l), (long) 1, (long) 1, sizeof(long), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_double, &(dbl), (long) 1, (long) 1, sizeof(double), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_decimal, &(dec), (long) 1, (long) 1, sizeof(decimal), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_date, &(dat), (long) 1, (long) 1, sizeof(date), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_timestamp, &(tmp), (long) 1, (long) 1, sizeof(timestamp), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 78 "rnull.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 78 "rnull.pgc" @@ -269,23 +297,32 @@ if (sqlca.sqlcode < 0) sqlprint ( );} test_null(CDATETYPE, (char *) &dat); test_null(CDTIMETYPE, (char *) &tmp); - { ECPGdo(__LINE__, 1, 0, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 0, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT); #line 91 "rnull.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 91 "rnull.pgc" - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 92 "rnull.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 92 "rnull.pgc" - { ECPGdisconnect(__LINE__, "CURRENT"); + { + ECPGdisconnect(__LINE__, "CURRENT"); #line 94 "rnull.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 94 "rnull.pgc" diff --git a/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c b/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c index 53e39a008d7..166a15c5f09 100644 --- a/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c +++ b/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c @@ -25,149 +25,199 @@ static void openit(void); -static void dosqlprint(void) { +static void +dosqlprint(void) +{ printf("doSQLprint: Error: %s\n", sqlca.sqlerrm.sqlerrmc); } -int main(void) +int +main(void) { - + #line 14 "test_informix.pgc" - int i = 14 ; + int i = 14; #line 14 "test_informix.pgc" - - + + #line 15 "test_informix.pgc" - decimal j , m , n ; + decimal j, + m, + n; #line 15 "test_informix.pgc" ECPGdebug(1, stderr); - /* exec sql whenever sqlerror do dosqlprint ( ) ; */ + /* exec sql whenever sqlerror do dosqlprint ( ) ; */ #line 18 "test_informix.pgc" - { ECPGconnect(__LINE__, 1, "regress1" , NULL,NULL , NULL, 0); + { + ECPGconnect(__LINE__, 1, "regress1", NULL, NULL, NULL, 0); #line 20 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 20 "test_informix.pgc" - if (sqlca.sqlcode != 0) exit(1); + if (sqlca.sqlcode != 0) + exit(1); - { ECPGdo(__LINE__, 1, 1, NULL, "create table test ( i int primary key , j int ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 1, NULL, "create table test ( i int primary key , j int ) ", ECPGt_EOIT, ECPGt_EORT); #line 23 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 23 "test_informix.pgc" /* this INSERT works */ - rsetnull(CDECIMALTYPE, (char *)&j); - { ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i , j ) values( 7 , ? ) ", - ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + rsetnull(CDECIMALTYPE, (char *) &j); + { + ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i , j ) values( 7 , ? ) ", + ECPGt_decimal, &(j), (long) 1, (long) 1, sizeof(decimal), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 27 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 27 "test_informix.pgc" - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 28 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 28 "test_informix.pgc" /* this INSERT should fail because i is a unique column */ - { ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i , j ) values( 7 , 12 ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i , j ) values( 7 , 12 ) ", ECPGt_EOIT, ECPGt_EORT); #line 31 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 31 "test_informix.pgc" printf("INSERT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); - if (sqlca.sqlcode != 0) { ECPGtrans(__LINE__, NULL, "rollback"); + if (sqlca.sqlcode != 0) + { + ECPGtrans(__LINE__, NULL, "rollback"); #line 33 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 33 "test_informix.pgc" - { ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i , j ) values( ? , 1 ) ", - ECPGt_int,&(i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i , j ) values( ? , 1 ) ", + ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 35 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 35 "test_informix.pgc" - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 36 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 36 "test_informix.pgc" /* this will fail (more than one row in subquery) */ - { ECPGdo(__LINE__, 1, 1, NULL, "select i from test where j = ( select j from test ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 1, NULL, "select i from test where j = ( select j from test ) ", ECPGt_EOIT, ECPGt_EORT); #line 39 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 39 "test_informix.pgc" - { ECPGtrans(__LINE__, NULL, "rollback"); + { + ECPGtrans(__LINE__, NULL, "rollback"); #line 40 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 40 "test_informix.pgc" /* this however should be ok */ - { ECPGdo(__LINE__, 1, 1, NULL, "select i from test where j = ( select j from test order by i limit 1 ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 1, NULL, "select i from test where j = ( select j from test order by i limit 1 ) ", ECPGt_EOIT, ECPGt_EORT); #line 43 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 43 "test_informix.pgc" printf("SELECT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); - if (sqlca.sqlcode != 0) { ECPGtrans(__LINE__, NULL, "rollback"); + if (sqlca.sqlcode != 0) + { + ECPGtrans(__LINE__, NULL, "rollback"); #line 45 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 45 "test_informix.pgc" - ECPG_informix_set_var( 0, &( i ), __LINE__);\ - /* declare c cursor for select * from test where i <= ? */ + ECPG_informix_set_var(0, &(i), __LINE__); + \ + /* declare c cursor for select * from test where i <= ? */ #line 47 "test_informix.pgc" - openit(); + openit(); deccvint(0, &j); while (1) { - { ECPGdo(__LINE__, 1, 1, NULL, "fetch forward from c", ECPGt_EOIT, - ECPGt_int,&(i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 1, NULL, "fetch forward from c", ECPGt_EOIT, + ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_decimal, &(j), (long) 1, (long) 1, sizeof(decimal), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 54 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 54 "test_informix.pgc" - if (sqlca.sqlcode == 100) break; - else if (sqlca.sqlcode != 0) printf ("Error: %ld\n", sqlca.sqlcode); + if (sqlca.sqlcode == 100) + break; + else if (sqlca.sqlcode != 0) + printf("Error: %ld\n", sqlca.sqlcode); - if (risnull(CDECIMALTYPE, (char *)&j)) + if (risnull(CDECIMALTYPE, (char *) &j)) printf("%d NULL\n", i); else { - int a; + int a; dectoint(&j, &a); printf("%d %d\n", i, a); @@ -177,70 +227,94 @@ if (sqlca.sqlcode < 0) dosqlprint ( );} deccvint(7, &j); deccvint(14, &m); decadd(&j, &m, &n); - { ECPGdo(__LINE__, 1, 1, NULL, "delete from test where i = ? ", - ECPGt_decimal,&(n),(long)1,(long)1,sizeof(decimal), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 1, NULL, "delete from test where i = ? ", + ECPGt_decimal, &(n), (long) 1, (long) 1, sizeof(decimal), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 72 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 72 "test_informix.pgc" printf("DELETE: %ld\n", sqlca.sqlcode); - { ECPGdo(__LINE__, 1, 1, NULL, "select 1 from test where i = 14 ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 1, NULL, "select 1 from test where i = 14 ", ECPGt_EOIT, ECPGt_EORT); #line 75 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 75 "test_informix.pgc" printf("Exists: %ld\n", sqlca.sqlcode); - { ECPGdo(__LINE__, 1, 1, NULL, "select 1 from test where i = 147 ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 1, NULL, "select 1 from test where i = 147 ", ECPGt_EOIT, ECPGt_EORT); #line 78 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 78 "test_informix.pgc" printf("Does not exist: %ld\n", sqlca.sqlcode); - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 81 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 81 "test_informix.pgc" - { ECPGdo(__LINE__, 1, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT); #line 82 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 82 "test_informix.pgc" - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 83 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 83 "test_informix.pgc" - { ECPGdisconnect(__LINE__, "CURRENT"); + { + ECPGdisconnect(__LINE__, "CURRENT"); #line 85 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 85 "test_informix.pgc" return 0; } -static void openit(void) +static void +openit(void) { - { ECPGdo(__LINE__, 1, 1, NULL, "declare c cursor for select * from test where i <= ? ", - ECPGt_int,&(*( int *)(ECPG_informix_get_var( 0))),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 1, NULL, "declare c cursor for select * from test where i <= ? ", + ECPGt_int, &(*(int *) (ECPG_informix_get_var(0))), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 92 "test_informix.pgc" -if (sqlca.sqlcode < 0) dosqlprint ( );} + if (sqlca.sqlcode < 0) + dosqlprint(); + } #line 92 "test_informix.pgc" } - diff --git a/src/interfaces/ecpg/test/expected/compat_informix-test_informix2.c b/src/interfaces/ecpg/test/expected/compat_informix-test_informix2.c index 12c34203fa5..7926d782516 100644 --- a/src/interfaces/ecpg/test/expected/compat_informix-test_informix2.c +++ b/src/interfaces/ecpg/test/expected/compat_informix-test_informix2.c @@ -79,7 +79,6 @@ struct sqlca_t *ECPGget_sqlca(void); #ifdef __cplusplus } #endif - #endif #line 5 "test_informix2.pgc" @@ -97,72 +96,79 @@ struct sqlca_t *ECPGget_sqlca(void); /* Check SQLCODE, and produce a "standard error" if it's wrong! */ -static void sql_check(char *fn, char *caller, int ignore) +static void +sql_check(char *fn, char *caller, int ignore) { - char errorstring[255]; - - if (SQLCODE == ignore) - return; - else - { - if (SQLCODE != 0) - { - - sprintf(errorstring, "**SQL error %ld doing '%s' in function '%s'. [%s]", - SQLCODE, caller, fn, sqlca.sqlerrm.sqlerrmc); - fprintf(stderr, "%s", errorstring); - printf("%s\n", errorstring); - - /* attempt a ROLLBACK */ - { ECPGtrans(__LINE__, NULL, "rollback");} + char errorstring[255]; + + if (SQLCODE == ignore) + return; + else + { + if (SQLCODE != 0) + { + + sprintf(errorstring, "**SQL error %ld doing '%s' in function '%s'. [%s]", + SQLCODE, caller, fn, sqlca.sqlerrm.sqlerrmc); + fprintf(stderr, "%s", errorstring); + printf("%s\n", errorstring); + + /* attempt a ROLLBACK */ + { + ECPGtrans(__LINE__, NULL, "rollback"); + } #line 27 "test_informix2.pgc" - if (SQLCODE == 0) - { - sprintf(errorstring, "Rollback successful.\n"); - } else { - sprintf(errorstring, "Rollback failed with code %ld.\n", SQLCODE); - } + if (SQLCODE == 0) + { + sprintf(errorstring, "Rollback successful.\n"); + } + else + { + sprintf(errorstring, "Rollback failed with code %ld.\n", SQLCODE); + } - fprintf(stderr, "%s", errorstring); - printf("%s\n", errorstring); + fprintf(stderr, "%s", errorstring); + printf("%s\n", errorstring); - exit(1); - } - } + exit(1); + } + } } -int main(void) +int +main(void) { /* exec sql begin declare section */ - - - - - - + + + + + + #line 49 "test_informix2.pgc" - int c ; - + int c; + #line 50 "test_informix2.pgc" - timestamp d ; - + timestamp d; + #line 51 "test_informix2.pgc" - timestamp e ; - + timestamp e; + #line 52 "test_informix2.pgc" - timestamp maxd ; - + timestamp maxd; + #line 53 "test_informix2.pgc" - char dbname [ 30 ] ; + char dbname[30]; + /* exec sql end declare section */ #line 54 "test_informix2.pgc" - interval *intvl; + interval *intvl; /* exec sql whenever sqlerror sqlprint ; */ #line 58 "test_informix2.pgc" @@ -171,57 +177,75 @@ int main(void) ECPGdebug(1, stderr); strcpy(dbname, "regress1"); - { ECPGconnect(__LINE__, 1, dbname , NULL,NULL , NULL, 0); + { + ECPGconnect(__LINE__, 1, dbname, NULL, NULL, NULL, 0); #line 63 "test_informix2.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 63 "test_informix2.pgc" sql_check("main", "connect", 0); - { ECPGdo(__LINE__, 1, 1, NULL, "set DateStyle to 'DMY'", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 1, NULL, "set DateStyle to 'DMY'", ECPGt_EOIT, ECPGt_EORT); #line 66 "test_informix2.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 66 "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); + { + 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 68 "test_informix2.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 68 "test_informix2.pgc" sql_check("main", "create", 0); - - { 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); + + { + 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 73 "test_informix2.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 73 "test_informix2.pgc" sql_check("main", "insert", 0); - { 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); + { + 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 78 "test_informix2.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 78 "test_informix2.pgc" sql_check("main", "select max", 100); - { 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); + { + 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 85 "test_informix2.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 85 "test_informix2.pgc" sql_check("main", "select", 0); @@ -233,44 +257,59 @@ if (sqlca.sqlcode < 0) sqlprint();} c++; - { 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); + { + 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 97 "test_informix2.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 97 "test_informix2.pgc" sql_check("main", "update", 0); - - { ECPGtrans(__LINE__, NULL, "commit"); + + { + ECPGtrans(__LINE__, NULL, "commit"); #line 100 "test_informix2.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 100 "test_informix2.pgc" - { ECPGdo(__LINE__, 1, 1, NULL, "drop table history ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 1, 1, NULL, "drop table history ", ECPGt_EOIT, ECPGt_EORT); #line 102 "test_informix2.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 102 "test_informix2.pgc" sql_check("main", "drop", 0); - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 105 "test_informix2.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 105 "test_informix2.pgc" - { ECPGdisconnect(__LINE__, "CURRENT"); + { + ECPGdisconnect(__LINE__, "CURRENT"); #line 107 "test_informix2.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 107 "test_informix2.pgc" sql_check("main", "disconnect", 0); @@ -280,13 +319,13 @@ if (sqlca.sqlcode < 0) sqlprint();} exit(0); /* - Table "public.history" - Column | Type | Modifiers + Table "public.history" + Column | Type | Modifiers --------------+-----------------------------+----------- - customerid | integer | not null - timestamp | timestamp without time zone | not null - action_taken | character(5) | not null - narrative | character varying(100) | + customerid | integer | not null + timestamp | timestamp without time zone | not null + action_taken | character(5) | not null + narrative | character varying(100) | */ } diff --git a/src/interfaces/ecpg/test/expected/connect-test1.c b/src/interfaces/ecpg/test/expected/connect-test1.c index 86f3d8d1d37..59a3b739972 100644 --- a/src/interfaces/ecpg/test/expected/connect-test1.c +++ b/src/interfaces/ecpg/test/expected/connect-test1.c @@ -25,125 +25,184 @@ int main(void) { /* exec sql begin declare section */ - - + + #line 16 "test1.pgc" - char db [ 200 ] ; - + char db[200]; + #line 17 "test1.pgc" - char pw [ 200 ] ; + char pw[200]; + /* exec sql end declare section */ #line 18 "test1.pgc" ECPGdebug(1, stderr); - { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0); + } #line 22 "test1.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "alter user connectuser encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "alter user connectuser encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT); + } #line 23 "test1.pgc" - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 24 "test1.pgc" - /* <-- "main" not specified */ + /* <-- "main" not specified */ - { ECPGconnect(__LINE__, 0, "connectdb@localhost" , NULL,NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "connectdb@localhost", NULL, NULL, "main", 0); + } #line 26 "test1.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 27 "test1.pgc" - { ECPGconnect(__LINE__, 0, "@localhost" , "connectdb" , NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "@localhost", "connectdb", NULL, "main", 0); + } #line 29 "test1.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 30 "test1.pgc" - { ECPGconnect(__LINE__, 0, "connectdb@localhost:55432" , NULL,NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "connectdb@localhost:55432", NULL, NULL, "main", 0); + } #line 32 "test1.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 33 "test1.pgc" - { ECPGconnect(__LINE__, 0, "@localhost:55432" , "connectdb" , NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "@localhost:55432", "connectdb", NULL, "main", 0); + } #line 35 "test1.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 36 "test1.pgc" - { ECPGconnect(__LINE__, 0, "connectdb:55432" , NULL,NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "connectdb:55432", NULL, NULL, "main", 0); + } #line 38 "test1.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 39 "test1.pgc" - { ECPGconnect(__LINE__, 0, ":55432" , "connectdb" , NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, ":55432", "connectdb", NULL, "main", 0); + } #line 41 "test1.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 42 "test1.pgc" - { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/connectdb" , "connectuser" , "connectpw" , NULL, 0); } + { + ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/connectdb", "connectuser", "connectpw", NULL, 0); + } #line 44 "test1.pgc" - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 45 "test1.pgc" - { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/" , "connectdb" , NULL , NULL, 0); } + { + ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/", "connectdb", NULL, NULL, 0); + } #line 47 "test1.pgc" - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 48 "test1.pgc" strcpy(pw, "connectpw"); strcpy(db, "tcp:postgresql://localhost:55432/connectdb"); - { ECPGconnect(__LINE__, 0, db , "connectuser" , pw , NULL, 0); } + { + ECPGconnect(__LINE__, 0, db, "connectuser", pw, NULL, 0); + } #line 52 "test1.pgc" - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 53 "test1.pgc" - { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb" , "connectuser" , "connectpw" , NULL, 0); } + { + ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb", "connectuser", "connectpw", NULL, 0); + } #line 55 "test1.pgc" - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 56 "test1.pgc" - { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb" , "connectuser" , NULL , NULL, 0); } + { + ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb", "connectuser", NULL, NULL, 0); + } #line 58 "test1.pgc" - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 59 "test1.pgc" /* wrong db */ - { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/nonexistant" , "connectuser" , "connectpw" , NULL, 0); } + { + ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/nonexistant", "connectuser", "connectpw", NULL, 0); + } #line 62 "test1.pgc" - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 63 "test1.pgc" /* wrong port */ - { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:20/connectdb" , "connectuser" , "connectpw" , NULL, 0); } + { + ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:20/connectdb", "connectuser", "connectpw", NULL, 0); + } #line 66 "test1.pgc" /* no disconnect necessary */ /* wrong password */ - { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb" , "connectuser" , "wrongpw" , NULL, 0); } + { + ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb", "connectuser", "wrongpw", NULL, 0); + } #line 70 "test1.pgc" /* no disconnect necessary */ diff --git a/src/interfaces/ecpg/test/expected/connect-test2.c b/src/interfaces/ecpg/test/expected/connect-test2.c index ce18b08bf89..464a7cdf4d3 100644 --- a/src/interfaces/ecpg/test/expected/connect-test2.c +++ b/src/interfaces/ecpg/test/expected/connect-test2.c @@ -32,14 +32,15 @@ int main(void) { /* exec sql begin declare section */ - - + + #line 17 "test2.pgc" - char id [ 200 ] ; - + char id[200]; + #line 18 "test2.pgc" - char res [ 200 ] ; + char res[200]; + /* exec sql end declare section */ #line 19 "test2.pgc" @@ -47,56 +48,78 @@ main(void) ECPGdebug(1, stderr); strcpy(id, "first"); - { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , id, 0); } + { + ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, id, 0); + } #line 24 "test2.pgc" - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , "second", 0); } + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, "second", 0); + } #line 25 "test2.pgc" /* this selects from "second" which was opened last */ - { ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT, - ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT, + ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); + } #line 28 "test2.pgc" - { ECPGdo(__LINE__, 0, 1, "first", "select current_database () ", ECPGt_EOIT, - ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, "first", "select current_database () ", ECPGt_EOIT, + ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); + } #line 29 "test2.pgc" - { ECPGdo(__LINE__, 0, 1, "second", "select current_database () ", ECPGt_EOIT, - ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, "second", "select current_database () ", ECPGt_EOIT, + ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); + } #line 30 "test2.pgc" - { ECPGsetconn(__LINE__, "first");} + { + ECPGsetconn(__LINE__, "first"); + } #line 32 "test2.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT, - ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT, + ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); + } #line 33 "test2.pgc" /* this will disconnect from "first" */ - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 36 "test2.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT, - ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT, + ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); + } #line 37 "test2.pgc" /* error here since "first" is already disconnected */ - { ECPGdisconnect(__LINE__, id);} + { + ECPGdisconnect(__LINE__, id); + } #line 40 "test2.pgc" /* disconnect from "second" */ - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 43 "test2.pgc" diff --git a/src/interfaces/ecpg/test/expected/connect-test3.c b/src/interfaces/ecpg/test/expected/connect-test3.c index 5e4451a4c57..496083da5e0 100644 --- a/src/interfaces/ecpg/test/expected/connect-test3.c +++ b/src/interfaces/ecpg/test/expected/connect-test3.c @@ -31,14 +31,15 @@ int main(void) { /* exec sql begin declare section */ - - + + #line 16 "test3.pgc" - char id [ 200 ] ; - + char id[200]; + #line 17 "test3.pgc" - char res [ 200 ] ; + char res[200]; + /* exec sql end declare section */ #line 18 "test3.pgc" @@ -46,60 +47,83 @@ main(void) ECPGdebug(1, stderr); strcpy(id, "first"); - { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , id, 0); } + { + ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, id, 0); + } #line 23 "test3.pgc" - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , "second", 0); } + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, "second", 0); + } #line 24 "test3.pgc" /* this selects from "second" which was opened last */ - { ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT, - ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT, + ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); + } #line 27 "test3.pgc" /* will close "second" */ - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 30 "test3.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT, - ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "select current_database () ", ECPGt_EOIT, + ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); + } #line 31 "test3.pgc" - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , "second", 0); } + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, "second", 0); + } #line 33 "test3.pgc" /* will close "second" */ - { ECPGdisconnect(__LINE__, "DEFAULT");} + { + ECPGdisconnect(__LINE__, "DEFAULT"); + } #line 35 "test3.pgc" - { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "second", 0); } + { + ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "second", 0); + } #line 37 "test3.pgc" - { ECPGdisconnect(__LINE__, "ALL");} + { + ECPGdisconnect(__LINE__, "ALL"); + } #line 38 "test3.pgc" - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 40 "test3.pgc" - { ECPGdisconnect(__LINE__, "DEFAULT");} + { + ECPGdisconnect(__LINE__, "DEFAULT"); + } #line 41 "test3.pgc" - { ECPGdisconnect(__LINE__, "ALL");} + { + ECPGdisconnect(__LINE__, "ALL"); + } #line 42 "test3.pgc" /* - * exec sql disconnect; - * exec sql disconnect name; + * exec sql disconnect; exec sql disconnect name; * - * are used in other tests + * are used in other tests */ return (0); diff --git a/src/interfaces/ecpg/test/expected/connect-test4.c b/src/interfaces/ecpg/test/expected/connect-test4.c index ba15660f336..2b9f4ff2972 100644 --- a/src/interfaces/ecpg/test/expected/connect-test4.c +++ b/src/interfaces/ecpg/test/expected/connect-test4.c @@ -28,15 +28,21 @@ main(void) { ECPGdebug(1, stderr); - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, "main", 0); + } #line 13 "test4.pgc" - { ECPGsetconn(__LINE__, "main");} + { + ECPGsetconn(__LINE__, "main"); + } #line 15 "test4.pgc" - { ECPGdisconnect(__LINE__, "DEFAULT");} + { + ECPGdisconnect(__LINE__, "DEFAULT"); + } #line 17 "test4.pgc" diff --git a/src/interfaces/ecpg/test/expected/connect-test5.c b/src/interfaces/ecpg/test/expected/connect-test5.c index 6075aacf13c..36e902979ce 100644 --- a/src/interfaces/ecpg/test/expected/connect-test5.c +++ b/src/interfaces/ecpg/test/expected/connect-test5.c @@ -22,122 +22,181 @@ int main(void) { /* exec sql begin declare section */ - - + + #line 16 "test5.pgc" - char db [ 200 ] ; - + char db[200]; + #line 17 "test5.pgc" - char id [ 200 ] ; + char id[200]; + /* exec sql end declare section */ #line 18 "test5.pgc" ECPGdebug(1, stderr); - { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0); + } #line 22 "test5.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "alter user connectuser encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "alter user connectuser encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT); + } #line 23 "test5.pgc" - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 24 "test5.pgc" - /* <-- "main" not specified */ + /* <-- "main" not specified */ strcpy(db, "connectdb"); strcpy(id, "main"); - { ECPGconnect(__LINE__, 0, db , NULL,NULL , id, 0); } + { + ECPGconnect(__LINE__, 0, db, NULL, NULL, id, 0); + } #line 28 "test5.pgc" - { ECPGdisconnect(__LINE__, id);} + { + ECPGdisconnect(__LINE__, id); + } #line 29 "test5.pgc" - { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0); + } #line 31 "test5.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 32 "test5.pgc" - { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0); + } #line 34 "test5.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 35 "test5.pgc" - { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0); + } #line 37 "test5.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 38 "test5.pgc" - { ECPGconnect(__LINE__, 0, "" , "connectdb" , NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "", "connectdb", NULL, "main", 0); + } #line 40 "test5.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 41 "test5.pgc" - { ECPGconnect(__LINE__, 0, "connectdb" , "connectuser" , "connectdb" , "main", 0); } + { + ECPGconnect(__LINE__, 0, "connectdb", "connectuser", "connectdb", "main", 0); + } #line 43 "test5.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 44 "test5.pgc" - { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb", "connectuser", NULL, "main", 0); + } #line 46 "test5.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 47 "test5.pgc" - { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb", "connectuser", NULL, "main", 0); + } #line 49 "test5.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 50 "test5.pgc" - { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb", "connectuser", NULL, "main", 0); + } #line 52 "test5.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 53 "test5.pgc" - { ECPGconnect(__LINE__, 0, "unix:postgresql://200.46.204.71/connectdb" , "connectuser" , NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "unix:postgresql://200.46.204.71/connectdb", "connectuser", NULL, "main", 0); + } #line 55 "test5.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 56 "test5.pgc" - { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/" , "connectdb" , NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/", "connectdb", NULL, "main", 0); + } #line 58 "test5.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 59 "test5.pgc" /* connect twice */ - { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0); + } #line 62 "test5.pgc" - { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); } + { + ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0); + } #line 63 "test5.pgc" - { ECPGdisconnect(__LINE__, "main");} + { + ECPGdisconnect(__LINE__, "main"); + } #line 64 "test5.pgc" /* not connected */ - { ECPGdisconnect(__LINE__, "nonexistant");} + { + ECPGdisconnect(__LINE__, "nonexistant"); + } #line 67 "test5.pgc" diff --git a/src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c b/src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c index 0ce27f4596d..a8186346751 100644 --- a/src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c +++ b/src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c @@ -29,94 +29,116 @@ int main(void) { /* exec sql begin declare section */ - - - - - + + + + + #line 14 "dt_test.pgc" - date date1 ; - + date date1; + #line 15 "dt_test.pgc" - timestamp ts1 ; - + timestamp ts1; + #line 16 "dt_test.pgc" - interval * iv1 , iv2 ; - + interval *iv1, + iv2; + #line 17 "dt_test.pgc" - char * text ; + char *text; + /* exec sql end declare section */ #line 18 "dt_test.pgc" - date date2; - int mdy[3] = { 4, 19, 1998 }; - char *fmt, *out, *in; - char *d1 = "Mon Jan 17 1966"; - char *t1 = "2000-7-12 17:34:29"; - int i; - - ECPGdebug(1, stderr); - /* exec sql whenever sqlerror do sqlprint ( ) ; */ + date date2; + int mdy[3] = {4, 19, 1998}; + char *fmt, + *out, + *in; + char *d1 = "Mon Jan 17 1966"; + char *t1 = "2000-7-12 17:34:29"; + int i; + + ECPGdebug(1, stderr); + /* exec sql whenever sqlerror do sqlprint ( ) ; */ #line 27 "dt_test.pgc" - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); #line 28 "dt_test.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 28 "dt_test.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table date_test ( d date , ts timestamp ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table date_test ( d date , ts timestamp ) ", ECPGt_EOIT, ECPGt_EORT); #line 29 "dt_test.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 29 "dt_test.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT); #line 30 "dt_test.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 30 "dt_test.pgc" - date1 = PGTYPESdate_from_asc(d1, NULL); - ts1 = PGTYPEStimestamp_from_asc(t1, NULL); + date1 = PGTYPESdate_from_asc(d1, NULL); + ts1 = PGTYPEStimestamp_from_asc(t1, NULL); - { ECPGdo(__LINE__, 0, 1, NULL, "insert into date_test ( d , ts ) values( ? , ? ) ", - ECPGt_date,&(date1),(long)1,(long)1,sizeof(date), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_timestamp,&(ts1),(long)1,(long)1,sizeof(timestamp), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into date_test ( d , ts ) values( ? , ? ) ", + ECPGt_date, &(date1), (long) 1, (long) 1, sizeof(date), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_timestamp, &(ts1), (long) 1, (long) 1, sizeof(timestamp), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 35 "dt_test.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 35 "dt_test.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select * from date_test where d = ? ", - ECPGt_date,&(date1),(long)1,(long)1,sizeof(date), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_date,&(date1),(long)1,(long)1,sizeof(date), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_timestamp,&(ts1),(long)1,(long)1,sizeof(timestamp), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select * from date_test where d = ? ", + ECPGt_date, &(date1), (long) 1, (long) 1, sizeof(date), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_date, &(date1), (long) 1, (long) 1, sizeof(date), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_timestamp, &(ts1), (long) 1, (long) 1, sizeof(timestamp), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 37 "dt_test.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 37 "dt_test.pgc" text = PGTYPESdate_to_asc(date1); - printf ("Date: %s\n", text); + + printf("Date: %s\n", text); free(text); text = PGTYPEStimestamp_to_asc(ts1); - printf ("timestamp: %s\n", text); + + printf("timestamp: %s\n", text); free(text); iv1 = PGTYPESinterval_from_asc("13556 days 12 hours 34 minutes 14 seconds ", NULL); PGTYPESinterval_copy(iv1, &iv2); text = PGTYPESinterval_to_asc(&iv2); - printf ("interval: %s\n", text); + + printf("interval: %s\n", text); free(text); PGTYPESdate_mdyjul(mdy, &date2); @@ -131,8 +153,9 @@ if (sqlca.sqlcode < 0) sqlprint ( );} ts1 = PGTYPEStimestamp_from_asc("2003-12-04 17:34:29", NULL); text = PGTYPEStimestamp_to_asc(ts1); + fmt = "(ddd), mmm. dd, yyyy, repeat: (ddd), mmm. dd, yyyy. end"; - out = (char*) malloc(strlen(fmt) + 1); + out = (char *) malloc(strlen(fmt) + 1); date1 = PGTYPESdate_from_timestamp(ts1); PGTYPESdate_fmt_asc(date1, fmt, out); printf("date_day of %s is %d\n", text, PGTYPESdate_dayofweek(date1)); @@ -142,249 +165,306 @@ if (sqlca.sqlcode < 0) sqlprint ( );} /* rdate_defmt_asc() */ - date1 = 0; text = ""; + date1 = 0; + text = ""; + fmt = "yy/mm/dd"; in = "In the year 1995, the month of December, it is the 25th day"; - /* 0123456789012345678901234567890123456789012345678901234567890 - * 0 1 2 3 4 5 6 + + /* + * 0123456789012345678901234567890123456789012345678901234567890 0 + * 1 2 3 4 5 6 */ PGTYPESdate_defmt_asc(&date1, fmt, in); text = PGTYPESdate_to_asc(date1); + printf("date_defmt_asc1: %s\n", text); free(text); - date1 = 0; text = ""; + date1 = 0; + text = ""; + fmt = "mmmm. dd. yyyy"; in = "12/25/95"; PGTYPESdate_defmt_asc(&date1, fmt, in); text = PGTYPESdate_to_asc(date1); + printf("date_defmt_asc2: %s\n", text); free(text); - date1 = 0; text = ""; + date1 = 0; + text = ""; + fmt = "yy/mm/dd"; in = "95/12/25"; PGTYPESdate_defmt_asc(&date1, fmt, in); text = PGTYPESdate_to_asc(date1); + printf("date_defmt_asc3: %s\n", text); free(text); - date1 = 0; text = ""; + date1 = 0; + text = ""; + fmt = "yy/mm/dd"; in = "1995, December 25th"; PGTYPESdate_defmt_asc(&date1, fmt, in); text = PGTYPESdate_to_asc(date1); + printf("date_defmt_asc4: %s\n", text); free(text); - date1 = 0; text = ""; + date1 = 0; + text = ""; + fmt = "dd-mm-yy"; in = "This is 25th day of December, 1995"; PGTYPESdate_defmt_asc(&date1, fmt, in); text = PGTYPESdate_to_asc(date1); + printf("date_defmt_asc5: %s\n", text); free(text); - date1 = 0; text = ""; + date1 = 0; + text = ""; + fmt = "mmddyy"; in = "Dec. 25th, 1995"; PGTYPESdate_defmt_asc(&date1, fmt, in); text = PGTYPESdate_to_asc(date1); + printf("date_defmt_asc6: %s\n", text); free(text); - date1 = 0; text = ""; + date1 = 0; + text = ""; + fmt = "mmm. dd. yyyy"; in = "dec 25th 1995"; PGTYPESdate_defmt_asc(&date1, fmt, in); text = PGTYPESdate_to_asc(date1); + printf("date_defmt_asc7: %s\n", text); free(text); - date1 = 0; text = ""; + date1 = 0; + text = ""; + fmt = "mmm. dd. yyyy"; in = "DEC-25-1995"; PGTYPESdate_defmt_asc(&date1, fmt, in); text = PGTYPESdate_to_asc(date1); + printf("date_defmt_asc8: %s\n", text); free(text); - date1 = 0; text = ""; + date1 = 0; + text = ""; + fmt = "mm yy dd."; in = "12199525"; PGTYPESdate_defmt_asc(&date1, fmt, in); text = PGTYPESdate_to_asc(date1); + printf("date_defmt_asc9: %s\n", text); free(text); - date1 = 0; text = ""; + date1 = 0; + text = ""; + fmt = "yyyy fierj mm dd."; in = "19951225"; PGTYPESdate_defmt_asc(&date1, fmt, in); text = PGTYPESdate_to_asc(date1); + printf("date_defmt_asc10: %s\n", text); free(text); - date1 = 0; text = ""; + date1 = 0; + text = ""; + fmt = "mm/dd/yy"; in = "122595"; PGTYPESdate_defmt_asc(&date1, fmt, in); text = PGTYPESdate_to_asc(date1); + printf("date_defmt_asc12: %s\n", text); free(text); PGTYPEStimestamp_current(&ts1); text = PGTYPEStimestamp_to_asc(ts1); + /* can't output this in regression mode */ /* printf("timestamp_current: Now: %s\n", text); */ free(text); ts1 = PGTYPEStimestamp_from_asc("96-02-29", NULL); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_to_asc1: %s\n", text); free(text); ts1 = PGTYPEStimestamp_from_asc("1994-02-11 3:10:35", NULL); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_to_asc2: %s\n", text); free(text); ts1 = PGTYPEStimestamp_from_asc("1994-02-11 26:10:35", NULL); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_to_asc3: %s\n", text); free(text); /* abc-03:10:35-def-02/11/94-gh */ -/* 12345678901234567890123456789 */ +/* 12345678901234567890123456789 */ - out = (char*) malloc(32); + out = (char *) malloc(32); i = PGTYPEStimestamp_fmt_asc(&ts1, out, 31, "abc-%X-def-%x-ghi%%"); printf("timestamp_fmt_asc: %d: %s\n", i, out); free(out); fmt = "This is a %m/%d/%y %H-%Ml%Stest"; - in = "This is a 4/12/80 3-39l12test"; + in = "This is a 4/12/80 3-39l12test"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i); free(text); fmt = "%a %b %d %H:%M:%S %z %Y"; - in = "Tue Jul 22 17:28:44 +0200 2003"; + in = "Tue Jul 22 17:28:44 +0200 2003"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i); free(text); fmt = "%a %b %d %H:%M:%S %z %Y"; - in = "Tue Feb 29 17:28:44 +0200 2000"; + in = "Tue Feb 29 17:28:44 +0200 2000"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i); free(text); fmt = "%a %b %d %H:%M:%S %z %Y"; - in = "Tue Feb 29 17:28:44 +0200 1900"; + in = "Tue Feb 29 17:28:44 +0200 1900"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i); free(text); fmt = "%a %b %d %H:%M:%S %z %Y"; - in = "Tue Feb 29 17:28:44 +0200 1996"; + in = "Tue Feb 29 17:28:44 +0200 1996"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i); free(text); fmt = "%b %d %H:%M:%S %z %Y"; - in = " Jul 31 17:28:44 +0200 1996"; + in = " Jul 31 17:28:44 +0200 1996"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i); free(text); fmt = "%b %d %H:%M:%S %z %Y"; - in = " Jul 32 17:28:44 +0200 1996"; + in = " Jul 32 17:28:44 +0200 1996"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i); free(text); fmt = "%a %b %d %H:%M:%S %z %Y"; - in = "Tue Feb 29 17:28:44 +0200 1997"; + in = "Tue Feb 29 17:28:44 +0200 1997"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i); free(text); fmt = "%"; - in = "Tue Jul 22 17:28:44 +0200 2003"; + in = "Tue Jul 22 17:28:44 +0200 2003"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i); free(text); fmt = "a %"; - in = "Tue Jul 22 17:28:44 +0200 2003"; + in = "Tue Jul 22 17:28:44 +0200 2003"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i); free(text); fmt = "%b, %d %H_%M`%S %z %Y"; - in = " Jul, 22 17_28 `44 +0200 2003 "; + in = " Jul, 22 17_28 `44 +0200 2003 "; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i); free(text); fmt = "%a %b %%%d %H:%M:%S %Z %Y"; - in = "Tue Jul %22 17:28:44 CEST 2003"; + in = "Tue Jul %22 17:28:44 CEST 2003"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i); free(text); fmt = "%a %b %%%d %H:%M:%S %Z %Y"; - in = "Tue Jul %22 17:28:44 CEST 2003"; + in = "Tue Jul %22 17:28:44 CEST 2003"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i); free(text); fmt = "abc%n %C %B %%%d %H:%M:%S %Z %Y"; - in = "abc\n 19 October %22 17:28:44 CEST 2003"; + in = "abc\n 19 October %22 17:28:44 CEST 2003"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i); free(text); fmt = "abc%n %C %B %%%d %H:%M:%S %Z %y"; - in = "abc\n 18 October %34 17:28:44 CEST 80"; + in = "abc\n 18 October %34 17:28:44 CEST 80"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i); free(text); fmt = ""; - in = "abc\n 18 October %34 17:28:44 CEST 80"; + in = "abc\n 18 October %34 17:28:44 CEST 80"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i); free(text); fmt = NULL; - in = "1980-04-12 3:49:44 "; + in = "1980-04-12 3:49:44 "; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, NULL) = %s, error: %d\n", in, text, i); free(text); fmt = "%B %d, %Y. Time: %I:%M%p"; - in = "July 14, 1988. Time: 9:15am"; + in = "July 14, 1988. Time: 9:15am"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i); free(text); @@ -392,6 +472,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} fmt = "%B %d at %I:%M %p in the year %Y"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i); free(text); @@ -399,6 +480,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} fmt = "%Y, %B %d. Time: %I:%M %p"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i); free(text); @@ -406,6 +488,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} fmt = "%Y, %B %d. Time: %I:%M%p"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i); free(text); @@ -413,22 +496,28 @@ if (sqlca.sqlcode < 0) sqlprint ( );} fmt = "%Y, %P %B %d. Time: %I:%M"; i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1); text = PGTYPEStimestamp_to_asc(ts1); + printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i); free(text); - { ECPGtrans(__LINE__, NULL, "rollback"); + { + ECPGtrans(__LINE__, NULL, "rollback"); #line 350 "dt_test.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 350 "dt_test.pgc" - { ECPGdisconnect(__LINE__, "CURRENT"); + { + ECPGdisconnect(__LINE__, "CURRENT"); #line 351 "dt_test.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 351 "dt_test.pgc" return (0); } - diff --git a/src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c b/src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c index e5388b6fa8d..72b1199dd8e 100644 --- a/src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c +++ b/src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c @@ -25,73 +25,76 @@ #line 8 "dt_test2.pgc" -char *dates[] = { "19990108foobar", - "19990108 foobar", - "1999-01-08 foobar", - "January 8, 1999", - "1999-01-08", - "1/8/1999", - "1/18/1999", - "01/02/03", - "1999-Jan-08", - "Jan-08-1999", - "08-Jan-1999", - "99-Jan-08", - "08-Jan-99", - "08-Jan-06", - "Jan-08-99", - "19990108", - "990108", - "1999.008", - "J2451187", - "January 8, 99 BC", - NULL }; - -char *times[] = { "0:04", - "1:59 PDT", - "13:24:40 -8:00", - "13:24:40.495+3", - NULL }; - -char *intervals[] = { "1 minute", - "1 12:59:10", - "2 day 12 hour 59 minute 10 second", - "1 days 12 hrs 59 mins 10 secs", - "1 days 1 hours 1 minutes 1 seconds", - "1 year 59 mins", - "1 year 59 mins foobar", - NULL }; +char *dates[] = {"19990108foobar", + "19990108 foobar", + "1999-01-08 foobar", + "January 8, 1999", + "1999-01-08", + "1/8/1999", + "1/18/1999", + "01/02/03", + "1999-Jan-08", + "Jan-08-1999", + "08-Jan-1999", + "99-Jan-08", + "08-Jan-99", + "08-Jan-06", + "Jan-08-99", + "19990108", + "990108", + "1999.008", + "J2451187", + "January 8, 99 BC", +NULL}; + +char *times[] = {"0:04", + "1:59 PDT", + "13:24:40 -8:00", + "13:24:40.495+3", +NULL}; + +char *intervals[] = {"1 minute", + "1 12:59:10", + "2 day 12 hour 59 minute 10 second", + "1 days 12 hrs 59 mins 10 secs", + "1 days 1 hours 1 minutes 1 seconds", + "1 year 59 mins", + "1 year 59 mins foobar", +NULL}; int main(void) { /* exec sql begin declare section */ - - - - - - + + + + + + #line 51 "dt_test2.pgc" - date date1 ; - + date date1; + #line 52 "dt_test2.pgc" - timestamp ts1 , ts2 ; - + timestamp ts1, + ts2; + #line 53 "dt_test2.pgc" - char * text ; - + char *text; + #line 54 "dt_test2.pgc" - interval * i1 ; - + interval *i1; + #line 55 "dt_test2.pgc" - date * dc ; + date *dc; + /* exec sql end declare section */ #line 56 "dt_test2.pgc" - int i, j; - char *endptr; + int i, + j; + char *endptr; ECPGdebug(1, stderr); @@ -105,38 +108,45 @@ main(void) dc = PGTYPESdate_new(); *dc = date1; text = PGTYPESdate_to_asc(*dc); + printf("Date of timestamp: %s\n", text); free(text); PGTYPESdate_free(dc); for (i = 0; dates[i]; i++) { - bool err = false; + bool err = false; + date1 = PGTYPESdate_from_asc(dates[i], &endptr); - if (date1 == INT_MIN) { + if (date1 == INT_MIN) + { err = true; } text = PGTYPESdate_to_asc(date1); + printf("Date[%d]: %s (%c - %c)\n", - i, err ? "-" : text, - endptr ? 'N' : 'Y', - err ? 'T' : 'F'); + i, err ? "-" : text, + endptr ? 'N' : 'Y', + err ? 'T' : 'F'); free(text); if (!err) { for (j = 0; times[j]; j++) { - int length = strlen(dates[i]) - + 1 - + strlen(times[j]) - + 1; - char* t = malloc(length); + int length = strlen(dates[i]) + + 1 + + strlen(times[j]) + + 1; + char *t = malloc(length); + sprintf(t, "%s %s", dates[i], times[j]); ts1 = PGTYPEStimestamp_from_asc(t, NULL); text = PGTYPEStimestamp_to_asc(ts1); - if (i != 19 || j != 3) /* timestamp as integer or double differ for this case */ + + if (i != 19 || j != 3) /* timestamp as integer or double + * differ for this case */ printf("TS[%d,%d]: %s\n", - i, j, errno ? "-" : text); + i, j, errno ? "-" : text); free(text); } } @@ -146,7 +156,8 @@ main(void) for (i = 0; intervals[i]; i++) { - interval *ic; + interval *ic; + i1 = PGTYPESinterval_from_asc(intervals[i], &endptr); if (*endptr) printf("endptr set to %s\n", endptr); @@ -159,12 +170,14 @@ main(void) if (j < 0) continue; text = PGTYPESinterval_to_asc(i1); + printf("interval[%d]: %s\n", i, text ? text : "-"); free(text); ic = PGTYPESinterval_new(); PGTYPESinterval_copy(i1, ic); text = PGTYPESinterval_to_asc(i1); + printf("interval_copy[%d]: %s\n", i, text ? text : "-"); free(text); PGTYPESinterval_free(ic); @@ -172,4 +185,3 @@ main(void) return (0); } - diff --git a/src/interfaces/ecpg/test/expected/pgtypeslib-num_test.c b/src/interfaces/ecpg/test/expected/pgtypeslib-num_test.c index e45abe63688..903b8247042 100644 --- a/src/interfaces/ecpg/test/expected/pgtypeslib-num_test.c +++ b/src/interfaces/ecpg/test/expected/pgtypeslib-num_test.c @@ -34,49 +34,64 @@ NOTE: This file has a different expect file for regression tests on MinGW32 int main(void) { - char *text="error\n"; - numeric *value1, *value2, *res; + char *text = "error\n"; + numeric *value1, + *value2, + *res; + /* exec sql begin declare section */ - - /* = {0, 0, 0, 0, 0, NULL, NULL} ; */ - + + /* = {0, 0, 0, 0, 0, NULL, NULL} ; */ + #line 22 "num_test.pgc" - numeric * des ; + numeric *des; + /* exec sql end declare section */ #line 24 "num_test.pgc" - double d; - long l1, l2; - int i; + double d; + long l1, + l2; + int i; ECPGdebug(1, stderr); /* exec sql whenever sqlerror do sqlprint ( ) ; */ #line 30 "num_test.pgc" - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); #line 32 "num_test.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 32 "num_test.pgc" - { ECPGsetcommit(__LINE__, "off", NULL); + { + ECPGsetcommit(__LINE__, "off", NULL); #line 34 "num_test.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 34 "num_test.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( text char ( 5 ) , num numeric ( 14 , 7 ) ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table test ( text char ( 5 ) , num numeric ( 14 , 7 ) ) ", ECPGt_EOIT, ECPGt_EORT); #line 35 "num_test.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 35 "num_test.pgc" value1 = PGTYPESnumeric_new(); PGTYPESnumeric_from_int(1407, value1); text = PGTYPESnumeric_to_asc(value1, -1); + printf("from int = %s\n", text); free(text); PGTYPESnumeric_free(value1); @@ -86,23 +101,28 @@ if (sqlca.sqlcode < 0) sqlprint ( );} res = PGTYPESnumeric_new(); PGTYPESnumeric_add(value1, value2, res); text = PGTYPESnumeric_to_asc(res, -1); + printf("add = %s\n", text); free(text); PGTYPESnumeric_sub(res, value2, res); text = PGTYPESnumeric_to_asc(res, -1); + printf("sub = %s\n", text); free(text); PGTYPESnumeric_free(value2); des = PGTYPESnumeric_new(); PGTYPESnumeric_copy(res, des); - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( text , num ) values( 'test' , ? ) ", - ECPGt_numeric,&(des),(long)1,(long)0,sizeof(numeric), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( text , num ) values( 'test' , ? ) ", + ECPGt_numeric, &(des), (long) 1, (long) 0, sizeof(numeric), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 60 "num_test.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 60 "num_test.pgc" @@ -110,17 +130,21 @@ if (sqlca.sqlcode < 0) sqlprint ( );} PGTYPESnumeric_mul(value1, value2, res); PGTYPESnumeric_free(value2); - { ECPGdo(__LINE__, 0, 1, NULL, "select num from test where text = 'test' ", ECPGt_EOIT, - ECPGt_numeric,&(des),(long)1,(long)0,sizeof(numeric), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select num from test where text = 'test' ", ECPGt_EOIT, + ECPGt_numeric, &(des), (long) 1, (long) 0, sizeof(numeric), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 66 "num_test.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 66 "num_test.pgc" PGTYPESnumeric_mul(res, des, res); text = PGTYPESnumeric_to_asc(res, -1); + printf("mul = %s\n", text); free(text); PGTYPESnumeric_free(des); @@ -128,6 +152,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );} value2 = PGTYPESnumeric_from_asc("10000", NULL); PGTYPESnumeric_div(res, value2, res); text = PGTYPESnumeric_to_asc(res, -1); + PGTYPESnumeric_to_double(res, &d); printf("div = %s %e\n", text, d); @@ -141,19 +166,24 @@ if (sqlca.sqlcode < 0) sqlprint ( );} PGTYPESnumeric_free(value2); PGTYPESnumeric_free(res); - { ECPGtrans(__LINE__, NULL, "rollback"); + { + ECPGtrans(__LINE__, NULL, "rollback"); #line 90 "num_test.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 90 "num_test.pgc" - { ECPGdisconnect(__LINE__, "CURRENT"); + { + ECPGdisconnect(__LINE__, "CURRENT"); #line 91 "num_test.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 91 "num_test.pgc" return (0); } - diff --git a/src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c b/src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c index 9db09e71889..41d2511c40f 100644 --- a/src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c +++ b/src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c @@ -32,112 +32,149 @@ NOTE: This file has a different expect file for regression tests on MinGW32 */ -char* nums[] = { "2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4", - "2E-394", ".1E-2", "+.0", "-592.49E-07", "+32.84e-4", - ".500001", "-.5000001", - "1234567890123456789012345678.91", /* 30 digits should fit - into decimal */ - "1234567890123456789012345678.921", /* 31 digits should NOT - fit into decimal */ - "not a number", - NULL}; +char *nums[] = {"2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4", + "2E-394", ".1E-2", "+.0", "-592.49E-07", "+32.84e-4", + ".500001", "-.5000001", + "1234567890123456789012345678.91", /* 30 digits should fit into decimal */ + "1234567890123456789012345678.921", /* 31 digits should NOT fit into + * decimal */ + "not a number", +NULL}; static void -check_errno(void); + check_errno(void); int main(void) { - char *text="error\n"; - char *endptr; - numeric *num, *nin; - decimal *dec; - long l; - int i, j, k, q, r, count = 0; - double d; - numeric **numarr = (numeric **) calloc(1, sizeof(numeric)); + char *text = "error\n"; + char *endptr; + numeric *num, + *nin; + decimal *dec; + long l; + int i, + j, + k, + q, + r, + count = 0; + double d; + numeric **numarr = (numeric **) calloc(1, sizeof(numeric)); ECPGdebug(1, stderr); for (i = 0; nums[i]; i++) { num = PGTYPESnumeric_from_asc(nums[i], &endptr); - if (!num) 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; + if (!num) + continue; numarr = realloc(numarr, sizeof(numeric *) * (count + 1)); numarr[count++] = num; text = PGTYPESnumeric_to_asc(num, -1); - if (!text) check_errno(); - printf("num[%d,1]: %s\n", i, text); free(text); + + if (!text) + check_errno(); + printf("num[%d,1]: %s\n", i, text); + free(text); text = PGTYPESnumeric_to_asc(num, 0); - if (!text) check_errno(); - printf("num[%d,2]: %s\n", i, text); free(text); + + if (!text) + check_errno(); + printf("num[%d,2]: %s\n", i, text); + free(text); text = PGTYPESnumeric_to_asc(num, 1); - if (!text) check_errno(); - printf("num[%d,3]: %s\n", i, text); free(text); + + if (!text) + check_errno(); + printf("num[%d,3]: %s\n", i, text); + free(text); text = PGTYPESnumeric_to_asc(num, 2); - if (!text) check_errno(); - printf("num[%d,4]: %s\n", i, text); free(text); + + if (!text) + check_errno(); + printf("num[%d,4]: %s\n", i, text); + free(text); nin = PGTYPESnumeric_new(); text = PGTYPESnumeric_to_asc(nin, 2); - if (!text) check_errno(); - printf("num[%d,5]: %s\n", i, text); free(text); + + if (!text) + check_errno(); + printf("num[%d,5]: %s\n", i, text); + free(text); r = PGTYPESnumeric_to_long(num, &l); - if (r) check_errno(); - printf("num[%d,6]: %ld (r: %d)\n", i, r?0L:l, r); + 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); - if (r) 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); free(text); } r = PGTYPESnumeric_to_int(num, &k); - if (r) check_errno(); - printf("num[%d,8]: %d (r: %d)\n", i, r?0:k, r); + 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); - if (r) 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); free(text); } r = PGTYPESnumeric_to_double(num, &d); - if (r) check_errno(); - printf("num[%d,10]: %g (r: %d)\n", i, r?0.0:d, r); - /* do not test double to numeric because - * - extra digits are different on different architectures - * - PGTYPESnumeric_from_double internally calls PGTYPESnumeric_from_asc anyway + if (r) + check_errno(); + printf("num[%d,10]: %g (r: %d)\n", i, r ? 0.0 : d, r); + + /* + * do not test double to numeric because - extra digits are different + * on different architectures - PGTYPESnumeric_from_double internally + * calls PGTYPESnumeric_from_asc anyway */ dec = PGTYPESdecimal_new(); r = PGTYPESnumeric_to_decimal(num, dec); - if (r) check_errno(); - /* we have no special routine for outputting decimal, it would - * convert to a numeric anyway */ + if (r) + check_errno(); + + /* + * we have no special routine for outputting decimal, it would convert + * to a numeric anyway + */ printf("num[%d,11]: - (r: %d)\n", i, r); if (r == 0) { r = PGTYPESnumeric_from_decimal(dec, nin); - if (r) check_errno(); + if (r) + check_errno(); text = PGTYPESnumeric_to_asc(nin, 2); + q = PGTYPESnumeric_cmp(num, nin); printf("num[%d,12]: %s (r: %d - cmp: %d)\n", i, text, r, q); free(text); @@ -152,10 +189,11 @@ main(void) { for (j = 0; j < count; j++) { - numeric* a = PGTYPESnumeric_new(); - numeric* s = PGTYPESnumeric_new(); - numeric* m = PGTYPESnumeric_new(); - numeric* d = PGTYPESnumeric_new(); + 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) { @@ -165,6 +203,7 @@ main(void) else { text = PGTYPESnumeric_to_asc(a, 10); + printf("num[a,%d,%d]: %s\n", i, j, text); free(text); } @@ -177,6 +216,7 @@ main(void) else { text = PGTYPESnumeric_to_asc(s, 10); + printf("num[s,%d,%d]: %s\n", i, j, text); free(text); } @@ -189,6 +229,7 @@ main(void) else { text = PGTYPESnumeric_to_asc(m, 10); + printf("num[m,%d,%d]: %s\n", i, j, text); free(text); } @@ -201,6 +242,7 @@ main(void) else { text = PGTYPESnumeric_to_asc(d, 10); + printf("num[d,%d,%d]: %s\n", i, j, text); free(text); } @@ -210,6 +252,7 @@ main(void) for (i = 0; i < count; i++) { text = PGTYPESnumeric_to_asc(numarr[i], -1); + printf("%d: %s\n", i, text); free(text); } @@ -220,7 +263,7 @@ main(void) static void check_errno(void) { - switch(errno) + switch (errno) { case 0: printf("(no errno set) - "); diff --git a/src/interfaces/ecpg/test/expected/preproc-comment.c b/src/interfaces/ecpg/test/expected/preproc-comment.c index 23e81708eee..3297ede6b6e 100644 --- a/src/interfaces/ecpg/test/expected/preproc-comment.c +++ b/src/interfaces/ecpg/test/expected/preproc-comment.c @@ -20,24 +20,29 @@ #line 3 "comment.pgc" -/* just a test comment */ int i; -/* just a test comment int j*/; + /* just a test comment */ int i; + + /* just a test comment int j*/ ; /****************************************************************************/ -/* Test comment */ +/* Test comment */ /*--------------------------------------------------------------------------*/ -int main(void) +int +main(void) { - ECPGdebug(1, stderr); + ECPGdebug(1, stderr); - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); } + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); + } #line 17 "comment.pgc" - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 19 "comment.pgc" - exit (0); + exit(0); } - diff --git a/src/interfaces/ecpg/test/expected/preproc-define.c b/src/interfaces/ecpg/test/expected/preproc-define.c index 4c4caa7295c..9978fead817 100644 --- a/src/interfaces/ecpg/test/expected/preproc-define.c +++ b/src/interfaces/ecpg/test/expected/preproc-define.c @@ -30,133 +30,165 @@ -/* exec sql type intarray is int [ 6 ] */ +/* exec sql type intarray is int [ 6 ] */ #line 13 "define.pgc" -typedef int intarray[ 6]; +typedef int intarray[6]; int main(void) { /* exec sql begin declare section */ - typedef char string [ 8 ] ; + typedef char string[8]; #line 21 "define.pgc" - - - - + + + + #line 22 "define.pgc" - intarray amount ; - + intarray amount; + #line 23 "define.pgc" - char name [ 6 ] [ 8 ] ; - + char name[6][8]; + #line 24 "define.pgc" - char letter [ 6 ] [ 1 ] ; - + char letter[6][1]; + #if 0 - + #line 26 "define.pgc" - int not_used ; - + int not_used; #endif /* exec sql end declare section */ #line 29 "define.pgc" - int i,j; + int i, + j; ECPGdebug(1, stderr); - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); #line 34 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 34 "define.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) ) ", ECPGt_EOIT, ECPGt_EORT); #line 36 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 36 "define.pgc" - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 37 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 37 "define.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into Test ( name , amount , letter ) values ( 'false' , 1 , 'f' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into Test ( name , amount , letter ) values ( 'false' , 1 , 'f' ) ", ECPGt_EOIT, ECPGt_EORT); #line 39 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 39 "define.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( name , amount , letter ) values ( 'true' , 2 , 't' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( name , amount , letter ) values ( 'true' , 2 , 't' ) ", ECPGt_EOIT, ECPGt_EORT); #line 40 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 40 "define.pgc" - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 41 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 41 "define.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select * from test ", ECPGt_EOIT, - ECPGt_char,(name),(long)8,(long)6,(8)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_int,(amount),(long)1,(long)6,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(letter),(long)1,(long)6,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select * from test ", ECPGt_EOIT, + ECPGt_char, (name), (long) 8, (long) 6, (8) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_int, (amount), (long) 1, (long) 6, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, (letter), (long) 1, (long) 6, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 43 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 43 "define.pgc" - for (i=0, j=sqlca.sqlerrd[2]; i<j; i++) + for (i = 0, j = sqlca.sqlerrd[2]; i < j; i++) { /* exec sql begin declare section */ - - - + + + #line 48 "define.pgc" - char n [ 8 ] , l = letter [ i ] [ 0 ] ; - + char n[8], + l = letter[i][0]; + #line 49 "define.pgc" - int a = amount [ i ] ; + int a = amount[i]; + /* exec sql end declare section */ #line 50 "define.pgc" - strncpy(n, name[i], 8); + strncpy(n, name[i], 8); printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l); } - { ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT); #line 56 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 56 "define.pgc" - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 57 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 57 "define.pgc" - { ECPGdisconnect(__LINE__, "CURRENT"); + { + ECPGdisconnect(__LINE__, "CURRENT"); #line 58 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 58 "define.pgc" diff --git a/src/interfaces/ecpg/test/expected/preproc-init.c b/src/interfaces/ecpg/test/expected/preproc-init.c index 0d085b140dd..f5e8e9e19a1 100644 --- a/src/interfaces/ecpg/test/expected/preproc-init.c +++ b/src/interfaces/ecpg/test/expected/preproc-init.c @@ -73,16 +73,22 @@ struct sqlca_t *ECPGget_sqlca(void); #ifdef __cplusplus } #endif - #endif #line 1 "init.pgc" -enum e { ENUM0, ENUM1 }; -struct sa { int member; }; +enum e +{ + ENUM0, ENUM1 +}; +struct sa +{ + int member; +}; -static int fa(void) +static int +fa(void) { printf("in fa\n"); return 2; @@ -102,19 +108,22 @@ fc(const char *x) return *x; } -static int fd(const char *x,int i) +static int +fd(const char *x, int i) { printf("in fd (%s, %d)\n", x, i); - return (*x)*i; + return (*x) * i; } -static int fe(enum e x) +static int +fe(enum e x) { printf("in fe (%d)\n", (int) x); - return (int)x; + return (int) x; } -static void sqlnotice(char *notice, short trans) +static void +sqlnotice(char *notice, short trans) { if (!notice) notice = "-empty-"; @@ -126,76 +135,79 @@ static void sqlnotice(char *notice, short trans) #define YES 1 #ifdef _cplusplus -namespace N +namespace N { - static const int i=2; + static const int i = 2; }; #endif -int main(void) +int +main(void) { - struct sa x = { 14 },*y = &x; + struct sa x = {14}, *y = &x; + /* exec sql begin declare section */ - - - - - - - - - - - - /* = 1L */ - + + + + + + + + + + + + /* = 1L */ + #line 60 "init.pgc" - int a = ( int ) 2 ; - + int a = (int) 2; + #line 61 "init.pgc" - int b = 2 + 2 ; - + int b = 2 + 2; + #line 62 "init.pgc" - int b2 = ( 14 * 7 ) ; - + int b2 = (14 * 7); + #line 63 "init.pgc" - int d = x . member ; - + int d = x.member; + #line 64 "init.pgc" - int g = fb ( 2 ) ; - + int g = fb(2); + #line 65 "init.pgc" - int i = 3 ^ 1 ; - + int i = 3 ^ 1; + #line 66 "init.pgc" - int j = 1 ? 1 : 2 ; - + int j = 1 ? 1 : 2; + #line 68 "init.pgc" - int e = y -> member ; - + int e = y->member; + #line 69 "init.pgc" - int c = 10 >> 2 ; - + int c = 10 >> 2; + #line 70 "init.pgc" - bool h = 2 || 1 ; - + bool h = 2 || 1; + #line 71 "init.pgc" - long iay ; + long iay; + /* exec sql end declare section */ #line 72 "init.pgc" - int f=fa(); + int f = fa(); #ifdef _cplusplus /* exec sql begin declare section */ - /* compile error */ - + /* compile error */ + #line 78 "init.pgc" - int k = N : : i ; + int k = N::i; + /* exec sql end declare section */ #line 79 "init.pgc" - #endif ECPGdebug(1, stderr); @@ -203,58 +215,76 @@ int main(void) printf("%d %d %d %d %d %d %d %d %d %d %d\n", a, b, b2, c, d, e, f, g, h, i, j); iay = 0; printf("%ld\n", iay); - /* exec sql whenever sqlerror do fa ( ) ; */ + /* exec sql whenever sqlerror do fa ( ) ; */ #line 87 "init.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT); #line 88 "init.pgc" -if (sqlca.sqlcode < 0) fa ( );} + if (sqlca.sqlcode < 0) + fa(); + } #line 88 "init.pgc" /* exec sql whenever sqlerror do fb ( 20 ) ; */ #line 89 "init.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT); #line 90 "init.pgc" -if (sqlca.sqlcode < 0) fb ( 20 );} + if (sqlca.sqlcode < 0) + fb(20); + } #line 90 "init.pgc" /* exec sql whenever sqlerror do fc ( \"50\" ) ; */ #line 91 "init.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT); #line 92 "init.pgc" -if (sqlca.sqlcode < 0) fc ( "50" );} + if (sqlca.sqlcode < 0) + fc("50"); + } #line 92 "init.pgc" /* exec sql whenever sqlerror do fd ( \"50\" , 1 ) ; */ #line 93 "init.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT); #line 94 "init.pgc" -if (sqlca.sqlcode < 0) fd ( "50" , 1 );} + if (sqlca.sqlcode < 0) + fd("50", 1); + } #line 94 "init.pgc" /* exec sql whenever sqlerror do fe ( ENUM0 ) ; */ #line 95 "init.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT); #line 96 "init.pgc" -if (sqlca.sqlcode < 0) fe ( ENUM0 );} + if (sqlca.sqlcode < 0) + fe(ENUM0); + } #line 96 "init.pgc" /* exec sql whenever sqlerror do sqlnotice ( NULL , 0 ) ; */ #line 97 "init.pgc" - - { ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT); + + { + ECPGdo(__LINE__, 0, 1, NULL, "select now () ", ECPGt_EOIT, ECPGt_EORT); #line 98 "init.pgc" -if (sqlca.sqlcode < 0) sqlnotice ( NULL , 0 );} + if (sqlca.sqlcode < 0) + sqlnotice(NULL, 0); + } #line 98 "init.pgc" return 0; diff --git a/src/interfaces/ecpg/test/expected/preproc-type.c b/src/interfaces/ecpg/test/expected/preproc-type.c index 20e937188c1..fc9334b8c14 100644 --- a/src/interfaces/ecpg/test/expected/preproc-type.c +++ b/src/interfaces/ecpg/test/expected/preproc-type.c @@ -21,150 +21,164 @@ #line 4 "type.pgc" -typedef long mmInteger ; +typedef long mmInteger; #line 6 "type.pgc" #line 6 "type.pgc" -typedef char mmChar ; +typedef char mmChar; #line 7 "type.pgc" #line 7 "type.pgc" -typedef short mmSmallInt ; +typedef short mmSmallInt; #line 8 "type.pgc" #line 8 "type.pgc" -/* exec sql type string is char [ 11 ] */ +/* exec sql type string is char [ 11 ] */ #line 10 "type.pgc" typedef char string[11]; -/* exec sql type c is char reference */ +/* exec sql type c is char reference */ #line 13 "type.pgc" -typedef char* c; +typedef char *c; /* exec sql begin declare section */ - - - - -struct TBempl { + + + + +struct TBempl +{ #line 19 "type.pgc" - mmInteger idnum ; - + mmInteger idnum; + #line 20 "type.pgc" - mmChar name [ 21 ] ; - + mmChar name[21]; + #line 21 "type.pgc" - mmSmallInt accs ; - } ;/* exec sql end declare section */ + mmSmallInt accs; +}; /* exec sql end declare section */ + #line 23 "type.pgc" int -main (void) +main(void) { - /* exec sql begin declare section */ - - - - - - - - - + /* exec sql begin declare section */ + + + + + + + + + #line 29 "type.pgc" - struct TBempl empl ; - + struct TBempl empl; + #line 30 "type.pgc" - string str ; - + string str; + #line 31 "type.pgc" - c ptr = NULL ; - + c ptr = NULL; + #line 36 "type.pgc" - struct varchar_vc { + struct varchar_vc + { #line 34 "type.pgc" - int len ; - + int len; + #line 35 "type.pgc" - char text [ 10 ] ; - } vc ; + char text [10]; + } vc; + /* exec sql end declare section */ #line 37 "type.pgc" - /* exec sql var vc is [ 10 ] */ + /* exec sql var vc is [ 10 ] */ #line 39 "type.pgc" - ECPGdebug (1, stderr); + ECPGdebug(1, stderr); - empl.idnum = 1; - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); } + empl.idnum = 1; + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); + } #line 43 "type.pgc" - if (sqlca.sqlcode) - { - printf ("connect error = %ld\n", sqlca.sqlcode); - exit (sqlca.sqlcode); - } + if (sqlca.sqlcode) + { + printf("connect error = %ld\n", sqlca.sqlcode); + exit(sqlca.sqlcode); + } - { ECPGdo(__LINE__, 0, 1, NULL, "create table empl ( idnum integer , name char ( 20 ) , accs smallint , string1 char ( 10 ) , string2 char ( 10 ) , string3 char ( 10 ) ) ", ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "create table empl ( idnum integer , name char ( 20 ) , accs smallint , string1 char ( 10 ) , string2 char ( 10 ) , string3 char ( 10 ) ) ", ECPGt_EOIT, ECPGt_EORT); + } #line 51 "type.pgc" - if (sqlca.sqlcode) - { - printf ("create error = %ld\n", sqlca.sqlcode); - exit (sqlca.sqlcode); - } + if (sqlca.sqlcode) + { + printf("create error = %ld\n", sqlca.sqlcode); + exit(sqlca.sqlcode); + } - { ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values ( 1 , 'user name' , 320 , 'first str' , 'second str' , 'third str' ) ", ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values ( 1 , 'user name' , 320 , 'first str' , 'second str' , 'third str' ) ", ECPGt_EOIT, ECPGt_EORT); + } #line 58 "type.pgc" - if (sqlca.sqlcode) - { - printf ("insert error = %ld\n", sqlca.sqlcode); - exit (sqlca.sqlcode); - } - - { ECPGdo(__LINE__, 0, 1, NULL, "select idnum , name , accs , string1 , string2 , string3 from empl where idnum = ? ", - ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,&(empl.name),(long)21,(long)1,(21)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(str),(long)11,(long)1,(11)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,&(ptr),(long)0,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_varchar,&(vc),(long)10,(long)1,sizeof(struct varchar_vc), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + if (sqlca.sqlcode) + { + printf("insert error = %ld\n", sqlca.sqlcode); + exit(sqlca.sqlcode); + } + + { + ECPGdo(__LINE__, 0, 1, NULL, "select idnum , name , accs , string1 , string2 , string3 from empl where idnum = ? ", + ECPGt_long, &(empl.idnum), (long) 1, (long) 1, sizeof(long), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long, &(empl.idnum), (long) 1, (long) 1, sizeof(long), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, &(empl.name), (long) 21, (long) 1, (21) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_short, &(empl.accs), (long) 1, (long) 1, sizeof(short), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, (str), (long) 11, (long) 1, (11) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, &(ptr), (long) 0, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_varchar, &(vc), (long) 10, (long) 1, sizeof(struct varchar_vc), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); + } #line 68 "type.pgc" - if (sqlca.sqlcode) - { - printf ("select error = %ld\n", sqlca.sqlcode); - exit (sqlca.sqlcode); - } - printf ("id=%ld name='%s' accs=%d str='%s' ptr='%s' vc='%10.10s'\n", empl.idnum, empl.name, empl.accs, str, ptr, vc.text); + if (sqlca.sqlcode) + { + printf("select error = %ld\n", sqlca.sqlcode); + exit(sqlca.sqlcode); + } + printf("id=%ld name='%s' accs=%d str='%s' ptr='%s' vc='%10.10s'\n", empl.idnum, empl.name, empl.accs, str, ptr, vc.text); - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 76 "type.pgc" - free(ptr); - exit (0); + free(ptr); + exit(0); } diff --git a/src/interfaces/ecpg/test/expected/preproc-variable.c b/src/interfaces/ecpg/test/expected/preproc-variable.c index 37819927477..83761b1f968 100644 --- a/src/interfaces/ecpg/test/expected/preproc-variable.c +++ b/src/interfaces/ecpg/test/expected/preproc-variable.c @@ -25,197 +25,245 @@ #line 6 "variable.pgc" -/* exec sql type c is char reference */ +/* exec sql type c is char reference */ #line 8 "variable.pgc" -typedef char* c; +typedef char *c; -/* exec sql type ind is union { +/* exec sql type ind is union { #line 11 "variable.pgc" - int integer ; - + int integer ; + #line 11 "variable.pgc" - short smallint ; - } */ + short smallint ; + } */ #line 11 "variable.pgc" -typedef union { int integer; short smallint; } ind; +typedef union +{ + int integer; + short smallint; +} ind; #define BUFFERSIZ 8 -/* exec sql type str is [ BUFFERSIZ ] */ +/* exec sql type str is [ BUFFERSIZ ] */ #line 15 "variable.pgc" -/* declare cur cursor for select name , born , age , married , children from family */ +/* declare cur cursor for select name , born , age , married , children from family */ #line 18 "variable.pgc" int -main (void) +main(void) { - struct birthinfo { + struct birthinfo + { #line 23 "variable.pgc" - long born ; - + long born; + #line 23 "variable.pgc" - short age ; - } ; + short age; + }; + #line 23 "variable.pgc" /* exec sql begin declare section */ - - - - - - - + + + + + + + #line 27 "variable.pgc" - struct personal_struct { + struct personal_struct + { #line 25 "variable.pgc" - struct varchar_name { int len; char arr[ BUFFERSIZ ]; } name ; - + struct varchar_name + { + int len; + char arr[BUFFERSIZ]; + } name; + #line 26 "variable.pgc" - struct birthinfo birth ; - } personal , * p ; - + struct birthinfo birth; + } personal, *p; + #line 30 "variable.pgc" - struct personal_indicator { + struct personal_indicator + { #line 28 "variable.pgc" - int ind_name ; - + int ind_name; + #line 29 "variable.pgc" - struct birthinfo ind_birth ; - } ind_personal , * i ; - + struct birthinfo ind_birth; + } ind_personal, *i; + #line 31 "variable.pgc" - ind ind_children ; + ind ind_children; + /* exec sql end declare section */ #line 32 "variable.pgc" - + #line 34 "variable.pgc" - char * married = NULL ; + char *married = NULL; #line 34 "variable.pgc" - + #line 35 "variable.pgc" - long ind_married ; + long ind_married; #line 35 "variable.pgc" - + #line 36 "variable.pgc" - ind children ; + ind children; #line 36 "variable.pgc" - char msg[128]; + char msg[128]; - ECPGdebug(1, stderr); + ECPGdebug(1, stderr); strcpy(msg, "connect"); - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); #line 43 "variable.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 43 "variable.pgc" strcpy(msg, "set"); - { ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT); #line 46 "variable.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 46 "variable.pgc" strcpy(msg, "create"); - { ECPGdo(__LINE__, 0, 1, NULL, "create table family ( name char ( 8 ) , born integer , age smallint , married date , children integer ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table family ( name char ( 8 ) , born integer , age smallint , married date , children integer ) ", ECPGt_EOIT, ECPGt_EORT); #line 49 "variable.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 49 "variable.pgc" strcpy(msg, "insert"); - { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , married , children ) values ( 'Mum' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , married , children ) values ( 'Mum' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT); #line 52 "variable.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 52 "variable.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , born , married , children ) values ( 'Dad' , '19610721' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , born , married , children ) values ( 'Dad' , '19610721' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT); #line 53 "variable.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 53 "variable.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 1' , 16 ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 1' , 16 ) ", ECPGt_EOIT, ECPGt_EORT); #line 54 "variable.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 54 "variable.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 2' , 14 ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 2' , 14 ) ", ECPGt_EOIT, ECPGt_EORT); #line 55 "variable.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 55 "variable.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 3' , 9 ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 3' , 9 ) ", ECPGt_EOIT, ECPGt_EORT); #line 56 "variable.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 56 "variable.pgc" strcpy(msg, "commit"); - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 59 "variable.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 59 "variable.pgc" strcpy(msg, "open"); - { ECPGdo(__LINE__, 0, 1, NULL, "declare cur cursor for select name , born , age , married , children from family ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "declare cur cursor for select name , born , age , married , children from family ", ECPGt_EOIT, ECPGt_EORT); #line 62 "variable.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 62 "variable.pgc" - /* exec sql whenever not found break ; */ + /* exec sql whenever not found break ; */ #line 64 "variable.pgc" - p=&personal; - i=&ind_personal; + p = &personal; + i = &ind_personal; memset(i, 0, sizeof(ind_personal)); - while (1) { + while (1) + { strcpy(msg, "fetch"); - { ECPGdo(__LINE__, 0, 1, NULL, "fetch cur", ECPGt_EOIT, - ECPGt_varchar,&(p->name),(long)BUFFERSIZ,(long)1,sizeof(struct varchar_name), - ECPGt_int,&(i->ind_name),(long)1,(long)1,sizeof(int), - ECPGt_long,&(p->birth.born),(long)1,(long)1,sizeof(long), - ECPGt_long,&(i->ind_birth.born),(long)1,(long)1,sizeof(long), - ECPGt_short,&(p->birth.age),(long)1,(long)1,sizeof(short), - ECPGt_short,&(i->ind_birth.age),(long)1,(long)1,sizeof(short), - ECPGt_char,&(married),(long)0,(long)1,(1)*sizeof(char), - ECPGt_long,&(ind_married),(long)1,(long)1,sizeof(long), - ECPGt_int,&(children.integer),(long)1,(long)1,sizeof(int), - ECPGt_short,&(ind_children.smallint),(long)1,(long)1,sizeof(short), ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "fetch cur", ECPGt_EOIT, + ECPGt_varchar, &(p->name), (long) BUFFERSIZ, (long) 1, sizeof(struct varchar_name), + ECPGt_int, &(i->ind_name), (long) 1, (long) 1, sizeof(int), + ECPGt_long, &(p->birth.born), (long) 1, (long) 1, sizeof(long), + ECPGt_long, &(i->ind_birth.born), (long) 1, (long) 1, sizeof(long), + ECPGt_short, &(p->birth.age), (long) 1, (long) 1, sizeof(short), + ECPGt_short, &(i->ind_birth.age), (long) 1, (long) 1, sizeof(short), + ECPGt_char, &(married), (long) 0, (long) 1, (1) * sizeof(char), + ECPGt_long, &(ind_married), (long) 1, (long) 1, sizeof(long), + ECPGt_int, &(children.integer), (long) 1, (long) 1, sizeof(int), + ECPGt_short, &(ind_children.smallint), (long) 1, (long) 1, sizeof(short), ECPGt_EORT); #line 71 "variable.pgc" -if (sqlca.sqlcode == ECPG_NOT_FOUND) break; + if (sqlca.sqlcode == ECPG_NOT_FOUND) + break; #line 71 "variable.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 71 "variable.pgc" printf("%8.8s", personal.name.arr); @@ -234,34 +282,46 @@ if (sqlca.sqlcode < 0) sqlprint();} } strcpy(msg, "close"); - { ECPGdo(__LINE__, 0, 1, NULL, "close cur", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "close cur", ECPGt_EOIT, ECPGt_EORT); #line 88 "variable.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 88 "variable.pgc" strcpy(msg, "drop"); - { ECPGdo(__LINE__, 0, 1, NULL, "drop table family ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "drop table family ", ECPGt_EOIT, ECPGt_EORT); #line 91 "variable.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 91 "variable.pgc" strcpy(msg, "commit"); - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 94 "variable.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 94 "variable.pgc" - strcpy(msg, "disconnect"); - { ECPGdisconnect(__LINE__, "CURRENT"); + strcpy(msg, "disconnect"); + { + ECPGdisconnect(__LINE__, "CURRENT"); #line 97 "variable.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 97 "variable.pgc" diff --git a/src/interfaces/ecpg/test/expected/preproc-whenever.c b/src/interfaces/ecpg/test/expected/preproc-whenever.c index 79983ce2f3d..270287624d8 100644 --- a/src/interfaces/ecpg/test/expected/preproc-whenever.c +++ b/src/interfaces/ecpg/test/expected/preproc-whenever.c @@ -24,221 +24,288 @@ #line 5 "whenever.pgc" -static void print(char *msg) +static void +print(char *msg) { - fprintf(stderr, "Error in statement '%s':\n", msg); - sqlprint(); + fprintf(stderr, "Error in statement '%s':\n", msg); + sqlprint(); } -static void print2(void) +static void +print2(void) { - fprintf(stderr, "Found another error\n"); - sqlprint(); + fprintf(stderr, "Found another error\n"); + sqlprint(); } -static void warn(void) +static void +warn(void) { - fprintf(stderr, "Warning: At least one column was truncated\n"); + fprintf(stderr, "Warning: At least one column was truncated\n"); } -int main(void) +int +main(void) { - + #line 26 "whenever.pgc" - int i ; + int i; #line 26 "whenever.pgc" - + #line 27 "whenever.pgc" - char c [ 6 ] ; + char c[6]; #line 27 "whenever.pgc" ECPGdebug(1, stderr); - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); #line 31 "whenever.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 31 "whenever.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( i int , c char ( 10 ) ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table test ( i int , c char ( 10 ) ) ", ECPGt_EOIT, ECPGt_EORT); #line 32 "whenever.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 32 "whenever.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values ( 1 , 'abcdefghij' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test values ( 1 , 'abcdefghij' ) ", ECPGt_EOIT, ECPGt_EORT); #line 33 "whenever.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 33 "whenever.pgc" /* exec sql whenever sql_warning do warn ( ) ; */ #line 35 "whenever.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select * from test ", ECPGt_EOIT, - ECPGt_int,&(i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(c),(long)6,(long)1,(6)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select * from test ", ECPGt_EOIT, + ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, (c), (long) 6, (long) 1, (6) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 36 "whenever.pgc" -if (sqlca.sqlwarn[0] == 'W') warn ( ); + if (sqlca.sqlwarn[0] == 'W') + warn(); #line 36 "whenever.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 36 "whenever.pgc" - { ECPGtrans(__LINE__, NULL, "rollback"); + { + ECPGtrans(__LINE__, NULL, "rollback"); #line 37 "whenever.pgc" -if (sqlca.sqlwarn[0] == 'W') warn ( ); + if (sqlca.sqlwarn[0] == 'W') + warn(); #line 37 "whenever.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 37 "whenever.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, - ECPGt_int,&(i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, + ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 39 "whenever.pgc" -if (sqlca.sqlwarn[0] == 'W') warn ( ); + if (sqlca.sqlwarn[0] == 'W') + warn(); #line 39 "whenever.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 39 "whenever.pgc" - { ECPGtrans(__LINE__, NULL, "rollback"); + { + ECPGtrans(__LINE__, NULL, "rollback"); #line 40 "whenever.pgc" -if (sqlca.sqlwarn[0] == 'W') warn ( ); + if (sqlca.sqlwarn[0] == 'W') + warn(); #line 40 "whenever.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 40 "whenever.pgc" /* exec sql whenever sqlerror do print ( \"select\" ) ; */ #line 42 "whenever.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, - ECPGt_int,&(i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, + ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 43 "whenever.pgc" -if (sqlca.sqlwarn[0] == 'W') warn ( ); + if (sqlca.sqlwarn[0] == 'W') + warn(); #line 43 "whenever.pgc" -if (sqlca.sqlcode < 0) print ( "select" );} + if (sqlca.sqlcode < 0) + print("select"); + } #line 43 "whenever.pgc" - { ECPGtrans(__LINE__, NULL, "rollback"); + { + ECPGtrans(__LINE__, NULL, "rollback"); #line 44 "whenever.pgc" -if (sqlca.sqlwarn[0] == 'W') warn ( ); + if (sqlca.sqlwarn[0] == 'W') + warn(); #line 44 "whenever.pgc" -if (sqlca.sqlcode < 0) print ( "select" );} + if (sqlca.sqlcode < 0) + print("select"); + } #line 44 "whenever.pgc" /* exec sql whenever sqlerror call print2 ( ) ; */ #line 46 "whenever.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, - ECPGt_int,&(i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, + ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 47 "whenever.pgc" -if (sqlca.sqlwarn[0] == 'W') warn ( ); + if (sqlca.sqlwarn[0] == 'W') + warn(); #line 47 "whenever.pgc" -if (sqlca.sqlcode < 0) print2 ( );} + if (sqlca.sqlcode < 0) + print2(); + } #line 47 "whenever.pgc" - { ECPGtrans(__LINE__, NULL, "rollback"); + { + ECPGtrans(__LINE__, NULL, "rollback"); #line 48 "whenever.pgc" -if (sqlca.sqlwarn[0] == 'W') warn ( ); + if (sqlca.sqlwarn[0] == 'W') + warn(); #line 48 "whenever.pgc" -if (sqlca.sqlcode < 0) print2 ( );} + if (sqlca.sqlcode < 0) + print2(); + } #line 48 "whenever.pgc" /* exec sql whenever sqlerror continue ; */ #line 50 "whenever.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, - ECPGt_int,&(i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, + ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 51 "whenever.pgc" -if (sqlca.sqlwarn[0] == 'W') warn ( );} + if (sqlca.sqlwarn[0] == 'W') + warn(); + } #line 51 "whenever.pgc" - { ECPGtrans(__LINE__, NULL, "rollback"); + { + ECPGtrans(__LINE__, NULL, "rollback"); #line 52 "whenever.pgc" -if (sqlca.sqlwarn[0] == 'W') warn ( );} + if (sqlca.sqlwarn[0] == 'W') + warn(); + } #line 52 "whenever.pgc" /* exec sql whenever sqlerror goto error ; */ #line 54 "whenever.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, - ECPGt_int,&(i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, + ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 55 "whenever.pgc" -if (sqlca.sqlwarn[0] == 'W') warn ( ); + if (sqlca.sqlwarn[0] == 'W') + warn(); #line 55 "whenever.pgc" -if (sqlca.sqlcode < 0) goto error;} + if (sqlca.sqlcode < 0) + goto error; + } #line 55 "whenever.pgc" printf("Should not be reachable\n"); - error: - { ECPGtrans(__LINE__, NULL, "rollback"); +error: + { + ECPGtrans(__LINE__, NULL, "rollback"); #line 59 "whenever.pgc" -if (sqlca.sqlwarn[0] == 'W') warn ( ); + if (sqlca.sqlwarn[0] == 'W') + warn(); #line 59 "whenever.pgc" -if (sqlca.sqlcode < 0) goto error;} + if (sqlca.sqlcode < 0) + goto error; + } #line 59 "whenever.pgc" /* exec sql whenever sqlerror stop ; */ #line 61 "whenever.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, - ECPGt_int,&(i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select * from nonexistant ", ECPGt_EOIT, + ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 62 "whenever.pgc" -if (sqlca.sqlwarn[0] == 'W') warn ( ); + if (sqlca.sqlwarn[0] == 'W') + warn(); #line 62 "whenever.pgc" -if (sqlca.sqlcode < 0) exit (1);} + if (sqlca.sqlcode < 0) + exit(1); + } #line 62 "whenever.pgc" - { ECPGtrans(__LINE__, NULL, "rollback"); + { + ECPGtrans(__LINE__, NULL, "rollback"); #line 63 "whenever.pgc" -if (sqlca.sqlwarn[0] == 'W') warn ( ); + if (sqlca.sqlwarn[0] == 'W') + warn(); #line 63 "whenever.pgc" -if (sqlca.sqlcode < 0) exit (1);} + if (sqlca.sqlcode < 0) + exit(1); + } #line 63 "whenever.pgc" - exit (0); -} + exit(0); +} diff --git a/src/interfaces/ecpg/test/expected/sql-array.c b/src/interfaces/ecpg/test/expected/sql-array.c index 87ec88f985a..8b7dec49e79 100644 --- a/src/interfaces/ecpg/test/expected/sql-array.c +++ b/src/interfaces/ecpg/test/expected/sql-array.c @@ -81,7 +81,6 @@ struct sqlca_t *ECPGget_sqlca(void); #ifdef __cplusplus } #endif - #endif #line 7 "array.pgc" @@ -98,33 +97,34 @@ struct sqlca_t *ECPGget_sqlca(void); int -main (void) +main(void) { /* exec sql begin declare section */ - - - - - - + + + + + + #line 14 "array.pgc" - int i = 1 ; - + int i = 1; + #line 15 "array.pgc" - int * did = & i ; - + int *did = &i; + #line 16 "array.pgc" - int a [ 10 ] = { 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 } ; - + int a[10] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; + #line 17 "array.pgc" - char text [ 25 ] = "klmnopqrst" ; - + char text [25] = "klmnopqrst"; + #line 18 "array.pgc" - char * t = ( char * ) malloc ( 11 ) ; - + char *t = (char *) malloc(11); + #line 19 "array.pgc" - double f ; + double f; + /* exec sql end declare section */ #line 20 "array.pgc" @@ -134,103 +134,136 @@ main (void) ECPGdebug(1, stderr); - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); #line 27 "array.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 27 "array.pgc" - { ECPGsetcommit(__LINE__, "on", NULL); + { + ECPGsetcommit(__LINE__, "on", NULL); #line 29 "array.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 29 "array.pgc" - { ECPGtrans(__LINE__, NULL, "begin transaction "); + { + ECPGtrans(__LINE__, NULL, "begin transaction "); #line 31 "array.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 31 "array.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( f float , i int , a int [ 10 ] , text char ( 10 ) ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table test ( f float , i int , a int [ 10 ] , text char ( 10 ) ) ", ECPGt_EOIT, ECPGt_EORT); #line 33 "array.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 33 "array.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f , i , a , text ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f , i , a , text ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' ) ", ECPGt_EOIT, ECPGt_EORT); #line 35 "array.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 35 "array.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f , i , a , text ) values ( 140787.0 , 2 , ? , ? ) ", - ECPGt_int,(a),(long)1,(long)10,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f , i , a , text ) values ( 140787.0 , 2 , ? , ? ) ", + ECPGt_int, (a), (long) 1, (long) 10, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, (text), (long) 25, (long) 1, (25) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 37 "array.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 37 "array.pgc" - - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f , i , a , text ) values ( 14.07 , ? , ? , ? ) ", - ECPGt_int,&(did),(long)1,(long)0,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_int,(a),(long)1,(long)10,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f , i , a , text ) values ( 14.07 , ? , ? , ? ) ", + ECPGt_int, &(did), (long) 1, (long) 0, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_int, (a), (long) 1, (long) 10, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, &(t), (long) 0, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 39 "array.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 39 "array.pgc" - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 41 "array.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 41 "array.pgc" - { ECPGtrans(__LINE__, NULL, "begin transaction "); + { + ECPGtrans(__LINE__, NULL, "begin transaction "); #line 43 "array.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 43 "array.pgc" - - { ECPGdo(__LINE__, 0, 1, NULL, "select f , text from test where i = 1 ", ECPGt_EOIT, - ECPGt_double,&(f),(long)1,(long)1,sizeof(double), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + + { + ECPGdo(__LINE__, 0, 1, NULL, "select f , text from test where i = 1 ", ECPGt_EOIT, + ECPGt_double, &(f), (long) 1, (long) 1, sizeof(double), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, (text), (long) 25, (long) 1, (25) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 48 "array.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 48 "array.pgc" printf("Found f=%f text=%10.10s\n", f, text); - f=140787; - { ECPGdo(__LINE__, 0, 1, NULL, "select a , text from test where f = ? ", - ECPGt_double,&(f),(long)1,(long)1,sizeof(double), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_int,(a),(long)1,(long)10,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + f = 140787; + { + ECPGdo(__LINE__, 0, 1, NULL, "select a , text from test where f = ? ", + ECPGt_double, &(f), (long) 1, (long) 1, sizeof(double), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int, (a), (long) 1, (long) 10, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, &(t), (long) 0, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 56 "array.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 56 "array.pgc" @@ -239,37 +272,49 @@ if (sqlca.sqlcode < 0) sqlprint();} printf("Found text=%10.10s\n", t); - { ECPGdo(__LINE__, 0, 1, NULL, "select a from test where f = ? ", - ECPGt_double,&(f),(long)1,(long)1,sizeof(double), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select a from test where f = ? ", + ECPGt_double, &(f), (long) 1, (long) 1, sizeof(double), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char, (text), (long) 25, (long) 1, (25) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 66 "array.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 66 "array.pgc" printf("Found text=%s\n", text); - { ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT); #line 70 "array.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 70 "array.pgc" - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 72 "array.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 72 "array.pgc" - { ECPGdisconnect(__LINE__, "CURRENT"); + { + ECPGdisconnect(__LINE__, "CURRENT"); #line 74 "array.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 74 "array.pgc" diff --git a/src/interfaces/ecpg/test/expected/sql-binary.c b/src/interfaces/ecpg/test/expected/sql-binary.c index deb0220d44f..ae444253f7a 100644 --- a/src/interfaces/ecpg/test/expected/sql-binary.c +++ b/src/interfaces/ecpg/test/expected/sql-binary.c @@ -22,143 +22,174 @@ /* exec sql begin declare section */ - - - - - -struct TBempl { + + + + + +struct TBempl +{ #line 9 "binary.pgc" - long idnum ; - + long idnum; + #line 10 "binary.pgc" - char name [ 21 ] ; - + char name[21]; + #line 11 "binary.pgc" - short accs ; - + short accs; + #line 12 "binary.pgc" - char byte [ 20 ] ; - } ;/* exec sql end declare section */ + char byte[20]; +}; /* exec sql end declare section */ + #line 14 "binary.pgc" int -main (void) +main(void) { - /* exec sql begin declare section */ - - - + /* exec sql begin declare section */ + + + #line 20 "binary.pgc" - struct TBempl empl ; - + struct TBempl empl; + #line 21 "binary.pgc" - char * data = "\\001\\155\\000\\212" ; + char *data = "\\001\\155\\000\\212"; + /* exec sql end declare section */ #line 22 "binary.pgc" - int i; + int i; - ECPGdebug (1, stderr); + ECPGdebug(1, stderr); - empl.idnum = 1; - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); } + empl.idnum = 1; + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); + } #line 28 "binary.pgc" - if (sqlca.sqlcode) - { - printf ("connect error = %ld\n", sqlca.sqlcode); - exit (sqlca.sqlcode); - } + if (sqlca.sqlcode) + { + printf("connect error = %ld\n", sqlca.sqlcode); + exit(sqlca.sqlcode); + } - { ECPGdo(__LINE__, 0, 1, NULL, "create table empl ( idnum integer , name char ( 20 ) , accs smallint , byte bytea ) ", ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "create table empl ( idnum integer , name char ( 20 ) , accs smallint , byte bytea ) ", ECPGt_EOIT, ECPGt_EORT); + } #line 36 "binary.pgc" - if (sqlca.sqlcode) - { - printf ("create error = %ld\n", sqlca.sqlcode); - exit (sqlca.sqlcode); - } - - { ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values ( 1 , 'first user' , 320 , ? ) ", - ECPGt_char,&(data),(long)0,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} + if (sqlca.sqlcode) + { + printf("create error = %ld\n", sqlca.sqlcode); + exit(sqlca.sqlcode); + } + + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values ( 1 , 'first user' , 320 , ? ) ", + ECPGt_char, &(data), (long) 0, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + } #line 43 "binary.pgc" - if (sqlca.sqlcode) - { - printf ("insert error = %ld\n", sqlca.sqlcode); - exit (sqlca.sqlcode); - } + if (sqlca.sqlcode) + { + printf("insert error = %ld\n", sqlca.sqlcode); + exit(sqlca.sqlcode); + } - /* declare C cursor for select name , accs , byte from empl where idnum = ? */ + /* + * declare C cursor for select name , accs , byte from empl where + * idnum = ? + */ #line 50 "binary.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "declare C cursor for select name , accs , byte from empl where idnum = ? ", - ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "declare C cursor for select name , accs , byte from empl where idnum = ? ", + ECPGt_long, &(empl.idnum), (long) 1, (long) 1, sizeof(long), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + } #line 51 "binary.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "fetch C", ECPGt_EOIT, - ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "fetch C", ECPGt_EOIT, + ECPGt_char, (empl.name), (long) 21, (long) 1, (21) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_short, &(empl.accs), (long) 1, (long) 1, sizeof(short), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, (empl.byte), (long) 20, (long) 1, (20) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); + } #line 52 "binary.pgc" - if (sqlca.sqlcode) - { - printf ("fetch error = %ld\n", sqlca.sqlcode); - exit (sqlca.sqlcode); - } + if (sqlca.sqlcode) + { + printf("fetch error = %ld\n", sqlca.sqlcode); + exit(sqlca.sqlcode); + } + + printf("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte); - printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte); + memset(empl.name, 0, 21L); + memset(empl.byte, '#', 20L); - memset(empl.name, 0, 21L); - memset(empl.byte, '#', 20L); - /* declare B binary cursor for select name , accs , byte from empl where idnum = ? */ + /* + * declare B binary cursor for select name , accs , byte from empl + * where idnum = ? + */ #line 63 "binary.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "declare B binary cursor for select name , accs , byte from empl where idnum = ? ", - ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "declare B binary cursor for select name , accs , byte from empl where idnum = ? ", + ECPGt_long, &(empl.idnum), (long) 1, (long) 1, sizeof(long), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + } #line 64 "binary.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "fetch B", ECPGt_EOIT, - ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "fetch B", ECPGt_EOIT, + ECPGt_char, (empl.name), (long) 21, (long) 1, (21) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_short, &(empl.accs), (long) 1, (long) 1, sizeof(short), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, (empl.byte), (long) 20, (long) 1, (20) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); + } #line 65 "binary.pgc" - if (sqlca.sqlcode) - { - printf ("fetch error = %ld\n", sqlca.sqlcode); - exit (sqlca.sqlcode); - } + if (sqlca.sqlcode) + { + printf("fetch error = %ld\n", sqlca.sqlcode); + exit(sqlca.sqlcode); + } - { ECPGdo(__LINE__, 0, 1, NULL, "close B", ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "close B", ECPGt_EOIT, ECPGt_EORT); + } #line 72 "binary.pgc" - /* do not print a.accs because big/little endian will have different outputs here */ - printf ("name=%s, byte=", empl.name); - for (i=0; i<20; i++) - { - if (empl.byte[i] == '#') - break; - printf("(%o)", (unsigned char)empl.byte[i]); - } - printf("\n"); - { ECPGdisconnect(__LINE__, "CURRENT");} + /* + * do not print a.accs because big/little endian will have different + * outputs here + */ + printf("name=%s, byte=", empl.name); + for (i = 0; i < 20; i++) + { + if (empl.byte[i] == '#') + break; + printf("(%o)", (unsigned char) empl.byte[i]); + } + printf("\n"); + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 83 "binary.pgc" - exit (0); + exit(0); } diff --git a/src/interfaces/ecpg/test/expected/sql-code100.c b/src/interfaces/ecpg/test/expected/sql-code100.c index 88bb07925a9..036672ff230 100644 --- a/src/interfaces/ecpg/test/expected/sql-code100.c +++ b/src/interfaces/ecpg/test/expected/sql-code100.c @@ -73,7 +73,6 @@ struct sqlca_t *ECPGget_sqlca(void); #ifdef __cplusplus } #endif - #endif #line 1 "code100.pgc" @@ -92,73 +91,109 @@ struct sqlca_t *ECPGget_sqlca(void); -int main(int argc, char **argv) -{ /* exec sql begin declare section */ - - +int +main(int argc, char **argv) +{ /* exec sql begin declare section */ + + #line 9 "code100.pgc" - int index ; + int index; + /* exec sql end declare section */ #line 10 "code100.pgc" - ECPGdebug(1,stderr); - - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); } + ECPGdebug(1, stderr); + + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); + } #line 15 "code100.pgc" - if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); + if (sqlca.sqlcode) + printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); - { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( \"index\" numeric ( 3 ) primary key , \"payload\" int4 not null ) ", ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "create table test ( \"index\" numeric ( 3 ) primary key , \"payload\" int4 not null ) ", ECPGt_EOIT, ECPGt_EORT); + } #line 20 "code100.pgc" - if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); - { ECPGtrans(__LINE__, NULL, "commit");} + if (sqlca.sqlcode) + printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + { + ECPGtrans(__LINE__, NULL, "commit"); + } #line 22 "code100.pgc" - if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); - - for (index=0;index<10;++index) - { { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( payload , index ) values( 0 , ? ) ", - ECPGt_int,&(index),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} + if (sqlca.sqlcode) + printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + + for (index = 0; index < 10; ++index) + { + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( payload , index ) values( 0 , ? ) ", + ECPGt_int, &(index), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + } #line 28 "code100.pgc" - if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); - } - { ECPGtrans(__LINE__, NULL, "commit");} + if (sqlca.sqlcode) + printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + } + { + ECPGtrans(__LINE__, NULL, "commit"); + } #line 31 "code100.pgc" - if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); - - { ECPGdo(__LINE__, 0, 1, NULL, "update test set payload = payload + 1 where index = - 1 ", ECPGt_EOIT, ECPGt_EORT);} + if (sqlca.sqlcode) + printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + + { + ECPGdo(__LINE__, 0, 1, NULL, "update test set payload = payload + 1 where index = - 1 ", ECPGt_EOIT, ECPGt_EORT); + } #line 35 "code100.pgc" - if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); - - { ECPGdo(__LINE__, 0, 1, NULL, "delete from test where index = - 1 ", ECPGt_EOIT, ECPGt_EORT);} + if (sqlca.sqlcode != 100) + printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + + { + ECPGdo(__LINE__, 0, 1, NULL, "delete from test where index = - 1 ", ECPGt_EOIT, ECPGt_EORT); + } #line 38 "code100.pgc" - if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); + if (sqlca.sqlcode != 100) + printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( select * from test where index = - 1 ) ", ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( select * from test where index = - 1 ) ", ECPGt_EOIT, ECPGt_EORT); + } #line 41 "code100.pgc" - if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); + if (sqlca.sqlcode != 100) + printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); - { ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT); + } #line 44 "code100.pgc" - if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); - { ECPGtrans(__LINE__, NULL, "commit");} + if (sqlca.sqlcode) + printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + { + ECPGtrans(__LINE__, NULL, "commit"); + } #line 46 "code100.pgc" - if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); - - { ECPGdisconnect(__LINE__, "CURRENT");} + if (sqlca.sqlcode) + printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 49 "code100.pgc" - if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); - return 0; + if (sqlca.sqlcode) + printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + return 0; } diff --git a/src/interfaces/ecpg/test/expected/sql-copystdout.c b/src/interfaces/ecpg/test/expected/sql-copystdout.c index 8e144528728..83444f801b7 100644 --- a/src/interfaces/ecpg/test/expected/sql-copystdout.c +++ b/src/interfaces/ecpg/test/expected/sql-copystdout.c @@ -75,7 +75,6 @@ struct sqlca_t *ECPGget_sqlca(void); #ifdef __cplusplus } #endif - #endif #line 3 "copystdout.pgc" @@ -96,7 +95,7 @@ struct sqlca_t *ECPGget_sqlca(void); int -main () +main() { /* EXEC SQL BEGIN DECLARE SECTION; @@ -104,57 +103,78 @@ main () EXEC SQL END DECLARE SECTION; */ - ECPGdebug (1, stderr); + ECPGdebug(1, stderr); - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); #line 19 "copystdout.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 19 "copystdout.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table foo ( a int , b varchar ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table foo ( a int , b varchar ) ", ECPGt_EOIT, ECPGt_EORT); #line 20 "copystdout.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 20 "copystdout.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values( 5 , 'abc' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values( 5 , 'abc' ) ", ECPGt_EOIT, ECPGt_EORT); #line 21 "copystdout.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 21 "copystdout.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values( 6 , 'def' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values( 6 , 'def' ) ", ECPGt_EOIT, ECPGt_EORT); #line 22 "copystdout.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 22 "copystdout.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values( 7 , 'ghi' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values( 7 , 'ghi' ) ", ECPGt_EOIT, ECPGt_EORT); #line 23 "copystdout.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 23 "copystdout.pgc" - /* produces expected file "/tmp/foo" */ - /* EXEC SQL COPY foo TO:fname WITH DELIMITER ','; */ - /* printf ("copy to /tmp/foo : sqlca.sqlcode = %ld", sqlca.sqlcode); */ + /* produces expected file "/tmp/foo" */ + /* EXEC SQL COPY foo TO:fname WITH DELIMITER ','; */ + /* printf ("copy to /tmp/foo : sqlca.sqlcode = %ld", sqlca.sqlcode); */ - { ECPGdo(__LINE__, 0, 1, NULL, "copy foo to stdout with delimiter ','", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "copy foo to stdout with delimiter ','", ECPGt_EOIT, ECPGt_EORT); #line 29 "copystdout.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 29 "copystdout.pgc" - printf ("copy to STDOUT : sqlca.sqlcode = %ld\n", sqlca.sqlcode); + printf("copy to STDOUT : sqlca.sqlcode = %ld\n", sqlca.sqlcode); - { ECPGdisconnect(__LINE__, "CURRENT"); + { + ECPGdisconnect(__LINE__, "CURRENT"); #line 32 "copystdout.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 32 "copystdout.pgc" - return 0; + return 0; } diff --git a/src/interfaces/ecpg/test/expected/sql-define.c b/src/interfaces/ecpg/test/expected/sql-define.c index 44cd13bedb3..ed8dfb56816 100644 --- a/src/interfaces/ecpg/test/expected/sql-define.c +++ b/src/interfaces/ecpg/test/expected/sql-define.c @@ -73,7 +73,6 @@ struct sqlca_t *ECPGget_sqlca(void); #ifdef __cplusplus } #endif - #endif #line 1 "define.pgc" @@ -92,114 +91,143 @@ struct sqlca_t *ECPGget_sqlca(void); -int main(void) +int +main(void) { - /* exec sql begin declare section */ - - - + /* exec sql begin declare section */ + + + #line 10 "define.pgc" - int i ; - + int i; + #line 11 "define.pgc" - char s [ 200 ] ; + char s[200]; + /* exec sql end declare section */ #line 12 "define.pgc" - ECPGdebug(1, stderr); + ECPGdebug(1, stderr); - /* exec sql whenever sqlerror do sqlprint ( ) ; */ + /* exec sql whenever sqlerror do sqlprint ( ) ; */ #line 16 "define.pgc" - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); #line 17 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 17 "define.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( a int , b text ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table test ( a int , b text ) ", ECPGt_EOIT, ECPGt_EORT); #line 19 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 19 "define.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 29 , 'abcdef' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 29 , 'abcdef' ) ", ECPGt_EOIT, ECPGt_EORT); #line 20 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 20 "define.pgc" - - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( null , 'defined' ) ", ECPGt_EOIT, ECPGt_EORT); + + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( null , 'defined' ) ", ECPGt_EOIT, ECPGt_EORT); #line 23 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 23 "define.pgc" - - - - - - - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( null , 'someothervar not defined' ) ", ECPGt_EOIT, ECPGt_EORT); + + + + + + + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( null , 'someothervar not defined' ) ", ECPGt_EOIT, ECPGt_EORT); #line 31 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 31 "define.pgc" - - - { ECPGdo(__LINE__, 0, 1, NULL, "select 1 , 29 :: text || '-' || 'abcdef' ", ECPGt_EOIT, - ECPGt_int,&(i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(s),(long)200,(long)1,(200)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + + + { + ECPGdo(__LINE__, 0, 1, NULL, "select 1 , 29 :: text || '-' || 'abcdef' ", ECPGt_EOIT, + ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, (s), (long) 200, (long) 1, (200) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 36 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 36 "define.pgc" - printf("i: %d, s: %s\n", i, s); + printf("i: %d, s: %s\n", i, s); + - - - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 29 , 'no string' ) ", ECPGt_EOIT, ECPGt_EORT); + + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 29 , 'no string' ) ", ECPGt_EOIT, ECPGt_EORT); #line 42 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 42 "define.pgc" - - /* no value */ - - - - - - - { ECPGdo(__LINE__, 0, 1, NULL, "set TIMEZONE to 'UTC'", ECPGt_EOIT, ECPGt_EORT); + /* no value */ + + + + + + + + { + ECPGdo(__LINE__, 0, 1, NULL, "set TIMEZONE to 'UTC'", ECPGt_EOIT, ECPGt_EORT); #line 53 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 53 "define.pgc" - - { ECPGdisconnect(__LINE__, "CURRENT"); + + { + ECPGdisconnect(__LINE__, "CURRENT"); #line 56 "define.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 56 "define.pgc" - return 0; + return 0; } diff --git a/src/interfaces/ecpg/test/expected/sql-desc.c b/src/interfaces/ecpg/test/expected/sql-desc.c index d1c776fca1d..c54e67ee7ee 100644 --- a/src/interfaces/ecpg/test/expected/sql-desc.c +++ b/src/interfaces/ecpg/test/expected/sql-desc.c @@ -25,39 +25,43 @@ int main(void) { /* exec sql begin declare section */ - - - - - - - - - - + + + + + + + + + + #line 8 "desc.pgc" - char * stmt1 = "INSERT INTO test1 VALUES (?, ?)" ; - + char *stmt1 = "INSERT INTO test1 VALUES (?, ?)"; + #line 9 "desc.pgc" - char * stmt2 = "SELECT * from test1 where a = ? and b = ?" ; - + char *stmt2 = "SELECT * from test1 where a = ? and b = ?"; + #line 10 "desc.pgc" - char * stmt3 = "SELECT * from test1 where a = ?" ; - + char *stmt3 = "SELECT * from test1 where a = ?"; + #line 12 "desc.pgc" - int val1 = 1 ; - + int val1 = 1; + #line 13 "desc.pgc" - char val2 [ 4 ] = "one" , val2output [] = "AAA" ; - + char val2[4] = "one", + val2output[] = "AAA"; + #line 14 "desc.pgc" - int val1output = 2 , val2i = 0 ; - + int val1output = 2, + val2i = 0; + #line 15 "desc.pgc" - int val2null = - 1 ; - + int val2null = -1; + #line 16 "desc.pgc" - int ind1 , ind2 ; + int ind1, + ind2; + /* exec sql end declare section */ #line 17 "desc.pgc" @@ -67,172 +71,228 @@ main(void) ECPGallocate_desc(__LINE__, "indesc"); #line 21 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint(); + if (sqlca.sqlcode < 0) + sqlprint(); #line 21 "desc.pgc" ECPGallocate_desc(__LINE__, "outdesc"); #line 22 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint(); + if (sqlca.sqlcode < 0) + sqlprint(); #line 22 "desc.pgc" - { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data, - ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT); + { + ECPGset_desc(__LINE__, "indesc", 1, ECPGd_data, + ECPGt_int, &(val1), (long) 1, (long) 1, sizeof(int), ECPGd_EODT); #line 24 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 24 "desc.pgc" - { ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data, - ECPGt_char,(val2),(long)4,(long)1,(4)*sizeof(char), ECPGd_indicator, - ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGd_EODT); + { + ECPGset_desc(__LINE__, "indesc", 2, ECPGd_data, + ECPGt_char, (val2), (long) 4, (long) 1, (4) * sizeof(char), ECPGd_indicator, + ECPGt_int, &(val2i), (long) 1, (long) 1, sizeof(int), ECPGd_EODT); #line 25 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 25 "desc.pgc" - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); #line 27 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 27 "desc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table test1 ( a int , b text ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table test1 ( a int , b text ) ", ECPGt_EOIT, ECPGt_EORT); #line 29 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 29 "desc.pgc" - { ECPGprepare(__LINE__, "foo1" , stmt1); + { + ECPGprepare(__LINE__, "foo1", stmt1); #line 30 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 30 "desc.pgc" - { ECPGprepare(__LINE__, "foo2" , stmt2); + { + ECPGprepare(__LINE__, "foo2", stmt2); #line 31 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 31 "desc.pgc" - { ECPGprepare(__LINE__, "foo3" , stmt3); + { + ECPGprepare(__LINE__, "foo3", stmt3); #line 32 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 32 "desc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "?", - ECPGt_char_variable,(ECPGprepared_statement("foo1")),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_descriptor, "indesc", 0L, 0L, 0L, - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "?", + ECPGt_char_variable, (ECPGprepared_statement("foo1")), (long) 1, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_descriptor, "indesc", 0L, 0L, 0L, + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 34 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 34 "desc.pgc" - { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data, - ECPGt_const,"2",(long)1,(long)1,strlen("2"), ECPGd_EODT); + { + ECPGset_desc(__LINE__, "indesc", 1, ECPGd_data, + ECPGt_const, "2", (long) 1, (long) 1, strlen("2"), ECPGd_EODT); #line 36 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 36 "desc.pgc" - { ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data, - ECPGt_char,(val2),(long)4,(long)1,(4)*sizeof(char), ECPGd_indicator, - ECPGt_int,&(val2null),(long)1,(long)1,sizeof(int), ECPGd_EODT); + { + ECPGset_desc(__LINE__, "indesc", 2, ECPGd_data, + ECPGt_char, (val2), (long) 4, (long) 1, (4) * sizeof(char), ECPGd_indicator, + ECPGt_int, &(val2null), (long) 1, (long) 1, sizeof(int), ECPGd_EODT); #line 37 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 37 "desc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "?", - ECPGt_char_variable,(ECPGprepared_statement("foo1")),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_descriptor, "indesc", 0L, 0L, 0L, - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "?", + ECPGt_char_variable, (ECPGprepared_statement("foo1")), (long) 1, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_descriptor, "indesc", 0L, 0L, 0L, + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 39 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 39 "desc.pgc" - { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data, - ECPGt_const,"3",(long)1,(long)1,strlen("3"), ECPGd_EODT); + { + ECPGset_desc(__LINE__, "indesc", 1, ECPGd_data, + ECPGt_const, "3", (long) 1, (long) 1, strlen("3"), ECPGd_EODT); #line 41 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 41 "desc.pgc" - { ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data, - ECPGt_const,"this is a long test",(long)19,(long)1,strlen("this is a long test"), ECPGd_indicator, - ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT); + { + ECPGset_desc(__LINE__, "indesc", 2, ECPGd_data, + ECPGt_const, "this is a long test", (long) 19, (long) 1, strlen("this is a long test"), ECPGd_indicator, + ECPGt_int, &(val1), (long) 1, (long) 1, sizeof(int), ECPGd_EODT); #line 42 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 42 "desc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "?", - ECPGt_char_variable,(ECPGprepared_statement("foo1")),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_descriptor, "indesc", 0L, 0L, 0L, - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "?", + ECPGt_char_variable, (ECPGprepared_statement("foo1")), (long) 1, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_descriptor, "indesc", 0L, 0L, 0L, + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 44 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 44 "desc.pgc" - { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data, - ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT); + { + ECPGset_desc(__LINE__, "indesc", 1, ECPGd_data, + ECPGt_int, &(val1), (long) 1, (long) 1, sizeof(int), ECPGd_EODT); #line 46 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 46 "desc.pgc" - { ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data, - ECPGt_char,(val2),(long)4,(long)1,(4)*sizeof(char), ECPGd_indicator, - ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGd_EODT); + { + ECPGset_desc(__LINE__, "indesc", 2, ECPGd_data, + ECPGt_char, (val2), (long) 4, (long) 1, (4) * sizeof(char), ECPGd_indicator, + ECPGt_int, &(val2i), (long) 1, (long) 1, sizeof(int), ECPGd_EODT); #line 47 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 47 "desc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "?", - ECPGt_char_variable,(ECPGprepared_statement("foo2")),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_descriptor, "indesc", 0L, 0L, 0L, - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_descriptor, "outdesc", 0L, 0L, 0L, - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "?", + ECPGt_char_variable, (ECPGprepared_statement("foo2")), (long) 1, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_descriptor, "indesc", 0L, 0L, 0L, + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_descriptor, "outdesc", 0L, 0L, 0L, + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 49 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 49 "desc.pgc" - { ECPGget_desc(__LINE__, "outdesc", 1,ECPGd_data, - ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), ECPGd_EODT); + { + ECPGget_desc(__LINE__, "outdesc", 1, ECPGd_data, + ECPGt_char, (val2output), (long) sizeof("AAA"), (long) 1, (sizeof("AAA")) *sizeof(char), ECPGd_EODT); #line 51 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 51 "desc.pgc" printf("output = %s\n", val2output); @@ -240,121 +300,156 @@ if (sqlca.sqlcode < 0) sqlprint();} /* declare c1 cursor for ? */ #line 54 "desc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "declare c1 cursor for ?", - ECPGt_char_variable,(ECPGprepared_statement("foo2")),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_descriptor, "indesc", 0L, 0L, 0L, - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "declare c1 cursor for ?", + ECPGt_char_variable, (ECPGprepared_statement("foo2")), (long) 1, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_descriptor, "indesc", 0L, 0L, 0L, + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 55 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 55 "desc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c1", ECPGt_EOIT, - ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), - ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int), - ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), - ECPGt_int,&(ind2),(long)1,(long)1,sizeof(int), ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c1", ECPGt_EOIT, + ECPGt_int, &(val1output), (long) 1, (long) 1, sizeof(int), + ECPGt_int, &(ind1), (long) 1, (long) 1, sizeof(int), + ECPGt_char, (val2output), (long) sizeof("AAA"), (long) 1, (sizeof("AAA")) *sizeof(char), + ECPGt_int, &(ind2), (long) 1, (long) 1, sizeof(int), ECPGt_EORT); #line 57 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 57 "desc.pgc" printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n", - val1output, ind1, val2output, ind2); + val1output, ind1, val2output, ind2); - { ECPGdo(__LINE__, 0, 1, NULL, "close c1", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "close c1", ECPGt_EOIT, ECPGt_EORT); #line 61 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 61 "desc.pgc" - { ECPGset_desc_header(__LINE__, "indesc", (int)(1)); + { + ECPGset_desc_header(__LINE__, "indesc", (int) (1)); #line 63 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 63 "desc.pgc" - { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data, - ECPGt_const,"2",(long)1,(long)1,strlen("2"), ECPGd_EODT); + { + ECPGset_desc(__LINE__, "indesc", 1, ECPGd_data, + ECPGt_const, "2", (long) 1, (long) 1, strlen("2"), ECPGd_EODT); #line 64 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 64 "desc.pgc" /* declare c2 cursor for ? */ #line 66 "desc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "declare c2 cursor for ?", - ECPGt_char_variable,(ECPGprepared_statement("foo3")),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_descriptor, "indesc", 0L, 0L, 0L, - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "declare c2 cursor for ?", + ECPGt_char_variable, (ECPGprepared_statement("foo3")), (long) 1, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_descriptor, "indesc", 0L, 0L, 0L, + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 67 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 67 "desc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c2", ECPGt_EOIT, - ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), - ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c2", ECPGt_EOIT, + ECPGt_int, &(val1output), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, (val2output), (long) sizeof("AAA"), (long) 1, (sizeof("AAA")) *sizeof(char), + ECPGt_int, &(val2i), (long) 1, (long) 1, sizeof(int), ECPGt_EORT); #line 69 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 69 "desc.pgc" printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output); - { ECPGdo(__LINE__, 0, 1, NULL, "close c2", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "close c2", ECPGt_EOIT, ECPGt_EORT); #line 72 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 72 "desc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select * from test1 where a = 3 ", ECPGt_EOIT, - ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), - ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select * from test1 where a = 3 ", ECPGt_EOIT, + ECPGt_int, &(val1output), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, (val2output), (long) sizeof("AAA"), (long) 1, (sizeof("AAA")) *sizeof(char), + ECPGt_int, &(val2i), (long) 1, (long) 1, sizeof(int), ECPGt_EORT); #line 74 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 74 "desc.pgc" printf("val1=%d val2=%c%c%c%c warn=%c truncate=%d\n", val1output, val2output[0], val2output[1], val2output[2], val2output[3], sqlca.sqlwarn[0], val2i); - { ECPGdo(__LINE__, 0, 1, NULL, "drop table test1 ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "drop table test1 ", ECPGt_EOIT, ECPGt_EORT); #line 77 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 77 "desc.pgc" - { ECPGdisconnect(__LINE__, "CURRENT"); + { + ECPGdisconnect(__LINE__, "CURRENT"); #line 78 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 78 "desc.pgc" ECPGdeallocate_desc(__LINE__, "indesc"); #line 80 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint(); + if (sqlca.sqlcode < 0) + sqlprint(); #line 80 "desc.pgc" ECPGdeallocate_desc(__LINE__, "outdesc"); #line 81 "desc.pgc" -if (sqlca.sqlcode < 0) sqlprint(); + if (sqlca.sqlcode < 0) + sqlprint(); #line 81 "desc.pgc" diff --git a/src/interfaces/ecpg/test/expected/sql-dynalloc.c b/src/interfaces/ecpg/test/expected/sql-dynalloc.c index 77cfa52b199..ac6e722af10 100644 --- a/src/interfaces/ecpg/test/expected/sql-dynalloc.c +++ b/src/interfaces/ecpg/test/expected/sql-dynalloc.c @@ -74,7 +74,6 @@ struct sqlca_t *ECPGget_sqlca(void); #ifdef __cplusplus } #endif - #endif #line 2 "dynalloc.pgc" @@ -91,250 +90,315 @@ struct sqlca_t *ECPGget_sqlca(void); #line 4 "dynalloc.pgc" -int main(void) +int +main(void) { - /* exec sql begin declare section */ - - - - - - - -/* char **d8=0; */ - - - - - - - - -/* int *i8=0; */ - - + /* exec sql begin declare section */ + + + + + + + +/* char **d8=0; */ + + + + + + + + +/* int *i8=0; */ + + #line 9 "dynalloc.pgc" - int * d1 = 0 ; - + int *d1 = 0; + #line 10 "dynalloc.pgc" - double * d2 = 0 ; - + double *d2 = 0; + #line 11 "dynalloc.pgc" - char ** d3 = 0 ; - + char **d3 = 0; + #line 12 "dynalloc.pgc" - char ** d4 = 0 ; - + char **d4 = 0; + #line 13 "dynalloc.pgc" - char ** d5 = 0 ; - + char **d5 = 0; + #line 14 "dynalloc.pgc" - char ** d6 = 0 ; - + char **d6 = 0; + #line 15 "dynalloc.pgc" - char ** d7 = 0 ; - + char **d7 = 0; + #line 17 "dynalloc.pgc" - char ** d9 = 0 ; - + char **d9 = 0; + #line 18 "dynalloc.pgc" - int * i1 = 0 ; - + int *i1 = 0; + #line 19 "dynalloc.pgc" - int * i2 = 0 ; - + int *i2 = 0; + #line 20 "dynalloc.pgc" - int * i3 = 0 ; - + int *i3 = 0; + #line 21 "dynalloc.pgc" - int * i4 = 0 ; - + int *i4 = 0; + #line 22 "dynalloc.pgc" - int * i5 = 0 ; - + int *i5 = 0; + #line 23 "dynalloc.pgc" - int * i6 = 0 ; - + int *i6 = 0; + #line 24 "dynalloc.pgc" - int * i7 = 0 ; - + int *i7 = 0; + #line 26 "dynalloc.pgc" - int * i9 = 0 ; + int *i9 = 0; + /* exec sql end declare section */ #line 27 "dynalloc.pgc" - int i; + int i; - ECPGdebug(1, stderr); + ECPGdebug(1, stderr); - /* exec sql whenever sqlerror do sqlprint ( ) ; */ + /* exec sql whenever sqlerror do sqlprint ( ) ; */ #line 32 "dynalloc.pgc" - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); #line 33 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 33 "dynalloc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to mdy", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to mdy", ECPGt_EOIT, ECPGt_EORT); #line 35 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 35 "dynalloc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( a serial , b numeric ( 12 , 3 ) , c varchar , d varchar ( 3 ) , e char ( 4 ) , f timestamptz , g boolean , h box , i inet ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table test ( a serial , b numeric ( 12 , 3 ) , c varchar , d varchar ( 3 ) , e char ( 4 ) , f timestamptz , g boolean , h box , i inet ) ", ECPGt_EOIT, ECPGt_EORT); #line 37 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 37 "dynalloc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( b , c , d , e , f , g , h , i ) values( 23.456 , 'varchar' , 'v' , 'c' , '2003-03-03 12:33:07 PDT' , true , '(1,2,3,4)' , '2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( b , c , d , e , f , g , h , i ) values( 23.456 , 'varchar' , 'v' , 'c' , '2003-03-03 12:33:07 PDT' , true , '(1,2,3,4)' , '2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128' ) ", ECPGt_EOIT, ECPGt_EORT); #line 38 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 38 "dynalloc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( b , c , d , e , f , g , h , i ) values( 2.446456 , null , 'v' , 'c' , '2003-03-03 12:33:07 PDT' , false , null , null ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( b , c , d , e , f , g , h , i ) values( 2.446456 , null , 'v' , 'c' , '2003-03-03 12:33:07 PDT' , false , null , null ) ", ECPGt_EOIT, ECPGt_EORT); #line 39 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 39 "dynalloc.pgc" - ECPGallocate_desc(__LINE__, "mydesc"); + ECPGallocate_desc(__LINE__, "mydesc"); #line 41 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( ); + if (sqlca.sqlcode < 0) + sqlprint(); #line 41 "dynalloc.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select a , b , c , d , e , f , g , h , i from test order by a", ECPGt_EOIT, - ECPGt_descriptor, "mydesc", 0L, 0L, 0L, - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select a , b , c , d , e , f , g , h , i from test order by a", ECPGt_EOIT, + ECPGt_descriptor, "mydesc", 0L, 0L, 0L, + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 42 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 42 "dynalloc.pgc" - { ECPGget_desc(__LINE__, "mydesc", 1,ECPGd_indicator, - ECPGt_int,&(i1),(long)1,(long)0,sizeof(int), ECPGd_data, - ECPGt_int,&(d1),(long)1,(long)0,sizeof(int), ECPGd_EODT); + { + ECPGget_desc(__LINE__, "mydesc", 1, ECPGd_indicator, + ECPGt_int, &(i1), (long) 1, (long) 0, sizeof(int), ECPGd_data, + ECPGt_int, &(d1), (long) 1, (long) 0, sizeof(int), ECPGd_EODT); #line 43 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 43 "dynalloc.pgc" - { ECPGget_desc(__LINE__, "mydesc", 2,ECPGd_indicator, - ECPGt_int,&(i2),(long)1,(long)0,sizeof(int), ECPGd_data, - ECPGt_double,&(d2),(long)1,(long)0,sizeof(double), ECPGd_EODT); + { + ECPGget_desc(__LINE__, "mydesc", 2, ECPGd_indicator, + ECPGt_int, &(i2), (long) 1, (long) 0, sizeof(int), ECPGd_data, + ECPGt_double, &(d2), (long) 1, (long) 0, sizeof(double), ECPGd_EODT); #line 44 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 44 "dynalloc.pgc" - { ECPGget_desc(__LINE__, "mydesc", 3,ECPGd_indicator, - ECPGt_int,&(i3),(long)1,(long)0,sizeof(int), ECPGd_data, - ECPGt_char,&(d3),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT); + { + ECPGget_desc(__LINE__, "mydesc", 3, ECPGd_indicator, + ECPGt_int, &(i3), (long) 1, (long) 0, sizeof(int), ECPGd_data, + ECPGt_char, &(d3), (long) 0, (long) 0, (1) * sizeof(char), ECPGd_EODT); #line 45 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 45 "dynalloc.pgc" - { ECPGget_desc(__LINE__, "mydesc", 4,ECPGd_indicator, - ECPGt_int,&(i4),(long)1,(long)0,sizeof(int), ECPGd_data, - ECPGt_char,&(d4),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT); + { + ECPGget_desc(__LINE__, "mydesc", 4, ECPGd_indicator, + ECPGt_int, &(i4), (long) 1, (long) 0, sizeof(int), ECPGd_data, + ECPGt_char, &(d4), (long) 0, (long) 0, (1) * sizeof(char), ECPGd_EODT); #line 46 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 46 "dynalloc.pgc" - { ECPGget_desc(__LINE__, "mydesc", 5,ECPGd_indicator, - ECPGt_int,&(i5),(long)1,(long)0,sizeof(int), ECPGd_data, - ECPGt_char,&(d5),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT); + { + ECPGget_desc(__LINE__, "mydesc", 5, ECPGd_indicator, + ECPGt_int, &(i5), (long) 1, (long) 0, sizeof(int), ECPGd_data, + ECPGt_char, &(d5), (long) 0, (long) 0, (1) * sizeof(char), ECPGd_EODT); #line 47 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 47 "dynalloc.pgc" - { ECPGget_desc(__LINE__, "mydesc", 6,ECPGd_indicator, - ECPGt_int,&(i6),(long)1,(long)0,sizeof(int), ECPGd_data, - ECPGt_char,&(d6),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT); + { + ECPGget_desc(__LINE__, "mydesc", 6, ECPGd_indicator, + ECPGt_int, &(i6), (long) 1, (long) 0, sizeof(int), ECPGd_data, + ECPGt_char, &(d6), (long) 0, (long) 0, (1) * sizeof(char), ECPGd_EODT); #line 48 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 48 "dynalloc.pgc" - { ECPGget_desc(__LINE__, "mydesc", 7,ECPGd_indicator, - ECPGt_int,&(i7),(long)1,(long)0,sizeof(int), ECPGd_data, - ECPGt_char,&(d7),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT); + { + ECPGget_desc(__LINE__, "mydesc", 7, ECPGd_indicator, + ECPGt_int, &(i7), (long) 1, (long) 0, sizeof(int), ECPGd_data, + ECPGt_char, &(d7), (long) 0, (long) 0, (1) * sizeof(char), ECPGd_EODT); #line 49 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 49 "dynalloc.pgc" - /* skip box for now */ - /* exec sql get descriptor mydesc value 8 :d8=DATA, :i8=INDICATOR; */ - { ECPGget_desc(__LINE__, "mydesc", 9,ECPGd_indicator, - ECPGt_int,&(i9),(long)1,(long)0,sizeof(int), ECPGd_data, - ECPGt_char,&(d9),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT); + /* skip box for now */ + /* exec sql get descriptor mydesc value 8 :d8=DATA, :i8=INDICATOR; */ + { + ECPGget_desc(__LINE__, "mydesc", 9, ECPGd_indicator, + ECPGt_int, &(i9), (long) 1, (long) 0, sizeof(int), ECPGd_data, + ECPGt_char, &(d9), (long) 0, (long) 0, (1) * sizeof(char), ECPGd_EODT); #line 52 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 52 "dynalloc.pgc" - printf("Result:\n"); - for (i=0;i<sqlca.sqlerrd[2];++i) - { - if (i1[i]) printf("NULL, "); - else printf("%d, ",d1[i]); - - if (i2[i]) printf("NULL, "); - else printf("%f, ",d2[i]); - - if (i3[i]) printf("NULL, "); - else printf("'%s', ",d3[i]); - - if (i4[i]) printf("NULL, "); - else printf("'%s', ",d4[i]); - - if (i5[i]) printf("NULL, "); - else printf("'%s', ",d5[i]); - - if (i6[i]) printf("NULL, "); - else printf("'%s', ",d6[i]); - - if (i7[i]) printf("NULL, "); - else printf("'%s', ",d7[i]); - - if (i9[i]) printf("NULL, "); - else printf("'%s', ",d9[i]); - - printf("\n"); - } - ECPGfree_auto_mem(); - printf("\n"); - - ECPGdeallocate_desc(__LINE__, "mydesc"); + printf("Result:\n"); + for (i = 0; i < sqlca.sqlerrd[2]; ++i) + { + if (i1[i]) + printf("NULL, "); + else + printf("%d, ", d1[i]); + + if (i2[i]) + printf("NULL, "); + else + printf("%f, ", d2[i]); + + if (i3[i]) + printf("NULL, "); + else + printf("'%s', ", d3[i]); + + if (i4[i]) + printf("NULL, "); + else + printf("'%s', ", d4[i]); + + if (i5[i]) + printf("NULL, "); + else + printf("'%s', ", d5[i]); + + if (i6[i]) + printf("NULL, "); + else + printf("'%s', ", d6[i]); + + if (i7[i]) + printf("NULL, "); + else + printf("'%s', ", d7[i]); + + if (i9[i]) + printf("NULL, "); + else + printf("'%s', ", d9[i]); + + printf("\n"); + } + ECPGfree_auto_mem(); + printf("\n"); + + ECPGdeallocate_desc(__LINE__, "mydesc"); #line 86 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( ); + if (sqlca.sqlcode < 0) + sqlprint(); #line 86 "dynalloc.pgc" - { ECPGdisconnect(__LINE__, "CURRENT"); + { + ECPGdisconnect(__LINE__, "CURRENT"); #line 87 "dynalloc.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 87 "dynalloc.pgc" - return 0; + return 0; } diff --git a/src/interfaces/ecpg/test/expected/sql-dynalloc2.c b/src/interfaces/ecpg/test/expected/sql-dynalloc2.c index 69d9446169a..2f9faf6fa98 100644 --- a/src/interfaces/ecpg/test/expected/sql-dynalloc2.c +++ b/src/interfaces/ecpg/test/expected/sql-dynalloc2.c @@ -74,7 +74,6 @@ struct sqlca_t *ECPGget_sqlca(void); #ifdef __cplusplus } #endif - #endif #line 2 "dynalloc2.pgc" @@ -91,166 +90,219 @@ struct sqlca_t *ECPGget_sqlca(void); #line 4 "dynalloc2.pgc" -int main(void) +int +main(void) { - /* exec sql begin declare section */ - - - - - - + /* exec sql begin declare section */ + + + + + + #line 9 "dynalloc2.pgc" - int * ip1 = 0 ; - + int *ip1 = 0; + #line 10 "dynalloc2.pgc" - char ** cp2 = 0 ; - + char **cp2 = 0; + #line 11 "dynalloc2.pgc" - int * ipointer1 = 0 ; - + int *ipointer1 = 0; + #line 12 "dynalloc2.pgc" - int * ipointer2 = 0 ; - + int *ipointer2 = 0; + #line 13 "dynalloc2.pgc" - int colnum ; + int colnum; + /* exec sql end declare section */ #line 14 "dynalloc2.pgc" - int i; + int i; - ECPGdebug(1, stderr); + ECPGdebug(1, stderr); - /* exec sql whenever sqlerror do sqlprint ( ) ; */ + /* exec sql whenever sqlerror do sqlprint ( ) ; */ #line 19 "dynalloc2.pgc" - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); #line 20 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 20 "dynalloc2.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to postgres", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to postgres", ECPGt_EOIT, ECPGt_EORT); #line 22 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 22 "dynalloc2.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( a int , b text ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table test ( a int , b text ) ", ECPGt_EOIT, ECPGt_EORT); #line 24 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 24 "dynalloc2.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 1 , 'one' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 1 , 'one' ) ", ECPGt_EOIT, ECPGt_EORT); #line 25 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 25 "dynalloc2.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 2 , 'two' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 2 , 'two' ) ", ECPGt_EOIT, ECPGt_EORT); #line 26 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 26 "dynalloc2.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( null , 'three' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( null , 'three' ) ", ECPGt_EOIT, ECPGt_EORT); #line 27 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 27 "dynalloc2.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 4 , 'four' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 4 , 'four' ) ", ECPGt_EOIT, ECPGt_EORT); #line 28 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 28 "dynalloc2.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 5 , null ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 5 , null ) ", ECPGt_EOIT, ECPGt_EORT); #line 29 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 29 "dynalloc2.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( null , null ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( null , null ) ", ECPGt_EOIT, ECPGt_EORT); #line 30 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 30 "dynalloc2.pgc" - ECPGallocate_desc(__LINE__, "mydesc"); + ECPGallocate_desc(__LINE__, "mydesc"); #line 32 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( ); + if (sqlca.sqlcode < 0) + sqlprint(); #line 32 "dynalloc2.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select * from test ", ECPGt_EOIT, - ECPGt_descriptor, "mydesc", 0L, 0L, 0L, - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select * from test ", ECPGt_EOIT, + ECPGt_descriptor, "mydesc", 0L, 0L, 0L, + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 33 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 33 "dynalloc2.pgc" - { ECPGget_desc_header(__LINE__, "mydesc", &(colnum)); + { + ECPGget_desc_header(__LINE__, "mydesc", &(colnum)); #line 34 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 34 "dynalloc2.pgc" - { ECPGget_desc(__LINE__, "mydesc", 1,ECPGd_indicator, - ECPGt_int,&(ipointer1),(long)1,(long)0,sizeof(int), ECPGd_data, - ECPGt_int,&(ip1),(long)1,(long)0,sizeof(int), ECPGd_EODT); + { + ECPGget_desc(__LINE__, "mydesc", 1, ECPGd_indicator, + ECPGt_int, &(ipointer1), (long) 1, (long) 0, sizeof(int), ECPGd_data, + ECPGt_int, &(ip1), (long) 1, (long) 0, sizeof(int), ECPGd_EODT); #line 35 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 35 "dynalloc2.pgc" - { ECPGget_desc(__LINE__, "mydesc", 2,ECPGd_indicator, - ECPGt_int,&(ipointer2),(long)1,(long)0,sizeof(int), ECPGd_data, - ECPGt_char,&(cp2),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT); + { + ECPGget_desc(__LINE__, "mydesc", 2, ECPGd_indicator, + ECPGt_int, &(ipointer2), (long) 1, (long) 0, sizeof(int), ECPGd_data, + ECPGt_char, &(cp2), (long) 0, (long) 0, (1) * sizeof(char), ECPGd_EODT); #line 36 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 36 "dynalloc2.pgc" - printf("Result (%d columns):\n", colnum); - for (i=0;i < sqlca.sqlerrd[2];++i) - { - if (ipointer1[i]) printf("NULL, "); - else printf("%d, ",ip1[i]); - - if (ipointer2[i]) printf("NULL, "); - else printf("'%s', ",cp2[i]); - printf("\n"); - } - ECPGfree_auto_mem(); - printf("\n"); - - ECPGdeallocate_desc(__LINE__, "mydesc"); + printf("Result (%d columns):\n", colnum); + for (i = 0; i < sqlca.sqlerrd[2]; ++i) + { + if (ipointer1[i]) + printf("NULL, "); + else + printf("%d, ", ip1[i]); + + if (ipointer2[i]) + printf("NULL, "); + else + printf("'%s', ", cp2[i]); + printf("\n"); + } + ECPGfree_auto_mem(); + printf("\n"); + + ECPGdeallocate_desc(__LINE__, "mydesc"); #line 51 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( ); + if (sqlca.sqlcode < 0) + sqlprint(); #line 51 "dynalloc2.pgc" - { ECPGtrans(__LINE__, NULL, "rollback"); + { + ECPGtrans(__LINE__, NULL, "rollback"); #line 52 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 52 "dynalloc2.pgc" - { ECPGdisconnect(__LINE__, "CURRENT"); + { + ECPGdisconnect(__LINE__, "CURRENT"); #line 53 "dynalloc2.pgc" -if (sqlca.sqlcode < 0) sqlprint ( );} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 53 "dynalloc2.pgc" - return 0; + return 0; } diff --git a/src/interfaces/ecpg/test/expected/sql-dyntest.c b/src/interfaces/ecpg/test/expected/sql-dyntest.c index 5ecd7c65183..5ca8c356a4a 100644 --- a/src/interfaces/ecpg/test/expected/sql-dyntest.c +++ b/src/interfaces/ecpg/test/expected/sql-dyntest.c @@ -56,7 +56,6 @@ enum SQL3_DDT_ILLEGAL /* not a datetime data type (not part of * standard) */ }; - #endif /* !_ECPG_SQL3TYPES_H */ #line 7 "dyntest.pgc" @@ -127,7 +126,6 @@ struct sqlca_t *ECPGget_sqlca(void); #ifdef __cplusplus } #endif - #endif #line 8 "dyntest.pgc" @@ -144,346 +142,409 @@ struct sqlca_t *ECPGget_sqlca(void); static void -error (void) +error(void) { - printf ("\n#%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); - exit (1); + printf("\n#%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + exit(1); } int -main (int argc, char **argv) +main(int argc, char **argv) { - /* exec sql begin declare section */ - - - - - - - - - - - + /* exec sql begin declare section */ + + + + + + + + + + + #line 22 "dyntest.pgc" - int COUNT ; - + int COUNT; + #line 23 "dyntest.pgc" - int INTVAR ; - + int INTVAR; + #line 24 "dyntest.pgc" - int INDEX ; - + int INDEX; + #line 25 "dyntest.pgc" - int INDICATOR ; - + int INDICATOR; + #line 26 "dyntest.pgc" - int TYPE , LENGTH , OCTET_LENGTH , PRECISION , SCALE , RETURNED_OCTET_LENGTH ; - + int TYPE, + LENGTH, + OCTET_LENGTH, + PRECISION, + SCALE, + RETURNED_OCTET_LENGTH; + #line 27 "dyntest.pgc" - int DATETIME_INTERVAL_CODE ; - + int DATETIME_INTERVAL_CODE; + #line 28 "dyntest.pgc" - char NAME [ 120 ] , BOOLVAR ; - + char NAME[120], + BOOLVAR; + #line 29 "dyntest.pgc" - char STRINGVAR [ 1024 ] ; - + char STRINGVAR[1024]; + #line 30 "dyntest.pgc" - double DOUBLEVAR ; - + double DOUBLEVAR; + #line 31 "dyntest.pgc" - char * QUERY ; + char *QUERY; + /* exec sql end declare section */ #line 32 "dyntest.pgc" - int done = 0; + int done = 0; - /* exec sql var BOOLVAR is bool */ + /* exec sql var BOOLVAR is bool */ #line 35 "dyntest.pgc" - ECPGdebug (1, stderr); + ECPGdebug(1, stderr); - QUERY = "select * from dyntest"; + QUERY = "select * from dyntest"; - /* exec sql whenever sqlerror do error ( ) ; */ + /* exec sql whenever sqlerror do error ( ) ; */ #line 43 "dyntest.pgc" - ECPGallocate_desc(__LINE__, "MYDESC"); + ECPGallocate_desc(__LINE__, "MYDESC"); #line 45 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( ); + if (sqlca.sqlcode < 0) + error(); #line 45 "dyntest.pgc" - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); #line 47 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 47 "dyntest.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to german", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to german", ECPGt_EOIT, ECPGt_EORT); #line 49 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 49 "dyntest.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table dyntest ( name char ( 14 ) , d float8 , i int , bignumber int8 , b boolean , comment text , day date ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table dyntest ( name char ( 14 ) , d float8 , i int , bignumber int8 , b boolean , comment text , day date ) ", ECPGt_EOIT, ECPGt_EORT); #line 53 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 53 "dyntest.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into dyntest values( 'first entry' , 14.7 , 14 , 123045607890 , true , 'The world''s most advanced open source database.' , '1987-07-14' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into dyntest values( 'first entry' , 14.7 , 14 , 123045607890 , true , 'The world''s most advanced open source database.' , '1987-07-14' ) ", ECPGt_EOIT, ECPGt_EORT); #line 54 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 54 "dyntest.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into dyntest values( 'second entry' , 1407.87 , 1407 , 987065403210 , false , 'The elephant never forgets.' , '1999-11-5' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into dyntest values( 'second entry' , 1407.87 , 1407 , 987065403210 , false , 'The elephant never forgets.' , '1999-11-5' ) ", ECPGt_EOIT, ECPGt_EORT); #line 55 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 55 "dyntest.pgc" - { ECPGprepare(__LINE__, "MYQUERY" , QUERY); + { + ECPGprepare(__LINE__, "MYQUERY", QUERY); #line 57 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 57 "dyntest.pgc" - /* declare MYCURS cursor for ? */ + /* declare MYCURS cursor for ? */ #line 58 "dyntest.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "declare MYCURS cursor for ?", - ECPGt_char_variable,(ECPGprepared_statement("MYQUERY")),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "declare MYCURS cursor for ?", + ECPGt_char_variable, (ECPGprepared_statement("MYQUERY")), (long) 1, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 60 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 60 "dyntest.pgc" - while (1) - { - { ECPGdo(__LINE__, 0, 1, NULL, "fetch in MYCURS", ECPGt_EOIT, - ECPGt_descriptor, "MYDESC", 0L, 0L, 0L, - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + while (1) + { + { + ECPGdo(__LINE__, 0, 1, NULL, "fetch in MYCURS", ECPGt_EOIT, + ECPGt_descriptor, "MYDESC", 0L, 0L, 0L, + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 64 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 64 "dyntest.pgc" - if (sqlca.sqlcode) - break; + if (sqlca.sqlcode) + break; - { ECPGget_desc_header(__LINE__, "MYDESC", &(COUNT)); + { + ECPGget_desc_header(__LINE__, "MYDESC", &(COUNT)); #line 69 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 69 "dyntest.pgc" - if (!done) - { - printf ("Found %d columns\n", COUNT); - done = 1; - } + if (!done) + { + printf("Found %d columns\n", COUNT); + done = 1; + } - for (INDEX = 1; INDEX <= COUNT; ++INDEX) - { - { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_indicator, - ECPGt_int,&(INDICATOR),(long)1,(long)1,sizeof(int), ECPGd_name, - ECPGt_char,(NAME),(long)120,(long)1,(120)*sizeof(char), ECPGd_scale, - ECPGt_int,&(SCALE),(long)1,(long)1,sizeof(int), ECPGd_precision, - ECPGt_int,&(PRECISION),(long)1,(long)1,sizeof(int), ECPGd_ret_octet, - ECPGt_int,&(RETURNED_OCTET_LENGTH),(long)1,(long)1,sizeof(int), ECPGd_octet, - ECPGt_int,&(OCTET_LENGTH),(long)1,(long)1,sizeof(int), ECPGd_length, - ECPGt_int,&(LENGTH),(long)1,(long)1,sizeof(int), ECPGd_type, - ECPGt_int,&(TYPE),(long)1,(long)1,sizeof(int), ECPGd_EODT); + for (INDEX = 1; INDEX <= COUNT; ++INDEX) + { + { + ECPGget_desc(__LINE__, "MYDESC", INDEX, ECPGd_indicator, + ECPGt_int, &(INDICATOR), (long) 1, (long) 1, sizeof(int), ECPGd_name, + ECPGt_char, (NAME), (long) 120, (long) 1, (120) * sizeof(char), ECPGd_scale, + ECPGt_int, &(SCALE), (long) 1, (long) 1, sizeof(int), ECPGd_precision, + ECPGt_int, &(PRECISION), (long) 1, (long) 1, sizeof(int), ECPGd_ret_octet, + ECPGt_int, &(RETURNED_OCTET_LENGTH), (long) 1, (long) 1, sizeof(int), ECPGd_octet, + ECPGt_int, &(OCTET_LENGTH), (long) 1, (long) 1, sizeof(int), ECPGd_length, + ECPGt_int, &(LENGTH), (long) 1, (long) 1, sizeof(int), ECPGd_type, + ECPGt_int, &(TYPE), (long) 1, (long) 1, sizeof(int), ECPGd_EODT); #line 86 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 86 "dyntest.pgc" - printf ("%2d\t%s (type: %d length: %d precision: %d scale: %d = " , INDEX, NAME, TYPE, LENGTH, PRECISION, SCALE); - switch (TYPE) - { - case SQL3_BOOLEAN: - printf ("bool"); - break; - case SQL3_NUMERIC: - printf ("numeric(%d,%d)", PRECISION, SCALE); - break; - case SQL3_DECIMAL: - printf ("decimal(%d,%d)", PRECISION, SCALE); - break; - case SQL3_INTEGER: - printf ("integer"); - break; - case SQL3_SMALLINT: - printf ("smallint"); - break; - case SQL3_FLOAT: - printf ("float(%d,%d)", PRECISION, SCALE); - break; - case SQL3_REAL: - printf ("real"); - break; - case SQL3_DOUBLE_PRECISION: - printf ("double precision"); - break; - case SQL3_DATE_TIME_TIMESTAMP: - { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_di_code, - ECPGt_int,&(DATETIME_INTERVAL_CODE),(long)1,(long)1,sizeof(int), ECPGd_EODT); + printf("%2d\t%s (type: %d length: %d precision: %d scale: %d = ", INDEX, NAME, TYPE, LENGTH, PRECISION, SCALE); + switch (TYPE) + { + case SQL3_BOOLEAN: + printf("bool"); + break; + case SQL3_NUMERIC: + printf("numeric(%d,%d)", PRECISION, SCALE); + break; + case SQL3_DECIMAL: + printf("decimal(%d,%d)", PRECISION, SCALE); + break; + case SQL3_INTEGER: + printf("integer"); + break; + case SQL3_SMALLINT: + printf("smallint"); + break; + case SQL3_FLOAT: + printf("float(%d,%d)", PRECISION, SCALE); + break; + case SQL3_REAL: + printf("real"); + break; + case SQL3_DOUBLE_PRECISION: + printf("double precision"); + break; + case SQL3_DATE_TIME_TIMESTAMP: + { + ECPGget_desc(__LINE__, "MYDESC", INDEX, ECPGd_di_code, + ECPGt_int, &(DATETIME_INTERVAL_CODE), (long) 1, (long) 1, sizeof(int), ECPGd_EODT); #line 116 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 116 "dyntest.pgc" - switch (DATETIME_INTERVAL_CODE) - { - case SQL3_DDT_DATE: - printf ("date"); - break; - case SQL3_DDT_TIME: - printf ("time"); - break; - case SQL3_DDT_TIMESTAMP: - printf ("timestamp"); - break; - case SQL3_DDT_TIME_WITH_TIME_ZONE: - printf ("time with time zone"); - break; - case SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE: - printf ("timestamp with time zone"); - break; - } - break; - case SQL3_INTERVAL: - printf ("interval"); - break; - case SQL3_CHARACTER: - if (LENGTH > 0) - printf ("char(%d)", LENGTH); - else - printf ("text"); - break; - case SQL3_CHARACTER_VARYING: - if (LENGTH > 0) - printf ("varchar(%d)", LENGTH); - else - printf ("varchar()"); - break; - default: - if (TYPE < 0) - printf ("<OID %d>", -TYPE); - else - printf ("<SQL3 %d>", TYPE); - break; - } - printf (")\n\toctet_length: %d returned_octet_length: %d)\n\t= ", - OCTET_LENGTH, RETURNED_OCTET_LENGTH); - if (INDICATOR == -1) - printf ("NULL\n"); - else - switch (TYPE) - { - case SQL3_BOOLEAN: - { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data, - ECPGt_bool,&(BOOLVAR),(long)1,(long)1,sizeof(bool), ECPGd_EODT); + switch (DATETIME_INTERVAL_CODE) + { + case SQL3_DDT_DATE: + printf("date"); + break; + case SQL3_DDT_TIME: + printf("time"); + break; + case SQL3_DDT_TIMESTAMP: + printf("timestamp"); + break; + case SQL3_DDT_TIME_WITH_TIME_ZONE: + printf("time with time zone"); + break; + case SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE: + printf("timestamp with time zone"); + break; + } + break; + case SQL3_INTERVAL: + printf("interval"); + break; + case SQL3_CHARACTER: + if (LENGTH > 0) + printf("char(%d)", LENGTH); + else + printf("text"); + break; + case SQL3_CHARACTER_VARYING: + if (LENGTH > 0) + printf("varchar(%d)", LENGTH); + else + printf("varchar()"); + break; + default: + if (TYPE < 0) + printf("<OID %d>", -TYPE); + else + printf("<SQL3 %d>", TYPE); + break; + } + printf(")\n\toctet_length: %d returned_octet_length: %d)\n\t= ", + OCTET_LENGTH, RETURNED_OCTET_LENGTH); + if (INDICATOR == -1) + printf("NULL\n"); + else + switch (TYPE) + { + case SQL3_BOOLEAN: + { + ECPGget_desc(__LINE__, "MYDESC", INDEX, ECPGd_data, + ECPGt_bool, &(BOOLVAR), (long) 1, (long) 1, sizeof(bool), ECPGd_EODT); #line 166 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 166 "dyntest.pgc" - printf ("%s\n", BOOLVAR ? "true" : "false"); - break; - case SQL3_INTEGER: - case SQL3_SMALLINT: - { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data, - ECPGt_int,&(INTVAR),(long)1,(long)1,sizeof(int), ECPGd_EODT); + printf("%s\n", BOOLVAR ? "true" : "false"); + break; + case SQL3_INTEGER: + case SQL3_SMALLINT: + { + ECPGget_desc(__LINE__, "MYDESC", INDEX, ECPGd_data, + ECPGt_int, &(INTVAR), (long) 1, (long) 1, sizeof(int), ECPGd_EODT); #line 171 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 171 "dyntest.pgc" - printf ("%d\n", INTVAR); - break; - case SQL3_DOUBLE_PRECISION: - { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data, - ECPGt_double,&(DOUBLEVAR),(long)1,(long)1,sizeof(double), ECPGd_EODT); + printf("%d\n", INTVAR); + break; + case SQL3_DOUBLE_PRECISION: + { + ECPGget_desc(__LINE__, "MYDESC", INDEX, ECPGd_data, + ECPGt_double, &(DOUBLEVAR), (long) 1, (long) 1, sizeof(double), ECPGd_EODT); #line 175 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 175 "dyntest.pgc" - printf ("%.*f\n", PRECISION, DOUBLEVAR); - break; - case SQL3_DATE_TIME_TIMESTAMP: - { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data, - ECPGt_char,(STRINGVAR),(long)1024,(long)1,(1024)*sizeof(char), ECPGd_di_code, - ECPGt_int,&(DATETIME_INTERVAL_CODE),(long)1,(long)1,sizeof(int), ECPGd_EODT); + printf("%.*f\n", PRECISION, DOUBLEVAR); + break; + case SQL3_DATE_TIME_TIMESTAMP: + { + ECPGget_desc(__LINE__, "MYDESC", INDEX, ECPGd_data, + ECPGt_char, (STRINGVAR), (long) 1024, (long) 1, (1024) * sizeof(char), ECPGd_di_code, + ECPGt_int, &(DATETIME_INTERVAL_CODE), (long) 1, (long) 1, sizeof(int), ECPGd_EODT); #line 181 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 181 "dyntest.pgc" - printf ("%d \"%s\"\n", DATETIME_INTERVAL_CODE, STRINGVAR); - break; - case SQL3_CHARACTER: - case SQL3_CHARACTER_VARYING: - { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data, - ECPGt_char,(STRINGVAR),(long)1024,(long)1,(1024)*sizeof(char), ECPGd_EODT); + printf("%d \"%s\"\n", DATETIME_INTERVAL_CODE, STRINGVAR); + break; + case SQL3_CHARACTER: + case SQL3_CHARACTER_VARYING: + { + ECPGget_desc(__LINE__, "MYDESC", INDEX, ECPGd_data, + ECPGt_char, (STRINGVAR), (long) 1024, (long) 1, (1024) * sizeof(char), ECPGd_EODT); #line 186 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 186 "dyntest.pgc" - printf ("\"%s\"\n", STRINGVAR); - break; - default: - { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data, - ECPGt_char,(STRINGVAR),(long)1024,(long)1,(1024)*sizeof(char), ECPGd_EODT); + printf("\"%s\"\n", STRINGVAR); + break; + default: + { + ECPGget_desc(__LINE__, "MYDESC", INDEX, ECPGd_data, + ECPGt_char, (STRINGVAR), (long) 1024, (long) 1, (1024) * sizeof(char), ECPGd_EODT); #line 190 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 190 "dyntest.pgc" - printf ("<\"%s\">\n", STRINGVAR); - break; - } + printf("<\"%s\">\n", STRINGVAR); + break; + } + } } - } - { ECPGdo(__LINE__, 0, 1, NULL, "close MYCURS", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "close MYCURS", ECPGt_EOIT, ECPGt_EORT); #line 197 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( );} + if (sqlca.sqlcode < 0) + error(); + } #line 197 "dyntest.pgc" - ECPGdeallocate_desc(__LINE__, "MYDESC"); + ECPGdeallocate_desc(__LINE__, "MYDESC"); #line 199 "dyntest.pgc" -if (sqlca.sqlcode < 0) error ( ); + if (sqlca.sqlcode < 0) + error(); #line 199 "dyntest.pgc" - return 0; - } + return 0; +} diff --git a/src/interfaces/ecpg/test/expected/sql-execute.c b/src/interfaces/ecpg/test/expected/sql-execute.c index 662f554f4ee..d07d82cc97a 100644 --- a/src/interfaces/ecpg/test/expected/sql-execute.c +++ b/src/interfaces/ecpg/test/expected/sql-execute.c @@ -31,155 +31,195 @@ int main(void) { /* exec sql begin declare section */ - - - - - + + + + + #line 14 "execute.pgc" - int amount [ 8 ] ; - + int amount[8]; + #line 15 "execute.pgc" - int increment = 100 ; - + int increment = 100; + #line 16 "execute.pgc" - char name [ 8 ] [ 8 ] ; - + char name[8][8]; + #line 17 "execute.pgc" - char letter [ 8 ] [ 1 ] ; - + char letter[8][1]; + #line 18 "execute.pgc" - char command [ 128 ] ; + char command[128]; + /* exec sql end declare section */ #line 19 "execute.pgc" - int i,j; + int i, + j; ECPGdebug(1, stderr); - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , "main", 0); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, "main", 0); #line 24 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 24 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) ) ", ECPGt_EOIT, ECPGt_EORT); #line 25 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 25 "execute.pgc" - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 26 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 26 "execute.pgc" sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 1, 'f')"); - { ECPGdo(__LINE__, 0, 1, NULL, "?", - ECPGt_char_variable,(command),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "?", + ECPGt_char_variable, (command), (long) 1, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 29 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 29 "execute.pgc" sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 2, 't')"); - { ECPGdo(__LINE__, 0, 1, NULL, "?", - ECPGt_char_variable,(command),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "?", + ECPGt_char_variable, (command), (long) 1, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 32 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 32 "execute.pgc" sprintf(command, "insert into test (name, amount, letter) select name, amount+10, letter from test"); - { ECPGdo(__LINE__, 0, 1, NULL, "?", - ECPGt_char_variable,(command),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "?", + ECPGt_char_variable, (command), (long) 1, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 35 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 35 "execute.pgc" printf("Inserted %ld tuples via execute immediate\n", sqlca.sqlerrd[2]); sprintf(command, "insert into test (name, amount, letter) select name, amount+?, letter from test"); - { ECPGprepare(__LINE__, "I" , command); + { + ECPGprepare(__LINE__, "I", command); #line 40 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 40 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "?", - ECPGt_char_variable,(ECPGprepared_statement("I")),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_int,&(increment),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "?", + ECPGt_char_variable, (ECPGprepared_statement("I")), (long) 1, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_int, &(increment), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 41 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 41 "execute.pgc" printf("Inserted %ld tuples via prepared execute\n", sqlca.sqlerrd[2]); - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 45 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 45 "execute.pgc" - sprintf (command, "select * from test"); + sprintf(command, "select * from test"); - { ECPGprepare(__LINE__, "F" , command); + { + ECPGprepare(__LINE__, "F", command); #line 49 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 49 "execute.pgc" - /* declare CUR cursor for ? */ + /* declare CUR cursor for ? */ #line 50 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "declare CUR cursor for ?", - ECPGt_char_variable,(ECPGprepared_statement("F")),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "declare CUR cursor for ?", + ECPGt_char_variable, (ECPGprepared_statement("F")), (long) 1, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 52 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 52 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "fetch 8 in CUR", ECPGt_EOIT, - ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_int,(amount),(long)1,(long)8,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "fetch 8 in CUR", ECPGt_EOIT, + ECPGt_char, (name), (long) 8, (long) 8, (8) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_int, (amount), (long) 1, (long) 8, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, (letter), (long) 1, (long) 8, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 53 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 53 "execute.pgc" - for (i=0, j=sqlca.sqlerrd[2]; i<j; i++) + for (i = 0, j = sqlca.sqlerrd[2]; i < j; i++) { /* exec sql begin declare section */ - - - + + + #line 58 "execute.pgc" - char n [ 8 ] , l = letter [ i ] [ 0 ] ; - + char n[8], + l = letter[i][0]; + #line 59 "execute.pgc" - int a = amount [ i ] ; + int a = amount[i]; + /* exec sql end declare section */ #line 60 "execute.pgc" @@ -188,59 +228,73 @@ if (sqlca.sqlcode < 0) sqlprint();} printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l); } - { ECPGdo(__LINE__, 0, 1, NULL, "close CUR", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "close CUR", ECPGt_EOIT, ECPGt_EORT); #line 66 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 66 "execute.pgc" - sprintf (command, "select * from test where amount = ?"); + sprintf(command, "select * from test where amount = ?"); - { ECPGprepare(__LINE__, "F" , command); + { + ECPGprepare(__LINE__, "F", command); #line 70 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 70 "execute.pgc" /* declare CUR2 cursor for ? */ #line 71 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "declare CUR2 cursor for ?", - ECPGt_char_variable,(ECPGprepared_statement("F")),(long)1,(long)1,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_const,"1",(long)1,(long)1,strlen("1"), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "declare CUR2 cursor for ?", + ECPGt_char_variable, (ECPGprepared_statement("F")), (long) 1, (long) 1, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_const, "1", (long) 1, (long) 1, strlen("1"), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 73 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 73 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "fetch in CUR2", ECPGt_EOIT, - ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_int,(amount),(long)1,(long)8,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "fetch in CUR2", ECPGt_EOIT, + ECPGt_char, (name), (long) 8, (long) 8, (8) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_int, (amount), (long) 1, (long) 8, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, (letter), (long) 1, (long) 8, (1) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 74 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 74 "execute.pgc" - for (i=0, j=sqlca.sqlerrd[2]; i<j; i++) + for (i = 0, j = sqlca.sqlerrd[2]; i < j; i++) { /* exec sql begin declare section */ - - - + + + #line 79 "execute.pgc" - char n [ 8 ] , l = letter [ i ] [ 0 ] ; - + char n[8], + l = letter[i][0]; + #line 80 "execute.pgc" - int a = amount [ i ] ; + int a = amount[i]; + /* exec sql end declare section */ #line 81 "execute.pgc" @@ -249,28 +303,40 @@ if (sqlca.sqlcode < 0) sqlprint();} printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l); } - { ECPGdo(__LINE__, 0, 1, NULL, "close CUR2", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "close CUR2", ECPGt_EOIT, ECPGt_EORT); #line 87 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 87 "execute.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT); #line 88 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 88 "execute.pgc" - { ECPGtrans(__LINE__, NULL, "commit"); + { + ECPGtrans(__LINE__, NULL, "commit"); #line 89 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 89 "execute.pgc" - { ECPGdisconnect(__LINE__, "CURRENT"); + { + ECPGdisconnect(__LINE__, "CURRENT"); #line 90 "execute.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 90 "execute.pgc" diff --git a/src/interfaces/ecpg/test/expected/sql-fetch.c b/src/interfaces/ecpg/test/expected/sql-fetch.c index 2d6ff974262..617eb80e404 100644 --- a/src/interfaces/ecpg/test/expected/sql-fetch.c +++ b/src/interfaces/ecpg/test/expected/sql-fetch.c @@ -22,175 +22,231 @@ #line 5 "fetch.pgc" -int main(int argc, char* argv[]) { - /* exec sql begin declare section */ - - - +int +main(int argc, char *argv[]) +{ + /* exec sql begin declare section */ + + + #line 9 "fetch.pgc" - char str [ 25 ] ; - + char str[25]; + #line 10 "fetch.pgc" - int i , how_many = 1 ; + int i, + how_many = 1; + /* exec sql end declare section */ #line 11 "fetch.pgc" - ECPGdebug(1, stderr); - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); } + ECPGdebug(1, stderr); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); + } #line 14 "fetch.pgc" - /* exec sql whenever sql_warning sqlprint ; */ + /* exec sql whenever sql_warning sqlprint ; */ #line 16 "fetch.pgc" - /* exec sql whenever sqlerror sqlprint ; */ + /* exec sql whenever sqlerror sqlprint ; */ #line 17 "fetch.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table My_Table ( Item1 int , Item2 text ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table My_Table ( Item1 int , Item2 text ) ", ECPGt_EOIT, ECPGt_EORT); #line 19 "fetch.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 19 "fetch.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 19 "fetch.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values ( 1 , 'text1' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values ( 1 , 'text1' ) ", ECPGt_EOIT, ECPGt_EORT); #line 21 "fetch.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 21 "fetch.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 21 "fetch.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values ( 2 , 'text2' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values ( 2 , 'text2' ) ", ECPGt_EOIT, ECPGt_EORT); #line 22 "fetch.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 22 "fetch.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 22 "fetch.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values ( 3 , 'text3' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values ( 3 , 'text3' ) ", ECPGt_EOIT, ECPGt_EORT); #line 23 "fetch.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 23 "fetch.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 23 "fetch.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values ( 4 , 'text4' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values ( 4 , 'text4' ) ", ECPGt_EOIT, ECPGt_EORT); #line 24 "fetch.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 24 "fetch.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 24 "fetch.pgc" - /* declare C cursor for select * from My_Table */ + /* declare C cursor for select * from My_Table */ #line 26 "fetch.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "declare C cursor for select * from My_Table ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "declare C cursor for select * from My_Table ", ECPGt_EOIT, ECPGt_EORT); #line 28 "fetch.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 28 "fetch.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 28 "fetch.pgc" - /* exec sql whenever not found break ; */ + /* exec sql whenever not found break ; */ #line 30 "fetch.pgc" - while (1) { - { ECPGdo(__LINE__, 0, 1, NULL, "fetch 1 in C", ECPGt_EOIT, - ECPGt_int,&(i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + while (1) + { + { + ECPGdo(__LINE__, 0, 1, NULL, "fetch 1 in C", ECPGt_EOIT, + ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, (str), (long) 25, (long) 1, (25) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 32 "fetch.pgc" -if (sqlca.sqlcode == ECPG_NOT_FOUND) break; + if (sqlca.sqlcode == ECPG_NOT_FOUND) + break; #line 32 "fetch.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 32 "fetch.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 32 "fetch.pgc" - printf("%d: %s\n", i, str); - } + printf("%d: %s\n", i, str); + } - /* exec sql whenever not found continue ; */ + /* exec sql whenever not found continue ; */ #line 36 "fetch.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT); #line 37 "fetch.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 37 "fetch.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 37 "fetch.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "fetch ? in C", - ECPGt_int,&(how_many),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_int,&(i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "fetch ? in C", + ECPGt_int, &(how_many), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_char, (str), (long) 25, (long) 1, (25) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 39 "fetch.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 39 "fetch.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 39 "fetch.pgc" - printf("%d: %s\n", i, str); + printf("%d: %s\n", i, str); - { ECPGdo(__LINE__, 0, 1, NULL, "close C", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "close C", ECPGt_EOIT, ECPGt_EORT); #line 42 "fetch.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 42 "fetch.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 42 "fetch.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "drop table My_Table ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "drop table My_Table ", ECPGt_EOIT, ECPGt_EORT); #line 44 "fetch.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 44 "fetch.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 44 "fetch.pgc" - { ECPGdisconnect(__LINE__, "ALL"); + { + ECPGdisconnect(__LINE__, "ALL"); #line 46 "fetch.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 46 "fetch.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 46 "fetch.pgc" - return 0; + return 0; } diff --git a/src/interfaces/ecpg/test/expected/sql-func.c b/src/interfaces/ecpg/test/expected/sql-func.c index 6f8bf3a17fb..59e830bc5f6 100644 --- a/src/interfaces/ecpg/test/expected/sql-func.c +++ b/src/interfaces/ecpg/test/expected/sql-func.c @@ -22,113 +22,155 @@ #line 5 "func.pgc" -int main(int argc, char* argv[]) { - - ECPGdebug(1, stderr); - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); } +int +main(int argc, char *argv[]) +{ + + ECPGdebug(1, stderr); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); + } #line 10 "func.pgc" - { ECPGsetcommit(__LINE__, "on", NULL);} + { + ECPGsetcommit(__LINE__, "on", NULL); + } #line 12 "func.pgc" - /* exec sql whenever sql_warning sqlprint ; */ + /* exec sql whenever sql_warning sqlprint ; */ #line 13 "func.pgc" - /* exec sql whenever sqlerror sqlprint ; */ + /* exec sql whenever sqlerror sqlprint ; */ #line 14 "func.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table My_Table ( Item1 int , Item2 text ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table My_Table ( Item1 int , Item2 text ) ", ECPGt_EOIT, ECPGt_EORT); #line 16 "func.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 16 "func.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 16 "func.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create function My_Table_Check () returns trigger as $test$\ + { + ECPGdo(__LINE__, 0, 1, NULL, "create function My_Table_Check () returns trigger as $test$\ BEGIN\ RAISE WARNING 'Notice: TG_NAME=%, TG WHEN=%', TG_NAME, TG_WHEN;\ RETURN NEW;\ END; $test$ language plpgsql", ECPGt_EOIT, ECPGt_EORT); #line 24 "func.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 24 "func.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 24 "func.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create trigger My_Table_Check_Trigger before insert on My_Table for each row execute procedure My_Table_Check ( )", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create trigger My_Table_Check_Trigger before insert on My_Table for each row execute procedure My_Table_Check ( )", ECPGt_EOIT, ECPGt_EORT); #line 30 "func.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 30 "func.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 30 "func.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values( 1234 , 'Some random text' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values( 1234 , 'Some random text' ) ", ECPGt_EOIT, ECPGt_EORT); #line 32 "func.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 32 "func.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 32 "func.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values( 5678 , 'The Quick Brown' ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values( 5678 , 'The Quick Brown' ) ", ECPGt_EOIT, ECPGt_EORT); #line 33 "func.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 33 "func.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 33 "func.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "drop trigger My_Table_Check_Trigger on My_Table ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "drop trigger My_Table_Check_Trigger on My_Table ", ECPGt_EOIT, ECPGt_EORT); #line 35 "func.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 35 "func.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 35 "func.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "drop function My_Table_Check () ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "drop function My_Table_Check () ", ECPGt_EOIT, ECPGt_EORT); #line 36 "func.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 36 "func.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 36 "func.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "drop table My_Table ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "drop table My_Table ", ECPGt_EOIT, ECPGt_EORT); #line 37 "func.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 37 "func.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 37 "func.pgc" - { ECPGdisconnect(__LINE__, "ALL"); + { + ECPGdisconnect(__LINE__, "ALL"); #line 39 "func.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 39 "func.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 39 "func.pgc" - return 0; + return 0; } diff --git a/src/interfaces/ecpg/test/expected/sql-indicators.c b/src/interfaces/ecpg/test/expected/sql-indicators.c index cc7054d4731..1a910ae03d7 100644 --- a/src/interfaces/ecpg/test/expected/sql-indicators.c +++ b/src/interfaces/ecpg/test/expected/sql-indicators.c @@ -75,7 +75,6 @@ struct sqlca_t *ECPGget_sqlca(void); #ifdef __cplusplus } #endif - #endif #line 3 "indicators.pgc" @@ -92,98 +91,133 @@ struct sqlca_t *ECPGget_sqlca(void); -int main(int argc, char **argv) +int +main(int argc, char **argv) { /* exec sql begin declare section */ - - - + + + #line 10 "indicators.pgc" - int intvar = 5 ; - + int intvar = 5; + #line 11 "indicators.pgc" - int nullind = - 1 ; + int nullind = -1; + /* exec sql end declare section */ #line 12 "indicators.pgc" - ECPGdebug(1,stderr); + ECPGdebug(1, stderr); - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); } + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); + } #line 16 "indicators.pgc" - { ECPGsetcommit(__LINE__, "off", NULL);} + { + ECPGsetcommit(__LINE__, "off", NULL); + } #line 17 "indicators.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( \"id\" int primary key , \"str\" text not null , val int null ) ", ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "create table test ( \"id\" int primary key , \"str\" text not null , val int null ) ", ECPGt_EOIT, ECPGt_EORT); + } #line 22 "indicators.pgc" - { ECPGtrans(__LINE__, NULL, "commit");} + { + ECPGtrans(__LINE__, NULL, "commit"); + } #line 23 "indicators.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( id , str , val ) values( 1 , 'Hello' , 0 ) ", ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( id , str , val ) values( 1 , 'Hello' , 0 ) ", ECPGt_EOIT, ECPGt_EORT); + } #line 25 "indicators.pgc" /* use indicator in insert */ - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( id , str , val ) values( 2 , 'Hi there' , ? ) ", - ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), - ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( id , str , val ) values( 2 , 'Hi there' , ? ) ", + ECPGt_int, &(intvar), (long) 1, (long) 1, sizeof(int), + ECPGt_int, &(nullind), (long) 1, (long) 1, sizeof(int), ECPGt_EOIT, ECPGt_EORT); + } #line 28 "indicators.pgc" nullind = 0; - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( id , str , val ) values( 3 , 'Good evening' , ? ) ", - ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), - ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( id , str , val ) values( 3 , 'Good evening' , ? ) ", + ECPGt_int, &(intvar), (long) 1, (long) 1, sizeof(int), + ECPGt_int, &(nullind), (long) 1, (long) 1, sizeof(int), ECPGt_EOIT, ECPGt_EORT); + } #line 30 "indicators.pgc" - { ECPGtrans(__LINE__, NULL, "commit");} + { + ECPGtrans(__LINE__, NULL, "commit"); + } #line 31 "indicators.pgc" /* use indicators to get information about selects */ - { ECPGdo(__LINE__, 0, 1, NULL, "select val from test where id = 1 ", ECPGt_EOIT, - ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "select val from test where id = 1 ", ECPGt_EOIT, + ECPGt_int, &(intvar), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); + } #line 34 "indicators.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select val from test where id = 2 ", ECPGt_EOIT, - ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), - ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "select val from test where id = 2 ", ECPGt_EOIT, + ECPGt_int, &(intvar), (long) 1, (long) 1, sizeof(int), + ECPGt_int, &(nullind), (long) 1, (long) 1, sizeof(int), ECPGt_EORT); + } #line 35 "indicators.pgc" printf("intvar: %d, nullind: %d\n", intvar, nullind); - { ECPGdo(__LINE__, 0, 1, NULL, "select val from test where id = 3 ", ECPGt_EOIT, - ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), - ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "select val from test where id = 3 ", ECPGt_EOIT, + ECPGt_int, &(intvar), (long) 1, (long) 1, sizeof(int), + ECPGt_int, &(nullind), (long) 1, (long) 1, sizeof(int), ECPGt_EORT); + } #line 37 "indicators.pgc" printf("intvar: %d, nullind: %d\n", intvar, nullind); /* use indicators for update */ - intvar = 5; nullind = -1; - { ECPGdo(__LINE__, 0, 1, NULL, "update test set val = ? where id = 1 ", - ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), - ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);} + intvar = 5; + nullind = -1; + { + ECPGdo(__LINE__, 0, 1, NULL, "update test set val = ? where id = 1 ", + ECPGt_int, &(intvar), (long) 1, (long) 1, sizeof(int), + ECPGt_int, &(nullind), (long) 1, (long) 1, sizeof(int), ECPGt_EOIT, ECPGt_EORT); + } #line 42 "indicators.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select val from test where id = 1 ", ECPGt_EOIT, - ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), - ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "select val from test where id = 1 ", ECPGt_EOIT, + ECPGt_int, &(intvar), (long) 1, (long) 1, sizeof(int), + ECPGt_int, &(nullind), (long) 1, (long) 1, sizeof(int), ECPGt_EORT); + } #line 43 "indicators.pgc" printf("intvar: %d, nullind: %d\n", intvar, nullind); - { ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT); + } #line 46 "indicators.pgc" - { ECPGtrans(__LINE__, NULL, "commit");} + { + ECPGtrans(__LINE__, NULL, "commit"); + } #line 47 "indicators.pgc" - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 49 "indicators.pgc" return 0; diff --git a/src/interfaces/ecpg/test/expected/sql-quote.c b/src/interfaces/ecpg/test/expected/sql-quote.c index 5bb9ab005ac..7ab022d9b4e 100644 --- a/src/interfaces/ecpg/test/expected/sql-quote.c +++ b/src/interfaces/ecpg/test/expected/sql-quote.c @@ -22,135 +22,182 @@ #line 5 "quote.pgc" -int main(int argc, char* argv[]) { - /* exec sql begin declare section */ - - +int +main(int argc, char *argv[]) +{ + /* exec sql begin declare section */ + + #line 9 "quote.pgc" - char var [ 25 ] ; + char var[25]; + /* exec sql end declare section */ #line 10 "quote.pgc" - ECPGdebug(1, stderr); - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); } + ECPGdebug(1, stderr); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); + } #line 13 "quote.pgc" - { ECPGsetcommit(__LINE__, "on", NULL);} + { + ECPGsetcommit(__LINE__, "on", NULL); + } #line 15 "quote.pgc" - /* exec sql whenever sql_warning sqlprint ; */ + /* exec sql whenever sql_warning sqlprint ; */ #line 16 "quote.pgc" - /* exec sql whenever sqlerror sqlprint ; */ + /* exec sql whenever sqlerror sqlprint ; */ #line 17 "quote.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table \"My_Table\" ( Item1 int , Item2 text ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table \"My_Table\" ( Item1 int , Item2 text ) ", ECPGt_EOIT, ECPGt_EORT); #line 19 "quote.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 19 "quote.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 19 "quote.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "show standard_conforming_strings", ECPGt_EOIT, - ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "show standard_conforming_strings", ECPGt_EOIT, + ECPGt_char, (var), (long) 25, (long) 1, (25) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 21 "quote.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 21 "quote.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 21 "quote.pgc" - printf("Standard conforming strings: %s\n", var); + printf("Standard conforming strings: %s\n", var); - /* this is a\\b actually */ - { ECPGdo(__LINE__, 0, 1, NULL, "insert into \"My_Table\" values ( 1 , 'a\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT); + /* this is a\\b actually */ + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into \"My_Table\" values ( 1 , 'a\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT); #line 25 "quote.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 25 "quote.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 25 "quote.pgc" - /* this is a\b */ - { ECPGdo(__LINE__, 0, 1, NULL, "insert into \"My_Table\" values ( 1 , 'a\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT); + /* this is a\b */ + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into \"My_Table\" values ( 1 , 'a\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT); #line 27 "quote.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 27 "quote.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 27 "quote.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "set standard_conforming_strings to on", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "set standard_conforming_strings to on", ECPGt_EOIT, ECPGt_EORT); #line 29 "quote.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 29 "quote.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 29 "quote.pgc" - /* this is a\\b actually */ - { ECPGdo(__LINE__, 0, 1, NULL, "insert into \"My_Table\" values ( 1 , 'a\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT); + /* this is a\\b actually */ + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into \"My_Table\" values ( 1 , 'a\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT); #line 32 "quote.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 32 "quote.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 32 "quote.pgc" - /* this is a\b */ - { ECPGdo(__LINE__, 0, 1, NULL, "insert into \"My_Table\" values ( 1 , 'a\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT); + /* this is a\b */ + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into \"My_Table\" values ( 1 , 'a\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT); #line 34 "quote.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 34 "quote.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 34 "quote.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select * from \"My_Table\" ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "select * from \"My_Table\" ", ECPGt_EOIT, ECPGt_EORT); #line 36 "quote.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 36 "quote.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 36 "quote.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "drop table \"My_Table\" ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "drop table \"My_Table\" ", ECPGt_EOIT, ECPGt_EORT); #line 38 "quote.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 38 "quote.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 38 "quote.pgc" - { ECPGdisconnect(__LINE__, "ALL"); + { + ECPGdisconnect(__LINE__, "ALL"); #line 40 "quote.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 40 "quote.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 40 "quote.pgc" - return 0; + return 0; } diff --git a/src/interfaces/ecpg/test/expected/sql-show.c b/src/interfaces/ecpg/test/expected/sql-show.c index e5c906b45eb..a0cba021afc 100644 --- a/src/interfaces/ecpg/test/expected/sql-show.c +++ b/src/interfaces/ecpg/test/expected/sql-show.c @@ -22,105 +22,134 @@ #line 5 "show.pgc" -int main(int argc, char* argv[]) { - /* exec sql begin declare section */ - - +int +main(int argc, char *argv[]) +{ + /* exec sql begin declare section */ + + #line 9 "show.pgc" - char var [ 25 ] ; + char var[25]; + /* exec sql end declare section */ #line 10 "show.pgc" - ECPGdebug(1, stderr); - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); } + ECPGdebug(1, stderr); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); + } #line 13 "show.pgc" - /* exec sql whenever sql_warning sqlprint ; */ + /* exec sql whenever sql_warning sqlprint ; */ #line 15 "show.pgc" - /* exec sql whenever sqlerror sqlprint ; */ + /* exec sql whenever sqlerror sqlprint ; */ #line 16 "show.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "show search_path", ECPGt_EOIT, - ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "show search_path", ECPGt_EOIT, + ECPGt_char, (var), (long) 25, (long) 1, (25) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 18 "show.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 18 "show.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 18 "show.pgc" - printf("Var: Search path: %s\n", var); + printf("Var: Search path: %s\n", var); - { ECPGdo(__LINE__, 0, 1, NULL, "show wal_buffers", ECPGt_EOIT, - ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "show wal_buffers", ECPGt_EOIT, + ECPGt_char, (var), (long) 25, (long) 1, (25) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 21 "show.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 21 "show.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 21 "show.pgc" - printf("Var: WAL buffers: %s\n", var); + printf("Var: WAL buffers: %s\n", var); - { ECPGdo(__LINE__, 0, 1, NULL, "show standard_conforming_strings", ECPGt_EOIT, - ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "show standard_conforming_strings", ECPGt_EOIT, + ECPGt_char, (var), (long) 25, (long) 1, (25) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 24 "show.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 24 "show.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 24 "show.pgc" - printf("Var: Standard conforming strings: %s\n", var); + printf("Var: Standard conforming strings: %s\n", var); - { ECPGdo(__LINE__, 0, 1, NULL, "show time zone", ECPGt_EOIT, - ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "show time zone", ECPGt_EOIT, + ECPGt_char, (var), (long) 25, (long) 1, (25) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 27 "show.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 27 "show.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 27 "show.pgc" - printf("Time Zone: %s\n", var); + printf("Time Zone: %s\n", var); - { ECPGdo(__LINE__, 0, 1, NULL, "show transaction isolation level", ECPGt_EOIT, - ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "show transaction isolation level", ECPGt_EOIT, + ECPGt_char, (var), (long) 25, (long) 1, (25) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 30 "show.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 30 "show.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 30 "show.pgc" - printf("Transaction isolation level: %s\n", var); + printf("Transaction isolation level: %s\n", var); - /* Do not ask for the user name, it may differ in a regression test */ - /* EXEC SQL SHOW SESSION AUTHORIZATION INTO :var; */ + /* Do not ask for the user name, it may differ in a regression test */ + /* EXEC SQL SHOW SESSION AUTHORIZATION INTO :var; */ - { ECPGdisconnect(__LINE__, "ALL"); + { + ECPGdisconnect(__LINE__, "ALL"); #line 36 "show.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 36 "show.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 36 "show.pgc" - return 0; + return 0; } diff --git a/src/interfaces/ecpg/test/expected/sql-update.c b/src/interfaces/ecpg/test/expected/sql-update.c index 39e4ddd6f60..adfed5593dd 100644 --- a/src/interfaces/ecpg/test/expected/sql-update.c +++ b/src/interfaces/ecpg/test/expected/sql-update.c @@ -22,119 +22,161 @@ #line 5 "update.pgc" -int main(int argc, char* argv[]) { - /* exec sql begin declare section */ - - +int +main(int argc, char *argv[]) +{ + /* exec sql begin declare section */ + + #line 9 "update.pgc" - int i1 [ 3 ] , i2 [ 3 ] ; + int i1[3], + i2[3]; + /* exec sql end declare section */ #line 10 "update.pgc" - ECPGdebug(1, stderr); - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); } + ECPGdebug(1, stderr); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); + } #line 13 "update.pgc" - /* exec sql whenever sql_warning sqlprint ; */ + /* exec sql whenever sql_warning sqlprint ; */ #line 15 "update.pgc" - /* exec sql whenever sqlerror sqlprint ; */ + /* exec sql whenever sqlerror sqlprint ; */ #line 16 "update.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table test ( a int , b int ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "create table test ( a int , b int ) ", ECPGt_EOIT, ECPGt_EORT); #line 18 "update.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 18 "update.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 18 "update.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( a , b ) values( 1 , 1 ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( a , b ) values( 1 , 1 ) ", ECPGt_EOIT, ECPGt_EORT); #line 20 "update.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 20 "update.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 20 "update.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( a , b ) values( 2 , 2 ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( a , b ) values( 2 , 2 ) ", ECPGt_EOIT, ECPGt_EORT); #line 21 "update.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 21 "update.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 21 "update.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( a , b ) values( 3 , 3 ) ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( a , b ) values( 3 , 3 ) ", ECPGt_EOIT, ECPGt_EORT); #line 22 "update.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 22 "update.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 22 "update.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "update test set a = a + 1 ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "update test set a = a + 1 ", ECPGt_EOIT, ECPGt_EORT); #line 24 "update.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 24 "update.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 24 "update.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "update test set ( a , b )=( 5 , 5 ) where a = 4 ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "update test set ( a , b )=( 5 , 5 ) where a = 4 ", ECPGt_EOIT, ECPGt_EORT); #line 25 "update.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 25 "update.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 25 "update.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "update test set a = 4 where a = 3 ", ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "update test set a = 4 where a = 3 ", ECPGt_EOIT, ECPGt_EORT); #line 26 "update.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 26 "update.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 26 "update.pgc" -; - - { ECPGdo(__LINE__, 0, 1, NULL, "select a , b from test order by a", ECPGt_EOIT, - ECPGt_int,(i1),(long)1,(long)3,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_int,(i2),(long)1,(long)3,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); + ; + + { + ECPGdo(__LINE__, 0, 1, NULL, "select a , b from test order by a", ECPGt_EOIT, + ECPGt_int, (i1), (long) 1, (long) 3, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_int, (i2), (long) 1, (long) 3, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); #line 28 "update.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 28 "update.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 28 "update.pgc" - printf("test\na b\n%d %d\n%d %d\n%d %d\n", i1[0], i2[0], i1[1], i2[1], i1[2], i2[2]); + printf("test\na b\n%d %d\n%d %d\n%d %d\n", i1[0], i2[0], i1[1], i2[1], i1[2], i2[2]); - { ECPGdisconnect(__LINE__, "ALL"); + { + ECPGdisconnect(__LINE__, "ALL"); #line 32 "update.pgc" -if (sqlca.sqlwarn[0] == 'W') sqlprint(); + if (sqlca.sqlwarn[0] == 'W') + sqlprint(); #line 32 "update.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 32 "update.pgc" - return 0; + return 0; } diff --git a/src/interfaces/ecpg/test/expected/thread-thread.c b/src/interfaces/ecpg/test/expected/thread-thread.c index 96be500f6f1..f2d4b3ff7af 100644 --- a/src/interfaces/ecpg/test/expected/thread-thread.c +++ b/src/interfaces/ecpg/test/expected/thread-thread.c @@ -36,171 +36,215 @@ main(void) #line 19 "thread.pgc" -void *test_thread(void *arg); +void *test_thread(void *arg); -int nthreads = 10; -int iterations = 20; +int nthreads = 10; +int iterations = 20; -int main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { - pthread_t *threads; - int n; - /* exec sql begin declare section */ - - + pthread_t *threads; + int n; + + /* exec sql begin declare section */ + + #line 31 "thread.pgc" - int l_rows ; + int l_rows; + /* exec sql end declare section */ #line 32 "thread.pgc" - /* Switch off debug output for regression tests. The threads get executed in - * more or less random order */ - ECPGdebug(0, stderr); + /* + * Switch off debug output for regression tests. The threads get executed + * in more or less random order + */ + ECPGdebug(0, stderr); - /* setup test_thread table */ - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); } + /* setup test_thread table */ + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); + } #line 41 "thread.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "drop table test_thread ", ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "drop table test_thread ", ECPGt_EOIT, ECPGt_EORT); + } #line 42 "thread.pgc" - /* DROP might fail */ - { ECPGtrans(__LINE__, NULL, "commit");} + /* DROP might fail */ + { + ECPGtrans(__LINE__, NULL, "commit"); + } #line 43 "thread.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table test_thread ( tstamp timestamp not null default cast( timeofday () as timestamp ) , thread TEXT not null , iteration integer not null , primary key( thread , iteration ) ) ", ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "create table test_thread ( tstamp timestamp not null default cast( timeofday () as timestamp ) , thread TEXT not null , iteration integer not null , primary key( thread , iteration ) ) ", ECPGt_EOIT, ECPGt_EORT); + } #line 48 "thread.pgc" - { ECPGtrans(__LINE__, NULL, "commit");} + { + ECPGtrans(__LINE__, NULL, "commit"); + } #line 49 "thread.pgc" - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 50 "thread.pgc" - /* create, and start, threads */ - threads = calloc(nthreads, sizeof(pthread_t)); - if( threads == NULL ) - { - fprintf(stderr, "Cannot alloc memory\n"); - return( 1 ); - } - for( n = 0; n < nthreads; n++ ) - { - pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1)); - } - - /* wait for thread completion */ - for( n = 0; n < nthreads; n++ ) - { - pthread_join(threads[n], NULL); - } - free(threads); - - /* and check results */ - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); } + /* create, and start, threads */ + threads = calloc(nthreads, sizeof(pthread_t)); + if (threads == NULL) + { + fprintf(stderr, "Cannot alloc memory\n"); + return (1); + } + for (n = 0; n < nthreads; n++) + { + pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1)); + } + + /* wait for thread completion */ + for (n = 0; n < nthreads; n++) + { + pthread_join(threads[n], NULL); + } + free(threads); + + /* and check results */ + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); + } #line 72 "thread.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select count (*) from test_thread ", ECPGt_EOIT, - ECPGt_int,&(l_rows),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "select count (*) from test_thread ", ECPGt_EOIT, + ECPGt_int, &(l_rows), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); + } #line 73 "thread.pgc" - { ECPGtrans(__LINE__, NULL, "commit");} + { + ECPGtrans(__LINE__, NULL, "commit"); + } #line 74 "thread.pgc" - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 75 "thread.pgc" - if( l_rows == (nthreads * iterations) ) - printf("Success.\n"); - else - printf("ERROR: Failure - expecting %d rows, got %d.\n", nthreads * iterations, l_rows); + if (l_rows == (nthreads * iterations)) + printf("Success.\n"); + else + printf("ERROR: Failure - expecting %d rows, got %d.\n", nthreads * iterations, l_rows); - return( 0 ); + return (0); } -void *test_thread(void *arg) +void * +test_thread(void *arg) { - long threadnum = (long)arg; - /* exec sql begin declare section */ - - - + long threadnum = (long) arg; + + /* exec sql begin declare section */ + + + #line 88 "thread.pgc" - int l_i ; - + int l_i; + #line 89 "thread.pgc" - char l_connection [ 128 ] ; + char l_connection[128]; + /* exec sql end declare section */ #line 90 "thread.pgc" - /* build up connection name, and connect to database */ - snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum); - /* exec sql whenever sqlerror sqlprint ; */ + /* build up connection name, and connect to database */ + snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum); + /* exec sql whenever sqlerror sqlprint ; */ #line 94 "thread.pgc" - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , l_connection, 0); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, l_connection, 0); #line 95 "thread.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 95 "thread.pgc" - if( sqlca.sqlcode != 0 ) - { - printf("%s: ERROR: cannot connect to database!\n", l_connection); - return( NULL ); - } - { ECPGtrans(__LINE__, l_connection, "begin transaction "); + if (sqlca.sqlcode != 0) + { + printf("%s: ERROR: cannot connect to database!\n", l_connection); + return (NULL); + } + { + ECPGtrans(__LINE__, l_connection, "begin transaction "); #line 101 "thread.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 101 "thread.pgc" - /* insert into test_thread table */ - for( l_i = 1; l_i <= iterations; l_i++ ) - { + /* insert into test_thread table */ + for (l_i = 1; l_i <= iterations; l_i++) + { #ifdef DEBUG - printf("%s: inserting %d\n", l_connection, l_i); + printf("%s: inserting %d\n", l_connection, l_i); #endif - { ECPGdo(__LINE__, 0, 1, l_connection, "insert into test_thread ( thread , iteration ) values( ? , ? ) ", - ECPGt_char,(l_connection),(long)128,(long)1,(128)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, l_connection, "insert into test_thread ( thread , iteration ) values( ? , ? ) ", + ECPGt_char, (l_connection), (long) 128, (long) 1, (128) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_int, &(l_i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 109 "thread.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 109 "thread.pgc" #ifdef DEBUG - if( sqlca.sqlcode == 0 ) - printf("%s: insert done\n", l_connection); - else - printf("%s: ERROR: insert failed!\n", l_connection); + if (sqlca.sqlcode == 0) + printf("%s: insert done\n", l_connection); + else + printf("%s: ERROR: insert failed!\n", l_connection); #endif - } + } - /* all done */ - { ECPGtrans(__LINE__, l_connection, "commit"); + /* all done */ + { + ECPGtrans(__LINE__, l_connection, "commit"); #line 119 "thread.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 119 "thread.pgc" - { ECPGdisconnect(__LINE__, l_connection); + { + ECPGdisconnect(__LINE__, l_connection); #line 120 "thread.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 120 "thread.pgc" #ifdef DEBUG - printf("%s: done!\n", l_connection); + printf("%s: done!\n", l_connection); #endif - return( NULL ); + return (NULL); } -#endif /* ENABLE_THREAD_SAFETY */ + +#endif /* ENABLE_THREAD_SAFETY */ diff --git a/src/interfaces/ecpg/test/expected/thread-thread_implicit.c b/src/interfaces/ecpg/test/expected/thread-thread_implicit.c index b2a95d54006..f7bf6fab763 100644 --- a/src/interfaces/ecpg/test/expected/thread-thread_implicit.c +++ b/src/interfaces/ecpg/test/expected/thread-thread_implicit.c @@ -37,171 +37,215 @@ main(void) #line 20 "thread_implicit.pgc" -void *test_thread(void *arg); +void *test_thread(void *arg); -int nthreads = 10; -int iterations = 20; +int nthreads = 10; +int iterations = 20; -int main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { - pthread_t *threads; - int n; - /* exec sql begin declare section */ - - + pthread_t *threads; + int n; + + /* exec sql begin declare section */ + + #line 32 "thread_implicit.pgc" - int l_rows ; + int l_rows; + /* exec sql end declare section */ #line 33 "thread_implicit.pgc" - /* Switch off debug output for regression tests. The threads get executed in - * more or less random order */ - ECPGdebug(0, stderr); + /* + * Switch off debug output for regression tests. The threads get executed + * in more or less random order + */ + ECPGdebug(0, stderr); - /* setup test_thread table */ - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); } + /* setup test_thread table */ + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); + } #line 42 "thread_implicit.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "drop table test_thread ", ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "drop table test_thread ", ECPGt_EOIT, ECPGt_EORT); + } #line 43 "thread_implicit.pgc" - /* DROP might fail */ - { ECPGtrans(__LINE__, NULL, "commit");} + /* DROP might fail */ + { + ECPGtrans(__LINE__, NULL, "commit"); + } #line 44 "thread_implicit.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "create table test_thread ( tstamp timestamp not null default cast( timeofday () as timestamp ) , thread TEXT not null , iteration integer not null , primary key( thread , iteration ) ) ", ECPGt_EOIT, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "create table test_thread ( tstamp timestamp not null default cast( timeofday () as timestamp ) , thread TEXT not null , iteration integer not null , primary key( thread , iteration ) ) ", ECPGt_EOIT, ECPGt_EORT); + } #line 49 "thread_implicit.pgc" - { ECPGtrans(__LINE__, NULL, "commit");} + { + ECPGtrans(__LINE__, NULL, "commit"); + } #line 50 "thread_implicit.pgc" - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 51 "thread_implicit.pgc" - /* create, and start, threads */ - threads = calloc(nthreads, sizeof(pthread_t)); - if( threads == NULL ) - { - fprintf(stderr, "Cannot alloc memory\n"); - return( 1 ); - } - for( n = 0; n < nthreads; n++ ) - { - pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1)); - } - - /* wait for thread completion */ - for( n = 0; n < nthreads; n++ ) - { - pthread_join(threads[n], NULL); - } - free(threads); - - /* and check results */ - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); } + /* create, and start, threads */ + threads = calloc(nthreads, sizeof(pthread_t)); + if (threads == NULL) + { + fprintf(stderr, "Cannot alloc memory\n"); + return (1); + } + for (n = 0; n < nthreads; n++) + { + pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1)); + } + + /* wait for thread completion */ + for (n = 0; n < nthreads; n++) + { + pthread_join(threads[n], NULL); + } + free(threads); + + /* and check results */ + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0); + } #line 73 "thread_implicit.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, "select count (*) from test_thread ", ECPGt_EOIT, - ECPGt_int,&(l_rows),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + { + ECPGdo(__LINE__, 0, 1, NULL, "select count (*) from test_thread ", ECPGt_EOIT, + ECPGt_int, &(l_rows), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); + } #line 74 "thread_implicit.pgc" - { ECPGtrans(__LINE__, NULL, "commit");} + { + ECPGtrans(__LINE__, NULL, "commit"); + } #line 75 "thread_implicit.pgc" - { ECPGdisconnect(__LINE__, "CURRENT");} + { + ECPGdisconnect(__LINE__, "CURRENT"); + } #line 76 "thread_implicit.pgc" - if( l_rows == (nthreads * iterations) ) - printf("Success.\n"); - else - printf("ERROR: Failure - expecting %d rows, got %d.\n", nthreads * iterations, l_rows); + if (l_rows == (nthreads * iterations)) + printf("Success.\n"); + else + printf("ERROR: Failure - expecting %d rows, got %d.\n", nthreads * iterations, l_rows); - return( 0 ); + return (0); } -void *test_thread(void *arg) +void * +test_thread(void *arg) { - long threadnum = (long)arg; - /* exec sql begin declare section */ - - - + long threadnum = (long) arg; + + /* exec sql begin declare section */ + + + #line 89 "thread_implicit.pgc" - int l_i ; - + int l_i; + #line 90 "thread_implicit.pgc" - char l_connection [ 128 ] ; + char l_connection[128]; + /* exec sql end declare section */ #line 91 "thread_implicit.pgc" - /* build up connection name, and connect to database */ - snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum); - /* exec sql whenever sqlerror sqlprint ; */ + /* build up connection name, and connect to database */ + snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum); + /* exec sql whenever sqlerror sqlprint ; */ #line 95 "thread_implicit.pgc" - { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , l_connection, 0); + { + ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, l_connection, 0); #line 96 "thread_implicit.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 96 "thread_implicit.pgc" - if( sqlca.sqlcode != 0 ) - { - printf("%s: ERROR: cannot connect to database!\n", l_connection); - return( NULL ); - } - { ECPGtrans(__LINE__, NULL, "begin transaction "); + if (sqlca.sqlcode != 0) + { + printf("%s: ERROR: cannot connect to database!\n", l_connection); + return (NULL); + } + { + ECPGtrans(__LINE__, NULL, "begin transaction "); #line 102 "thread_implicit.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 102 "thread_implicit.pgc" - /* insert into test_thread table */ - for( l_i = 1; l_i <= iterations; l_i++ ) - { + /* insert into test_thread table */ + for (l_i = 1; l_i <= iterations; l_i++) + { #ifdef DEBUG - printf("%s: inserting %d\n", l_connection, l_i); + printf("%s: inserting %d\n", l_connection, l_i); #endif - { ECPGdo(__LINE__, 0, 1, NULL, "insert into test_thread ( thread , iteration ) values( ? , ? ) ", - ECPGt_char,(l_connection),(long)128,(long)1,(128)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); + { + ECPGdo(__LINE__, 0, 1, NULL, "insert into test_thread ( thread , iteration ) values( ? , ? ) ", + ECPGt_char, (l_connection), (long) 128, (long) 1, (128) * sizeof(char), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, + ECPGt_int, &(l_i), (long) 1, (long) 1, sizeof(int), + ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); #line 110 "thread_implicit.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 110 "thread_implicit.pgc" #ifdef DEBUG - if( sqlca.sqlcode == 0 ) - printf("%s: insert done\n", l_connection); - else - printf("%s: ERROR: insert failed!\n", l_connection); + if (sqlca.sqlcode == 0) + printf("%s: insert done\n", l_connection); + else + printf("%s: ERROR: insert failed!\n", l_connection); #endif - } + } - /* all done */ - { ECPGtrans(__LINE__, NULL, "commit"); + /* all done */ + { + ECPGtrans(__LINE__, NULL, "commit"); #line 120 "thread_implicit.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 120 "thread_implicit.pgc" - { ECPGdisconnect(__LINE__, l_connection); + { + ECPGdisconnect(__LINE__, l_connection); #line 121 "thread_implicit.pgc" -if (sqlca.sqlcode < 0) sqlprint();} + if (sqlca.sqlcode < 0) + sqlprint(); + } #line 121 "thread_implicit.pgc" #ifdef DEBUG - printf("%s: done!\n", l_connection); + printf("%s: done!\n", l_connection); #endif - return( NULL ); + return (NULL); } -#endif /* ENABLE_THREAD_SAFETY */ + +#endif /* ENABLE_THREAD_SAFETY */ diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index bcc4c570bf5..7725f52f354 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -10,7 +10,7 @@ * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.120 2006/09/22 21:39:58 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.121 2006/10/04 00:30:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -100,7 +100,7 @@ pg_an_to_ln(char *aname) * Various krb5 state which is not connection specific, and a flag to * indicate whether we have initialised it yet. */ -/* +/* static int pg_krb5_initialised; static krb5_context pg_krb5_context; static krb5_ccache pg_krb5_ccache; @@ -110,16 +110,16 @@ static char *pg_krb5_name; struct krb5_info { - int pg_krb5_initialised; - krb5_context pg_krb5_context; - krb5_ccache pg_krb5_ccache; - krb5_principal pg_krb5_client; - char *pg_krb5_name; + int pg_krb5_initialised; + krb5_context pg_krb5_context; + krb5_ccache pg_krb5_ccache; + krb5_principal pg_krb5_client; + char *pg_krb5_name; }; static int -pg_krb5_init(char *PQerrormsg, struct krb5_info *info) +pg_krb5_init(char *PQerrormsg, struct krb5_info * info) { krb5_error_code retval; @@ -175,8 +175,8 @@ pg_krb5_init(char *PQerrormsg, struct krb5_info *info) return STATUS_OK; } -static void -pg_krb5_destroy(struct krb5_info *info) +static void +pg_krb5_destroy(struct krb5_info * info) { krb5_free_principal(info->pg_krb5_context, info->pg_krb5_client); krb5_cc_close(info->pg_krb5_context, info->pg_krb5_ccache); @@ -193,8 +193,9 @@ pg_krb5_destroy(struct krb5_info *info) static char * pg_krb5_authname(char *PQerrormsg) { - char *tmp_name; + char *tmp_name; struct krb5_info info; + info.pg_krb5_initialised = 0; if (pg_krb5_init(PQerrormsg, &info) != STATUS_OK) @@ -219,6 +220,7 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, const char *hostname, const char *s krb5_auth_context auth_context = NULL; krb5_error *err_ret = NULL; struct krb5_info info; + info.pg_krb5_initialised = 0; if (!hostname) @@ -519,7 +521,7 @@ char * pg_fe_getauthname(char *PQerrormsg) { #ifdef KRB5 - char *krb5_name = NULL; + char *krb5_name = NULL; #endif const char *name = NULL; char *authn; @@ -545,10 +547,12 @@ pg_fe_getauthname(char *PQerrormsg) pglock_thread(); #ifdef KRB5 - /* pg_krb5_authname gives us a strdup'd value that we need - * to free later, however, we don't want to free 'name' directly - * in case it's *not* a Kerberos login and we fall through to - * name = pw->pw_name; */ + + /* + * pg_krb5_authname gives us a strdup'd value that we need to free later, + * however, we don't want to free 'name' directly in case it's *not* a + * Kerberos login and we fall through to name = pw->pw_name; + */ krb5_name = pg_krb5_authname(PQerrormsg); name = krb5_name; #endif @@ -583,7 +587,7 @@ pg_fe_getauthname(char *PQerrormsg) * * This is intended to be used by client applications that wish to send * commands like ALTER USER joe PASSWORD 'pwd'. The password need not - * be sent in cleartext if it is encrypted on the client side. This is + * be sent in cleartext if it is encrypted on the client side. This is * good because it ensures the cleartext password won't end up in logs, * pg_stat displays, etc. We export the function so that clients won't * be dependent on low-level details like whether the enceyption is MD5 diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 0dca43803f1..fd08023aae7 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.336 2006/09/27 15:41:24 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.337 2006/10/04 00:30:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,7 +66,7 @@ typedef struct timeval LDAP_TIMEVAL; #endif static int ldapServiceLookup(const char *purl, PQconninfoOption *options, - PQExpBuffer errorMessage); + PQExpBuffer errorMessage); #endif #include "libpq/ip.h" @@ -513,9 +513,9 @@ connectOptions2(PGconn *conn) conn->sslmode = strdup(DefaultSSLMode); /* - * Only if we get this far is it appropriate to try to connect. - * (We need a state flag, rather than just the boolean result of - * this function, in case someone tries to PQreset() the PGconn.) + * Only if we get this far is it appropriate to try to connect. (We need a + * state flag, rather than just the boolean result of this function, in + * case someone tries to PQreset() the PGconn.) */ conn->options_valid = true; @@ -2385,13 +2385,31 @@ static int ldapServiceLookup(const char *purl, PQconninfoOption *options, PQExpBuffer errorMessage) { - int port = LDAP_DEF_PORT, scope, rc, msgid, size, state, oldstate, i; + int port = LDAP_DEF_PORT, + scope, + rc, + msgid, + size, + state, + oldstate, + i; bool found_keyword; - char *url, *hostname, *portstr, *endptr, *dn, *scopestr, *filter, - *result, *p, *p1 = NULL, *optname = NULL, *optval = NULL; + char *url, + *hostname, + *portstr, + *endptr, + *dn, + *scopestr, + *filter, + *result, + *p, + *p1 = NULL, + *optname = NULL, + *optval = NULL; char *attrs[2] = {NULL, NULL}; LDAP *ld = NULL; - LDAPMessage *res, *entry; + LDAPMessage *res, + *entry; struct berval **values; LDAP_TIMEVAL time = {PGLDAP_TIMEOUT, 0}; @@ -2402,9 +2420,9 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, } /* - * Parse URL components, check for correctness. Basically, url has - * '\0' placed at component boundaries and variables are pointed - * at each component. + * Parse URL components, check for correctness. Basically, url has '\0' + * placed at component boundaries and variables are pointed at each + * component. */ if (pg_strncasecmp(url, LDAP_URL, strlen(LDAP_URL)) != 0) @@ -2417,26 +2435,26 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, /* hostname */ hostname = url + strlen(LDAP_URL); - if (*hostname == '/') /* no hostname? */ - hostname = "localhost"; /* the default */ + if (*hostname == '/') /* no hostname? */ + hostname = "localhost"; /* the default */ /* dn, "distinguished name" */ - p = strchr(url + strlen(LDAP_URL), '/'); + p = strchr(url + strlen(LDAP_URL), '/'); if (p == NULL || *(p + 1) == '\0' || *(p + 1) == '?') { printfPQExpBuffer(errorMessage, libpq_gettext( - "bad LDAP URL \"%s\": missing distinguished name\n"), purl); + "bad LDAP URL \"%s\": missing distinguished name\n"), purl); free(url); return 3; } - *p = '\0'; /* terminate hostname */ + *p = '\0'; /* terminate hostname */ dn = p + 1; /* attribute */ if ((p = strchr(dn, '?')) == NULL || *(p + 1) == '\0' || *(p + 1) == '?') { printfPQExpBuffer(errorMessage, libpq_gettext( - "bad LDAP URL \"%s\": must have exactly one attribute\n"), purl); + "bad LDAP URL \"%s\": must have exactly one attribute\n"), purl); free(url); return 3; } @@ -2447,7 +2465,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, if ((p = strchr(attrs[0], '?')) == NULL || *(p + 1) == '\0' || *(p + 1) == '?') { printfPQExpBuffer(errorMessage, libpq_gettext( - "bad LDAP URL \"%s\": must have search scope (base/one/sub)\n"), purl); + "bad LDAP URL \"%s\": must have search scope (base/one/sub)\n"), purl); free(url); return 3; } @@ -2479,7 +2497,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, if (*portstr == '\0' || *endptr != '\0' || errno || lport < 0 || lport > 65535) { printfPQExpBuffer(errorMessage, libpq_gettext( - "bad LDAP URL \"%s\": invalid port number\n"), purl); + "bad LDAP URL \"%s\": invalid port number\n"), purl); free(url); return 3; } @@ -2490,7 +2508,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, if (strchr(attrs[0], ',') != NULL) { printfPQExpBuffer(errorMessage, libpq_gettext( - "bad LDAP URL \"%s\": must have exactly one attribute\n"), purl); + "bad LDAP URL \"%s\": must have exactly one attribute\n"), purl); free(url); return 3; } @@ -2505,7 +2523,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, else { printfPQExpBuffer(errorMessage, libpq_gettext( - "bad LDAP URL \"%s\": must have search scope (base/one/sub)\n"), purl); + "bad LDAP URL \"%s\": must have search scope (base/one/sub)\n"), purl); free(url); return 3; } @@ -2520,8 +2538,8 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, } /* - * Initialize connection to the server. We do an explicit bind because - * we want to return 2 if the bind fails. + * Initialize connection to the server. We do an explicit bind because we + * want to return 2 if the bind fails. */ if ((msgid = ldap_simple_bind(ld, NULL, NULL)) == -1) { @@ -2655,8 +2673,8 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, else if (ld_is_nl_cr(*p)) { printfPQExpBuffer(errorMessage, libpq_gettext( - "missing \"=\" after \"%s\" in connection info string\n"), - optname); + "missing \"=\" after \"%s\" in connection info string\n"), + optname); return 3; } else if (*p == '=') @@ -2673,8 +2691,8 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, else if (!ld_is_sp_tab(*p)) { printfPQExpBuffer(errorMessage, libpq_gettext( - "missing \"=\" after \"%s\" in connection info string\n"), - optname); + "missing \"=\" after \"%s\" in connection info string\n"), + optname); return 3; } break; @@ -2737,7 +2755,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, { printfPQExpBuffer(errorMessage, libpq_gettext("invalid connection option \"%s\"\n"), - optname); + optname); return 1; } optname = NULL; @@ -2749,7 +2767,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, if (state == 5 || state == 6) { printfPQExpBuffer(errorMessage, libpq_gettext( - "unterminated quoted string in connection info string\n")); + "unterminated quoted string in connection info string\n")); return 3; } @@ -2854,7 +2872,8 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage) #ifdef USE_LDAP if (strncmp(line, "ldap", 4) == 0) { - int rc = ldapServiceLookup(line, options, errorMessage); + int rc = ldapServiceLookup(line, options, errorMessage); + /* if rc = 2, go on reading for fallback */ switch (rc) { @@ -3376,10 +3395,10 @@ PQsetClientEncoding(PGconn *conn, const char *encoding) else { /* - * In protocol 2 we have to assume the setting will stick, and - * adjust our state immediately. In protocol 3 and up we can - * rely on the backend to report the parameter value, and we'll - * change state at that time. + * In protocol 2 we have to assume the setting will stick, and adjust + * our state immediately. In protocol 3 and up we can rely on the + * backend to report the parameter value, and we'll change state at + * that time. */ if (PG_PROTOCOL_MAJOR(conn->pversion) < 3) pqSaveParameterStatus(conn, "client_encoding", encoding); @@ -3547,14 +3566,14 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username) if (hostname == NULL) hostname = DefaultHost; else if (is_absolute_path(hostname)) + /* - * We should probably use canonicalize_path(), but then - * we have to bring path.c into libpq, and it doesn't - * seem worth it. + * We should probably use canonicalize_path(), but then we have to + * bring path.c into libpq, and it doesn't seem worth it. */ if (strcmp(hostname, DEFAULT_PGSOCKET_DIR) == 0) hostname = DefaultHost; - + if (port == NULL) port = DEF_PGPORT_STR; diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 71d9c02eb1e..5a7adb2ff8b 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.190 2006/08/18 19:52:39 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.191 2006/10/04 00:30:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ char *const pgresStatus[] = { * values that result in backward-compatible behavior */ static int static_client_encoding = PG_SQL_ASCII; -static bool static_std_strings = false; +static bool static_std_strings = false; static bool PQsendQueryStart(PGconn *conn); @@ -61,8 +61,8 @@ static int PQsendQueryGuts(PGconn *conn, static void parseInput(PGconn *conn); static bool PQexecStart(PGconn *conn); static PGresult *PQexecFinish(PGconn *conn); -static int PQsendDescribe(PGconn *conn, char desc_type, - const char *desc_target); +static int PQsendDescribe(PGconn *conn, char desc_type, + const char *desc_target); /* ---------------- @@ -626,11 +626,11 @@ pqSaveParameterStatus(PGconn *conn, const char *name, const char *value) } /* - * Special hacks: remember client_encoding and standard_conforming_strings, - * and convert server version to a numeric form. We keep the first two of - * these in static variables as well, so that PQescapeString and - * PQescapeBytea can behave somewhat sanely (at least in single- - * connection-using programs). + * Special hacks: remember client_encoding and + * standard_conforming_strings, and convert server version to a numeric + * form. We keep the first two of these in static variables as well, so + * that PQescapeString and PQescapeBytea can behave somewhat sanely (at + * least in single- connection-using programs). */ if (strcmp(name, "client_encoding") == 0) { @@ -1483,7 +1483,7 @@ PQexecFinish(PGconn *conn) * If the query was not even sent, return NULL; conn->errorMessage is set to * a relevant message. * If the query was sent, a new PGresult is returned (which could indicate - * either success or failure). On success, the PGresult contains status + * either success or failure). On success, the PGresult contains status * PGRES_COMMAND_OK, and its parameter and column-heading fields describe * the statement's inputs and outputs respectively. * The user is responsible for freeing the PGresult via PQclear() @@ -1549,8 +1549,8 @@ PQsendDescribePortal(PGconn *conn, const char *portal) * Common code to send a Describe command * * Available options for desc_type are - * 'S' to describe a prepared statement; or - * 'P' to describe a portal. + * 'S' to describe a prepared statement; or + * 'P' to describe a portal. * Returns 1 on success and 0 on failure. */ static int @@ -1661,11 +1661,11 @@ PQputCopyData(PGconn *conn, const char *buffer, int nbytes) /* * Process any NOTICE or NOTIFY messages that might be pending in the - * input buffer. Since the server might generate many notices during - * the COPY, we want to clean those out reasonably promptly to prevent - * indefinite expansion of the input buffer. (Note: the actual read - * of input data into the input buffer happens down inside pqSendSome, - * but it's not authorized to get rid of the data again.) + * input buffer. Since the server might generate many notices during the + * COPY, we want to clean those out reasonably promptly to prevent + * indefinite expansion of the input buffer. (Note: the actual read of + * input data into the input buffer happens down inside pqSendSome, but + * it's not authorized to get rid of the data again.) */ parseInput(conn); @@ -2134,7 +2134,7 @@ check_param_number(const PGresult *res, int param_num) param_num, res->numParameters - 1); return FALSE; } - + return TRUE; } @@ -2377,7 +2377,8 @@ PQoidValue(const PGresult *res) char * PQcmdTuples(PGresult *res) { - char *p, *c; + char *p, + *c; if (!res) return ""; @@ -2389,7 +2390,7 @@ PQcmdTuples(PGresult *res) while (*p && *p != ' ') p++; if (*p == 0) - goto interpret_error; /* no space? */ + goto interpret_error; /* no space? */ p++; } else if (strncmp(res->cmdStatus, "DELETE ", 7) == 0 || @@ -2413,7 +2414,7 @@ PQcmdTuples(PGresult *res) goto interpret_error; return p; - + interpret_error: pqInternalNotice(&res->noticeHooks, "could not interpret result from server: %s", @@ -2462,7 +2463,7 @@ PQgetisnull(const PGresult *res, int tup_num, int field_num) } /* PQnparams: - * returns the number of input parameters of a prepared statement. + * returns the number of input parameters of a prepared statement. */ int PQnparams(const PGresult *res) @@ -2473,7 +2474,7 @@ PQnparams(const PGresult *res) } /* PQparamtype: - * returns type Oid of the specified statement parameter. + * returns type Oid of the specified statement parameter. */ Oid PQparamtype(const PGresult *res, int param_num) @@ -2612,9 +2613,9 @@ PQescapeStringInternal(PGconn *conn, while (remaining > 0 && *source != '\0') { - char c = *source; - int len; - int i; + char c = *source; + int len; + int i; /* Fast path for plain ASCII */ if (!IS_HIGHBIT_SET(c)) @@ -2643,9 +2644,9 @@ PQescapeStringInternal(PGconn *conn, /* * If we hit premature end of string (ie, incomplete multibyte - * character), try to pad out to the correct length with spaces. - * We may not be able to pad completely, but we will always be able - * to insert at least one pad space (since we'd not have quoted a + * character), try to pad out to the correct length with spaces. We + * may not be able to pad completely, but we will always be able to + * insert at least one pad space (since we'd not have quoted a * multibyte character). This should be enough to make a string that * the server will error out on. */ @@ -2655,7 +2656,7 @@ PQescapeStringInternal(PGconn *conn, *error = 1; if (conn) printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("incomplete multibyte character\n")); + libpq_gettext("incomplete multibyte character\n")); for (; i < len; i++) { if (((size_t) (target - to)) / 2 >= length) diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c index 998a5648992..10e8a91ed3e 100644 --- a/src/interfaces/libpq/fe-lobj.c +++ b/src/interfaces/libpq/fe-lobj.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.59 2006/09/07 15:37:25 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.60 2006/10/04 00:30:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -479,10 +479,10 @@ lo_import(PGconn *conn, const char *filename) if (tmp != nbytes) { /* - * If lo_write() failed, we are now in an aborted transaction - * so there's no need for lo_close(); furthermore, if we tried - * it we'd overwrite the useful error result with a useless one. - * So just nail the doors shut and get out of town. + * If lo_write() failed, we are now in an aborted transaction so + * there's no need for lo_close(); furthermore, if we tried it + * we'd overwrite the useful error result with a useless one. So + * just nail the doors shut and get out of town. */ (void) close(fd); return InvalidOid; @@ -492,7 +492,7 @@ lo_import(PGconn *conn, const char *filename) if (nbytes < 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not read from file \"%s\": %s\n"), + libpq_gettext("could not read from file \"%s\": %s\n"), filename, pqStrerror(errno, sebuf, sizeof(sebuf))); lobjOid = InvalidOid; } @@ -565,10 +565,10 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) } /* - * If lo_read() failed, we are now in an aborted transaction - * so there's no need for lo_close(); furthermore, if we tried - * it we'd overwrite the useful error result with a useless one. - * So skip lo_close() if we got a failure result. + * If lo_read() failed, we are now in an aborted transaction so there's no + * need for lo_close(); furthermore, if we tried it we'd overwrite the + * useful error result with a useless one. So skip lo_close() if we got a + * failure result. */ if (nbytes < 0 || lo_close(conn, lobj) != 0) diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index 2c76dfdde36..635c3f0674d 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -23,7 +23,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.129 2006/07/14 05:28:29 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.130 2006/10/04 00:30:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,7 +62,7 @@ static int pqPutMsgBytes(const void *buf, size_t len, PGconn *conn); static int pqSendSome(PGconn *conn, int len); -static int pqSocketCheck(PGconn *conn, int forRead, int forWrite, +static int pqSocketCheck(PGconn *conn, int forRead, int forWrite, time_t end_time); static int pqSocketPoll(int sock, int forRead, int forWrite, time_t end_time); diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c index 0ecbcf4ad03..9ae7a1fa076 100644 --- a/src/interfaces/libpq/fe-print.c +++ b/src/interfaces/libpq/fe-print.c @@ -10,7 +10,7 @@ * didn't really belong there. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.72 2006/07/14 16:59:19 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.73 2006/10/04 00:30:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -276,7 +276,7 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po) { if (po->caption) fprintf(fout, - "<table %s><caption align=\"top\">%s</caption>\n", + "<table %s><caption align=\"top\">%s</caption>\n", po->tableOpt ? po->tableOpt : "", po->caption); else diff --git a/src/interfaces/libpq/fe-protocol3.c b/src/interfaces/libpq/fe-protocol3.c index 1feae23a437..8f75577c859 100644 --- a/src/interfaces/libpq/fe-protocol3.c +++ b/src/interfaces/libpq/fe-protocol3.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.28 2006/10/01 22:25:48 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.29 2006/10/04 00:30:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,7 +52,7 @@ static int getNotify(PGconn *conn); static int getCopyStart(PGconn *conn, ExecStatusType copytype); static int getReadyForQuery(PGconn *conn); static void reportErrorPosition(PQExpBuffer msg, const char *query, - int loc, int encoding); + int loc, int encoding); static int build_startup_packet(const PGconn *conn, char *packet, const PQEnvironmentOption *options); @@ -270,9 +270,10 @@ pqParseInput3(PGconn *conn) /* First 'T' in a query sequence */ if (getRowDescriptions(conn)) return; + /* - * If we're doing a Describe, we're ready to pass - * the result back to the client. + * If we're doing a Describe, we're ready to pass the + * result back to the client. */ if (conn->queryclass == PGQUERY_DESCRIBE) conn->asyncStatus = PGASYNC_READY; @@ -301,9 +302,10 @@ pqParseInput3(PGconn *conn) if (conn->result == NULL) conn->result = PQmakeEmptyPGresult(conn, PGRES_COMMAND_OK); + /* - * If we're doing a Describe, we're ready to pass - * the result back to the client. + * If we're doing a Describe, we're ready to pass the + * result back to the client. */ if (conn->queryclass == PGQUERY_DESCRIBE) conn->asyncStatus = PGASYNC_READY; @@ -443,9 +445,9 @@ getRowDescriptions(PGconn *conn) int i; /* - * When doing Describe for a prepared statement, there'll already be - * a PGresult created by getParamDescriptions, and we should fill - * data into that. Otherwise, create a new, empty PGresult. + * When doing Describe for a prepared statement, there'll already be a + * PGresult created by getParamDescriptions, and we should fill data into + * that. Otherwise, create a new, empty PGresult. */ if (conn->queryclass == PGQUERY_DESCRIBE) { @@ -527,14 +529,15 @@ getRowDescriptions(PGconn *conn) return 0; failure: + /* * Discard incomplete result, unless it's from getParamDescriptions. * * Note that if we hit a bufferload boundary while handling the * describe-statement case, we'll forget any PGresult space we just - * allocated, and then reallocate it on next try. This will bloat - * the PGresult a little bit but the space will be freed at PQclear, - * so it doesn't seem worth trying to be smarter. + * allocated, and then reallocate it on next try. This will bloat the + * PGresult a little bit but the space will be freed at PQclear, so it + * doesn't seem worth trying to be smarter. */ if (result != conn->result) PQclear(result); @@ -553,10 +556,10 @@ failure: static int getParamDescriptions(PGconn *conn) { - PGresult *result; - int nparams; - int i; - + PGresult *result; + int nparams; + int i; + result = PQmakeEmptyPGresult(conn, PGRES_COMMAND_OK); if (!result) goto failure; @@ -580,8 +583,8 @@ getParamDescriptions(PGconn *conn) /* get parameter info */ for (i = 0; i < nparams; i++) { - int typid; - + int typid; + if (pqGetInt(&typid, 4, conn)) goto failure; result->paramDescs[i].typid = typid; @@ -910,7 +913,7 @@ reportErrorPosition(PQExpBuffer msg, const char *query, int loc, int encoding) /* * Each character might occupy multiple physical bytes in the string, and * in some Far Eastern character sets it might take more than one screen - * column as well. We compute the starting byte offset and starting + * column as well. We compute the starting byte offset and starting * screen column of each logical character, and store these in qidx[] and * scridx[] respectively. */ @@ -936,13 +939,13 @@ reportErrorPosition(PQExpBuffer msg, const char *query, int loc, int encoding) mb_encoding = (pg_encoding_max_length(encoding) != 1); /* - * Within the scanning loop, cno is the current character's logical number, - * qoffset is its offset in wquery, and scroffset is its starting logical - * screen column (all indexed from 0). "loc" is the logical character - * number of the error location. We scan to determine loc_line (the - * 1-based line number containing loc) and ibeg/iend (first character - * number and last+1 character number of the line containing loc). - * Note that qidx[] and scridx[] are filled only as far as iend. + * Within the scanning loop, cno is the current character's logical + * number, qoffset is its offset in wquery, and scroffset is its starting + * logical screen column (all indexed from 0). "loc" is the logical + * character number of the error location. We scan to determine loc_line + * (the 1-based line number containing loc) and ibeg/iend (first character + * number and last+1 character number of the line containing loc). Note + * that qidx[] and scridx[] are filled only as far as iend. */ qoffset = 0; scroffset = 0; @@ -952,7 +955,7 @@ reportErrorPosition(PQExpBuffer msg, const char *query, int loc, int encoding) for (cno = 0; wquery[qoffset] != '\0'; cno++) { - char ch = wquery[qoffset]; + char ch = wquery[qoffset]; qidx[cno] = qoffset; scridx[cno] = scroffset; @@ -966,8 +969,8 @@ reportErrorPosition(PQExpBuffer msg, const char *query, int loc, int encoding) wquery[qoffset] = ' '; /* - * If end-of-line, count lines and mark positions. Each \r or \n counts - * as a line except when \r \n appear together. + * If end-of-line, count lines and mark positions. Each \r or \n + * counts as a line except when \r \n appear together. */ else if (ch == '\r' || ch == '\n') { @@ -992,7 +995,7 @@ reportErrorPosition(PQExpBuffer msg, const char *query, int loc, int encoding) /* Advance */ if (mb_encoding) { - int w; + int w; w = pg_encoding_dsplen(encoding, &wquery[qoffset]); /* treat any non-tab control chars as width 1 */ @@ -1069,7 +1072,7 @@ reportErrorPosition(PQExpBuffer msg, const char *query, int loc, int encoding) scroffset = 0; for (; i < msg->len; i += pg_encoding_mblen(encoding, &msg->data[i])) { - int w = pg_encoding_dsplen(encoding, &msg->data[i]); + int w = pg_encoding_dsplen(encoding, &msg->data[i]); if (w <= 0) w = 1; diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c index d886179f6d2..859df9acf87 100644 --- a/src/interfaces/libpq/fe-secure.c +++ b/src/interfaces/libpq/fe-secure.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.87 2006/09/27 15:41:24 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.88 2006/10/04 00:30:13 momjian Exp $ * * NOTES * [ Most of these notes are wrong/obsolete, but perhaps not all ] @@ -782,7 +782,7 @@ initialize_SSL(PGconn *conn) if (stat(fnbuf, &buf) == 0) { X509_STORE *cvstore; - + if (!SSL_CTX_load_verify_locations(SSL_context, fnbuf, NULL)) { char *err = SSLerrmessage(); @@ -800,13 +800,13 @@ initialize_SSL(PGconn *conn) if (X509_STORE_load_locations(cvstore, ROOT_CRL_FILE, NULL) != 0) /* OpenSSL 0.96 does not support X509_V_FLAG_CRL_CHECK */ #ifdef X509_V_FLAG_CRL_CHECK - X509_STORE_set_flags(cvstore, - X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL); + X509_STORE_set_flags(cvstore, + X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL); /* if not found, silently ignore; we do not require CRL */ #else { char *err = SSLerrmessage(); - + printfPQExpBuffer(&conn->errorMessage, libpq_gettext("Installed SSL library does not support CRL certificates, file \"%s\"\n"), fnbuf); @@ -815,7 +815,7 @@ initialize_SSL(PGconn *conn) } #endif } - + SSL_CTX_set_verify(SSL_context, SSL_VERIFY_PEER, verify_cb); } } diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index 135791a4f1e..daa29cc3b12 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.133 2006/09/07 15:37:25 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.134 2006/10/04 00:30:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -410,8 +410,8 @@ extern int PQnparams(const PGresult *res); extern Oid PQparamtype(const PGresult *res, int param_num); /* Describe prepared statements and portals */ -extern PGresult *PQdescribePrepared(PGconn *conn, const char *stmt); -extern PGresult *PQdescribePortal(PGconn *conn, const char *portal); +extern PGresult *PQdescribePrepared(PGconn *conn, const char *stmt); +extern PGresult *PQdescribePortal(PGconn *conn, const char *portal); extern int PQsendDescribePrepared(PGconn *conn, const char *stmt); extern int PQsendDescribePortal(PGconn *conn, const char *portal); @@ -437,13 +437,14 @@ extern PGresult *PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status); /* Quoting strings before inclusion in queries. */ extern size_t PQescapeStringConn(PGconn *conn, - char *to, const char *from, size_t length, - int *error); + char *to, const char *from, size_t length, + int *error); extern unsigned char *PQescapeByteaConn(PGconn *conn, const unsigned char *from, size_t from_length, size_t *to_length); extern unsigned char *PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen); + /* These forms are deprecated! */ extern size_t PQescapeString(char *to, const char *from, size_t length); extern unsigned char *PQescapeBytea(const unsigned char *from, size_t from_length, diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h index e3532fbf6f1..e69200f5af9 100644 --- a/src/interfaces/libpq/libpq-int.h +++ b/src/interfaces/libpq/libpq-int.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.115 2006/08/18 19:52:39 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.116 2006/10/04 00:30:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -285,7 +285,7 @@ struct pg_conn /* Status indicators */ ConnStatusType status; PGAsyncStatusType asyncStatus; - PGTransactionStatusType xactStatus; /* never changes to ACTIVE */ + PGTransactionStatusType xactStatus; /* never changes to ACTIVE */ PGQueryClass queryclass; char *last_query; /* last SQL command, or NULL if unknown */ bool options_valid; /* true if OK to attempt connection */ diff --git a/src/interfaces/libpq/win32.c b/src/interfaces/libpq/win32.c index 2867aba2d55..a4ec2ebb70c 100644 --- a/src/interfaces/libpq/win32.c +++ b/src/interfaces/libpq/win32.c @@ -29,7 +29,7 @@ #include "win32.h" -/* Declared here to avoid pulling in all includes, which causes name collissions */ +/* Declared here to avoid pulling in all includes, which causes name collissions */ #ifdef ENABLE_NLS extern char * libpq_gettext(const char *msgid) |