diff --git a/src/backend/utils/mb/encnames.c b/src/backend/utils/mb/encnames.c index 12b61cd..76e2e20 100644 --- a/src/backend/utils/mb/encnames.c +++ b/src/backend/utils/mb/encnames.c @@ -402,6 +402,53 @@ const pg_enc2gettext pg_enc2gettext_tbl[] = {0, NULL} }; +const pg_encmaxlen pg_encmaxlen_tbl[] = +{ + {PG_SQL_ASCII, 1}, + {PG_EUC_JP, 1}, + {PG_EUC_CN, 1}, + {PG_EUC_KR, 1}, + {PG_EUC_TW, 1}, + {PG_EUC_JIS_2004, 1}, + {PG_UTF8, 4}, + {PG_MULE_INTERNAL, 1}, + {PG_LATIN1, 1}, + {PG_LATIN2, 1}, + {PG_LATIN3, 1}, + {PG_LATIN4, 1}, + {PG_LATIN5, 1}, + {PG_LATIN6, 1}, + {PG_LATIN7, 1}, + {PG_LATIN8, 1}, + {PG_LATIN9, 1}, + {PG_LATIN10, 1}, + {PG_WIN1256, 1}, + {PG_WIN1258, 1}, + {PG_WIN866, 1}, + {PG_WIN874, 1}, + {PG_KOI8R, 1}, + {PG_WIN1251, 1}, + {PG_WIN1252, 1}, + {PG_ISO_8859_5, 1}, + {PG_ISO_8859_6, 1}, + {PG_ISO_8859_7, 1}, + {PG_ISO_8859_8, 1}, + {PG_WIN1250, 1}, + {PG_WIN1253, 1}, + {PG_WIN1254, 1}, + {PG_WIN1255, 1}, + {PG_WIN1256, 1}, + {PG_WIN1257, 1}, + {PG_KOI8U, 1}, + {PG_SJIS, 2}, + {PG_BIG5, 2}, + {PG_GBK, 2}, + {PG_UHC, 2}, + {PG_GB18030, 4}, + {PG_JOHAB, 3}, + {PG_SHIFT_JIS_2004, 2}, + {0, 0} +}; #ifndef FRONTEND diff --git a/src/include/mb/pg_wchar.h b/src/include/mb/pg_wchar.h index d57ef01..8f345ed 100644 --- a/src/include/mb/pg_wchar.h +++ b/src/include/mb/pg_wchar.h @@ -334,6 +334,14 @@ typedef struct pg_enc2gettext extern const pg_enc2gettext pg_enc2gettext_tbl[]; +typedef struct pg_encmaxlen +{ + pg_enc encoding; + int len; +} pg_encmaxlen; + +extern const pg_encmaxlen pg_encmaxlen_tbl[]; + /* * Encoding names for ICU */ diff --git a/src/interfaces/ecpg/ecpglib/Makefile b/src/interfaces/ecpg/ecpglib/Makefile index fbb1407..0fd43d4 100644 --- a/src/interfaces/ecpg/ecpglib/Makefile +++ b/src/interfaces/ecpg/ecpglib/Makefile @@ -26,7 +26,7 @@ override CFLAGS += $(PTHREAD_CFLAGS) LIBS := $(filter-out -lpgport, $(LIBS)) OBJS= execute.o typename.o descriptor.o sqlda.o data.o error.o prepare.o memory.o \ - connect.o misc.o path.o pgstrcasecmp.o \ + connect.o misc.o path.o pgstrcasecmp.o convertutf.o \ $(filter snprintf.o strlcpy.o win32setlocale.o isinf.o, $(LIBOBJS)) $(WIN32RES) # thread.c is needed only for non-WIN32 implementation of path.c diff --git a/src/interfaces/ecpg/ecpglib/convertutf.c b/src/interfaces/ecpg/ecpglib/convertutf.c new file mode 100644 index 0000000..03bb617 --- /dev/null +++ b/src/interfaces/ecpg/ecpglib/convertutf.c @@ -0,0 +1,180 @@ +/* +/* src/interfaces/ecpg/ecpglib/convertutf.c */ + +#include "convertutf.h" +#include "c.h" +#ifdef CVTUTF_DEBUG +#include +#endif +#include +#include + +#ifndef false +#define false 0 +#endif + +#ifndef true +#define true 1 +#endif + +static bool is_little_endian(void); + +/* Return true if utext string is null*/ +bool utext_is_null(char *source) +{ +#if defined(WIN32) + if(*(short int*)source == 0) +#else + if(*(int*)source == 0) +#endif + return true; + + return false; +} + + +/***** + * Get the UTF32 or UTF16 string length by characters. + * Four bytes UTF16 consider it as 2 characters. + * maxlen means the max character length of the unicode string. + * if maxlen = 0, then get the length until find the 0x0000. + */ +long get_utext_length(char *source, unsigned int maxlen) +{ + long len = 0; + + while(1) + { +#if defined(WIN32) + if ((short)(*source) == 0x00) +#else + if ((int)(*source) == 0x00) +#endif + break; + + len++; + source += UNICODE_CH_LEN; + + if(maxlen && len>=maxlen) + return maxlen; + } + + return len; +} + +ConversionResult +convert_func(char *from_code, char *to_code, char *from, size_t from_len, char *to, size_t to_len, int *real_len) +{ + iconv_t cd; + int len = to_len; + ConversionResult ret = conversionOK; + + //cd = iconv_open("UTF-16LE","SHIFT-JIS"); + cd = iconv_open(to_code,from_code); + + if((cd) == (iconv_t) -1) + return conversionUnsupported; + + if(iconv(cd, &from, &from_len, &to, &to_len) == -1) + { + int num = 0; + +#if defined(WIN32) + num = GetLastError(); + if (num ==0 && to_len == 0 && from_len > 0) + num = E2BIG; +#else + num = errno; +#endif + + if(num == E2BIG) + ret = targetExhausted; + else + ret = sourceIllegal; + } + else + { + if(real_len) + *real_len = (len - to_len); + } + + iconv_close(cd); + + return ret; +} + +/* + * This function return the need converted length by bytes. + */ +int get_converted_length(char *from_code, char *to_code, char *from, size_t from_len) +{ + iconv_t cd; + size_t to_len = from_len *4; + int max_len; + int convert_ret; + char buffer[512]={0}; + char *to = buffer; + bool need_free = false; + + if (to_len > 512) + { + to = (char*)malloc(to_len); + memset(to,0,to_len); + need_free = true; + } + + max_len = to_len; + + cd = iconv_open(to_code,from_code); + if((cd) == (iconv_t) -1) + return conversionUnsupported; + + convert_ret = (int)iconv(cd, &from, &from_len, &to, &to_len); + + iconv_close(cd); + + if(need_free) + free(to); + + if(convert_ret==-1) + return convert_ret; + + return (max_len - to_len); +} + +/***** + * Return the unicode encoding name based on the platform + */ +char * +get_utext_encoding() +{ +#if defined(WIN32) + if(is_little_endian()) + return "UTF-16LE"; + else + return "UTF-16BE"; +#else + if(is_little_endian()) + return "UTF32LE"; + else + return "UTF32BE"; +#endif +} + +/* + * Check which type of endianness format supported by the machine + * Return: + * True -- little endian + * False -- big endian + * + */ +static bool +is_little_endian() +{ + int n = 1; + + if(*(char *)&n == 1) + return true; + + return false; +} diff --git a/src/interfaces/ecpg/ecpglib/data.c b/src/interfaces/ecpg/ecpglib/data.c index a2f3916..509329e 100644 --- a/src/interfaces/ecpg/ecpglib/data.c +++ b/src/interfaces/ecpg/ecpglib/data.c @@ -15,6 +15,7 @@ #include "pgtypes_date.h" #include "pgtypes_timestamp.h" #include "pgtypes_interval.h" +#include "convertutf.h" /* returns true if character c is a delimiter for the given array type */ static bool @@ -235,6 +236,8 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, case ECPGt_unsigned_char: case ECPGt_varchar: case ECPGt_string: + case ECPGt_utext: + case ECPGt_uvarchar: break; default: @@ -506,7 +509,110 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, pval += size; } break; + case ECPGt_utext: + { + int real_len = 0; + int utext_len = 0; + char *str = (char *) (var + offset * act_tuple); + char *encoding = NULL; + int pval_len = size; + int to_len; + char *dest_encoding = get_utext_encoding(); + int dest_character_size = UNICODE_CH_LEN; + + ConversionResult convert_ret; + + /* Here will be modified later by setting length according to encoding */ + to_len = varcharsize>0?offset:size*dest_character_size; + + /* Check the PGCLIENTENCODING */ + encoding = PQGetEncodingName(PQGetEncodingFromPGres(results)); + if(encoding == NULL) + { + ecpg_raise(lineno, ECPG_CLIENT_ENCODING_ERROR, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL); + return false; + } + + /* + * If varcharsize is unknown and the offset is that of + * char *, then this variable represents the array of + * character pointers. So, use extra indirection. + */ + if (varcharsize == 0 && offset == sizeof(char *)) + str = *(char **) str; + + /* + * Don't know the real size of the utext pointer, + * so set the offset to be needed size. + * For utext pointer to pointer host variable with + * uninitialized the offset will be set zero as input + * parameter. + * For utext pointer host varaible the varcharsize is + * zero and offset is not. + */ + if (varcharsize == 0 || offset == 0) + { + real_len = get_converted_length(encoding,dest_encoding,pval,pval_len); + to_len = offset = real_len; + memset(str,0,offset+dest_character_size); + } + else + memset(str,0,offset); + + /* Start to convert encoding to UTF16 */ + convert_ret = convert_func(encoding,dest_encoding, pval,pval_len,str,to_len,&real_len); + if (convert_ret == sourceIllegal || convert_ret == conversionUnsupported) + { + ecpg_raise(lineno, ECPG_ENCODING_ERROR, ECPG_SQLSTATE_ECPG_ENCODING_ERROR, NULL); + return false; + } + else if (convert_ret == targetExhausted) + { + real_len = get_converted_length(encoding,dest_encoding,pval,pval_len); + if(real_len == -1) + { + ecpg_raise(lineno, ECPG_ENCODING_ERROR, ECPG_SQLSTATE_ECPG_ENCODING_ERROR, NULL); + return false; + } + } + + utext_len = real_len/dest_character_size; + /* + * If the need bytes by UTF16 string is larger than the + * length of host variable, set the ind variable + */ + if (varcharsize > 0 && varcharsize < utext_len) + { + /* truncation */ + switch (ind_type) + { + case ECPGt_short: + case ECPGt_unsigned_short: + *((short *) (ind + ind_offset * act_tuple)) = utext_len; + break; + case ECPGt_int: + case ECPGt_unsigned_int: + *((int *) (ind + ind_offset * act_tuple)) = utext_len; + break; + case ECPGt_long: + case ECPGt_unsigned_long: + *((long *) (ind + ind_offset * act_tuple)) = utext_len; + break; +#ifdef HAVE_LONG_LONG_INT + case ECPGt_long_long: + case ECPGt_unsigned_long_long: + *((long long int *) (ind + ind_offset * act_tuple)) = utext_len; + break; +#endif /* HAVE_LONG_LONG_INT */ + default: + break; + } + sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W'; + } + pval += size; + } + break; case ECPGt_varchar: { struct ECPGgeneric_varchar *variable = @@ -554,6 +660,87 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, } break; + case ECPGt_uvarchar: + { + int real_len = 0; + int utext_len = 0; + int to_len = 0; + int pval_len = size; + char *encoding = NULL; + ConversionResult convert_ret = conversionOK; + struct ECPGgeneric_varchar *variable = + (struct ECPGgeneric_varchar *) (var + offset * act_tuple); + + char *str = (char *) (variable->arr); + + char *dest_encoding = get_utext_encoding(); + int dest_character_size = UNICODE_CH_LEN; + + memset((char*)variable, 0, offset); + + /* Check the PGCLIENTENCODING */ + encoding = PQGetEncodingName(PQGetEncodingFromPGres(results)); + if(encoding == NULL) + { + ecpg_raise(lineno, ECPG_CLIENT_ENCODING_ERROR, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL); + return false; + } + + to_len = offset-sizeof(int); + + /* Start to convert encoding to UTF16 or UTF32 */ + convert_ret = convert_func(encoding,dest_encoding, pval,pval_len,str,to_len,&real_len); + + if (convert_ret == sourceIllegal || convert_ret == conversionUnsupported) + { + ecpg_raise(lineno, ECPG_ENCODING_ERROR, ECPG_SQLSTATE_ECPG_ENCODING_ERROR, NULL); + return false; + } + else if (convert_ret == targetExhausted) + { + real_len = get_converted_length(encoding,dest_encoding,pval,pval_len); + if(real_len == -1) + { + ecpg_raise(lineno, ECPG_ENCODING_ERROR, ECPG_SQLSTATE_ECPG_ENCODING_ERROR, NULL); + return false; + } + } + + /* Get the actual length of UTF16 characters */ + utext_len = real_len/dest_character_size; + variable->len = Min(utext_len,varcharsize); + + if (utext_len > varcharsize) + { + /* truncation */ + switch (ind_type) + { + case ECPGt_short: + case ECPGt_unsigned_short: + *((short *) (ind + ind_offset * act_tuple)) = utext_len; + break; + case ECPGt_int: + case ECPGt_unsigned_int: + *((int *) (ind + ind_offset * act_tuple)) = utext_len; + break; + case ECPGt_long: + case ECPGt_unsigned_long: + *((long *) (ind + ind_offset * act_tuple)) = utext_len; + break; +#ifdef HAVE_LONG_LONG_INT + case ECPGt_long_long: + case ECPGt_unsigned_long_long: + *((long long int *) (ind + ind_offset * act_tuple)) = utext_len; + break; +#endif /* HAVE_LONG_LONG_INT */ + default: + break; + } + sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W'; + } + pval += size; + } + break; case ECPGt_decimal: case ECPGt_numeric: for (endptr = pval; *endptr && *endptr != ',' && *endptr != '}'; endptr++); diff --git a/src/interfaces/ecpg/ecpglib/error.c b/src/interfaces/ecpg/ecpglib/error.c index f34ae4a..80979d5 100644 --- a/src/interfaces/ecpg/ecpglib/error.c +++ b/src/interfaces/ecpg/ecpglib/error.c @@ -40,6 +40,16 @@ ecpg_raise(int line, int code, const char *sqlstate, const char *str) ecpg_gettext("out of memory on line %d"), line); break; + case ECPG_ENCODING_ERROR: + snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), + + /* + * translator: this string will be truncated at 149 characters + * expanded. + */ + ecpg_gettext("encoding conversion error on line %d"), line); + break; + case ECPG_UNSUPPORTED: snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), /*------ @@ -200,6 +210,15 @@ ecpg_raise(int line, int code, const char *sqlstate, const char *str) ecpg_gettext("could not connect to database \"%s\" on line %d"), str, line); break; + case ECPG_CLIENT_ENCODING_ERROR: + snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), + + /* + * translator: this string will be truncated at 149 characters + * expanded. + */ + ecpg_gettext("Failed to get client encoding name on line %d"),line); + break; default: snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), /*------ diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index 50f831a..1e331d0 100644 --- a/src/interfaces/ecpg/ecpglib/execute.c +++ b/src/interfaces/ecpg/ecpglib/execute.c @@ -33,7 +33,10 @@ #include "pgtypes_date.h" #include "pgtypes_timestamp.h" #include "pgtypes_interval.h" +#include "convertutf.h" +static int ecpg_do_utext_encoding(struct variable * var, int client_encoding,int lineno); +static int ecpg_do_uvachar_encoding(struct variable * var, int client_encoding,int lineno); /* * This function returns a newly malloced string that has ' and \ * escaped. @@ -88,6 +91,11 @@ free_variable(struct variable *var) while (var) { + if (var->alloc_inf == 1) + ecpg_free(var->value); + if (var->ind_alloc_inf == 1) + ecpg_free(var->ind_value); + var_next = var->next; ecpg_free(var); var = var_next; @@ -382,9 +390,83 @@ ecpg_store_result(const PGresult *results, int act_field, len = var->offset * ntuples; } break; + case ECPGt_utext: + { + char *pval; + int pval_len; + int unicode_str_len; + + char *src_encoding; + char *dest_encoding = get_utext_encoding(); + + /* Check the PGCLIENTENCODING */ + src_encoding = PQGetEncodingName(PQGetEncodingFromPGres(results)); + if(src_encoding == NULL) + { + ecpg_raise(stmt->lineno, ECPG_CLIENT_ENCODING_ERROR, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL); + return false; + } + + if (!var->varcharsize && !var->arrsize) + { + /* special mode for handling utext **foo=0 */ + for (act_tuple = 0; act_tuple < ntuples; act_tuple++) + { + pval = (char *) PQgetvalue(results, act_tuple, act_field); + pval_len = PQgetlength(results, act_tuple, act_field); + + unicode_str_len = get_converted_length(src_encoding,dest_encoding,pval,pval_len); + if(unicode_str_len == -1) + { + ecpg_raise(stmt->lineno, ECPG_ENCODING_ERROR, ECPG_SQLSTATE_ECPG_ENCODING_ERROR, NULL); + return false; + } + + len += unicode_str_len + UNICODE_CH_LEN; + } + len += (ntuples + 1) * sizeof(char *); + } + else + { + var->varcharsize = 0; + /* check strlen for each tuple */ + for (act_tuple = 0; act_tuple < ntuples; act_tuple++) + { + pval = (char *) PQgetvalue(results, act_tuple, act_field); + pval_len = PQgetlength(results, act_tuple, act_field); + + unicode_str_len = get_converted_length(src_encoding,dest_encoding,pval,pval_len); + if(unicode_str_len == -1) + { + ecpg_raise(stmt->lineno, ECPG_ENCODING_ERROR, ECPG_SQLSTATE_ECPG_ENCODING_ERROR, NULL); + return false; + } + + /* utf16_str_len indicates the utf16 string length by bytes */ + unicode_str_len = unicode_str_len + UNICODE_CH_LEN; + + if (unicode_str_len > var->varcharsize) + var->varcharsize = unicode_str_len; + } + + /* Here offset is the utf16 length by bytes, + * so no need using '*' as used in char + */ + var->offset = var->varcharsize; + + /* varcharsize contains number of characters so divided by UNICODE_CH_LEN*/ + var->varcharsize = var->varcharsize/UNICODE_CH_LEN; + + len = var->offset * ntuples; + } + } + break; case ECPGt_varchar: len = ntuples * (var->varcharsize + sizeof(int)); break; + case ECPGt_uvarchar: + len = ntuples * (var->varcharsize*2 + sizeof(int)); + break; default: len = var->offset * ntuples; break; @@ -416,7 +498,7 @@ ecpg_store_result(const PGresult *results, int act_field, /* fill the variable with the tuple(s) */ if (!var->varcharsize && !var->arrsize && - (var->type == ECPGt_char || var->type == ECPGt_unsigned_char || var->type == ECPGt_string)) + (var->type == ECPGt_char || var->type == ECPGt_unsigned_char || var->type == ECPGt_string || var->type == ECPGt_utext)) { /* special mode for handling char**foo=0 */ @@ -437,7 +519,10 @@ ecpg_store_result(const PGresult *results, int act_field, else { *current_string = current_data_location; - current_data_location += len; + if(var->type == ECPGt_utext) + current_data_location += (get_utext_length(current_data_location,0)+1)*UNICODE_CH_LEN; + else + current_data_location += len; current_string++; } } @@ -772,6 +857,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari case ECPGt_char: case ECPGt_unsigned_char: case ECPGt_string: + case ECPGt_utext: { /* set slen to string length if type is char * */ int slen = (var->varcharsize == 0) ? strlen((char *) var->value) : (unsigned int) var->varcharsize; @@ -807,6 +893,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari } break; case ECPGt_varchar: + case ECPGt_uvarchar: { struct ECPGgeneric_varchar *variable = (struct ECPGgeneric_varchar *) (var->value); @@ -1754,6 +1841,7 @@ ecpg_do_prologue(int lineno, const int compat, const int force_indicator, enum ECPGttype type; struct variable **list; char *prepname; + int outparam = 0; *stmt_out = NULL; @@ -1869,7 +1957,10 @@ ecpg_do_prologue(int lineno, const int compat, const int force_indicator, while (type != ECPGt_EORT) { if (type == ECPGt_EOIT) + { + outparam = 1; list = &(stmt->outlist); + } else { struct variable *var, @@ -1900,6 +1991,39 @@ ecpg_do_prologue(int lineno, const int compat, const int force_indicator, else var->value = var->pointer; + if (var->type == ECPGt_utext) + { + if(outparam == 0 && + ecpg_do_utext_encoding(var, PQGetEncodingFromPGconn(con->connection),lineno) == -1) + { + if ( NULL != var ) + { + ecpg_free(var); + var = NULL; + } + + ecpg_do_epilogue(stmt); + + return false; + } + } + else if(var->type == ECPGt_uvarchar) + { + if(outparam == 0 && + ecpg_do_uvachar_encoding(var, PQGetEncodingFromPGconn(con->connection),lineno) == -1) + { + if ( NULL != var ) + { + ecpg_free(var); + var = NULL; + } + + ecpg_do_epilogue(stmt); + + return false; + } + } + /* * negative values are used to indicate an array without given * bounds @@ -2049,3 +2173,217 @@ ECPGdo_descriptor(int line, const char *connection, ECPGt_descriptor, descriptor, 0L, 0L, 0L, ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT); } + +/* + * Translate the var->value with type utext into a new value with ECPGCLIENT encoding + * and save it into ptr. + * The var->offset is changed to bytes unit. + * Success: return 0; + * Failure: return -1 + */ +static int +ecpg_do_utext_encoding(struct variable * var, int client_encoding,int lineno) +{ + + int i; + int src_offset; + char *src_offset_start = NULL; + int dest_offset; + char *dest_offset_start = NULL; + char *dest; + int dest_length; + long varcharsize = 0; + int arrsize; + ConversionResult convert_ret; + int dest_character_len; + + char *encoding = NULL; + char *utext_encoding = get_utext_encoding(); + + arrsize = var->arrsize; + + /* + * For utext type variable, the var->offset indicate the how many bytes + * in one element in array. + * utext is 2 bytes type in windows platform + */ + src_offset = var->offset; + + if (utext_is_null(var->value)) + { + /* Go to here means the content in the utext host varailbe is NULL, + * so no need convert it */ + var->varcharsize = 1; + return 0; + } + + encoding = PQGetEncodingName(client_encoding); + if(encoding == NULL) + { + ecpg_raise(lineno, ECPG_CLIENT_ENCODING_ERROR, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL); + return false; + } + + /* + * For the pointer variable varcharsize is zero so have to get the real + * varcharsize from the get_utext_length. + */ + if(var->varcharsize == 0) + { + varcharsize = get_utext_length(var->value,0); + if (varcharsize == 0) + { + /* Go to here means the content in the pointer is NULL, + * so no need convert it */ + var->varcharsize = 1; + return 0; + } + else + src_offset = varcharsize * UNICODE_CH_LEN; + } + else + varcharsize = var->varcharsize; + + dest_character_len = PQGenEncodingMaxLen(client_encoding); + + dest_length = var->arrsize * varcharsize *dest_character_len; + dest_offset = varcharsize *dest_character_len; + + dest = ecpg_alloc(dest_length, lineno); + if (!dest) + return -1; + + memset(dest, 0, dest_length); + + src_offset_start = var->value; + dest_offset_start = dest; + + /* Convert the string offset by offset */ + for(i=0; ioffset = dest_offset; + var->varcharsize = dest_offset; + var->value = dest; + + return 0; +} + + +/* + * Translate the var->value with type uvarchar into a new value with ECPGCLIENT encoding + * and save it into ptr. + * The var->offset is changed to bytes unit. + * Success: return 0; + * Failure: return -1 + */ +static int +ecpg_do_uvachar_encoding(struct variable * var, int client_encoding,int lineno) +{ + + int i; + int src_offset; + char *src_offset_start = NULL; + int dest_offset; + char *dest_offset_start = NULL; + char *dest; + int dest_length; + int final_len = 0; + int arrsize; + ConversionResult convert_ret; + int dest_character_len; + + char *encoding = NULL; + int num; + int num_bytes = 0; + char *utext_encoding = get_utext_encoding(); + + arrsize = var->arrsize; + + dest_character_len = PQGenEncodingMaxLen(client_encoding); + dest_offset = (var->varcharsize *dest_character_len +sizeof(int)); + dest_length = dest_offset *arrsize; + + dest = ecpg_alloc(dest_length, lineno); + if (!dest) + return -1; + + memset(dest, 0, dest_length); + + src_offset = var->offset; + src_offset_start = var->value; + dest_offset_start = dest; + + encoding = PQGetEncodingName(client_encoding); + if(encoding == NULL) + { + ecpg_raise(lineno, ECPG_CLIENT_ENCODING_ERROR, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL); + return false; + } + + /* Convert the string offset by offset */ + for(i=0; ioffset = dest_offset; + var->varcharsize = dest_offset; + var->value = dest; + + return 0; +} + diff --git a/src/interfaces/ecpg/ecpglib/extern.h b/src/interfaces/ecpg/ecpglib/extern.h index 91c7367..a9e501f 100644 --- a/src/interfaces/ecpg/ecpglib/extern.h +++ b/src/interfaces/ecpg/ecpglib/extern.h @@ -122,6 +122,8 @@ struct variable long ind_varcharsize; long ind_arrsize; long ind_offset; + int alloc_inf; + int ind_alloc_inf; struct variable *next; }; @@ -219,5 +221,6 @@ void ecpg_set_native_sqlda(int, struct sqlda_struct **, const PGresult *, int, /* implementation-defined internal errors of ecpg */ #define ECPG_SQLSTATE_ECPG_INTERNAL_ERROR "YE000" #define ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY "YE001" +#define ECPG_SQLSTATE_ECPG_ENCODING_ERROR "YE002" #endif /* _ECPG_LIB_EXTERN_H */ diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c index 2084d7f..dc4331e 100644 --- a/src/interfaces/ecpg/ecpglib/misc.c +++ b/src/interfaces/ecpg/ecpglib/misc.c @@ -369,6 +369,21 @@ ECPGset_noind_null(enum ECPGttype type, void *ptr) case ECPGt_timestamp: memset((char *) ptr, 0xff, sizeof(timestamp)); break; + case ECPGt_utext: +#if defined(WIN32) + memset(ptr, 0x00, 2); +#else + memset(ptr, 0x00, 4); +#endif + break; + case ECPGt_uvarchar: +#if defined(WIN32) + memset(((struct ECPGgeneric_varchar *) ptr)->arr, 0x00, 2); +#else + memset(((struct ECPGgeneric_varchar *) ptr)->arr, 0x00, 4); +#endif + ((struct ECPGgeneric_varchar *) ptr)->len = 0; + break; default: break; } @@ -442,6 +457,18 @@ ECPGis_noind_null(enum ECPGttype type, void *ptr) case ECPGt_timestamp: return _check(ptr, sizeof(timestamp)); break; + case ECPGt_utext: +#if defined(WIN32) + if (*((short int *) ptr) == 0) +#else + if (*((int *) ptr) == 0) +#endif + return true; + break; + case ECPGt_uvarchar: + if (((struct ECPGgeneric_varchar *) ptr)->len == 0) + return true; + break; default: break; } diff --git a/src/interfaces/ecpg/ecpglib/typename.c b/src/interfaces/ecpg/ecpglib/typename.c index 48587e4..aec3ac2 100644 --- a/src/interfaces/ecpg/ecpglib/typename.c +++ b/src/interfaces/ecpg/ecpglib/typename.c @@ -47,6 +47,10 @@ ecpg_type_name(enum ECPGttype typ) return "bool"; case ECPGt_varchar: return "varchar"; + case ECPGt_utext: + return "utext"; + case ECPGt_uvarchar: + return "uvarchar"; case ECPGt_char_variable: return "char"; case ECPGt_decimal: diff --git a/src/interfaces/ecpg/include/convertutf.h b/src/interfaces/ecpg/include/convertutf.h new file mode 100644 index 0000000..7bddf40 --- /dev/null +++ b/src/interfaces/ecpg/include/convertutf.h @@ -0,0 +1,42 @@ +#ifndef ConvertUTF_INCLUDED +#define ConvertUTF_INCLUDED +#include +#include "c.h" + +/* define unicode character length by bytes */ +#if defined(WIN32) +#define UNICODE_CH_LEN 2 +#else +#define UNICODE_CH_LEN 4 +#endif + +typedef enum +{ + conversionOK, /* conversion successful */ + sourceExhausted, /* partial character in source, but hit end */ + targetExhausted, /* insuff. room in target for conversion */ + sourceIllegal, /* source sequence is illegal/malformed */ + conversionUnsupported /* Don't support this type convert */ +} ConversionResult; + +/* This is for C++ and does no harm in C */ +#ifdef __cplusplus +extern "C" { +#endif + +bool utext_is_null(char *source); +long get_utext_length(char *source, unsigned int maxlen); + +ConversionResult convert_func(char *from_code, char *to_code, + char *from, size_t from_len, + char *to, size_t to_len, int *real_len); + +int get_converted_length(char *from_code, char *to_code, char *from, size_t from_len); +char *get_utext_encoding(void); +#ifdef __cplusplus +} +#endif + +/* --------------------------------------------------------------------- */ + +#endif /* ConvertUTF_INCLUDED */ diff --git a/src/interfaces/ecpg/include/ecpgerrno.h b/src/interfaces/ecpg/include/ecpgerrno.h index c4bc526..6d13065 100644 --- a/src/interfaces/ecpg/include/ecpgerrno.h +++ b/src/interfaces/ecpg/include/ecpgerrno.h @@ -44,6 +44,8 @@ #define ECPG_UNKNOWN_DESCRIPTOR_ITEM -242 #define ECPG_VAR_NOT_NUMERIC -243 #define ECPG_VAR_NOT_CHAR -244 +#define ECPG_ENCODING_ERROR -250 +#define ECPG_CLIENT_ENCODING_ERROR -301 /* finally the backend error messages, they start at 400 */ #define ECPG_PGSQL -400 diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h index 536b750..d546c49 100644 --- a/src/interfaces/ecpg/include/ecpglib.h +++ b/src/interfaces/ecpg/include/ecpglib.h @@ -11,13 +11,24 @@ #include "ecpgtype.h" #include "sqlca.h" #include - +#if defined(WIN32) +#include +#endif #ifdef ENABLE_NLS extern char *ecpg_gettext(const char *msgid) pg_attribute_format_arg(1); #else #define ecpg_gettext(x) (x) #endif +#if defined ECPG_ENABLE_UTEXT +#if defined(WIN32) +typedef WCHAR utext; +#else +#include +typedef wchar_t utext; +#endif +#endif + #ifndef __cplusplus #ifndef bool #define bool char diff --git a/src/interfaces/ecpg/include/ecpgtype.h b/src/interfaces/ecpg/include/ecpgtype.h index 38fb3b6..0316a84 100644 --- a/src/interfaces/ecpg/include/ecpgtype.h +++ b/src/interfaces/ecpg/include/ecpgtype.h @@ -63,7 +63,9 @@ enum ECPGttype ECPGt_EORT, /* End of result types. */ ECPGt_NO_INDICATOR, /* no indicator */ ECPGt_string, /* trimmed (char *) type */ - ECPGt_sqlda /* C struct descriptor */ + ECPGt_sqlda, /* C struct descriptor */ + ECPGt_utext, + ECPGt_uvarchar }; /* descriptor items */ @@ -88,7 +90,7 @@ enum ECPGdtype ECPGd_cardinality }; -#define IS_SIMPLE_TYPE(type) (((type) >= ECPGt_char && (type) <= ECPGt_interval) || ((type) == ECPGt_string)) +#define IS_SIMPLE_TYPE(type) (((type) >= ECPGt_char && (type) <= ECPGt_interval) || ((type) == ECPGt_string) || ((type) == ECPGt_utext) || ((type) == ECPGt_uvarchar)) /* we also have to handle different statement types */ enum ECPG_statement_type diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c index 536185f..0efdaff 100644 --- a/src/interfaces/ecpg/preproc/ecpg.c +++ b/src/interfaces/ecpg/preproc/ecpg.c @@ -10,6 +10,7 @@ #include "getopt_long.h" #include "extern.h" +#include "mb/pg_wchar.h" int ret_value = 0; bool autocommit = false, @@ -18,7 +19,8 @@ bool autocommit = false, force_indicator = true, questionmarks = false, regression_mode = false, - auto_prepare = false; + auto_prepare = false, + enable_utext = false; char *output_filename; @@ -54,6 +56,7 @@ help(const char *progname) " \"no_indicator\", \"prepare\", \"questionmarks\"\n")); printf(_(" --regression run in regression testing mode\n")); printf(_(" -t turn on autocommit of transactions\n")); + printf(_(" --enable-utext enable unicode feature\n")); printf(_(" -V, --version output version information, then exit\n")); printf(_(" -?, --help show this help, then exit\n")); printf(_("\nIf no output file is specified, the name is formed by adding .c to the\n" @@ -112,11 +115,13 @@ add_preprocessor_define(char *define) } #define ECPG_GETOPT_LONG_REGRESSION 1 +#define ECPG_GETOPT_LONG_ENABLE_UTEXT 2 int main(int argc, char *const argv[]) { static struct option ecpg_options[] = { {"regression", no_argument, NULL, ECPG_GETOPT_LONG_REGRESSION}, + {"enable-utext", no_argument, NULL, ECPG_GETOPT_LONG_ENABLE_UTEXT}, {NULL, 0, NULL, 0} }; @@ -237,6 +242,9 @@ main(int argc, char *const argv[]) fprintf(stderr, _("%s: parser debug support (-d) not available\n"), progname); #endif + case ECPG_GETOPT_LONG_ENABLE_UTEXT: + enable_utext = true; + break; break; default: fprintf(stderr, _("Try \"%s --help\" for more information.\n"), argv[0]); @@ -434,7 +442,11 @@ main(int argc, char *const argv[]) if (header_mode == false) { - fprintf(base_yyout, "/* These include files are added by the preprocessor */\n#include \n#include \n#include \n"); + fprintf(base_yyout, "/* These include files are added by the preprocessor */\n"); + + if(enable_utext) + fprintf(base_yyout, "#define ECPG_ENABLE_UTEXT 1\n"); + fprintf(base_yyout, "#include \n#include \n#include \n"); /* add some compatibility headers */ if (INFORMIX_MODE) diff --git a/src/interfaces/ecpg/preproc/ecpg.header b/src/interfaces/ecpg/preproc/ecpg.header index 8921bcb..304aea4 100644 --- a/src/interfaces/ecpg/preproc/ecpg.header +++ b/src/interfaces/ecpg/preproc/ecpg.header @@ -6,6 +6,7 @@ #include "extern.h" #include "ecpg_config.h" +#include "mb/pg_wchar.h" #include /* Location tracking support --- simpler than bison's default */ @@ -46,6 +47,7 @@ static char pacounter_buffer[sizeof(int) * CHAR_BIT * 10 / 3]; /* a rough guess static struct this_type actual_type[STRUCT_DEPTH]; static char *actual_startline[STRUCT_DEPTH]; static int varchar_counter = 1; +static int uvarchar_counter = 1; /* temporarily store struct members while creating the data structure */ struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH] = { NULL }; @@ -137,7 +139,7 @@ cat2_str(char *str1, char *str2) char * res_str = (char *)mm_alloc(strlen(str1) + strlen(str2) + 2); strcpy(res_str, str1); - if (strlen(str1) != 0 && strlen(str2) != 0) + if (strlen(str1) != 0 && strlen(str2) != 0 && strcmp(str1,"L") != 0) strcat(res_str, " "); strcat(res_str, str2); free(str1); @@ -288,7 +290,9 @@ adjust_outofscope_cursor_vars(struct cursor *cur) else if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char - && ptr->variable->type->type != ECPGt_string) + && ptr->variable->type->type != ECPGt_string + && ptr->variable->type->type != ECPGt_utext + && ptr->variable->type->type != ECPGt_uvarchar) && atoi(ptr->variable->type->size) > 1) { newvar = new_variable(cat_str(4, mm_strdup("("), @@ -304,7 +308,9 @@ adjust_outofscope_cursor_vars(struct cursor *cur) else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char - || ptr->variable->type->type == ECPGt_string) + || ptr->variable->type->type == ECPGt_string + || ptr->variable->type->type == ECPGt_utext + || ptr->variable->type->type == ECPGt_uvarchar) && atoi(ptr->variable->type->size) > 1) { newvar = new_variable(cat_str(4, mm_strdup("("), @@ -315,7 +321,7 @@ adjust_outofscope_cursor_vars(struct cursor *cur) ptr->variable->type->size, ptr->variable->type->counter), 0); - if (ptr->variable->type->type == ECPGt_varchar) + if (ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_uvarchar) var_ptr = true; } else if (ptr->variable->type->type == ECPGt_struct @@ -565,6 +571,8 @@ add_typedef(char *name, char *dimension, char *length, enum ECPGttype type_enum, type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char && type_enum != ECPGt_string && + type_enum != ECPGt_utext && + type_enum != ECPGt_uvarchar && atoi(this->type->type_index) >= 0) mmerror(PARSE_ERROR, ET_ERROR, "multidimensional arrays for simple data types are not supported"); diff --git a/src/interfaces/ecpg/preproc/ecpg.tokens b/src/interfaces/ecpg/preproc/ecpg.tokens index 68ba925..2072382 100644 --- a/src/interfaces/ecpg/preproc/ecpg.tokens +++ b/src/interfaces/ecpg/preproc/ecpg.tokens @@ -21,7 +21,8 @@ S_DOTPOINT S_EQUAL S_EXTERN S_INC S_LSHIFT S_MEMPOINT S_MEMBER S_MOD S_MUL S_NEQUAL S_OR S_REGISTER S_RSHIFT S_STATIC S_SUB S_VOLATILE - S_TYPEDEF + S_TYPEDEF UTEXT %token CSTRING CVARIABLE CPP_LINE IP %token DOLCONST ECONST NCONST UCONST UIDENT +%token UVARCHAR diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer index f60a620..4984aec 100644 --- a/src/interfaces/ecpg/preproc/ecpg.trailer +++ b/src/interfaces/ecpg/preproc/ecpg.trailer @@ -186,7 +186,7 @@ user_name: RoleId type = argsinsert->variable->type->u.element->type; /* handle varchars */ - if (type == ECPGt_varchar) + if (type == ECPGt_varchar || type == ECPGt_uvarchar) $$ = make2_str(mm_strdup(argsinsert->variable->name), mm_strdup(".arr")); else $$ = mm_strdup(argsinsert->variable->name); @@ -213,9 +213,11 @@ char_variable: cvariable case ECPGt_char: case ECPGt_unsigned_char: case ECPGt_string: + case ECPGt_utext: $$ = $1; break; case ECPGt_varchar: + case ECPGt_uvarchar: $$ = make2_str($1, mm_strdup(".arr")); break; default: @@ -550,6 +552,22 @@ var_type: simple_type $$.type_index = mm_strdup("-1"); $$.type_sizeof = NULL; } + else if (strcmp($1, "uvarchar") == 0 && enable_utext) + { + $$.type_enum = ECPGt_uvarchar; + $$.type_str = EMPTY; + $$.type_dimension = mm_strdup("-1"); + $$.type_index = mm_strdup("-1"); + $$.type_sizeof = NULL; + } + else if (strcmp($1, "utext") == 0 && enable_utext) + { + $$.type_enum = ECPGt_utext; + $$.type_str = EMPTY; + $$.type_dimension = mm_strdup("-1"); + $$.type_index = mm_strdup("-1"); + $$.type_sizeof = NULL; + } else if (strcmp($1, "float") == 0) { $$.type_enum = ECPGt_float; @@ -627,7 +645,7 @@ var_type: simple_type /* this is for typedef'ed types */ struct typedefs *this = get_typedef($1); - $$.type_str = (this->type->type_enum == ECPGt_varchar) ? EMPTY : mm_strdup(this->name); + $$.type_str = (this->type->type_enum == ECPGt_varchar || this->type->type_enum == ECPGt_uvarchar) ? EMPTY : mm_strdup(this->name); $$.type_enum = this->type->type_enum; $$.type_dimension = this->type->type_dimension; $$.type_index = this->type->type_index; @@ -838,7 +856,7 @@ variable_list: variable { $$ = $1; } | variable_list ',' variable { - if (actual_type[struct_level].type_enum == ECPGt_varchar) + if (actual_type[struct_level].type_enum == ECPGt_varchar || actual_type[struct_level].type_enum == ECPGt_uvarchar) $$ = cat_str(3, $1, mm_strdup(";"), $3); else $$ = cat_str(3, $1, mm_strdup(","), $3); @@ -890,7 +908,52 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize $$ = cat_str(8, make2_str(mm_strdup(" struct varchar_"), vcn), mm_strdup(" { int len; char arr["), mm_strdup(length), mm_strdup("]; } "), mm_strdup($2), dim_str, $4, $5); varchar_counter++; break; + case ECPGt_uvarchar: + if (atoi(dimension) < 0) + type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length, uvarchar_counter); + else + type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, uvarchar_counter), dimension); + if (strcmp(dimension, "0") == 0 || abs(atoi(dimension)) == 1) + dim_str=mm_strdup(""); + else + dim_str=cat_str(3, mm_strdup("["), mm_strdup(dimension), mm_strdup("]")); + /* cannot check for atoi <= 0 because a defined constant will yield 0 here as well */ + if (atoi(length) < 0 || strcmp(length, "0") == 0) + mmerror(PARSE_ERROR, ET_ERROR, "pointers to uvarchar are not implemented"); + + /* make sure varchar struct name is unique by adding a unique counter to its definition */ + vcn = (char *) mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3); + sprintf(vcn, "%d", uvarchar_counter); + if (strcmp(dimension, "0") == 0) + $$ = cat_str(7, make2_str(mm_strdup(" struct uvarchar_"), vcn), mm_strdup(" { int len; utext arr["), mm_strdup(length), mm_strdup("]; } *"), mm_strdup($2), $4, $5); + else + $$ = cat_str(8, make2_str(mm_strdup(" struct uvarchar_"), vcn), mm_strdup(" { int len; utext arr["), mm_strdup(length), mm_strdup("]; } "), mm_strdup($2), dim_str, $4, $5); + uvarchar_counter++; + break; + case ECPGt_utext: + if (atoi(dimension) == -1) + { + int i = strlen($5); + + if (atoi(length) == -1 && i > 0) /* char [] = "string" */ + { + /* if we have an initializer but no string size set, let's use the initializer's length */ + free(length); + length = mm_alloc(i+sizeof("sizeof()")); + #if defined(WIN32) + sprintf(length, "sizeof(%s)/2", $5+2); + #else + sprintf(length, "sizeof(%s)/4", $5+2); + #endif + } + type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length, 0); + } + else + type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, 0), dimension); + + $$ = cat_str(6, mm_strdup("utext"), $1, mm_strdup($2), $3.str, $4, $5); + break; case ECPGt_char: case ECPGt_unsigned_char: case ECPGt_string: @@ -1354,6 +1417,7 @@ ECPGVar: SQL_VAR break; case ECPGt_varchar: + case ECPGt_uvarchar: if (atoi(dimension) == -1) type = ECPGmake_simple_type($5.type_enum, length, 0); else @@ -1363,6 +1427,7 @@ ECPGVar: SQL_VAR case ECPGt_char: case ECPGt_unsigned_char: case ECPGt_string: + case ECPGt_utext: if (atoi(dimension) == -1) type = ECPGmake_simple_type($5.type_enum, length, 0); else @@ -1504,6 +1569,8 @@ ECPGKeywords_vanames: SQL_BREAK { $$ = mm_strdup("break"); } | SQL_SQLPRINT { $$ = mm_strdup("sqlprint"); } | SQL_SQLWARNING { $$ = mm_strdup("sqlwarning"); } | SQL_STOP { $$ = mm_strdup("stop"); } + | UVARCHAR { $$ = mm_strdup("uvarchar"); } + | UTEXT { $$ = mm_strdup("utext"); } ; ECPGKeywords_rest: SQL_CONNECT { $$ = mm_strdup("connect"); } @@ -1854,6 +1921,8 @@ c_anything: ecpg_ident { $$ = $1; } | TO { $$ = mm_strdup("to"); } | UNION { $$ = mm_strdup("union"); } | VARCHAR { $$ = mm_strdup("varchar"); } + | UVARCHAR { $$ = mm_strdup("uvarchar"); } + | UTEXT { $$ = mm_strdup("utext"); } | '[' { $$ = mm_strdup("["); } | ']' { $$ = mm_strdup("]"); } | '=' { $$ = mm_strdup("="); } diff --git a/src/interfaces/ecpg/preproc/ecpg.type b/src/interfaces/ecpg/preproc/ecpg.type index 9497b91..3a95f9f 100644 --- a/src/interfaces/ecpg/preproc/ecpg.type +++ b/src/interfaces/ecpg/preproc/ecpg.type @@ -128,6 +128,8 @@ %type SCONST %type UCONST %type UIDENT +%type UTEXT +%type UVARCHAR %type s_struct_union_symbol diff --git a/src/interfaces/ecpg/preproc/extern.h b/src/interfaces/ecpg/preproc/extern.h index 2c35426..d612977 100644 --- a/src/interfaces/ecpg/preproc/extern.h +++ b/src/interfaces/ecpg/preproc/extern.h @@ -25,7 +25,8 @@ extern bool autocommit, force_indicator, questionmarks, regression_mode, - auto_prepare; + auto_prepare, + enable_utext; extern int braces_open, ret_value, struct_level, diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index fc450f3..1acea33 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -246,6 +246,8 @@ less_equals "<=" greater_equals ">=" less_greater "<>" not_equals "!=" +utext [uU][tT][eE][xX][tT] +uvarchar [uU][vV][aA][rR][cC][hH][aA][rR] /* * "self" is the set of chars that should be returned as single-character @@ -770,6 +772,10 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+ base_yylval.str = mm_strdup(yytext+1); return CVARIABLE; } +{utext} { return(UTEXT); } +{uvarchar} { + return(UVARCHAR); + } {identifier} { const ScanKeyword *keyword; diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c index 256a3c3..649fcb2 100644 --- a/src/interfaces/ecpg/preproc/type.c +++ b/src/interfaces/ecpg/preproc/type.c @@ -175,6 +175,12 @@ get_type(enum ECPGttype type) break; case ECPGt_varchar: return "ECPGt_varchar"; + case ECPGt_utext: + /* FEP Feature - Unicode */ + return ("ECPGt_utext"); + case ECPGt_uvarchar: + /* FEP Feature - Unicode */ + return ("ECPGt_uvarchar"); case ECPGt_NO_INDICATOR: /* no indicator */ return "ECPGt_NO_INDICATOR"; break; @@ -454,6 +460,50 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type, else sprintf(offset, "sizeof(struct varchar)"); break; + case ECPGt_uvarchar: + + /* + * we have to use the pointer except for arrays with given + * bounds + */ + if (((atoi(arrsize) > 0) || + (atoi(arrsize) == 0 && strcmp(arrsize, "0") != 0)) && + size == NULL) + sprintf(variable, "(%s%s)", prefix ? prefix : "", name); + else + sprintf(variable, "&(%s%s)", prefix ? prefix : "", name); + + /* + * If we created a varchar structure automatically, counter is + * greater than 0. + */ + if (counter) + sprintf(offset, "sizeof(struct uvarchar_%d)", counter); + else + sprintf(offset, "sizeof(struct uvarchar)"); + break; + case ECPGt_utext: + { + char *sizeof_name = "utext"; + + /* + * we have to use the pointer except for arrays with given + * bounds, ecpglib will distinguish between * and [] + */ + if ((atoi(varcharsize) > 1 || + (atoi(arrsize) > 0) || + (atoi(varcharsize) == 0 && strcmp(varcharsize, "0") != 0) || + (atoi(arrsize) == 0 && strcmp(arrsize, "0") != 0)) + && size == NULL) + { + sprintf(variable, "(%s%s)", prefix ? prefix : "", name); + } + else + sprintf(variable, "&(%s%s)", prefix ? prefix : "", name); + + sprintf(offset, "(%s)*sizeof(%s)", strcmp(varcharsize, "0") == 0 ? "1" : varcharsize, sizeof_name); + break; + } case ECPGt_char: case ECPGt_unsigned_char: case ECPGt_char_variable: diff --git a/src/interfaces/ecpg/preproc/variable.c b/src/interfaces/ecpg/preproc/variable.c index 39bf3b2..8f681c9 100644 --- a/src/interfaces/ecpg/preproc/variable.c +++ b/src/interfaces/ecpg/preproc/variable.c @@ -535,7 +535,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty "multilevel pointers (more than 2 levels) are not supported; found %d levels", pointer_len), pointer_len); - if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char && type_enum != ECPGt_string) + if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char && type_enum != ECPGt_string && type_enum != ECPGt_utext) mmfatal(PARSE_ERROR, "pointer to pointer is not supported for this data type"); if (pointer_len > 1 && (atoi(*length) >= 0 || atoi(*dimension) >= 0)) @@ -560,6 +560,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty break; case ECPGt_varchar: + case ECPGt_uvarchar: /* pointer has to get dimension 0 */ if (pointer_len) *dimension = mm_strdup("0"); @@ -573,6 +574,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty break; case ECPGt_char: + case ECPGt_utext: case ECPGt_unsigned_char: case ECPGt_string: /* char ** */ diff --git a/src/interfaces/ecpg/test/ecpg_schedule b/src/interfaces/ecpg/test/ecpg_schedule index cff4eeb..04d80a5 100644 --- a/src/interfaces/ecpg/test/ecpg_schedule +++ b/src/interfaces/ecpg/test/ecpg_schedule @@ -49,6 +49,8 @@ test: sql/quote test: sql/show test: sql/insupd test: sql/parser +test: sql/utext +test: sql/uvarchar test: thread/thread test: thread/thread_implicit test: thread/prep diff --git a/src/interfaces/ecpg/test/ecpg_schedule_tcp b/src/interfaces/ecpg/test/ecpg_schedule_tcp index 77481b5..fdd0e14 100644 --- a/src/interfaces/ecpg/test/ecpg_schedule_tcp +++ b/src/interfaces/ecpg/test/ecpg_schedule_tcp @@ -47,6 +47,8 @@ test: sql/quote test: sql/show test: sql/insupd test: sql/parser +test: sql/utext +test: sql/uvarchar test: thread/thread test: thread/thread_implicit test: thread/prep diff --git a/src/interfaces/ecpg/test/expected/sql-utext.c b/src/interfaces/ecpg/test/expected/sql-utext.c new file mode 100644 index 0000000..fdaec97 --- /dev/null +++ b/src/interfaces/ecpg/test/expected/sql-utext.c @@ -0,0 +1,4451 @@ +/* Processed by ecpg (regression mode) */ +/* These include files are added by the preprocessor */ +#define ECPG_ENABLE_UTEXT 1 +#include +#include +#include +/* End of automatic include section */ +#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y)) + +#line 1 "utext.pgc" +#include +#include +#include +#include + +#line 1 "regression.h" + + + + + + +#line 5 "utext.pgc" + + +#define test(msg) printf("\n%s\n",msg) +#define VAR_SIZE 20 +#define ARRAY_SIZE 4 +#define P_VAR_SIZE 22 + + +/* Following is UTF8 and UTF16/UTF32 characters mapping table */ +/*太𠮷𠜱平洋𠱓大西洋印度洋北冰洋 +utf16 +0x592A 0xD842 0xDFB7 0xD841 0xDF31 0x5E73 0x6D0B 0xD843 +0xDC53 0x5927 0x897F 0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 +0x51B0 0x6D0B 0x0000,0x0000 + +utf32 +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B +*/ + +/*足球篮球羽毛球乒乓球橄榄球棒球冰球 +utf16 +0x8DB3,0x7403,0x7BEE,0x7403,0x7FBD,0x6BDB,0x7403,0x4E52, +0x4E53,0x7403,0x6A44,0x6984,0x7403,0x68D2,0x7403,0x51B0, +0x7403,0x0000,0x0000,0x0000 + +utf32 +0x8DB3 0x7403 0x7BEE 0x7403 0x7FBD 0x6BDB 0x7403 0x4E52 +0x4E53 0x7403 0x6A44 0x6984 0x7403 0x68D2 0x7403 0x51B0 +0x7403 +*/ + +/*世界杯每隔四年就会举行一次每次𠲖个球队 +utf16 +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0xD843 +0xDC96 0x4E2A 0x7403 0x961F + +utf32 +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0x20C96 +0x4E2A 0x7403 0x961F +*/ + +/* 亚洲欧洲非洲大洋洲北美洲南美洲南极洲没有北极洲 +0x4E9A,0x6D32,0x6B27,0x6D32,0x975E,0x6D32,0x5927,0x6D0B, +0x6D32,0x5317,0x7F8E,0x6D32,0x5357,0x7F8E,0x6D32,0x5357, +0x6781,0x6D32,0x6CA1,0x6709,0x5317,0x6781,0x6D32 +*/ +/* 太𠮷 +0x592A 0xD842 0xDFB7 +*/ +void init_var(void); +void test_var_1(void); +void test_var_2(void); +void test_var_3(void); +void test_var_4(void); +void test_var_5(void); +void test_var_6(void); +void test_var_7(void); +void test_var_8(void); +void test_var_9(void); +void test_var_10(void); +void test_var_11(void); +void test_var_12(void); +void test_var_13(void); +void test_var_14(void); +void test_var_15(void); +void test_var_16(void); +void test_array_1(void); +void test_array_2(void); +void test_array_3(void); +void test_array_4(void); +void test_array_5(void); +void test_array_6(void); +void test_array_7(void); +void test_array_8(void); +void test_array_9(void); +void test_array_10(void); +void test_array_11(void); +void test_array_12(void); +void test_array_13(void); +void test_array_14(void); +void test_array_15(void); +void test_array_16(void); +void test_pvar_1(void); +void test_pvar_2(void); +void test_pvar_3(void); +void test_pvar_4(void); +void test_pvar_5(void); +void test_pvar_6(void); +void test_pvar_7(void); +void test_pvar_8(void); +void test_pvar_9(void); +void test_pvar_10(void); +void test_pvar_11(void); +void test_pvar_12(void); +void test_pvar_13(void); +void test_pvar_14(void); +void test_pvar_15(void); +void test_pvar_16(void); +void test_pvar_17(void); +void test_pvar_18(void); +void test_pvar_19(void); +void test_pp_var_1(void); +void test_pp_var_2(void); +void test_pp_var_3(void); +void test_desc_1(void); +void test_all(void); + +void print_utext(utext *utext_var); +void print_utext_str(utext *utext_var); +void print_utext_ind(int utext_var_ind); +void print_utext_size(utext *utext_var,int size); +void print_array(void *array, int array_size, int var_size); +void print_array_with_index(int index); +int test_init(void); +void test_finish(void); +void init_table_value(void); + +/* exec sql begin declare section */ + + + + + + + + + + + + + + + + + +#line 126 "utext.pgc" + int utext_var_size = 20 ; + +#line 127 "utext.pgc" + int utext_array_size = 4 ; + +#line 128 "utext.pgc" + int count = 0 ; + +#line 129 "utext.pgc" + int total_tuples = 0 ; + +#line 130 "utext.pgc" + int i ; + +#line 131 "utext.pgc" + char char_var [ 10 ] = { 0xF0 , 0x90 , 0x90 , 0xB7 } ; + +#line 133 "utext.pgc" + utext utext_var [ VAR_SIZE ] ; + +#line 134 "utext.pgc" + utext utext_array [ ARRAY_SIZE ] [ VAR_SIZE ] ; + +#line 135 "utext.pgc" + utext utext_input_var [ 20 ] = { 0x592a , 0xd842 , 0xdfb7 , 0x0000 } ; + +#line 136 "utext.pgc" + utext * p_utext_var = NULL ; + +#line 139 "utext.pgc" + int utext_var_ind ; + +#line 140 "utext.pgc" + int count_array [ 4 ] = { 1 , 2 , 3 , 4 } ; +/* exec sql end declare section */ +#line 142 "utext.pgc" + + +void print_utext(utext *utext_var) +{ + int i; + printf("======print utext_var content======\n"); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n======End utext_var content======\n"); +} + +void print_utext_str(utext *utext_var) +{ + int i=0; + printf("======print utext_var_str content======\n"); + if (utext_var==0) + { + printf("utext_var is NULL\n"); + printf("\n======End utext_var_str content======\n"); + return; + } + while(utext_var[i] != 0) + { + printf ("0x%08X ", utext_var[i]); + if(i>6 && (i+1)%8==0) + printf("\n"); + i++; + if(i>100) + break; + } + printf("\n======End utext_var_str content======\n"); +} + +void print_utext_size(utext *utext_var,int size) +{ + int i; + printf("======print utext_var content======\n"); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n======End utext_var content======\n"); +} + +void print_utext_ind(int utext_var_ind) +{ + printf("utext_var_ind = %d\n",utext_var_ind); +} +void print_array(void *array, int array_size, int var_size) +{ + int i,j; + + for(i=0; iarray[%d]:\n", i); + + for(j=0; j6 && (j+1)%8==0) + printf("\n"); + } + printf("\n"); + } + + printf("\n"); +} + +int test_init() +{ + p_utext_var = (utext*)malloc(P_VAR_SIZE*sizeof(utext)); + if(!p_utext_var) + { + printf("Error: failed allco memory for p_utext_var. \n"); + return -1; + } + + { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); } +#line 227 "utext.pgc" + + + { ECPGsetcommit(__LINE__, "on", NULL);} +#line 229 "utext.pgc" + + /* exec sql whenever sql_warning sqlprint ; */ +#line 230 "utext.pgc" + + /* exec sql whenever sqlerror sqlprint ; */ +#line 231 "utext.pgc" + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "set client_encoding = 'UTF8'", ECPGt_EOIT, ECPGt_EORT); +#line 233 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 233 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 233 "utext.pgc" + + + //initialization of test table + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "create table if not exists tb1 ( Item varchar , count integer )", ECPGt_EOIT, ECPGt_EORT); +#line 236 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 236 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 236 "utext.pgc" + + + init_table_value(); + + return 0; +} + +void test_finish() +{ + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "drop table tb1", ECPGt_EOIT, ECPGt_EORT); +#line 245 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 245 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 245 "utext.pgc" + + { ECPGdisconnect(__LINE__, "ALL"); +#line 246 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 246 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 246 "utext.pgc" + +} + +void init_table_value() +{ + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "truncate tb1", ECPGt_EOIT, ECPGt_EORT); +#line 251 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 251 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 251 "utext.pgc" + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' , 1 )", ECPGt_EOIT, ECPGt_EORT); +#line 253 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 253 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 253 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( '足球篮球羽毛球乒乓球橄榄球棒球冰球' , 2 )", ECPGt_EOIT, ECPGt_EORT); +#line 254 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 254 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 254 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( '世界杯每隔四年就会举行一次每次𠲖个球队' , 3 )", ECPGt_EOIT, ECPGt_EORT); +#line 255 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 255 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 255 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( '亚洲欧洲非洲大洋洲北美洲南美洲南极洲没有北极洲' , 4 )", ECPGt_EOIT, ECPGt_EORT); +#line 256 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 256 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 256 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 ( count ) values ( 8 )", ECPGt_EOIT, ECPGt_EORT); +#line 257 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 257 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 257 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 ( count ) values ( 9 )", ECPGt_EOIT, ECPGt_EORT); +#line 258 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 258 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 258 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 ( count ) values ( 10 )", ECPGt_EOIT, ECPGt_EORT); +#line 259 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 259 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 259 "utext.pgc" + +} + +void init_var() +{ + count = 0; + memset(utext_var,'a',sizeof(utext_var)); + memset(utext_array,'a',sizeof(utext_array)); + memset(p_utext_var,'a',P_VAR_SIZE*sizeof(utext)); +} + +//simple select into utext var +void test_var_1() +{ + test("test_var_1: simple select into utext var"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT); +#line 276 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 276 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 276 "utext.pgc" + + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 2", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT); +#line 281 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 281 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 281 "utext.pgc" + + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT); +#line 286 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 286 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 286 "utext.pgc" + + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 4", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT); +#line 291 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 291 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 291 "utext.pgc" + + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); +} + + +//simple select using utext var +void test_var_2() +{ + test("test_var_2: simple select using utext var"); + init_var(); + + count = 0; + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 305 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 305 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 305 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count from tb1 where Item = $1 ", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 306 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 306 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 306 "utext.pgc" + + printf ("count=%d for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + count = 0; + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 310 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 310 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 310 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count from tb1 where Item = $1 ", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 311 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 311 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 311 "utext.pgc" + + printf ("count=%d for '世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); +} + +//simple update using utext var +void test_var_3() +{ + test("test_var_3: simple update using utext var"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 321 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 321 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 321 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "update tb1 set Item = $1 where count = 2", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 322 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 322 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 322 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "update tb1 set Item = $1 where count = 3", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 323 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 323 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 323 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 324 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 324 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 324 "utext.pgc" + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_table_value(); +} + +//simple delete using utext var +void test_var_4() +{ + test("test_var_4 : simple delete using utext var"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 336 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 336 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 336 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "delete from tb1 where Item = $1 ", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 337 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 337 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 337 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 338 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 338 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 338 "utext.pgc" + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 341 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 341 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 341 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "delete from tb1 where Item = $1 ", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 342 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 342 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 342 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 343 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 343 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 343 "utext.pgc" + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//simple insert using utext var +void test_var_5() +{ + test("test_var_5 : simple insert using utext"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 355 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 355 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 355 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 11 )", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 356 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 356 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 356 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 357 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 357 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 357 "utext.pgc" + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_var(); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 361 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 361 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 361 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 13 )", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 362 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 362 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 362 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 363 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 363 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 363 "utext.pgc" + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//prepared select into utext var +void test_var_6() +{ + test("test_var_6 : prepared select into utext var"); + init_var(); + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Item FROM tb1 WHERE Count=?"); +#line 375 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 375 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 375 "utext.pgc" + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_const,"1",(long)1,(long)1,strlen("1"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 377 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 377 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 377 "utext.pgc" + + print_utext(utext_var); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_const,"3",(long)1,(long)1,strlen("3"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 380 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 380 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 380 "utext.pgc" + + print_utext(utext_var); + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 383 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 383 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 383 "utext.pgc" + +} + +//prepared select using utext var +void test_var_7() +{ + test("test_var_7 : prepared select using utext var"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 392 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 392 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 392 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Count FROM tb1 WHERE Item=?"); +#line 394 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 394 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 394 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 395 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 395 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 395 "utext.pgc" + + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 398 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 398 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 398 "utext.pgc" + +} + +//prepared update using utext var +void test_var_8() +{ + test("test_var_8 : prepared update using utext var"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 407 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 407 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 407 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "UPDATE tb1 SET Item=? WHERE Count=?"); +#line 409 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 409 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 409 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + 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 410 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 410 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 410 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_const,"2",(long)1,(long)1,strlen("2"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 411 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 411 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 411 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 412 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 412 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 412 "utext.pgc" + + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 415 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 415 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 415 "utext.pgc" + + + init_table_value(); +} + +//prepared delete using utext var +void test_var_9() +{ + test("test_var_9 : prepared delete using utext var"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 426 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 426 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 426 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "DELETE FROM tb1 WHERE Item=?"); +#line 428 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 428 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 428 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 429 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 429 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 429 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 430 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 430 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 430 "utext.pgc" + + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 433 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 433 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 433 "utext.pgc" + + + init_table_value(); +} + +//prepared insert using utext var +void test_var_10() +{ + test("test_var_10 : prepared insert using utext var"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 444 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 444 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 444 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "INSERT INTO tb1 values (?, 13)"); +#line 446 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 446 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 446 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 447 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 447 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 447 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 448 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 448 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 448 "utext.pgc" + + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 451 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 451 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 451 "utext.pgc" + + + init_table_value(); +} + +//Open cursor using utext var +void test_var_11() +{ + test("test_var_11 : Open cursor using utext var"); + init_var(); + + { ECPGsetcommit(__LINE__, "off", NULL); +#line 462 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 462 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 462 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 463 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 463 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 463 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Count FROM tb1 WHERE Item=?"); +#line 465 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 465 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 465 "utext.pgc" + + /* declare cursor_var_11 cursor for $1 */ +#line 466 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "declare cursor_var_11 cursor for $1", + ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt", __LINE__)),(long)1,(long)1,(1)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 467 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 467 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 467 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "fetch cursor_var_11", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 468 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 468 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 468 "utext.pgc" + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "close cursor_var_11", ECPGt_EOIT, ECPGt_EORT); +#line 470 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 470 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 470 "utext.pgc" + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 471 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 471 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 471 "utext.pgc" + + { ECPGsetcommit(__LINE__, "on", NULL); +#line 472 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 472 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 472 "utext.pgc" + +} + +//Fecth cursor into utext var +void test_var_12() +{ + test("test_var_12 : Fecth cursor into utext var"); + init_var(); + + { ECPGsetcommit(__LINE__, "off", NULL); +#line 481 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 481 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 481 "utext.pgc" + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Item FROM tb1 WHERE Count=1"); +#line 482 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 482 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 482 "utext.pgc" + + /* declare cursor_var_12 cursor for $1 */ +#line 483 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "declare cursor_var_12 cursor for $1", + ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt", __LINE__)),(long)1,(long)1,(1)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 484 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 484 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 484 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "fetch cursor_var_12", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 485 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 485 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 485 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "close cursor_var_12", ECPGt_EOIT, ECPGt_EORT); +#line 486 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 486 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 486 "utext.pgc" + + + print_utext(utext_var); + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 490 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 490 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 490 "utext.pgc" + + { ECPGsetcommit(__LINE__, "on", NULL); +#line 491 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 491 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 491 "utext.pgc" + +} + +//simple insert utext var with L string inited +void test_var_13() +{ +/* exec sql begin declare section */ + + +#line 498 "utext.pgc" + utext utext_local_var [] = L"足球篮球羽毛球" ; +/* exec sql end declare section */ +#line 499 "utext.pgc" + + test("test_var_13 : simple insert utext var with L string inited"); + init_var(); + + print_utext_str(utext_local_var); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 16 )", + ECPGt_utext,(utext_local_var),(long)sizeof(L"足球篮球羽毛球")/4,(long)1,(sizeof(L"足球篮球羽毛球")/4)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 505 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 505 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 505 "utext.pgc" + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 16", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT); +#line 507 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 507 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 507 "utext.pgc" + + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + init_table_value(); +} + +//Open cursor using utext var directly in WHERE Clause +void test_var_14() +{ +/* exec sql begin declare section */ + + +#line 518 "utext.pgc" + utext utext_local_var [ 20 + 1 ] ; +/* exec sql end declare section */ +#line 519 "utext.pgc" + + memset(utext_local_var,'a',sizeof(utext_local_var)); + + test("test_var_14 : Open cursor using utext var directly in WHERE Clause"); + init_var(); + + { ECPGsetcommit(__LINE__, "off", NULL); +#line 525 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 525 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 525 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_local_var),(long)20 + 1,(long)1,(20 + 1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 526 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 526 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 526 "utext.pgc" + + ECPGset_var( 0, ( utext_local_var ), __LINE__);\ + /* declare cursor_var_14 cursor for select count from tb1 where Item = $1 */ +#line 527 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "declare cursor_var_14 cursor for select count from tb1 where Item = $1 ", + ECPGt_utext,(utext_local_var),(long)20 + 1,(long)1,(20 + 1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 528 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 528 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 528 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "fetch cursor_var_14", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 529 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 529 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 529 "utext.pgc" + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "close cursor_var_14", ECPGt_EOIT, ECPGt_EORT); +#line 532 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 532 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 532 "utext.pgc" + + + { ECPGsetcommit(__LINE__, "on", NULL); +#line 534 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 534 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 534 "utext.pgc" + +} + +//Test utext_var working with NULL without indicator +void test_var_15() +{ +/* exec sql begin declare section */ + + +#line 541 "utext.pgc" + utext utext_local_var [ 20 + 1 ] ; +/* exec sql end declare section */ +#line 542 "utext.pgc" + + test("test_var_15 : Test utext_var working with NULL without indicator"); + + memset(utext_local_var,'a',sizeof(utext_local_var)); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 8", ECPGt_EOIT, + ECPGt_utext,(utext_local_var),(long)20 + 1,(long)1,(20 + 1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 546 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 546 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 546 "utext.pgc" + + print_utext(utext_local_var); + + memset(utext_local_var,0x00,sizeof(utext_local_var)); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 18 )", + ECPGt_utext,(utext_local_var),(long)20 + 1,(long)1,(20 + 1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 550 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 550 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 550 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 19 )", + ECPGt_utext,(utext_local_var),(long)20 + 1,(long)1,(20 + 1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 551 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 551 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 551 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 20 )", + ECPGt_utext,(utext_local_var),(long)20 + 1,(long)1,(20 + 1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 552 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 552 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 552 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item is null", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 553 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 553 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 553 "utext.pgc" + + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//utext_var working with NULL with indicator +void test_var_16() +{ +/* exec sql begin declare section */ + + + +#line 563 "utext.pgc" + utext utext_local_var [ 20 + 1 ] ; + +#line 564 "utext.pgc" + int utext_var_ind = - 1 ; +/* exec sql end declare section */ +#line 565 "utext.pgc" + + test("test_var_16 : Test utext_var working with NULL with indicator"); + + memset(utext_local_var,'a',sizeof(utext_local_var)); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 8", ECPGt_EOIT, + ECPGt_utext,(utext_local_var),(long)20 + 1,(long)1,(20 + 1)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT); +#line 569 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 569 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 569 "utext.pgc" + + print_utext(utext_local_var); + print_utext_ind(utext_var_ind); + + memset(utext_local_var,0x00,sizeof(utext_local_var)); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 18 )", + ECPGt_utext,(utext_local_var),(long)20 + 1,(long)1,(20 + 1)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT); +#line 574 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 574 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 574 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 19 )", + ECPGt_utext,(utext_local_var),(long)20 + 1,(long)1,(20 + 1)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT); +#line 575 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 575 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 575 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 20 )", + ECPGt_utext,(utext_local_var),(long)20 + 1,(long)1,(20 + 1)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT); +#line 576 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 576 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 576 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item is null", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 577 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 577 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 577 "utext.pgc" + + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + + +//simple select into utext array +void test_array_1() +{ + test("test_array_1 : simple select into utext array "); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count <= 3", ECPGt_EOIT, + ECPGt_utext,(utext_array),(long)VAR_SIZE,(long)ARRAY_SIZE,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 590 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 590 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 590 "utext.pgc" + + + print_array(utext_array,ARRAY_SIZE,VAR_SIZE); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,(utext_array[0]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 595 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 595 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 595 "utext.pgc" + + print_array(utext_array,ARRAY_SIZE,VAR_SIZE); + init_var(); +} + +//simple select using utext array +void test_array_2() +{ + test("test_array_2 : simple select using array"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count <= 3", ECPGt_EOIT, + ECPGt_utext,(utext_array),(long)VAR_SIZE,(long)ARRAY_SIZE,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 606 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 606 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 606 "utext.pgc" + + + count = 0; + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count from tb1 where Item = $1 ", + ECPGt_utext,(utext_array[0]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 609 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 609 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 609 "utext.pgc" + + printf ("count=%d for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + count = 0; + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count from tb1 where Item = $1 ", + ECPGt_utext,(utext_array[2]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 613 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 613 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 613 "utext.pgc" + + printf ("count=%d for '世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); +} + +//simple update using utext array +void test_array_3() +{ + test("test_array_3 : simple update using utext array"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count <= 3", ECPGt_EOIT, + ECPGt_utext,(utext_array),(long)VAR_SIZE,(long)ARRAY_SIZE,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 623 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 623 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 623 "utext.pgc" + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "update tb1 set Item = $1 where count = 1", + ECPGt_utext,(utext_array[2]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 625 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 625 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 625 "utext.pgc" + + + count = 0; + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 628 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 628 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 628 "utext.pgc" + + printf ("find %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + count = 0; + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 632 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 632 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 632 "utext.pgc" + + printf ("find %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//simple delete using utext array +void test_array_4() +{ + test("test_array_4 : simple delete using utext array"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count <= 3", ECPGt_EOIT, + ECPGt_utext,(utext_array),(long)VAR_SIZE,(long)ARRAY_SIZE,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 644 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 644 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 644 "utext.pgc" + + + count = 100; + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "delete from tb1 where Item = $1 ", + ECPGt_utext,(utext_array[0]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 647 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 647 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 647 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 648 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 648 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 648 "utext.pgc" + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + count = 100; + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "delete from tb1 where Item = $1 ", + ECPGt_utext,(utext_array[2]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 652 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 652 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 652 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 653 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 653 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 653 "utext.pgc" + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//simple insert using utext array +void test_array_5() +{ + test("test_array_5 : simple insert using utext array"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count <= 3", ECPGt_EOIT, + ECPGt_utext,(utext_array),(long)VAR_SIZE,(long)ARRAY_SIZE,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 665 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 665 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 665 "utext.pgc" + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 11 )", + ECPGt_utext,(utext_array[0]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 667 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 667 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 667 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 668 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 668 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 668 "utext.pgc" + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 13 )", + ECPGt_utext,(utext_array[2]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 671 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 671 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 671 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 672 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 672 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 672 "utext.pgc" + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//prepared select into utext array +void test_array_6() +{ + test("test_array_6 : prepared select into utext array"); + init_var(); + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Item FROM tb1 WHERE Count<=?"); +#line 684 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 684 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 684 "utext.pgc" + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_const,"4",(long)1,(long)1,strlen("4"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_utext,(utext_array),(long)VAR_SIZE,(long)ARRAY_SIZE,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 686 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 686 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 686 "utext.pgc" + + + print_array(utext_array,ARRAY_SIZE,VAR_SIZE); + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 690 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 690 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 690 "utext.pgc" + +} + +//prepared select using utext array +void test_array_7() +{ + test("test_array_7 : prepared select using utext array"); + init_var(); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count <= 3", ECPGt_EOIT, + ECPGt_utext,(utext_array),(long)VAR_SIZE,(long)ARRAY_SIZE,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 698 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 698 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 698 "utext.pgc" + + + count = 0; + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Count FROM tb1 WHERE Item=?"); +#line 701 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 701 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 701 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,(utext_array[0]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 702 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 702 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 702 "utext.pgc" + + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 705 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 705 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 705 "utext.pgc" + +} + +//prepared update using utext array +void test_array_8() +{ + test("test_array_8 : prepared update using utext array"); + init_var(); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count <= 3", ECPGt_EOIT, + ECPGt_utext,(utext_array),(long)VAR_SIZE,(long)ARRAY_SIZE,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 713 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 713 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 713 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "UPDATE tb1 SET Item=? WHERE Count=?"); +#line 715 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 715 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 715 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,(utext_array[0]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_const,"2",(long)1,(long)1,strlen("2"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 716 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 716 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 716 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,(utext_array[0]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_const,"3",(long)1,(long)1,strlen("3"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 717 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 717 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 717 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 718 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 718 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 718 "utext.pgc" + + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 721 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 721 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 721 "utext.pgc" + + + init_table_value(); +} + +//prepared delete using utext array +void test_array_9() +{ + test("test_array_9 : prepared delete using utext array"); + init_var(); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count <= 3", ECPGt_EOIT, + ECPGt_utext,(utext_array),(long)VAR_SIZE,(long)ARRAY_SIZE,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 731 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 731 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 731 "utext.pgc" + + + count = 0; + { ECPGprepare(__LINE__, NULL, 0, "stmt", "DELETE FROM tb1 WHERE Item=?"); +#line 734 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 734 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 734 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,(utext_array[0]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 735 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 735 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 735 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 736 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 736 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 736 "utext.pgc" + + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 739 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 739 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 739 "utext.pgc" + + + init_table_value(); +} + +//prepared insert using utext array +void test_array_10() +{ + test("test_array_10 : prepared insert using utext array"); + init_var(); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count <= 3", ECPGt_EOIT, + ECPGt_utext,(utext_array),(long)VAR_SIZE,(long)ARRAY_SIZE,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 749 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 749 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 749 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "INSERT INTO tb1 values (?, ?)"); +#line 751 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 751 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 751 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,(utext_array[2]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_const,"13",(long)2,(long)1,strlen("13"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 752 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 752 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 752 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,(utext_array[2]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_const,"15",(long)2,(long)1,strlen("15"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 753 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 753 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 753 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 754 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 754 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 754 "utext.pgc" + + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 757 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 757 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 757 "utext.pgc" + + + init_table_value(); +} + +//Open cursor using utext array +void test_array_11() +{ + test("test_array_11 : Open cursor using utext array"); + init_var(); + + { ECPGsetcommit(__LINE__, "off", NULL); +#line 768 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 768 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 768 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count <= 3", ECPGt_EOIT, + ECPGt_utext,(utext_array),(long)VAR_SIZE,(long)ARRAY_SIZE,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 769 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 769 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 769 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Count FROM tb1 WHERE Item=?"); +#line 771 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 771 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 771 "utext.pgc" + + /* declare cursor_array_11 cursor for $1 */ +#line 772 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "declare cursor_array_11 cursor for $1", + ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt", __LINE__)),(long)1,(long)1,(1)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_utext,(utext_array[2]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 773 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 773 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 773 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "fetch cursor_array_11", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 774 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 774 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 774 "utext.pgc" + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "close cursor_array_11", ECPGt_EOIT, ECPGt_EORT); +#line 776 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 776 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 776 "utext.pgc" + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 777 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 777 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 777 "utext.pgc" + + { ECPGsetcommit(__LINE__, "on", NULL); +#line 778 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 778 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 778 "utext.pgc" + +} + +//Fecth cursor into utext array +void test_array_12() +{ + test("test_array_12 : Fecth cursor into utext array"); + init_var(); + + { ECPGsetcommit(__LINE__, "off", NULL); +#line 787 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 787 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 787 "utext.pgc" + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Item FROM tb1 WHERE Count<=3"); +#line 788 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 788 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 788 "utext.pgc" + + /* declare cursor_array_12 cursor for $1 */ +#line 789 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "declare cursor_array_12 cursor for $1", + ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt", __LINE__)),(long)1,(long)1,(1)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 790 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 790 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 790 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "fetch cursor_array_12", ECPGt_EOIT, + ECPGt_utext,(utext_array[0]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 791 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 791 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 791 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "fetch cursor_array_12", ECPGt_EOIT, + ECPGt_utext,(utext_array[1]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 792 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 792 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 792 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "fetch cursor_array_12", ECPGt_EOIT, + ECPGt_utext,(utext_array[2]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 793 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 793 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 793 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "close cursor_array_12", ECPGt_EOIT, ECPGt_EORT); +#line 794 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 794 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 794 "utext.pgc" + + + print_array(utext_array,ARRAY_SIZE,VAR_SIZE); + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 798 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 798 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 798 "utext.pgc" + + { ECPGsetcommit(__LINE__, "on", NULL); +#line 799 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 799 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 799 "utext.pgc" + +} + +//Insert array with L string inited +void test_array_13() +{ +/* exec sql begin declare section */ + + +#line 806 "utext.pgc" + utext utext_array13 [ 4 ] [ VAR_SIZE ] = { L"太𠮷𠜱平洋𠱓大西洋印度洋北冰洋" , L"足球篮球羽毛球乒乓球橄榄球棒球冰球" , L"世界杯每隔四年就会举行一次" } ; +/* exec sql end declare section */ +#line 807 "utext.pgc" + + + test("test_array_13 : Insert array with L string inited"); + init_var(); + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 20 )", + ECPGt_utext,(utext_array13[0]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 813 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 813 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 813 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 21 )", + ECPGt_utext,(utext_array13[1]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 814 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 814 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 814 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 22 )", + ECPGt_utext,(utext_array13[2]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 815 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 815 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 815 "utext.pgc" + + + init_var(); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count <= 22 and count >= 20", ECPGt_EOIT, + ECPGt_utext,(utext_array),(long)VAR_SIZE,(long)ARRAY_SIZE,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 818 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 818 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 818 "utext.pgc" + + print_array(utext_array,3,VAR_SIZE); + init_table_value(); +} + +//Open cursor using utext array directly in WHERE Clause +void test_array_14() +{ +/* exec sql begin declare section */ + + +#line 827 "utext.pgc" + utext utext_local_array [ 4 ] [ 20 + 1 ] ; +/* exec sql end declare section */ +#line 828 "utext.pgc" + + + test("test_array_14 : Open cursor using utext array directly in WHERE Clause"); + memset(utext_local_array,'a',sizeof(utext_local_array)); + + { ECPGsetcommit(__LINE__, "off", NULL); +#line 833 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 833 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 833 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count <= 3", ECPGt_EOIT, + ECPGt_utext,(utext_local_array),(long)20 + 1,(long)4,(20 + 1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 834 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 834 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 834 "utext.pgc" + + + ECPGset_var( 1, ( utext_local_array[2] ), __LINE__);\ + /* declare cursor_array_14 cursor for select count from tb1 where Item = $1 */ +#line 836 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "declare cursor_array_14 cursor for select count from tb1 where Item = $1 ", + ECPGt_utext,(utext_local_array[2]),(long)20 + 1,(long)1,(20 + 1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 837 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 837 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 837 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "fetch cursor_array_14", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 838 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 838 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 838 "utext.pgc" + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "close cursor_array_14", ECPGt_EOIT, ECPGt_EORT); +#line 840 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 840 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 840 "utext.pgc" + + + { ECPGsetcommit(__LINE__, "on", NULL); +#line 842 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 842 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 842 "utext.pgc" + +} + + +//utext array working with NULL without using indicator +void test_array_15() +{ +/* exec sql begin declare section */ + + +#line 850 "utext.pgc" + utext utext_local_array [ 3 ] [ 20 ] ; +/* exec sql end declare section */ +#line 851 "utext.pgc" + + test("test_array_15 : Test utext array working with NULL without using indicator"); + memset(utext_local_array,'a',sizeof(utext_local_array)); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count >= 8 and count <= 10", ECPGt_EOIT, + ECPGt_utext,(utext_local_array),(long)20,(long)3,(20)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 855 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 855 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 855 "utext.pgc" + + + print_array((void**)utext_local_array,3,20); + + memset(utext_local_array,0x00,sizeof(utext_local_array)); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 18 )", + ECPGt_utext,(utext_local_array[0]),(long)20,(long)1,(20)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 860 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 860 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 860 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 19 )", + ECPGt_utext,(utext_local_array[1]),(long)20,(long)1,(20)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 861 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 861 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 861 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 20 )", + ECPGt_utext,(utext_local_array[2]),(long)20,(long)1,(20)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 862 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 862 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 862 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item is null", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 863 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 863 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 863 "utext.pgc" + + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//utext array working with NULL using indicator +void test_array_16() +{ +/* exec sql begin declare section */ + + + +#line 873 "utext.pgc" + utext utext_local_array [ 3 ] [ 20 ] ; + +#line 874 "utext.pgc" + int utext_array_ind [ 3 ] ; +/* exec sql end declare section */ +#line 875 "utext.pgc" + + test("test_array_16 : Test utext array working with NULL using indicator"); + memset(utext_local_array,'a',sizeof(utext_local_array)); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count >= 8 and count <= 10", ECPGt_EOIT, + ECPGt_utext,(utext_local_array),(long)20,(long)3,(20)*sizeof(utext), + ECPGt_int,(utext_array_ind),(long)1,(long)3,sizeof(int), ECPGt_EORT); +#line 879 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 879 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 879 "utext.pgc" + + + print_array((void**)utext_local_array,3,20); + print_utext_ind(utext_array_ind[0]); + print_utext_ind(utext_array_ind[1]); + print_utext_ind(utext_array_ind[2]); + + memset(utext_local_array,0x00,sizeof(utext_local_array)); + utext_array_ind[0]=-1; + utext_array_ind[1]=-1; + utext_array_ind[2]=-1; + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 18 )", + ECPGt_utext,(utext_local_array[0]),(long)20,(long)1,(20)*sizeof(utext), + ECPGt_int,&(utext_array_ind[0]),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT); +#line 890 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 890 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 890 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 19 )", + ECPGt_utext,(utext_local_array[1]),(long)20,(long)1,(20)*sizeof(utext), + ECPGt_int,&(utext_array_ind[1]),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT); +#line 891 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 891 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 891 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 20 )", + ECPGt_utext,(utext_local_array[2]),(long)20,(long)1,(20)*sizeof(utext), + ECPGt_int,&(utext_array_ind[2]),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT); +#line 892 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 892 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 892 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item is null", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 893 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 893 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 893 "utext.pgc" + + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + + +//simple select into utext pointer +void test_pvar_1() +{ + test("test_pvar_1 : simple select into utext pointer"); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT); +#line 904 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 904 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 904 "utext.pgc" + + print_utext(p_utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 2", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT); +#line 909 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 909 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 909 "utext.pgc" + + print_utext(p_utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT); +#line 914 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 914 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 914 "utext.pgc" + + print_utext(p_utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 4", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT); +#line 919 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 919 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 919 "utext.pgc" + + print_utext(p_utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + init_table_value(); +} + + +//simple select using utext pointer +void test_pvar_2() +{ + test("test_pvar_2 : simple select using utext pointer"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 934 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 934 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 934 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count from tb1 where Item = $1 ", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 935 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 935 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 935 "utext.pgc" + + printf ("count=%d for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_var(); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 939 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 939 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 939 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count from tb1 where Item = $1 ", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 940 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 940 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 940 "utext.pgc" + + printf ("count=%d for '世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); +} + + +//simple update using utext pointer +void test_pvar_3() +{ + test("test_pvar_3 : simple update using utext pointer"); + init_var(); + + count = 0; + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 952 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 952 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 952 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "update tb1 set Item = $1 where count = 2", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 953 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 953 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 953 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "update tb1 set Item = $1 where count = 3", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 954 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 954 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 954 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 955 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 955 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 955 "utext.pgc" + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_table_value(); +} + +//simple delete using utext pointer +void test_pvar_4() +{ + test("test_pvar_4 : simple delete using utext pointer"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 967 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 967 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 967 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "delete from tb1 where Item = $1 ", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 968 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 968 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 968 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 969 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 969 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 969 "utext.pgc" + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_var(); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 973 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 973 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 973 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "delete from tb1 where Item = $1 ", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 974 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 974 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 974 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 975 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 975 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 975 "utext.pgc" + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//simple insert using utext pointer +void test_pvar_5() +{ + test("test_pvar_5 : simple insert using utext pointer"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 987 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 987 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 987 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 13 )", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 988 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 988 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 988 "utext.pgc" + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 990 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 990 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 990 "utext.pgc" + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//prepared select into utext pointer +void test_pvar_6() +{ + test("test_pvar_6 : prepared select into utext pointer"); + init_var(); + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Item FROM tb1 WHERE Count=?"); +#line 1002 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1002 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1002 "utext.pgc" + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_const,"1",(long)1,(long)1,strlen("1"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1004 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1004 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1004 "utext.pgc" + + print_utext(p_utext_var); + + init_var(); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_const,"3",(long)1,(long)1,strlen("3"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1008 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1008 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1008 "utext.pgc" + + print_utext(p_utext_var); + init_table_value(); + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 1012 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1012 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1012 "utext.pgc" + + +} + +//prepared select using utext pointer +void test_pvar_7() +{ + test("test_pvar_7 : prepared select using utext pointer"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1022 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1022 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1022 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Count FROM tb1 WHERE Item=?"); +#line 1024 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1024 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1024 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1025 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1025 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1025 "utext.pgc" + + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 1028 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1028 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1028 "utext.pgc" + +} + +//prepared update using utext pointer +void test_pvar_8() +{ + test("test_pvar_8 : prepared update using utext pointer"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1037 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1037 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1037 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "UPDATE tb1 SET Item=? WHERE Count=?"); +#line 1039 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1039 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1039 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + 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 1040 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1040 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1040 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_const,"2",(long)1,(long)1,strlen("2"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1041 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1041 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1041 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1042 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1042 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1042 "utext.pgc" + + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 1045 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1045 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1045 "utext.pgc" + + + init_table_value(); +} + +//prepared delete using utext pointer +void test_pvar_9() +{ + test("test_pvar_9 : prepared delete using utext pointer"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1056 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1056 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1056 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "DELETE FROM tb1 WHERE Item=?"); +#line 1058 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1058 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1058 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1059 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1059 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1059 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1060 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1060 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1060 "utext.pgc" + + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 1063 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1063 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1063 "utext.pgc" + + + init_table_value(); +} + +//prepared insert using utext pointer +void test_pvar_10() +{ + test("test_pvar_10 : prepared insert using utext pointer"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1074 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1074 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1074 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "INSERT INTO tb1 values (?, 13)"); +#line 1076 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1076 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1076 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1077 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1077 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1077 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1078 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1078 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1078 "utext.pgc" + + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 1081 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1081 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1081 "utext.pgc" + + + init_table_value(); +} + +//Open cursor using utext pointer +void test_pvar_11() +{ + test("test_pvar_11 : Open cursor using utext pointer"); + init_var(); + + { ECPGsetcommit(__LINE__, "off", NULL); +#line 1092 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1092 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1092 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1093 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1093 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1093 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Count FROM tb1 WHERE Item=?"); +#line 1095 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1095 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1095 "utext.pgc" + + /* declare cursor_pvar_11 cursor for $1 */ +#line 1096 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "declare cursor_pvar_11 cursor for $1", + ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt", __LINE__)),(long)1,(long)1,(1)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1097 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1097 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1097 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "fetch cursor_pvar_11", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1098 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1098 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1098 "utext.pgc" + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "close cursor_pvar_11", ECPGt_EOIT, ECPGt_EORT); +#line 1100 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1100 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1100 "utext.pgc" + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 1101 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1101 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1101 "utext.pgc" + + { ECPGsetcommit(__LINE__, "on", NULL); +#line 1102 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1102 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1102 "utext.pgc" + +} + +//Fecth cursor into utext pointer +void test_pvar_12() +{ + test("test_pvar_12 : Fecth cursor into utext pointer"); + init_var(); + + { ECPGsetcommit(__LINE__, "off", NULL); +#line 1111 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1111 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1111 "utext.pgc" + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Item FROM tb1 WHERE Count=1"); +#line 1112 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1112 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1112 "utext.pgc" + + /* declare cursor_pvar_12 cursor for $1 */ +#line 1113 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "declare cursor_pvar_12 cursor for $1", + ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt", __LINE__)),(long)1,(long)1,(1)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1114 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1114 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1114 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "fetch cursor_pvar_12", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1115 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1115 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1115 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "close cursor_pvar_12", ECPGt_EOIT, ECPGt_EORT); +#line 1116 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1116 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1116 "utext.pgc" + + + print_utext(p_utext_var); + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 1120 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1120 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1120 "utext.pgc" + + { ECPGsetcommit(__LINE__, "on", NULL); +#line 1121 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1121 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1121 "utext.pgc" + +} + +//simple insert utext pointer with L string inited +void test_pvar_13() +{ +/* exec sql begin declare section */ + + +#line 1128 "utext.pgc" + utext * utext_local_pvar = L"太𠮷𠜱平洋𠱓大西洋印度洋北冰洋" ; +/* exec sql end declare section */ +#line 1129 "utext.pgc" + + test("test_pvar_13 : simple insert utext pointer with L string inited"); + init_var(); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 16 )", + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1133 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1133 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1133 "utext.pgc" + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 16", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT); +#line 1135 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1135 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1135 "utext.pgc" + + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + init_table_value(); +} + +//Open cursor using utext var directly in WHERE Clause +void test_pvar_14() +{ +/* exec sql begin declare section */ + + +#line 1146 "utext.pgc" + utext * utext_local_pvar ; +/* exec sql end declare section */ +#line 1147 "utext.pgc" + + utext_local_pvar = (utext*)malloc(P_VAR_SIZE*sizeof(utext)); + memset(utext_local_pvar,'a',P_VAR_SIZE*sizeof(utext)); + + test("test_pvar_14 : Open cursor using utext var directly in WHERE Clause"); + init_var(); + + { ECPGsetcommit(__LINE__, "off", NULL); +#line 1154 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1154 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1154 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1155 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1155 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1155 "utext.pgc" + + + ECPGset_var( 2, &( utext_local_pvar ), __LINE__);\ + /* declare cursor_pvar_14 cursor for select count from tb1 where Item = $1 */ +#line 1157 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "declare cursor_pvar_14 cursor for select count from tb1 where Item = $1 ", + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1158 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1158 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1158 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "fetch cursor_pvar_14", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1159 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1159 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1159 "utext.pgc" + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "close cursor_pvar_14", ECPGt_EOIT, ECPGt_EORT); +#line 1161 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1161 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1161 "utext.pgc" + + + { ECPGsetcommit(__LINE__, "on", NULL); +#line 1163 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1163 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1163 "utext.pgc" + +} + + +//utext pointer working with NULL without using indicator +void test_pvar_15() +{ +/* exec sql begin declare section */ + + +#line 1171 "utext.pgc" + utext * utext_local_pvar ; +/* exec sql end declare section */ +#line 1172 "utext.pgc" + + utext_local_pvar = (utext*)malloc(P_VAR_SIZE*sizeof(utext)); + memset(utext_local_pvar,'a',P_VAR_SIZE*sizeof(utext)); + + test("test_pvar_15 : Test utext pointer working with NULL without using indicator"); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 8", ECPGt_EOIT, + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1178 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1178 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1178 "utext.pgc" + + + print_utext(utext_local_pvar); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 18 )", + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1182 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1182 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1182 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 19 )", + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1183 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1183 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1183 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 20 )", + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1184 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1184 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1184 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item is null", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1185 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1185 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1185 "utext.pgc" + + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//utext pointer working with NULL using indicator +void test_pvar_16() +{ +/* exec sql begin declare section */ + + + +#line 1195 "utext.pgc" + utext * utext_local_pvar ; + +#line 1196 "utext.pgc" + int utext_pvar_ind = - 1 ; +/* exec sql end declare section */ +#line 1197 "utext.pgc" + + utext_local_pvar = (utext*)malloc(P_VAR_SIZE*sizeof(utext)); + memset(utext_local_pvar,'a',P_VAR_SIZE*sizeof(utext)); + + test("test_pvar_16 : Test utext pointer working with NULL using indicator"); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 8", ECPGt_EOIT, + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_int,&(utext_pvar_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT); +#line 1203 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1203 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1203 "utext.pgc" + + + print_utext(utext_local_pvar); + print_utext_ind(utext_pvar_ind); + + memset(utext_local_pvar,0,P_VAR_SIZE*sizeof(utext)); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 18 )", + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_int,&(utext_pvar_ind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT); +#line 1209 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1209 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1209 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 19 )", + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_int,&(utext_pvar_ind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT); +#line 1210 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1210 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1210 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 20 )", + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_int,&(utext_pvar_ind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT); +#line 1211 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1211 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1211 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item is null", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1212 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1212 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1212 "utext.pgc" + + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//utext uninitialized pointer getting and setting data +void test_pvar_17() +{ +/* exec sql begin declare section */ + + + +#line 1222 "utext.pgc" + utext * utext_local_pvar = 0 ; + +#line 1223 "utext.pgc" + char local_str [ 50 ] ; +/* exec sql end declare section */ +#line 1224 "utext.pgc" + + + test("test_pvar_17 : Test utext uninitialized pointer getting and setting data"); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1228 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1228 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1228 "utext.pgc" + + + print_utext_str(utext_local_pvar); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 18 )", + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1232 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1232 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1232 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 18", ECPGt_EOIT, + ECPGt_char,(local_str),(long)50,(long)1,(50)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1233 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1233 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1233 "utext.pgc" + + printf ("Find Item = %s where Count=18\n", local_str); + + init_table_value(); +} + +//utext uninitialized pointer working with NULL without using indicator +void test_pvar_18() +{ +/* exec sql begin declare section */ + + +#line 1243 "utext.pgc" + utext * utext_local_pvar = 0 ; +/* exec sql end declare section */ +#line 1244 "utext.pgc" + + + test("test_pvar_18 : Test utext uninitialized pointer working with NULL without using indicator"); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 8", ECPGt_EOIT, + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1248 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1248 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1248 "utext.pgc" + + + print_utext_size(utext_local_pvar,1); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 18 )", + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1252 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1252 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1252 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 19 )", + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1253 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1253 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1253 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 20 )", + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1254 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1254 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1254 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item is null", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1255 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1255 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1255 "utext.pgc" + + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//utext uninitialized pointer working with NULL using indicator +void test_pvar_19() +{ +/* exec sql begin declare section */ + + + +#line 1265 "utext.pgc" + utext * utext_local_pvar = 0 ; + +#line 1266 "utext.pgc" + int utext_pvar_ind = - 1 ; +/* exec sql end declare section */ +#line 1267 "utext.pgc" + + + test("test_pvar_19 : Test utext uninitialized pointer working with NULL using indicator"); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 8", ECPGt_EOIT, + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_int,&(utext_pvar_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT); +#line 1271 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1271 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1271 "utext.pgc" + + + print_utext_size(utext_local_pvar,1); + print_utext_ind(utext_pvar_ind); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 18 )", + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_int,&(utext_pvar_ind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT); +#line 1276 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1276 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1276 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 19 )", + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_int,&(utext_pvar_ind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT); +#line 1277 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1277 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1277 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 20 )", + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_int,&(utext_pvar_ind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT); +#line 1278 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1278 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1278 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item is null", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1279 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1279 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1279 "utext.pgc" + + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//Test select into host varaibles from descriptor +void test_desc_1() +{ + /* exec sql begin declare section */ + + + + + +#line 1289 "utext.pgc" + utext utext_local_var [ 20 ] ; + +#line 1290 "utext.pgc" + utext * utext_local_pvar = 0 ; + +#line 1291 "utext.pgc" + utext ** utext_local_ppvar = 0 ; + +#line 1292 "utext.pgc" + char desc1 [ 8 ] = "outdesc" ; +/* exec sql end declare section */ +#line 1293 "utext.pgc" + + +// ECPGdebug(1, stderr); + + ECPGallocate_desc(__LINE__, "indesc"); +#line 1297 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1297 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint(); +#line 1297 "utext.pgc" + + ECPGallocate_desc(__LINE__, (desc1)); +#line 1298 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1298 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint(); +#line 1298 "utext.pgc" + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item , count from tb1 where count = 1", ECPGt_EOIT, + ECPGt_descriptor, (desc1), 1L, 1L, 1L, + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1300 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1300 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1300 "utext.pgc" + + + { ECPGget_desc(__LINE__, (desc1), 1,ECPGd_data, + ECPGt_utext,(utext_local_var),(long)20,(long)1,(20)*sizeof(utext), ECPGd_EODT); + +#line 1302 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1302 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1302 "utext.pgc" + + print_utext(utext_local_var); + + { ECPGget_desc(__LINE__, (desc1), 1,ECPGd_data, + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), ECPGd_EODT); + +#line 1305 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1305 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1305 "utext.pgc" + + print_utext_str(utext_local_pvar); + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item , count from tb1 where count <= 3", ECPGt_EOIT, + ECPGt_descriptor, (desc1), 1L, 1L, 1L, + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1309 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1309 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1309 "utext.pgc" + + { ECPGget_desc(__LINE__, (desc1), 1,ECPGd_data, + ECPGt_utext,&(utext_local_ppvar),(long)0,(long)0,(1)*sizeof(utext), ECPGd_EODT); + +#line 1310 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1310 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1310 "utext.pgc" + + print_utext_str(utext_local_ppvar[0]); + print_utext_str(utext_local_ppvar[1]); + print_utext_str(utext_local_ppvar[2]); + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item , count from tb1 where count <= 10 and count >= 8", ECPGt_EOIT, + ECPGt_descriptor, (desc1), 1L, 1L, 1L, + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1316 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1316 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1316 "utext.pgc" + + { ECPGget_desc(__LINE__, (desc1), 1,ECPGd_data, + ECPGt_utext,&(utext_local_ppvar),(long)0,(long)0,(1)*sizeof(utext), ECPGd_EODT); + +#line 1317 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1317 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1317 "utext.pgc" + + print_utext_str(utext_local_ppvar[0]); + print_utext_str(utext_local_ppvar[1]); + print_utext_str(utext_local_ppvar[2]); + + + ECPGdeallocate_desc(__LINE__, "indesc"); +#line 1323 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1323 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint(); +#line 1323 "utext.pgc" + + ECPGdeallocate_desc(__LINE__, (desc1)); +#line 1324 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1324 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint(); +#line 1324 "utext.pgc" + +} + + +//Test uninitialized pointer to pointer utext_var without initialize +void test_pp_var_1() +{ +/* exec sql begin declare section */ + + + + +#line 1332 "utext.pgc" + utext ** utext_local_ppvar = 0 ; + +#line 1333 "utext.pgc" + int * utext_local_ppvar_ind = 0 ; + +#line 1334 "utext.pgc" + char utext_local_char [ 80 ] ; +/* exec sql end declare section */ +#line 1335 "utext.pgc" + + test("test_pp_var_1 : Test pointer to pointer utext_var without initialize"); + + //memset(utext_local_var,'a',sizeof(utext_local_var)); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count <= 3", ECPGt_EOIT, + ECPGt_utext,&(utext_local_ppvar),(long)0,(long)0,(1)*sizeof(utext), + ECPGt_int,&(utext_local_ppvar_ind),(long)1,(long)0,sizeof(int), ECPGt_EORT); +#line 1339 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1339 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1339 "utext.pgc" + + print_utext_str(utext_local_ppvar[0]); + print_utext_ind(utext_local_ppvar_ind[0]); + + print_utext_str(utext_local_ppvar[1]); + print_utext_ind(utext_local_ppvar_ind[1]); + + print_utext_str(utext_local_ppvar[2]); + print_utext_ind(utext_local_ppvar_ind[2]); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 28 )", + ECPGt_utext,&(utext_local_ppvar[1]),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1349 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1349 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1349 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 28", ECPGt_EOIT, + ECPGt_char,(utext_local_char),(long)80,(long)1,(80)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1350 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1350 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1350 "utext.pgc" + + printf("%s\n",utext_local_char); + + init_table_value(); +} + + +//Test uninitialized pointer to pointer utext_var working with NULL without indicator +void test_pp_var_2() +{ +/* exec sql begin declare section */ + + +#line 1361 "utext.pgc" + utext ** utext_local_ppvar = 0 ; +/* exec sql end declare section */ +#line 1362 "utext.pgc" + + test("test_pp_var_2 : Test uninitialized pointer to pointer utext_var working with NULL without indicator"); + + //memset(utext_local_var,'a',sizeof(utext_local_var)); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count >= 8 and count <= 10", ECPGt_EOIT, + ECPGt_utext,&(utext_local_ppvar),(long)0,(long)0,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1366 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1366 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1366 "utext.pgc" + + print_utext_str(utext_local_ppvar[0]); + print_utext_str(utext_local_ppvar[1]); + print_utext_str(utext_local_ppvar[2]); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 18 )", + ECPGt_utext,&(utext_local_ppvar[0]),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1371 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1371 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1371 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 19 )", + ECPGt_utext,&(utext_local_ppvar[1]),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1372 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1372 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1372 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 20 )", + ECPGt_utext,&(utext_local_ppvar[2]),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1373 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1373 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1373 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item is null", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1374 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1374 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1374 "utext.pgc" + + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//Test uninitialized pointer to pointer utext_var working with NULL with indicator +void test_pp_var_3() +{ +/* exec sql begin declare section */ + + + +#line 1384 "utext.pgc" + utext ** utext_local_ppvar = 0 ; + +#line 1385 "utext.pgc" + int * utext_local_ppvar_ind = 0 ; +/* exec sql end declare section */ +#line 1386 "utext.pgc" + + test("test_pp_var_2 : Test uninitialized pointer to pointer utext_var working with NULL without indicator"); + + //memset(utext_local_var,'a',sizeof(utext_local_var)); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count >= 8 and count <= 10", ECPGt_EOIT, + ECPGt_utext,&(utext_local_ppvar),(long)0,(long)0,(1)*sizeof(utext), + ECPGt_int,&(utext_local_ppvar_ind),(long)1,(long)0,sizeof(int), ECPGt_EORT); +#line 1390 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1390 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1390 "utext.pgc" + + print_utext_str(utext_local_ppvar[0]); + print_utext_ind(utext_local_ppvar_ind[0]); + + print_utext_str(utext_local_ppvar[1]); + print_utext_ind(utext_local_ppvar_ind[1]); + + print_utext_str(utext_local_ppvar[2]); + print_utext_ind(utext_local_ppvar_ind[2]); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 18 )", + ECPGt_utext,&(utext_local_ppvar[0]),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1400 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1400 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1400 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 19 )", + ECPGt_utext,&(utext_local_ppvar[1]),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1401 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1401 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1401 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 20 )", + ECPGt_utext,&(utext_local_ppvar[2]),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 1402 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1402 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1402 "utext.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item is null", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 1403 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 1403 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 1403 "utext.pgc" + + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +void test_all() +{ + test_var_1(); + test_var_2(); + test_var_3(); + test_var_4(); + test_var_5(); + test_var_6(); + test_var_7(); + test_var_8(); + test_var_9(); + test_var_10(); + test_var_11(); + test_var_12(); + test_var_13(); + test_var_14(); + test_var_15(); + test_var_16(); + test_array_1(); + test_array_2(); + test_array_3(); + test_array_4(); + test_array_5(); + test_array_6(); + test_array_7(); + test_array_8(); + test_array_9(); + test_array_10(); + test_array_11(); + test_array_12(); + test_array_13(); + test_array_14(); + test_array_15(); + test_array_16(); + test_pvar_1(); + test_pvar_2(); + test_pvar_3(); + test_pvar_4(); + test_pvar_5(); + test_pvar_6(); + test_pvar_7(); + test_pvar_8(); + test_pvar_9(); + test_pvar_10(); + test_pvar_11(); + test_pvar_12(); + test_pvar_13(); + test_pvar_14(); + test_pvar_15(); + test_pvar_16(); + test_pvar_17(); + test_pvar_18(); + test_pvar_19(); + test_pp_var_1(); + test_pp_var_2(); + test_pp_var_3(); +} + +int main(int argc, char *argv[]) +{ +// ECPGdebug(1, stderr); + if(test_init() !=0) + return -1; + + test_all(); + test_finish(); + + return 0; +} diff --git a/src/interfaces/ecpg/test/expected/sql-utext.stderr b/src/interfaces/ecpg/test/expected/sql-utext.stderr new file mode 100644 index 0000000..885cfe4 --- /dev/null +++ b/src/interfaces/ecpg/test/expected/sql-utext.stderr @@ -0,0 +1,2 @@ +SQL error: +SQL error: diff --git a/src/interfaces/ecpg/test/expected/sql-utext.stdout b/src/interfaces/ecpg/test/expected/sql-utext.stdout new file mode 100644 index 0000000..c8dfd5b --- /dev/null +++ b/src/interfaces/ecpg/test/expected/sql-utext.stdout @@ -0,0 +1,433 @@ + +test_var_1: simple select into utext var +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x00000000 0x00000000 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00004E9A 0x00006D32 0x00006B27 0x00006D32 0x0000975E 0x00006D32 0x00005927 0x00006D0B +0x00006D32 0x00005317 0x00007F8E 0x00006D32 0x00005357 0x00007F8E 0x00006D32 0x00005357 +0x00006781 0x00006D32 0x00006CA1 0x00006709 +======End utext_var content====== +utext_var_ind = 23 + +test_var_2: simple select using utext var +count=1 for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +count=3 for '世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_3: simple update using utext var +found 3 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_var_4 : simple delete using utext var +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 0 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_5 : simple insert using utext +found 2 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_6 : prepared select into utext var +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +======End utext_var content====== +======print utext_var content====== +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +======End utext_var content====== + +test_var_7 : prepared select using utext var +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_8 : prepared update using utext var +found 3 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_9 : prepared delete using utext var +found 0 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_10 : prepared insert using utext var +found 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_11 : Open cursor using utext var +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_12 : Fecth cursor into utext var +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +======End utext_var content====== + +test_var_13 : simple insert utext var with L string inited +======print utext_var_str content====== +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 +======End utext_var_str content====== +======print utext_var content====== +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +======End utext_var content====== +utext_var_ind = 0 + +test_var_14 : Open cursor using utext var directly in WHERE Clause +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_15 : Test utext_var working with NULL without indicator +======print utext_var content====== +0x00000000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +found 6 rows for Item being NULL + +test_var_16 : Test utext_var working with NULL with indicator +======print utext_var content====== +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +utext_var_ind = -1 +found 6 rows for Item being NULL + +test_array_1 : simple select into utext array +---->array[0]: +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +---->array[1]: +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x00000000 0x00000000 +---->array[2]: +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +---->array[3]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + +---->array[0]: +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +---->array[1]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[2]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[3]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + + +test_array_2 : simple select using array +count=1 for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +count=3 for '世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_3 : simple update using utext array +find 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +find 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_4 : simple delete using utext array +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 0 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_5 : simple insert using utext array +found 2 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_6 : prepared select into utext array +---->array[0]: +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +---->array[1]: +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x00000000 0x00000000 +---->array[2]: +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +---->array[3]: +0x00004E9A 0x00006D32 0x00006B27 0x00006D32 0x0000975E 0x00006D32 0x00005927 0x00006D0B +0x00006D32 0x00005317 0x00007F8E 0x00006D32 0x00005357 0x00007F8E 0x00006D32 0x00005357 +0x00006781 0x00006D32 0x00006CA1 0x00006709 + + +test_array_7 : prepared select using utext array +count=1 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_8 : prepared update using utext array +found 3 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_array_9 : prepared delete using utext array +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_array_10 : prepared insert using utext array +found 3 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_11 : Open cursor using utext array +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_12 : Fecth cursor into utext array +---->array[0]: +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +---->array[1]: +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x00000000 0x00000000 +---->array[2]: +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +---->array[3]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + + +test_array_13 : Insert array with L string inited +---->array[0]: +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +---->array[1]: +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x00000000 0x00000000 +---->array[2]: +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00000000 0x00000000 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 + + +test_array_14 : Open cursor using utext array directly in WHERE Clause +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_15 : Test utext array working with NULL without using indicator +---->array[0]: +0x00000000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[1]: +0x00000000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[2]: +0x00000000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + +found 6 rows for Item being NULL + +test_array_16 : Test utext array working with NULL using indicator +---->array[0]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[1]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[2]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + +utext_var_ind = -1 +utext_var_ind = -1 +utext_var_ind = -1 +found 6 rows for Item being NULL + +test_pvar_1 : simple select into utext pointer +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x61616161 0x61616161 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00004E9A 0x00006D32 0x00006B27 0x00006D32 0x0000975E 0x00006D32 0x00005927 0x00006D0B +0x00006D32 0x00005317 0x00007F8E 0x00006D32 0x00005357 0x00007F8E 0x00006D32 0x00005357 +0x00006781 0x00006D32 0x00006CA1 0x00006709 +======End utext_var content====== +utext_var_ind = 0 + +test_pvar_2 : simple select using utext pointer +count=1 for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +count=0 for '世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_3 : simple update using utext pointer +found 3 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_pvar_4 : simple delete using utext pointer +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 1 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_5 : simple insert using utext pointer +found 1 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_6 : prepared select into utext pointer +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +======print utext_var content====== +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +======End utext_var content====== + +test_pvar_7 : prepared select using utext pointer +count=0 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_8 : prepared update using utext pointer +found 1 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_9 : prepared delete using utext pointer +found 1 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_10 : prepared insert using utext pointer +found 1 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_11 : Open cursor using utext pointer +count=0 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_12 : Fecth cursor into utext pointer +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== + +test_pvar_13 : simple insert utext pointer with L string inited +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +======End utext_var content====== +utext_var_ind = 0 + +test_pvar_14 : Open cursor using utext var directly in WHERE Clause +count=0 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_15 : Test utext pointer working with NULL without using indicator +======print utext_var content====== +0x00000000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +found 6 rows for Item being NULL + +test_pvar_16 : Test utext pointer working with NULL using indicator +======print utext_var content====== +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +utext_var_ind = -1 +found 6 rows for Item being NULL + +test_pvar_17 : Test utext uninitialized pointer getting and setting data +======print utext_var_str content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B +======End utext_var_str content====== +Find Item = 太𠮷𠜱平洋𠱓大西洋印度洋北冰洋 where Count=18 + +test_pvar_18 : Test utext uninitialized pointer working with NULL without using indicator +======print utext_var content====== +0x00000000 +======End utext_var content====== +found 6 rows for Item being NULL + +test_pvar_19 : Test utext uninitialized pointer working with NULL using indicator +======print utext_var content====== +0x00000000 +======End utext_var content====== +utext_var_ind = -1 +found 6 rows for Item being NULL + +test_pp_var_1 : Test pointer to pointer utext_var without initialize +======print utext_var_str content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B +======End utext_var_str content====== +utext_var_ind = 0 +======print utext_var_str content====== +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 +======End utext_var_str content====== +utext_var_ind = 0 +======print utext_var_str content====== +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F +======End utext_var_str content====== +utext_var_ind = 0 +足球篮球羽毛球乒乓球橄榄球棒球冰球 + +test_pp_var_2 : Test uninitialized pointer to pointer utext_var working with NULL without indicator +======print utext_var_str content====== + +======End utext_var_str content====== +======print utext_var_str content====== + +======End utext_var_str content====== +======print utext_var_str content====== + +======End utext_var_str content====== +found 6 rows for Item being NULL + +test_pp_var_2 : Test uninitialized pointer to pointer utext_var working with NULL without indicator +======print utext_var_str content====== + +======End utext_var_str content====== +utext_var_ind = -1 +======print utext_var_str content====== + +======End utext_var_str content====== +utext_var_ind = -1 +======print utext_var_str content====== + +======End utext_var_str content====== +utext_var_ind = -1 +found 6 rows for Item being NULL diff --git a/src/interfaces/ecpg/test/expected/sql-uvarchar.c b/src/interfaces/ecpg/test/expected/sql-uvarchar.c new file mode 100644 index 0000000..288eb14 --- /dev/null +++ b/src/interfaces/ecpg/test/expected/sql-uvarchar.c @@ -0,0 +1,2580 @@ +/* Processed by ecpg (regression mode) */ +/* These include files are added by the preprocessor */ +#define ECPG_ENABLE_UTEXT 1 +#include +#include +#include +/* End of automatic include section */ +#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y)) + +#line 1 "uvarchar.pgc" +#include +#include +#include + + +#line 1 "regression.h" + + + + + + +#line 5 "uvarchar.pgc" + + +#define test(msg) printf("\n%s\n",msg) +#define VAR_SIZE 20 +#define ARRAY_SIZE 4 + +/* Following is UTF8 and UTF16 characters mapping table */ +/*太𠮷𠜱平洋𠱓大西洋印度洋北冰洋 +0x592A,0x5E73,0x6D0B,0x5927,0x897F,0x6D0B,0x5370,0x5EA6, +0x6D0B,0x5317,0x51B0,0x6D0B,0x548C,0x5357,0x51B0,0x6D0B, +0x0000,0x0000,0x0000,0x0000*/ + +/*足球篮球羽毛球乒乓球橄榄球棒球冰球 +0x8DB3,0x7403,0x7BEE,0x7403,0x7FBD,0x6BDB,0x7403,0x4E52, +0x4E53,0x7403,0x6A44,0x6984,0x7403,0x68D2,0x7403,0x51B0, +0x7403,0x0000,0x0000,0x0000 +*/ + +/*世界杯每隔四年就会举行一次每次𠲖个球队 +0x4E16,0x754C,0x676F,0x6BCF,0x9694,0x56DB,0x5E74,0x5C31, +0x4F1A,0x4E3E,0x884C,0x4E00,0x6B21,0x6BCF,0x6B21,0x0033, +0x0032,0x4E2A,0x7403,0x961F +*/ + +/* 亚洲欧洲非洲大洋洲北美洲南美洲南极洲没有北极洲 +0x4E9A,0x6D32,0x6B27,0x6D32,0x975E,0x6D32,0x5927,0x6D0B, +0x6D32,0x5317,0x7F8E,0x6D32,0x5357,0x7F8E,0x6D32,0x5357, +0x6781,0x6D32,0x6CA1,0x6709,0x5317,0x6781,0x6D32 +*/ + +/* exec sql begin declare section */ + + + + + + + + + +#line 36 "uvarchar.pgc" + struct uvarchar_1 { int len; utext arr[ VAR_SIZE ]; } uvarchar_var ; + +#line 37 "uvarchar.pgc" + struct uvarchar_2 { int len; utext arr[ VAR_SIZE ]; } uvarchar_array [ ARRAY_SIZE ] ; + +#line 39 "uvarchar.pgc" + int uvarchar_var_ind ; + +#line 41 "uvarchar.pgc" + int count ; + +#line 42 "uvarchar.pgc" + int count_array [ 4 ] = { 1 , 2 , 3 , 4 } ; + +#line 43 "uvarchar.pgc" + int total_tuples = 0 ; +/* exec sql end declare section */ +#line 44 "uvarchar.pgc" + + +void print_uvarchar(void); +void print_uvarchar_ind(int uvarchar_var_ind); +void print_local_uvarchar(utext *utext_var, int var_len); +void print_array(void); +int test_init(void); +void test_finish(void); +void init_table_value(void); +void init_var(void); + +void test_var_1(void); +void test_var_2(void); +void test_var_3(void); +void test_var_4(void); +void test_var_5(void); +void test_var_6(void); +void test_var_7(void); +void test_var_8(void); +void test_var_9(void); +void test_var_10(void); +void test_var_11(void); +void test_var_12(void); +void test_var_13(void); +void test_var_14(void); +void test_var_15(void); +void test_var_16(void); +void test_array_1(void); +void test_array_2(void); +void test_array_3(void); +void test_array_4(void); +void test_array_5(void); +void test_array_6(void); +void test_array_7(void); +void test_array_8(void); +void test_array_9(void); +void test_array_10(void); +void test_array_11(void); +void test_array_12(void); +void test_array_13(void); +void test_array_14(void); +void test_array_15(void); +void test_array_16(void); + +void test_all(void); + +void print_uvarchar() +{ + int i; + + printf ("---->uvarchar variable,len=%d:\n",uvarchar_var.len); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n"); +} + +void print_uvarchar_ind(int uvarchar_var_ind) +{ + printf("uvarchar_var_ind = %d\n",uvarchar_var_ind); +} + +void print_local_uvarchar(utext *utext_var, int var_len) +{ + int i; + + printf ("---->uvarchar variable,len=%d:\n",var_len); + for(i=0; i<20; i++) + { + printf ("0x%04X ", utext_var[i]); + if(i>6 && (i+1)%8==0) + printf("\n"); + } + printf("\n"); +} + +void print_array() +{ + int i,j; + + for(i=0; iuvarchar array[%d]:(len=%d)\n", i,uvarchar_array[i].len); + + for(j=0; j6 && (j+1)%8==0) + printf("\n"); + } + printf("\n"); + } + + printf("\n"); +} + +int test_init() +{ + { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); } +#line 145 "uvarchar.pgc" + + + { ECPGsetcommit(__LINE__, "on", NULL);} +#line 147 "uvarchar.pgc" + + /* exec sql whenever sql_warning sqlprint ; */ +#line 148 "uvarchar.pgc" + + /* exec sql whenever sqlerror sqlprint ; */ +#line 149 "uvarchar.pgc" + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "set client_encoding = 'UTF8'", ECPGt_EOIT, ECPGt_EORT); +#line 151 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 151 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 151 "uvarchar.pgc" + + + //initialization of test table + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "create table tb1 ( Item varchar , count integer )", ECPGt_EOIT, ECPGt_EORT); +#line 154 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 154 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 154 "uvarchar.pgc" + + + init_table_value(); + + return 0; +} + +void test_finish() +{ + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "drop table tb1", ECPGt_EOIT, ECPGt_EORT); +#line 163 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 163 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 163 "uvarchar.pgc" + + { ECPGdisconnect(__LINE__, "ALL"); +#line 164 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 164 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 164 "uvarchar.pgc" + +} + + +void init_table_value() +{ + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "truncate tb1", ECPGt_EOIT, ECPGt_EORT); +#line 170 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 170 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 170 "uvarchar.pgc" + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' , 1 )", ECPGt_EOIT, ECPGt_EORT); +#line 172 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 172 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 172 "uvarchar.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( '足球篮球羽毛球乒乓球橄榄球棒球冰球' , 2 )", ECPGt_EOIT, ECPGt_EORT); +#line 173 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 173 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 173 "uvarchar.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( '世界杯每隔四年就会举行一次每次𠲖个球队' , 3 )", ECPGt_EOIT, ECPGt_EORT); +#line 174 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 174 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 174 "uvarchar.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( '亚洲欧洲非洲大洋洲北美洲南美洲南极洲没有北极洲' , 4 )", ECPGt_EOIT, ECPGt_EORT); +#line 175 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 175 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 175 "uvarchar.pgc" + + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 ( count ) values ( 8 )", ECPGt_EOIT, ECPGt_EORT); +#line 177 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 177 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 177 "uvarchar.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 ( count ) values ( 9 )", ECPGt_EOIT, ECPGt_EORT); +#line 178 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 178 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 178 "uvarchar.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 ( count ) values ( 10 )", ECPGt_EOIT, ECPGt_EORT); +#line 179 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 179 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 179 "uvarchar.pgc" + +} + +void init_var() +{ + int i; + memset((void*)&uvarchar_var,'a',sizeof(uvarchar_var)); + uvarchar_var.len = 0; + + memset((char*)uvarchar_array,'a',sizeof(uvarchar_array)*ARRAY_SIZE); + + for(i=0;i= 20", ECPGt_EOIT, + ECPGt_uvarchar,(uvarchar_array),(long)VAR_SIZE,(long)ARRAY_SIZE,sizeof(struct uvarchar_2), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 768 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 768 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 768 "uvarchar.pgc" + + print_array(); + init_table_value(); + +} + +//uvarchar array working with NULL without using indicator +void test_array_15() +{ +/* exec sql begin declare section */ + + +#line 778 "uvarchar.pgc" + struct uvarchar_8 { int len; utext arr[ 20 ]; } uvarchar_local_array [ 3 ] ; +/* exec sql end declare section */ +#line 779 "uvarchar.pgc" + + test("test_array_15 : Test uvarchar array working with NULL without using indicator"); + memset(uvarchar_local_array,'a',sizeof(uvarchar_local_array)); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count >= 8 and count <= 10", ECPGt_EOIT, + ECPGt_uvarchar,(uvarchar_local_array),(long)20,(long)3,sizeof(struct uvarchar_8), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 783 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 783 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 783 "uvarchar.pgc" + + + print_local_uvarchar(uvarchar_local_array[0].arr, 20); + print_local_uvarchar(uvarchar_local_array[1].arr, 20); + print_local_uvarchar(uvarchar_local_array[2].arr, 20); + + + memset(uvarchar_local_array,0x00,sizeof(uvarchar_local_array)); + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 18 )", + ECPGt_uvarchar,&(uvarchar_local_array[0]),(long)20,(long)1,sizeof(struct uvarchar_8), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 791 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 791 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 791 "uvarchar.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 19 )", + ECPGt_uvarchar,&(uvarchar_local_array[1]),(long)20,(long)1,sizeof(struct uvarchar_8), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 792 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 792 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 792 "uvarchar.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 20 )", + ECPGt_uvarchar,&(uvarchar_local_array[2]),(long)20,(long)1,sizeof(struct uvarchar_8), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT); +#line 793 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 793 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 793 "uvarchar.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item is null", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 794 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 794 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 794 "uvarchar.pgc" + + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//uvarchar array working with NULL using indicator +void test_array_16() +{ +/* exec sql begin declare section */ + + + +#line 804 "uvarchar.pgc" + struct uvarchar_9 { int len; utext arr[ 20 ]; } uvarchar_local_array [ 3 ] ; + +#line 805 "uvarchar.pgc" + int uvarchar_array_ind [ 3 ] ; +/* exec sql end declare section */ +#line 806 "uvarchar.pgc" + + test("test_array_16 : Test uvarchar array working with NULL using indicator"); + memset(uvarchar_local_array,'a',sizeof(uvarchar_local_array)); + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select Item from tb1 where count >= 8 and count <= 10", ECPGt_EOIT, + ECPGt_uvarchar,(uvarchar_local_array),(long)20,(long)3,sizeof(struct uvarchar_9), + ECPGt_int,(uvarchar_array_ind),(long)1,(long)3,sizeof(int), ECPGt_EORT); +#line 810 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 810 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 810 "uvarchar.pgc" + + + + print_local_uvarchar(uvarchar_local_array[0].arr, 20); + print_local_uvarchar(uvarchar_local_array[1].arr, 20); + print_local_uvarchar(uvarchar_local_array[2].arr, 20); + + print_uvarchar_ind(uvarchar_array_ind[0]); + print_uvarchar_ind(uvarchar_array_ind[1]); + print_uvarchar_ind(uvarchar_array_ind[2]); + + memset(uvarchar_local_array,0x00,sizeof(uvarchar_local_array)); + uvarchar_array_ind[0]=-1; + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 18 )", + ECPGt_uvarchar,&(uvarchar_local_array[0]),(long)20,(long)1,sizeof(struct uvarchar_9), + ECPGt_int,&(uvarchar_array_ind[0]),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT); +#line 823 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 823 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 823 "uvarchar.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 19 )", + ECPGt_uvarchar,&(uvarchar_local_array[1]),(long)20,(long)1,sizeof(struct uvarchar_9), + ECPGt_int,&(uvarchar_array_ind[0]),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT); +#line 824 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 824 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 824 "uvarchar.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 20 )", + ECPGt_uvarchar,&(uvarchar_local_array[2]),(long)20,(long)1,sizeof(struct uvarchar_9), + ECPGt_int,&(uvarchar_array_ind[0]),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT); +#line 825 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 825 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 825 "uvarchar.pgc" + + { ECPGdo(__LINE__, 0, 0, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item is null", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); +#line 826 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 826 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 826 "uvarchar.pgc" + + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +void test_all() +{ + test_var_1(); + test_var_2(); + test_var_3(); + test_var_4(); + test_var_5(); + test_var_6(); + test_var_7(); + test_var_8(); + test_var_9(); + test_var_10(); + test_var_11(); + test_var_12(); + test_var_13(); + test_var_14(); + test_var_15(); + test_var_16(); + test_array_1(); + test_array_2(); + test_array_3(); + test_array_4(); + test_array_5(); + test_array_6(); + test_array_7(); + test_array_8(); + test_array_9(); + test_array_10(); + test_array_11(); + test_array_12(); + test_array_13(); + test_array_15(); + test_array_16(); +} + +int main() +{ +// ECPGdebug(1, stderr); + if(test_init() !=0) + return -1; + + test_all(); + test_finish(); + + return 0; +} diff --git a/src/interfaces/ecpg/test/expected/sql-uvarchar.stderr b/src/interfaces/ecpg/test/expected/sql-uvarchar.stderr new file mode 100644 index 0000000..158fd24 --- /dev/null +++ b/src/interfaces/ecpg/test/expected/sql-uvarchar.stderr @@ -0,0 +1 @@ +SQL error: diff --git a/src/interfaces/ecpg/test/expected/sql-uvarchar.stdout b/src/interfaces/ecpg/test/expected/sql-uvarchar.stdout new file mode 100644 index 0000000..202cd5c --- /dev/null +++ b/src/interfaces/ecpg/test/expected/sql-uvarchar.stdout @@ -0,0 +1,252 @@ + +test_var_1 : simple select into uvarchar var +---->uvarchar variable,len=15: +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 +uvarchar_var_ind = 0 +---->uvarchar variable,len=17: +0x8DB3 0x7403 0x7BEE 0x7403 0x7FBD 0x6BDB 0x7403 0x4E52 +0x4E53 0x7403 0x6A44 0x6984 0x7403 0x68D2 0x7403 0x51B0 +0x7403 0x0000 0x0000 0x0000 +uvarchar_var_ind = 0 +---->uvarchar variable,len=19: +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0x20C96 +0x4E2A 0x7403 0x961F 0x0000 +uvarchar_var_ind = 0 +---->uvarchar variable,len=20: +0x4E9A 0x6D32 0x6B27 0x6D32 0x975E 0x6D32 0x5927 0x6D0B +0x6D32 0x5317 0x7F8E 0x6D32 0x5357 0x7F8E 0x6D32 0x5357 +0x6781 0x6D32 0x6CA1 0x6709 +uvarchar_var_ind = 23 + +test_var_2 : simple select using uvarchar var +count=1 for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +count=3 for '世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_3 : simple update using uvarchar +found 3 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_var_4 : simple delete using uvarchar var +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 0 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_5 : simple insert using uvarchar +found 2 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_6 : prepared select into uvarchar var +---->uvarchar variable,len=15: +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 +---->uvarchar variable,len=19: +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0x20C96 +0x4E2A 0x7403 0x961F 0x0000 + +test_var_7 : prepared select using uvarchar var +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_8 : prepared update using uvarchar var +found 3 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_9 : prepared delete using uvarchar var +found 0 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_10 : prepared insert using uvarchar var +found 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_11 : Open cursor using uvarchar var +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_12 : Fecth cursor into uvarchar var +---->uvarchar variable,len=15: +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 + +test_var_13 : simple insert using uvarchar with L string inited +uvarchar_local_var.len = 16 +found 2 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +---->uvarchar variable,len=15: +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 +uvarchar_var_ind = 0 + +test_var_14 : Open cursor using utext var directly in WHERE Clause +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_15 : Test uvarchar_var working with NULL without indicator +---->uvarchar variable,len=20: +0x0000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +found 6 rows for Item being NULL + +test_var_16 : Test uvarchar_var working with NULL with indicator +---->uvarchar variable,len=20: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +uvarchar_var_ind = -1 +found 6 rows for Item being NULL + +test_array_1 : simple select into uvarchar array +---->uvarchar array[0]:(len=15) +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 +---->uvarchar array[1]:(len=17) +0x8DB3 0x7403 0x7BEE 0x7403 0x7FBD 0x6BDB 0x7403 0x4E52 +0x4E53 0x7403 0x6A44 0x6984 0x7403 0x68D2 0x7403 0x51B0 +0x7403 0x0000 0x0000 0x0000 +---->uvarchar array[2]:(len=19) +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0x20C96 +0x4E2A 0x7403 0x961F 0x0000 +---->uvarchar array[3]:(len=0) +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + +---->uvarchar array[0]:(len=15) +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 +---->uvarchar array[1]:(len=0) +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->uvarchar array[2]:(len=0) +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->uvarchar array[3]:(len=0) +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + + +test_array_2 : simple select using uvarchar array +count=1 for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +count=3 for '世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_3 : simple update using uvarchar array +find 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +find 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_4 : simple delete using uvarchar array +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 0 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_5 : simple insert using uvarchar array +found 2 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_6 : prepared select into uvarchar array +---->uvarchar array[0]:(len=15) +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 +---->uvarchar array[1]:(len=17) +0x8DB3 0x7403 0x7BEE 0x7403 0x7FBD 0x6BDB 0x7403 0x4E52 +0x4E53 0x7403 0x6A44 0x6984 0x7403 0x68D2 0x7403 0x51B0 +0x7403 0x0000 0x0000 0x0000 +---->uvarchar array[2]:(len=19) +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0x20C96 +0x4E2A 0x7403 0x961F 0x0000 +---->uvarchar array[3]:(len=0) +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + + +test_array_7 : prepared select using uvarchar array +count=1 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_8 : prepared update using uvarchar array +found 2 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_array_9 : prepared delete using uvarchar array +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_array_10 : prepared insert using uvarchar array +found 3 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_11 : Open cursor using uvarchar array +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_12 : Fecth cursor into uvarchar array +---->uvarchar array[0]:(len=15) +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 +---->uvarchar array[1]:(len=17) +0x8DB3 0x7403 0x7BEE 0x7403 0x7FBD 0x6BDB 0x7403 0x4E52 +0x4E53 0x7403 0x6A44 0x6984 0x7403 0x68D2 0x7403 0x51B0 +0x7403 0x0000 0x0000 0x0000 +---->uvarchar array[2]:(len=19) +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0x20C96 +0x4E2A 0x7403 0x961F 0x0000 +---->uvarchar array[3]:(len=0) +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + + +test_array_13 : Insert array with L string inited +---->uvarchar array[0]:(len=15) +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 +---->uvarchar array[1]:(len=17) +0x8DB3 0x7403 0x7BEE 0x7403 0x7FBD 0x6BDB 0x7403 0x4E52 +0x4E53 0x7403 0x6A44 0x6984 0x7403 0x68D2 0x7403 0x51B0 +0x7403 0x0000 0x0000 0x0000 +---->uvarchar array[2]:(len=19) +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0x20C96 +0x4E2A 0x7403 0x961F 0x0000 +---->uvarchar array[3]:(len=0) +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + + +test_array_15 : Test uvarchar array working with NULL without using indicator +---->uvarchar variable,len=20: +0x0000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->uvarchar variable,len=20: +0x0000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->uvarchar variable,len=20: +0x0000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +found 6 rows for Item being NULL + +test_array_16 : Test uvarchar array working with NULL using indicator +---->uvarchar variable,len=20: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->uvarchar variable,len=20: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->uvarchar variable,len=20: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +uvarchar_var_ind = -1 +uvarchar_var_ind = -1 +uvarchar_var_ind = -1 +found 6 rows for Item being NULL diff --git a/src/interfaces/ecpg/test/sql/Makefile b/src/interfaces/ecpg/test/sql/Makefile index b7bc034..ed50ad7 100644 --- a/src/interfaces/ecpg/test/sql/Makefile +++ b/src/interfaces/ecpg/test/sql/Makefile @@ -23,9 +23,17 @@ TESTS = array array.c \ quote quote.c \ show show.c \ twophase twophase.c \ - insupd insupd.c + insupd insupd.c \ + utext utext.c \ + uvarchar uvarchar.c all: $(TESTS) oldexec.c: oldexec.pgc $(ECPG_TEST_DEPENDENCIES) $(ECPG) -r questionmarks -o $@ $< + +utext.c: utext.pgc $(ECPG_TEST_DEPENDENCIES) + $(ECPG) --enable-utext -r no_indicator -o $@ $< + +uvarchar.c: uvarchar.pgc $(ECPG_TEST_DEPENDENCIES) + $(ECPG) --enable-utext -r no_indicator -o $@ $< diff --git a/src/interfaces/ecpg/test/sql/utext.pgc b/src/interfaces/ecpg/test/sql/utext.pgc new file mode 100755 index 0000000..411de30 --- /dev/null +++ b/src/interfaces/ecpg/test/sql/utext.pgc @@ -0,0 +1,1477 @@ +#include +#include +#include +#include +EXEC SQL INCLUDE ../regression; + +#define test(msg) printf("\n%s\n",msg) +#define VAR_SIZE 20 +#define ARRAY_SIZE 4 +#define P_VAR_SIZE 22 + + +/* Following is UTF8 and UTF16/UTF32 characters mapping table */ +/*太𠮷𠜱平洋𠱓大西洋印度洋北冰洋 +utf16 +0x592A 0xD842 0xDFB7 0xD841 0xDF31 0x5E73 0x6D0B 0xD843 +0xDC53 0x5927 0x897F 0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 +0x51B0 0x6D0B 0x0000,0x0000 + +utf32 +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B +*/ + +/*足球篮球羽毛球乒乓球橄榄球棒球冰球 +utf16 +0x8DB3,0x7403,0x7BEE,0x7403,0x7FBD,0x6BDB,0x7403,0x4E52, +0x4E53,0x7403,0x6A44,0x6984,0x7403,0x68D2,0x7403,0x51B0, +0x7403,0x0000,0x0000,0x0000 + +utf32 +0x8DB3 0x7403 0x7BEE 0x7403 0x7FBD 0x6BDB 0x7403 0x4E52 +0x4E53 0x7403 0x6A44 0x6984 0x7403 0x68D2 0x7403 0x51B0 +0x7403 +*/ + +/*世界杯每隔四年就会举行一次每次𠲖个球队 +utf16 +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0xD843 +0xDC96 0x4E2A 0x7403 0x961F + +utf32 +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0x20C96 +0x4E2A 0x7403 0x961F +*/ + +/* 亚洲欧洲非洲大洋洲北美洲南美洲南极洲没有北极洲 +0x4E9A,0x6D32,0x6B27,0x6D32,0x975E,0x6D32,0x5927,0x6D0B, +0x6D32,0x5317,0x7F8E,0x6D32,0x5357,0x7F8E,0x6D32,0x5357, +0x6781,0x6D32,0x6CA1,0x6709,0x5317,0x6781,0x6D32 +*/ +/* 太𠮷 +0x592A 0xD842 0xDFB7 +*/ +void init_var(void); +void test_var_1(void); +void test_var_2(void); +void test_var_3(void); +void test_var_4(void); +void test_var_5(void); +void test_var_6(void); +void test_var_7(void); +void test_var_8(void); +void test_var_9(void); +void test_var_10(void); +void test_var_11(void); +void test_var_12(void); +void test_var_13(void); +void test_var_14(void); +void test_var_15(void); +void test_var_16(void); +void test_array_1(void); +void test_array_2(void); +void test_array_3(void); +void test_array_4(void); +void test_array_5(void); +void test_array_6(void); +void test_array_7(void); +void test_array_8(void); +void test_array_9(void); +void test_array_10(void); +void test_array_11(void); +void test_array_12(void); +void test_array_13(void); +void test_array_14(void); +void test_array_15(void); +void test_array_16(void); +void test_pvar_1(void); +void test_pvar_2(void); +void test_pvar_3(void); +void test_pvar_4(void); +void test_pvar_5(void); +void test_pvar_6(void); +void test_pvar_7(void); +void test_pvar_8(void); +void test_pvar_9(void); +void test_pvar_10(void); +void test_pvar_11(void); +void test_pvar_12(void); +void test_pvar_13(void); +void test_pvar_14(void); +void test_pvar_15(void); +void test_pvar_16(void); +void test_pvar_17(void); +void test_pvar_18(void); +void test_pvar_19(void); +void test_pp_var_1(void); +void test_pp_var_2(void); +void test_pp_var_3(void); +void test_desc_1(void); +void test_all(void); + +void print_utext(utext *utext_var); +void print_utext_str(utext *utext_var); +void print_utext_ind(int utext_var_ind); +void print_utext_size(utext *utext_var,int size); +void print_array(void *array, int array_size, int var_size); +void print_array_with_index(int index); +int test_init(void); +void test_finish(void); +void init_table_value(void); + +EXEC SQL BEGIN DECLARE SECTION; + int utext_var_size = 20; + int utext_array_size = 4; + int count=0; + int total_tuples = 0; + int i; + char char_var[10]={0xF0,0x90,0x90,0xB7}; + + utext utext_var[VAR_SIZE]; + utext utext_array[ARRAY_SIZE][VAR_SIZE]; + utext utext_input_var[20]={0x592a,0xd842, 0xdfb7, 0x0000}; + utext *p_utext_var = NULL; + + + int utext_var_ind; + int count_array[4]={1,2,3,4}; + +EXEC SQL END DECLARE SECTION; + +void print_utext(utext *utext_var) +{ + int i; + printf("======print utext_var content======\n"); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n======End utext_var content======\n"); +} + +void print_utext_str(utext *utext_var) +{ + int i=0; + printf("======print utext_var_str content======\n"); + if (utext_var==0) + { + printf("utext_var is NULL\n"); + printf("\n======End utext_var_str content======\n"); + return; + } + while(utext_var[i] != 0) + { + printf ("0x%08X ", utext_var[i]); + if(i>6 && (i+1)%8==0) + printf("\n"); + i++; + if(i>100) + break; + } + printf("\n======End utext_var_str content======\n"); +} + +void print_utext_size(utext *utext_var,int size) +{ + int i; + printf("======print utext_var content======\n"); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n======End utext_var content======\n"); +} + +void print_utext_ind(int utext_var_ind) +{ + printf("utext_var_ind = %d\n",utext_var_ind); +} +void print_array(void *array, int array_size, int var_size) +{ + int i,j; + + for(i=0; iarray[%d]:\n", i); + + for(j=0; j6 && (j+1)%8==0) + printf("\n"); + } + printf("\n"); + } + + printf("\n"); +} + +int test_init() +{ + p_utext_var = (utext*)malloc(P_VAR_SIZE*sizeof(utext)); + if(!p_utext_var) + { + printf("Error: failed allco memory for p_utext_var. \n"); + return -1; + } + + EXEC SQL CONNECT TO REGRESSDB1; + + EXEC SQL SET AUTOCOMMIT TO ON; + EXEC SQL WHENEVER SQLWARNING SQLPRINT; + EXEC SQL WHENEVER SQLERROR SQLPRINT; + + EXEC SQL SET client_encoding='UTF8'; + + //initialization of test table + EXEC SQL CREATE TABLE IF NOT EXISTS tb1 (Item varchar, Count integer); + + init_table_value(); + + return 0; +} + +void test_finish() +{ + EXEC SQL DROP TABLE tb1; + EXEC SQL DISCONNECT ALL; +} + +void init_table_value() +{ + EXEC SQL TRUNCATE tb1; + + EXEC SQL INSERT INTO tb1 VALUES ('太𠮷𠜱平洋𠱓大西洋印度洋北冰洋', 1); + EXEC SQL INSERT INTO tb1 VALUES ('足球篮球羽毛球乒乓球橄榄球棒球冰球', 2); + EXEC SQL INSERT INTO tb1 VALUES ('世界杯每隔四年就会举行一次每次𠲖个球队', 3); + EXEC SQL INSERT INTO tb1 VALUES ('亚洲欧洲非洲大洋洲北美洲南美洲南极洲没有北极洲', 4); + EXEC SQL INSERT INTO tb1 (Count) VALUES(8); + EXEC SQL INSERT INTO tb1 (Count) VALUES(9); + EXEC SQL INSERT INTO tb1 (Count) VALUES(10); +} + +void init_var() +{ + count = 0; + memset(utext_var,'a',sizeof(utext_var)); + memset(utext_array,'a',sizeof(utext_array)); + memset(p_utext_var,'a',P_VAR_SIZE*sizeof(utext)); +} + +//simple select into utext var +void test_var_1() +{ + test("test_var_1: simple select into utext var"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var:utext_var_ind FROM tb1 WHERE Count=1; + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var:utext_var_ind FROM tb1 WHERE Count=2; + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var:utext_var_ind FROM tb1 WHERE Count=3; + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var:utext_var_ind FROM tb1 WHERE Count=4; + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); +} + + +//simple select using utext var +void test_var_2() +{ + test("test_var_2: simple select using utext var"); + init_var(); + + count = 0; + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=1; + EXEC SQL SELECT Count INTO :count FROM tb1 WHERE Item=:utext_var; + printf ("count=%d for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + count = 0; + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=3; + EXEC SQL SELECT Count INTO :count FROM tb1 WHERE Item=:utext_var; + printf ("count=%d for '世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); +} + +//simple update using utext var +void test_var_3() +{ + test("test_var_3: simple update using utext var"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=1; + EXEC SQL UPDATE tb1 SET Item=:utext_var WHERE Count=2; + EXEC SQL UPDATE tb1 SET Item=:utext_var WHERE Count=3; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_table_value(); +} + +//simple delete using utext var +void test_var_4() +{ + test("test_var_4 : simple delete using utext var"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=1; + EXEC SQL DELETE FROM tb1 WHERE Item=:utext_var; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=3; + EXEC SQL DELETE FROM tb1 WHERE Item=:utext_var; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//simple insert using utext var +void test_var_5() +{ + test("test_var_5 : simple insert using utext"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=1; + EXEC SQL INSERT INTO tb1 values (:utext_var, 11); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_var(); + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=3; + EXEC SQL INSERT INTO tb1 values (:utext_var, 13); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//prepared select into utext var +void test_var_6() +{ + test("test_var_6 : prepared select into utext var"); + init_var(); + + EXEC SQL PREPARE stmt FROM "SELECT Item FROM tb1 WHERE Count=?"; + + EXEC SQL EXECUTE stmt INTO :utext_var USING 1; + print_utext(utext_var); + + EXEC SQL EXECUTE stmt INTO :utext_var USING 3; + print_utext(utext_var); + + EXEC SQL DEALLOCATE PREPARE stmt; +} + +//prepared select using utext var +void test_var_7() +{ + test("test_var_7 : prepared select using utext var"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "SELECT Count FROM tb1 WHERE Item=?"; + EXEC SQL EXECUTE stmt INTO :count USING :utext_var; + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; +} + +//prepared update using utext var +void test_var_8() +{ + test("test_var_8 : prepared update using utext var"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "UPDATE tb1 SET Item=? WHERE Count=?"; + EXEC SQL EXECUTE stmt USING :utext_var, 1; + EXEC SQL EXECUTE stmt USING :utext_var, 2; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//prepared delete using utext var +void test_var_9() +{ + test("test_var_9 : prepared delete using utext var"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "DELETE FROM tb1 WHERE Item=?"; + EXEC SQL EXECUTE stmt USING :utext_var; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//prepared insert using utext var +void test_var_10() +{ + test("test_var_10 : prepared insert using utext var"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "INSERT INTO tb1 values (?, 13)"; + EXEC SQL EXECUTE stmt USING :utext_var; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//Open cursor using utext var +void test_var_11() +{ + test("test_var_11 : Open cursor using utext var"); + init_var(); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "SELECT Count FROM tb1 WHERE Item=?"; + EXEC SQL DECLARE cursor_var_11 CURSOR FOR stmt; + EXEC SQL OPEN cursor_var_11 USING :utext_var; + EXEC SQL FETCH cursor_var_11 INTO :count; + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL CLOSE cursor_var_11; + EXEC SQL DEALLOCATE PREPARE stmt; + EXEC SQL SET AUTOCOMMIT TO ON; +} + +//Fecth cursor into utext var +void test_var_12() +{ + test("test_var_12 : Fecth cursor into utext var"); + init_var(); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL PREPARE stmt FROM "SELECT Item FROM tb1 WHERE Count=1"; + EXEC SQL DECLARE cursor_var_12 CURSOR FOR stmt; + EXEC SQL OPEN cursor_var_12; + EXEC SQL FETCH cursor_var_12 INTO :utext_var; + EXEC SQL CLOSE cursor_var_12; + + print_utext(utext_var); + + EXEC SQL DEALLOCATE PREPARE stmt; + EXEC SQL SET AUTOCOMMIT TO ON; +} + +//simple insert utext var with L string inited +void test_var_13() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext utext_local_var[]=L"足球篮球羽毛球"; +EXEC SQL END DECLARE SECTION; + test("test_var_13 : simple insert utext var with L string inited"); + init_var(); + + print_utext_str(utext_local_var); + + EXEC SQL INSERT INTO tb1 values (:utext_local_var, 16); + + EXEC SQL SELECT Item INTO :utext_var:utext_var_ind FROM tb1 WHERE Count=16; + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + init_table_value(); +} + +//Open cursor using utext var directly in WHERE Clause +void test_var_14() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext utext_local_var[20+1]; +EXEC SQL END DECLARE SECTION; + memset(utext_local_var,'a',sizeof(utext_local_var)); + + test("test_var_14 : Open cursor using utext var directly in WHERE Clause"); + init_var(); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL SELECT Item INTO :utext_local_var FROM tb1 WHERE Count=3; + EXEC SQL DECLARE cursor_var_14 CURSOR FOR SELECT Count FROM tb1 WHERE Item=:utext_local_var; + EXEC SQL OPEN cursor_var_14; + EXEC SQL FETCH cursor_var_14 INTO :count; + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + EXEC SQL CLOSE cursor_var_14; + + EXEC SQL SET AUTOCOMMIT TO ON; +} + +//Test utext_var working with NULL without indicator +void test_var_15() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext utext_local_var[20+1]; +EXEC SQL END DECLARE SECTION; + test("test_var_15 : Test utext_var working with NULL without indicator"); + + memset(utext_local_var,'a',sizeof(utext_local_var)); + EXEC SQL SELECT Item INTO :utext_local_var FROM tb1 WHERE Count=8; + print_utext(utext_local_var); + + memset(utext_local_var,0x00,sizeof(utext_local_var)); + EXEC SQL INSERT INTO tb1 values (:utext_local_var, 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_var, 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_var, 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//utext_var working with NULL with indicator +void test_var_16() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext utext_local_var[20+1]; + int utext_var_ind=-1; +EXEC SQL END DECLARE SECTION; + test("test_var_16 : Test utext_var working with NULL with indicator"); + + memset(utext_local_var,'a',sizeof(utext_local_var)); + EXEC SQL SELECT Item INTO :utext_local_var:utext_var_ind FROM tb1 WHERE Count=8; + print_utext(utext_local_var); + print_utext_ind(utext_var_ind); + + memset(utext_local_var,0x00,sizeof(utext_local_var)); + EXEC SQL INSERT INTO tb1 values (:utext_local_var:utext_var_ind, 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_var:utext_var_ind, 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_var:utext_var_ind, 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + + +//simple select into utext array +void test_array_1() +{ + test("test_array_1 : simple select into utext array "); + init_var(); + + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + print_array(utext_array,ARRAY_SIZE,VAR_SIZE); + init_var(); + + EXEC SQL SELECT Item INTO :utext_array[0] FROM tb1 WHERE Count=1; + print_array(utext_array,ARRAY_SIZE,VAR_SIZE); + init_var(); +} + +//simple select using utext array +void test_array_2() +{ + test("test_array_2 : simple select using array"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + count = 0; + EXEC SQL SELECT Count INTO :count FROM tb1 WHERE Item=:utext_array[0]; + printf ("count=%d for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + count = 0; + EXEC SQL SELECT Count INTO :count FROM tb1 WHERE Item=:utext_array[2]; + printf ("count=%d for '世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); +} + +//simple update using utext array +void test_array_3() +{ + test("test_array_3 : simple update using utext array"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + EXEC SQL UPDATE tb1 SET Item=:utext_array[2] WHERE Count=1; + + count = 0; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + printf ("find %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + count = 0; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + printf ("find %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//simple delete using utext array +void test_array_4() +{ + test("test_array_4 : simple delete using utext array"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + count = 100; + EXEC SQL DELETE FROM tb1 WHERE Item=:utext_array[0]; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + count = 100; + EXEC SQL DELETE FROM tb1 WHERE Item=:utext_array[2]; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//simple insert using utext array +void test_array_5() +{ + test("test_array_5 : simple insert using utext array"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + EXEC SQL INSERT INTO tb1 values (:utext_array[0], 11); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + EXEC SQL INSERT INTO tb1 values (:utext_array[2], 13); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//prepared select into utext array +void test_array_6() +{ + test("test_array_6 : prepared select into utext array"); + init_var(); + + EXEC SQL PREPARE stmt FROM "SELECT Item FROM tb1 WHERE Count<=?"; + + EXEC SQL EXECUTE stmt INTO :utext_array USING 4; + + print_array(utext_array,ARRAY_SIZE,VAR_SIZE); + + EXEC SQL DEALLOCATE PREPARE stmt; +} + +//prepared select using utext array +void test_array_7() +{ + test("test_array_7 : prepared select using utext array"); + init_var(); + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + count = 0; + EXEC SQL PREPARE stmt FROM "SELECT Count FROM tb1 WHERE Item=?"; + EXEC SQL EXECUTE stmt INTO :count USING :utext_array[0]; + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; +} + +//prepared update using utext array +void test_array_8() +{ + test("test_array_8 : prepared update using utext array"); + init_var(); + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + EXEC SQL PREPARE stmt FROM "UPDATE tb1 SET Item=? WHERE Count=?"; + EXEC SQL EXECUTE stmt USING :utext_array[0], 2; + EXEC SQL EXECUTE stmt USING :utext_array[0], 3; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//prepared delete using utext array +void test_array_9() +{ + test("test_array_9 : prepared delete using utext array"); + init_var(); + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + count = 0; + EXEC SQL PREPARE stmt FROM "DELETE FROM tb1 WHERE Item=?"; + EXEC SQL EXECUTE stmt USING :utext_array[0]; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//prepared insert using utext array +void test_array_10() +{ + test("test_array_10 : prepared insert using utext array"); + init_var(); + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + EXEC SQL PREPARE stmt FROM "INSERT INTO tb1 values (?, ?)"; + EXEC SQL EXECUTE stmt USING :utext_array[2], 13; + EXEC SQL EXECUTE stmt USING :utext_array[2], 15; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//Open cursor using utext array +void test_array_11() +{ + test("test_array_11 : Open cursor using utext array"); + init_var(); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + EXEC SQL PREPARE stmt FROM "SELECT Count FROM tb1 WHERE Item=?"; + EXEC SQL DECLARE cursor_array_11 CURSOR FOR stmt; + EXEC SQL OPEN cursor_array_11 USING :utext_array[2]; + EXEC SQL FETCH cursor_array_11 INTO :count; + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL CLOSE cursor_array_11; + EXEC SQL DEALLOCATE PREPARE stmt; + EXEC SQL SET AUTOCOMMIT TO ON; +} + +//Fecth cursor into utext array +void test_array_12() +{ + test("test_array_12 : Fecth cursor into utext array"); + init_var(); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL PREPARE stmt FROM "SELECT Item FROM tb1 WHERE Count<=3"; + EXEC SQL DECLARE cursor_array_12 CURSOR FOR stmt; + EXEC SQL OPEN cursor_array_12; + EXEC SQL FETCH cursor_array_12 INTO :utext_array[0]; + EXEC SQL FETCH cursor_array_12 INTO :utext_array[1]; + EXEC SQL FETCH cursor_array_12 INTO :utext_array[2]; + EXEC SQL CLOSE cursor_array_12; + + print_array(utext_array,ARRAY_SIZE,VAR_SIZE); + + EXEC SQL DEALLOCATE PREPARE stmt; + EXEC SQL SET AUTOCOMMIT TO ON; +} + +//Insert array with L string inited +void test_array_13() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext utext_array13[4][VAR_SIZE]={L"太𠮷𠜱平洋𠱓大西洋印度洋北冰洋",L"足球篮球羽毛球乒乓球橄榄球棒球冰球",L"世界杯每隔四年就会举行一次"}; +EXEC SQL END DECLARE SECTION; + + test("test_array_13 : Insert array with L string inited"); + init_var(); + + + EXEC SQL INSERT INTO tb1 values (:utext_array13[0], 20); + EXEC SQL INSERT INTO tb1 values (:utext_array13[1], 21); + EXEC SQL INSERT INTO tb1 values (:utext_array13[2], 22); + + init_var(); + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=22 AND Count>=20; + print_array(utext_array,3,VAR_SIZE); + init_table_value(); +} + +//Open cursor using utext array directly in WHERE Clause +void test_array_14() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext utext_local_array[4][20+1]; +EXEC SQL END DECLARE SECTION; + + test("test_array_14 : Open cursor using utext array directly in WHERE Clause"); + memset(utext_local_array,'a',sizeof(utext_local_array)); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL SELECT Item INTO :utext_local_array FROM tb1 WHERE Count<=3; + + EXEC SQL DECLARE cursor_array_14 CURSOR FOR SELECT Count FROM tb1 WHERE Item=:utext_local_array[2]; + EXEC SQL OPEN cursor_array_14; + EXEC SQL FETCH cursor_array_14 INTO :count; + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL CLOSE cursor_array_14; + + EXEC SQL SET AUTOCOMMIT TO ON; +} + + +//utext array working with NULL without using indicator +void test_array_15() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext utext_local_array[3][20]; +EXEC SQL END DECLARE SECTION; + test("test_array_15 : Test utext array working with NULL without using indicator"); + memset(utext_local_array,'a',sizeof(utext_local_array)); + + EXEC SQL SELECT Item INTO :utext_local_array FROM tb1 WHERE Count>=8 and Count<=10; + + print_array((void**)utext_local_array,3,20); + + memset(utext_local_array,0x00,sizeof(utext_local_array)); + EXEC SQL INSERT INTO tb1 values (:utext_local_array[0], 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_array[1], 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_array[2], 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//utext array working with NULL using indicator +void test_array_16() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext utext_local_array[3][20]; + int utext_array_ind[3]; +EXEC SQL END DECLARE SECTION; + test("test_array_16 : Test utext array working with NULL using indicator"); + memset(utext_local_array,'a',sizeof(utext_local_array)); + + EXEC SQL SELECT Item INTO :utext_local_array:utext_array_ind FROM tb1 WHERE Count>=8 and Count<=10; + + print_array((void**)utext_local_array,3,20); + print_utext_ind(utext_array_ind[0]); + print_utext_ind(utext_array_ind[1]); + print_utext_ind(utext_array_ind[2]); + + memset(utext_local_array,0x00,sizeof(utext_local_array)); + utext_array_ind[0]=-1; + utext_array_ind[1]=-1; + utext_array_ind[2]=-1; + EXEC SQL INSERT INTO tb1 values (:utext_local_array[0]:utext_array_ind[0], 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_array[1]:utext_array_ind[1], 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_array[2]:utext_array_ind[2], 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + + +//simple select into utext pointer +void test_pvar_1() +{ + test("test_pvar_1 : simple select into utext pointer"); + EXEC SQL SELECT Item INTO :p_utext_var:utext_var_ind FROM tb1 WHERE Count=1; + print_utext(p_utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var:utext_var_ind FROM tb1 WHERE Count=2; + print_utext(p_utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var:utext_var_ind FROM tb1 WHERE Count=3; + print_utext(p_utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var:utext_var_ind FROM tb1 WHERE Count=4; + print_utext(p_utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + init_table_value(); +} + + +//simple select using utext pointer +void test_pvar_2() +{ + test("test_pvar_2 : simple select using utext pointer"); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=1; + EXEC SQL SELECT Count INTO :count FROM tb1 WHERE Item=:p_utext_var; + printf ("count=%d for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_var(); + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=3; + EXEC SQL SELECT Count INTO :count FROM tb1 WHERE Item=:p_utext_var; + printf ("count=%d for '世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); +} + + +//simple update using utext pointer +void test_pvar_3() +{ + test("test_pvar_3 : simple update using utext pointer"); + init_var(); + + count = 0; + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=1; + EXEC SQL UPDATE tb1 SET Item=:p_utext_var WHERE Count=2; + EXEC SQL UPDATE tb1 SET Item=:p_utext_var WHERE Count=3; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_table_value(); +} + +//simple delete using utext pointer +void test_pvar_4() +{ + test("test_pvar_4 : simple delete using utext pointer"); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=1; + EXEC SQL DELETE FROM tb1 WHERE Item=:p_utext_var; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_var(); + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=3; + EXEC SQL DELETE FROM tb1 WHERE Item=:p_utext_var; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//simple insert using utext pointer +void test_pvar_5() +{ + test("test_pvar_5 : simple insert using utext pointer"); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=3; + EXEC SQL INSERT INTO tb1 values (:p_utext_var, 13); + + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//prepared select into utext pointer +void test_pvar_6() +{ + test("test_pvar_6 : prepared select into utext pointer"); + init_var(); + + EXEC SQL PREPARE stmt FROM "SELECT Item FROM tb1 WHERE Count=?"; + + EXEC SQL EXECUTE stmt INTO :p_utext_var USING 1; + print_utext(p_utext_var); + + init_var(); + EXEC SQL EXECUTE stmt INTO :p_utext_var USING 3; + print_utext(p_utext_var); + init_table_value(); + + EXEC SQL DEALLOCATE PREPARE stmt; + +} + +//prepared select using utext pointer +void test_pvar_7() +{ + test("test_pvar_7 : prepared select using utext pointer"); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "SELECT Count FROM tb1 WHERE Item=?"; + EXEC SQL EXECUTE stmt INTO :count USING :p_utext_var; + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; +} + +//prepared update using utext pointer +void test_pvar_8() +{ + test("test_pvar_8 : prepared update using utext pointer"); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "UPDATE tb1 SET Item=? WHERE Count=?"; + EXEC SQL EXECUTE stmt USING :p_utext_var, 1; + EXEC SQL EXECUTE stmt USING :p_utext_var, 2; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//prepared delete using utext pointer +void test_pvar_9() +{ + test("test_pvar_9 : prepared delete using utext pointer"); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "DELETE FROM tb1 WHERE Item=?"; + EXEC SQL EXECUTE stmt USING :p_utext_var; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//prepared insert using utext pointer +void test_pvar_10() +{ + test("test_pvar_10 : prepared insert using utext pointer"); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "INSERT INTO tb1 values (?, 13)"; + EXEC SQL EXECUTE stmt USING :p_utext_var; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//Open cursor using utext pointer +void test_pvar_11() +{ + test("test_pvar_11 : Open cursor using utext pointer"); + init_var(); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "SELECT Count FROM tb1 WHERE Item=?"; + EXEC SQL DECLARE cursor_pvar_11 CURSOR FOR stmt; + EXEC SQL OPEN cursor_pvar_11 USING :p_utext_var; + EXEC SQL FETCH cursor_pvar_11 INTO :count; + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL CLOSE cursor_pvar_11; + EXEC SQL DEALLOCATE PREPARE stmt; + EXEC SQL SET AUTOCOMMIT TO ON; +} + +//Fecth cursor into utext pointer +void test_pvar_12() +{ + test("test_pvar_12 : Fecth cursor into utext pointer"); + init_var(); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL PREPARE stmt FROM "SELECT Item FROM tb1 WHERE Count=1"; + EXEC SQL DECLARE cursor_pvar_12 CURSOR FOR stmt; + EXEC SQL OPEN cursor_pvar_12; + EXEC SQL FETCH cursor_pvar_12 INTO :p_utext_var; + EXEC SQL CLOSE cursor_pvar_12; + + print_utext(p_utext_var); + + EXEC SQL DEALLOCATE PREPARE stmt; + EXEC SQL SET AUTOCOMMIT TO ON; +} + +//simple insert utext pointer with L string inited +void test_pvar_13() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext *utext_local_pvar=L"太𠮷𠜱平洋𠱓大西洋印度洋北冰洋"; +EXEC SQL END DECLARE SECTION; + test("test_pvar_13 : simple insert utext pointer with L string inited"); + init_var(); + + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar, 16); + + EXEC SQL SELECT Item INTO :utext_var:utext_var_ind FROM tb1 WHERE Count=16; + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + init_table_value(); +} + +//Open cursor using utext var directly in WHERE Clause +void test_pvar_14() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext *utext_local_pvar; +EXEC SQL END DECLARE SECTION; + utext_local_pvar = (utext*)malloc(P_VAR_SIZE*sizeof(utext)); + memset(utext_local_pvar,'a',P_VAR_SIZE*sizeof(utext)); + + test("test_pvar_14 : Open cursor using utext var directly in WHERE Clause"); + init_var(); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL SELECT Item INTO :utext_local_pvar FROM tb1 WHERE Count=3; + + EXEC SQL DECLARE cursor_pvar_14 CURSOR FOR SELECT Count FROM tb1 WHERE Item=:utext_local_pvar; + EXEC SQL OPEN cursor_pvar_14; + EXEC SQL FETCH cursor_pvar_14 INTO :count; + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL CLOSE cursor_pvar_14; + + EXEC SQL SET AUTOCOMMIT TO ON; +} + + +//utext pointer working with NULL without using indicator +void test_pvar_15() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext *utext_local_pvar; +EXEC SQL END DECLARE SECTION; + utext_local_pvar = (utext*)malloc(P_VAR_SIZE*sizeof(utext)); + memset(utext_local_pvar,'a',P_VAR_SIZE*sizeof(utext)); + + test("test_pvar_15 : Test utext pointer working with NULL without using indicator"); + + EXEC SQL SELECT Item INTO :utext_local_pvar FROM tb1 WHERE Count=8; + + print_utext(utext_local_pvar); + + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar, 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar, 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar, 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//utext pointer working with NULL using indicator +void test_pvar_16() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext *utext_local_pvar; + int utext_pvar_ind = -1; +EXEC SQL END DECLARE SECTION; + utext_local_pvar = (utext*)malloc(P_VAR_SIZE*sizeof(utext)); + memset(utext_local_pvar,'a',P_VAR_SIZE*sizeof(utext)); + + test("test_pvar_16 : Test utext pointer working with NULL using indicator"); + + EXEC SQL SELECT Item INTO :utext_local_pvar:utext_pvar_ind FROM tb1 WHERE Count=8; + + print_utext(utext_local_pvar); + print_utext_ind(utext_pvar_ind); + + memset(utext_local_pvar,0,P_VAR_SIZE*sizeof(utext)); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar:utext_pvar_ind, 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar:utext_pvar_ind, 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar:utext_pvar_ind, 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//utext uninitialized pointer getting and setting data +void test_pvar_17() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext *utext_local_pvar=0; + char local_str[50]; +EXEC SQL END DECLARE SECTION; + + test("test_pvar_17 : Test utext uninitialized pointer getting and setting data"); + + EXEC SQL SELECT Item INTO :utext_local_pvar FROM tb1 WHERE Count=1; + + print_utext_str(utext_local_pvar); + + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar, 18); + EXEC SQL SELECT Item INTO :local_str FROM tb1 WHERE Count=18; + printf ("Find Item = %s where Count=18\n", local_str); + + init_table_value(); +} + +//utext uninitialized pointer working with NULL without using indicator +void test_pvar_18() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext *utext_local_pvar=0; +EXEC SQL END DECLARE SECTION; + + test("test_pvar_18 : Test utext uninitialized pointer working with NULL without using indicator"); + + EXEC SQL SELECT Item INTO :utext_local_pvar FROM tb1 WHERE Count=8; + + print_utext_size(utext_local_pvar,1); + + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar, 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar, 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar, 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//utext uninitialized pointer working with NULL using indicator +void test_pvar_19() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext *utext_local_pvar=0; + int utext_pvar_ind = -1; +EXEC SQL END DECLARE SECTION; + + test("test_pvar_19 : Test utext uninitialized pointer working with NULL using indicator"); + + EXEC SQL SELECT Item INTO :utext_local_pvar:utext_pvar_ind FROM tb1 WHERE Count=8; + + print_utext_size(utext_local_pvar,1); + print_utext_ind(utext_pvar_ind); + + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar:utext_pvar_ind, 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar:utext_pvar_ind, 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar:utext_pvar_ind, 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//Test select into host varaibles from descriptor +void test_desc_1() +{ + EXEC SQL BEGIN DECLARE SECTION; + utext utext_local_var[20]; + utext *utext_local_pvar=0; + utext **utext_local_ppvar=0; + char desc1[8] = "outdesc"; + EXEC SQL END DECLARE SECTION; + +// ECPGdebug(1, stderr); + + EXEC SQL ALLOCATE DESCRIPTOR indesc; + EXEC SQL ALLOCATE DESCRIPTOR :desc1; + + EXEC SQL SELECT Item,Count INTO SQL DESCRIPTOR :desc1 FROM tb1 WHERE Count=1; + + EXEC SQL GET DESCRIPTOR :desc1 VALUE 1 :utext_local_var = DATA; + print_utext(utext_local_var); + + EXEC SQL GET DESCRIPTOR :desc1 VALUE 1 :utext_local_pvar = DATA; + print_utext_str(utext_local_pvar); + + + EXEC SQL SELECT Item,Count INTO SQL DESCRIPTOR :desc1 FROM tb1 WHERE Count<=3; + EXEC SQL GET DESCRIPTOR :desc1 VALUE 1 :utext_local_ppvar = DATA; + print_utext_str(utext_local_ppvar[0]); + print_utext_str(utext_local_ppvar[1]); + print_utext_str(utext_local_ppvar[2]); + + + EXEC SQL SELECT Item,Count INTO SQL DESCRIPTOR :desc1 FROM tb1 WHERE Count<=10 and Count>=8; + EXEC SQL GET DESCRIPTOR :desc1 VALUE 1 :utext_local_ppvar = DATA; + print_utext_str(utext_local_ppvar[0]); + print_utext_str(utext_local_ppvar[1]); + print_utext_str(utext_local_ppvar[2]); + + + EXEC SQL DEALLOCATE DESCRIPTOR indesc; + EXEC SQL DEALLOCATE DESCRIPTOR :desc1; +} + + +//Test uninitialized pointer to pointer utext_var without initialize +void test_pp_var_1() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext **utext_local_ppvar=0; + int *utext_local_ppvar_ind=0; + char utext_local_char[80]; +EXEC SQL END DECLARE SECTION; + test("test_pp_var_1 : Test pointer to pointer utext_var without initialize"); + + //memset(utext_local_var,'a',sizeof(utext_local_var)); + EXEC SQL SELECT Item INTO :utext_local_ppvar:utext_local_ppvar_ind FROM tb1 WHERE Count<=3; + print_utext_str(utext_local_ppvar[0]); + print_utext_ind(utext_local_ppvar_ind[0]); + + print_utext_str(utext_local_ppvar[1]); + print_utext_ind(utext_local_ppvar_ind[1]); + + print_utext_str(utext_local_ppvar[2]); + print_utext_ind(utext_local_ppvar_ind[2]); + + EXEC SQL INSERT INTO tb1 values (:utext_local_ppvar[1], 28); + EXEC SQL SELECT Item INTO :utext_local_char FROM tb1 WHERE Count=28; + printf("%s\n",utext_local_char); + + init_table_value(); +} + + +//Test uninitialized pointer to pointer utext_var working with NULL without indicator +void test_pp_var_2() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext **utext_local_ppvar=0; +EXEC SQL END DECLARE SECTION; + test("test_pp_var_2 : Test uninitialized pointer to pointer utext_var working with NULL without indicator"); + + //memset(utext_local_var,'a',sizeof(utext_local_var)); + EXEC SQL SELECT Item INTO :utext_local_ppvar FROM tb1 WHERE Count>=8 and Count<=10; + print_utext_str(utext_local_ppvar[0]); + print_utext_str(utext_local_ppvar[1]); + print_utext_str(utext_local_ppvar[2]); + + EXEC SQL INSERT INTO tb1 values (:utext_local_ppvar[0], 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_ppvar[1], 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_ppvar[2], 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//Test uninitialized pointer to pointer utext_var working with NULL with indicator +void test_pp_var_3() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext **utext_local_ppvar=0; + int *utext_local_ppvar_ind=0; +EXEC SQL END DECLARE SECTION; + test("test_pp_var_2 : Test uninitialized pointer to pointer utext_var working with NULL without indicator"); + + //memset(utext_local_var,'a',sizeof(utext_local_var)); + EXEC SQL SELECT Item INTO :utext_local_ppvar:utext_local_ppvar_ind FROM tb1 WHERE Count>=8 and Count<=10; + print_utext_str(utext_local_ppvar[0]); + print_utext_ind(utext_local_ppvar_ind[0]); + + print_utext_str(utext_local_ppvar[1]); + print_utext_ind(utext_local_ppvar_ind[1]); + + print_utext_str(utext_local_ppvar[2]); + print_utext_ind(utext_local_ppvar_ind[2]); + + EXEC SQL INSERT INTO tb1 values (:utext_local_ppvar[0], 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_ppvar[1], 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_ppvar[2], 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +void test_all() +{ + test_var_1(); + test_var_2(); + test_var_3(); + test_var_4(); + test_var_5(); + test_var_6(); + test_var_7(); + test_var_8(); + test_var_9(); + test_var_10(); + test_var_11(); + test_var_12(); + test_var_13(); + test_var_14(); + test_var_15(); + test_var_16(); + test_array_1(); + test_array_2(); + test_array_3(); + test_array_4(); + test_array_5(); + test_array_6(); + test_array_7(); + test_array_8(); + test_array_9(); + test_array_10(); + test_array_11(); + test_array_12(); + test_array_13(); + test_array_14(); + test_array_15(); + test_array_16(); + test_pvar_1(); + test_pvar_2(); + test_pvar_3(); + test_pvar_4(); + test_pvar_5(); + test_pvar_6(); + test_pvar_7(); + test_pvar_8(); + test_pvar_9(); + test_pvar_10(); + test_pvar_11(); + test_pvar_12(); + test_pvar_13(); + test_pvar_14(); + test_pvar_15(); + test_pvar_16(); + test_pvar_17(); + test_pvar_18(); + test_pvar_19(); + test_pp_var_1(); + test_pp_var_2(); + test_pp_var_3(); +} + +int main(int argc, char *argv[]) +{ +// ECPGdebug(1, stderr); + if(test_init() !=0) + return -1; + + test_all(); + test_finish(); + + return 0; +} diff --git a/src/interfaces/ecpg/test/sql/uvarchar.pgc b/src/interfaces/ecpg/test/sql/uvarchar.pgc new file mode 100755 index 0000000..4dd894a --- /dev/null +++ b/src/interfaces/ecpg/test/sql/uvarchar.pgc @@ -0,0 +1,877 @@ +#include +#include +#include + +EXEC SQL INCLUDE ../regression; + +#define test(msg) printf("\n%s\n",msg) +#define VAR_SIZE 20 +#define ARRAY_SIZE 4 + +/* Following is UTF8 and UTF16 characters mapping table */ +/*太𠮷𠜱平洋𠱓大西洋印度洋北冰洋 +0x592A,0x5E73,0x6D0B,0x5927,0x897F,0x6D0B,0x5370,0x5EA6, +0x6D0B,0x5317,0x51B0,0x6D0B,0x548C,0x5357,0x51B0,0x6D0B, +0x0000,0x0000,0x0000,0x0000*/ + +/*足球篮球羽毛球乒乓球橄榄球棒球冰球 +0x8DB3,0x7403,0x7BEE,0x7403,0x7FBD,0x6BDB,0x7403,0x4E52, +0x4E53,0x7403,0x6A44,0x6984,0x7403,0x68D2,0x7403,0x51B0, +0x7403,0x0000,0x0000,0x0000 +*/ + +/*世界杯每隔四年就会举行一次每次𠲖个球队 +0x4E16,0x754C,0x676F,0x6BCF,0x9694,0x56DB,0x5E74,0x5C31, +0x4F1A,0x4E3E,0x884C,0x4E00,0x6B21,0x6BCF,0x6B21,0x0033, +0x0032,0x4E2A,0x7403,0x961F +*/ + +/* 亚洲欧洲非洲大洋洲北美洲南美洲南极洲没有北极洲 +0x4E9A,0x6D32,0x6B27,0x6D32,0x975E,0x6D32,0x5927,0x6D0B, +0x6D32,0x5317,0x7F8E,0x6D32,0x5357,0x7F8E,0x6D32,0x5357, +0x6781,0x6D32,0x6CA1,0x6709,0x5317,0x6781,0x6D32 +*/ + +EXEC SQL BEGIN DECLARE SECTION; + UVARCHAR uvarchar_var[VAR_SIZE]; + UVARCHAR uvarchar_array[ARRAY_SIZE][VAR_SIZE]; + + int uvarchar_var_ind; + + int count; + int count_array[4]={1,2,3,4}; + int total_tuples = 0; +EXEC SQL END DECLARE SECTION; + +void print_uvarchar(void); +void print_uvarchar_ind(int uvarchar_var_ind); +void print_local_uvarchar(utext *utext_var, int var_len); +void print_array(void); +int test_init(void); +void test_finish(void); +void init_table_value(void); +void init_var(void); + +void test_var_1(void); +void test_var_2(void); +void test_var_3(void); +void test_var_4(void); +void test_var_5(void); +void test_var_6(void); +void test_var_7(void); +void test_var_8(void); +void test_var_9(void); +void test_var_10(void); +void test_var_11(void); +void test_var_12(void); +void test_var_13(void); +void test_var_14(void); +void test_var_15(void); +void test_var_16(void); +void test_array_1(void); +void test_array_2(void); +void test_array_3(void); +void test_array_4(void); +void test_array_5(void); +void test_array_6(void); +void test_array_7(void); +void test_array_8(void); +void test_array_9(void); +void test_array_10(void); +void test_array_11(void); +void test_array_12(void); +void test_array_13(void); +void test_array_14(void); +void test_array_15(void); +void test_array_16(void); + +void test_all(void); + +void print_uvarchar() +{ + int i; + + printf ("---->uvarchar variable,len=%d:\n",uvarchar_var.len); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n"); +} + +void print_uvarchar_ind(int uvarchar_var_ind) +{ + printf("uvarchar_var_ind = %d\n",uvarchar_var_ind); +} + +void print_local_uvarchar(utext *utext_var, int var_len) +{ + int i; + + printf ("---->uvarchar variable,len=%d:\n",var_len); + for(i=0; i<20; i++) + { + printf ("0x%04X ", utext_var[i]); + if(i>6 && (i+1)%8==0) + printf("\n"); + } + printf("\n"); +} + +void print_array() +{ + int i,j; + + for(i=0; iuvarchar array[%d]:(len=%d)\n", i,uvarchar_array[i].len); + + for(j=0; j6 && (j+1)%8==0) + printf("\n"); + } + printf("\n"); + } + + printf("\n"); +} + +int test_init() +{ + EXEC SQL CONNECT TO REGRESSDB1; + + EXEC SQL SET AUTOCOMMIT TO ON; + EXEC SQL WHENEVER SQLWARNING SQLPRINT; + EXEC SQL WHENEVER SQLERROR SQLPRINT; + + EXEC SQL SET client_encoding='UTF8'; + + //initialization of test table + EXEC SQL CREATE TABLE tb1 (Item varchar, Count integer); + + init_table_value(); + + return 0; +} + +void test_finish() +{ + EXEC SQL DROP TABLE tb1; + EXEC SQL DISCONNECT ALL; +} + + +void init_table_value() +{ + EXEC SQL TRUNCATE tb1; + + EXEC SQL INSERT INTO tb1 VALUES ('太𠮷𠜱平洋𠱓大西洋印度洋北冰洋', 1); + EXEC SQL INSERT INTO tb1 VALUES ('足球篮球羽毛球乒乓球橄榄球棒球冰球', 2); + EXEC SQL INSERT INTO tb1 VALUES ('世界杯每隔四年就会举行一次每次𠲖个球队', 3); + EXEC SQL INSERT INTO tb1 VALUES ('亚洲欧洲非洲大洋洲北美洲南美洲南极洲没有北极洲', 4); + + EXEC SQL INSERT INTO tb1 (Count) VALUES(8); + EXEC SQL INSERT INTO tb1 (Count) VALUES(9); + EXEC SQL INSERT INTO tb1 (Count) VALUES(10); +} + +void init_var() +{ + int i; + memset((void*)&uvarchar_var,'a',sizeof(uvarchar_var)); + uvarchar_var.len = 0; + + memset((char*)uvarchar_array,'a',sizeof(uvarchar_array)*ARRAY_SIZE); + + for(i=0;i=20; + print_array(); + init_table_value(); + +} + +//uvarchar array working with NULL without using indicator +void test_array_15() +{ +EXEC SQL BEGIN DECLARE SECTION; + uvarchar uvarchar_local_array[3][20]; +EXEC SQL END DECLARE SECTION; + test("test_array_15 : Test uvarchar array working with NULL without using indicator"); + memset(uvarchar_local_array,'a',sizeof(uvarchar_local_array)); + + EXEC SQL SELECT Item INTO :uvarchar_local_array FROM tb1 WHERE Count>=8 and Count<=10; + + print_local_uvarchar(uvarchar_local_array[0].arr, 20); + print_local_uvarchar(uvarchar_local_array[1].arr, 20); + print_local_uvarchar(uvarchar_local_array[2].arr, 20); + + + memset(uvarchar_local_array,0x00,sizeof(uvarchar_local_array)); + EXEC SQL INSERT INTO tb1 values (:uvarchar_local_array[0], 18); + EXEC SQL INSERT INTO tb1 values (:uvarchar_local_array[1], 19); + EXEC SQL INSERT INTO tb1 values (:uvarchar_local_array[2], 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//uvarchar array working with NULL using indicator +void test_array_16() +{ +EXEC SQL BEGIN DECLARE SECTION; + uvarchar uvarchar_local_array[3][20]; + int uvarchar_array_ind[3]; +EXEC SQL END DECLARE SECTION; + test("test_array_16 : Test uvarchar array working with NULL using indicator"); + memset(uvarchar_local_array,'a',sizeof(uvarchar_local_array)); + + EXEC SQL SELECT Item INTO :uvarchar_local_array:uvarchar_array_ind FROM tb1 WHERE Count>=8 and Count<=10; + + + print_local_uvarchar(uvarchar_local_array[0].arr, 20); + print_local_uvarchar(uvarchar_local_array[1].arr, 20); + print_local_uvarchar(uvarchar_local_array[2].arr, 20); + + print_uvarchar_ind(uvarchar_array_ind[0]); + print_uvarchar_ind(uvarchar_array_ind[1]); + print_uvarchar_ind(uvarchar_array_ind[2]); + + memset(uvarchar_local_array,0x00,sizeof(uvarchar_local_array)); + uvarchar_array_ind[0]=-1; + EXEC SQL INSERT INTO tb1 values (:uvarchar_local_array[0]:uvarchar_array_ind[0], 18); + EXEC SQL INSERT INTO tb1 values (:uvarchar_local_array[1]:uvarchar_array_ind[0], 19); + EXEC SQL INSERT INTO tb1 values (:uvarchar_local_array[2]:uvarchar_array_ind[0], 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +void test_all() +{ + test_var_1(); + test_var_2(); + test_var_3(); + test_var_4(); + test_var_5(); + test_var_6(); + test_var_7(); + test_var_8(); + test_var_9(); + test_var_10(); + test_var_11(); + test_var_12(); + test_var_13(); + test_var_14(); + test_var_15(); + test_var_16(); + test_array_1(); + test_array_2(); + test_array_3(); + test_array_4(); + test_array_5(); + test_array_6(); + test_array_7(); + test_array_8(); + test_array_9(); + test_array_10(); + test_array_11(); + test_array_12(); + test_array_13(); + test_array_15(); + test_array_16(); +} + +int main() +{ +// ECPGdebug(1, stderr); + if(test_init() !=0) + return -1; + + test_all(); + test_finish(); + + return 0; +} diff --git a/src/interfaces/ecpg/test/unicode/expected/utext.c b/src/interfaces/ecpg/test/unicode/expected/utext.c new file mode 100755 index 0000000..f371a20 --- /dev/null +++ b/src/interfaces/ecpg/test/unicode/expected/utext.c @@ -0,0 +1,3115 @@ +/* Processed by ecpg (regression mode) */ +/* These include files are added by the preprocessor */ +#define ECPG_ENABLE_UTEXT 1 +#include +#include +#include +/* End of automatic include section */ +#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y)) + +#line 1 "utext.pgc" +#include +#include +#include +#include + +#line 1 "./../regression.h" + + + + + + +#line 5 "utext.pgc" + + +#define test(msg) printf("\n%s\n",msg) +#define VAR_SIZE 20 +#define ARRAY_SIZE 4 +#define P_VAR_SIZE 22 + + +/* Following is UTF8 and UTF16 characters mapping table */ +/*太𠮷𠜱平洋𠱓大西洋印度洋北冰洋 +0x592A 0xD842 0xDFB7 0xD841 0xDF31 0x5E73 0x6D0B 0xD843 +0xDC53 0x5927 0x897F 0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 +0x51B0 0x6D0B 0x0000,0x0000*/ + +/*足球篮球羽毛球乒乓球橄榄球棒球冰球 +0x8DB3,0x7403,0x7BEE,0x7403,0x7FBD,0x6BDB,0x7403,0x4E52, +0x4E53,0x7403,0x6A44,0x6984,0x7403,0x68D2,0x7403,0x51B0, +0x7403,0x0000,0x0000,0x0000 +*/ + +/*世界杯每隔四年就会举行一次每次𠲖个球队 +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0xD843 +0xDC96 0x4E2A 0x7403 0x961F +*/ + +/* 亚洲欧洲非洲大洋洲北美洲南美洲南极洲没有北极洲 +0x4E9A,0x6D32,0x6B27,0x6D32,0x975E,0x6D32,0x5927,0x6D0B, +0x6D32,0x5317,0x7F8E,0x6D32,0x5357,0x7F8E,0x6D32,0x5357, +0x6781,0x6D32,0x6CA1,0x6709,0x5317,0x6781,0x6D32 +*/ +/* 太𠮷 +0x592A 0xD842 0xDFB7 +*/ +void init_var(void); +void test_var_1(void); +void test_var_2(void); +void test_var_3(void); +void test_var_4(void); +void test_var_5(void); +void test_var_6(void); +void test_var_7(void); +void test_var_8(void); +void test_var_9(void); +void test_var_10(void); +void test_var_11(void); +void test_var_12(void); +void test_var_13(void); +void test_array_1(void); +void test_array_2(void); +void test_array_3(void); +void test_array_4(void); +void test_array_5(void); +void test_array_6(void); +void test_array_7(void); +void test_array_8(void); +void test_array_9(void); +void test_array_10(void); +void test_array_11(void); +void test_array_12(void); +void test_array_13(void); +void test_pvar_1(void); +void test_pvar_2(void); +void test_pvar_3(void); +void test_pvar_4(void); +void test_pvar_5(void); +void test_pvar_6(void); +void test_pvar_7(void); +void test_pvar_8(void); +void test_pvar_9(void); +void test_pvar_10(void); +void test_pvar_11(void); +void test_pvar_12(void); +void test_pvar_13(void); +void test_buckinsert_1(void); + +void test_all(void); + +void print_utext(utext *utext_var); +void print_utext_ind(int utext_var_ind); +void print_utext_size(utext *utext_var,int size); +void print_array(void); +void print_array_with_index(int index); +int test_init(void); +void test_finish(void); +void init_table_value(void); + +/* exec sql begin declare section */ + + + + + + + + + + + + + + + + + + +#line 93 "utext.pgc" + int utext_var_size = 20 ; + +#line 94 "utext.pgc" + int utext_array_size = 4 ; + +#line 95 "utext.pgc" + int count = 0 ; + +#line 96 "utext.pgc" + int total_tuples = 0 ; + +#line 97 "utext.pgc" + int i ; + +#line 98 "utext.pgc" + char char_var [ 10 ] = { 0xF0 , 0x90 , 0x90 , 0xB7 } ; + +#line 100 "utext.pgc" + utext utext_var [ VAR_SIZE ] ; + +#line 101 "utext.pgc" + utext utext_array [ ARRAY_SIZE ] [ VAR_SIZE ] ; + +#line 102 "utext.pgc" + utext utext_input_var [ 20 ] = { 0x592a , 0xd842 , 0xdfb7 , 0x0000 } ; + +#line 103 "utext.pgc" + utext utext_input_var2 [] = L"太𠮷" ; + +#line 104 "utext.pgc" + utext * p_utext_var = NULL ; + +#line 107 "utext.pgc" + int utext_var_ind ; + +#line 108 "utext.pgc" + int count_array [ 4 ] = { 1 , 2 , 3 , 4 } ; +/* exec sql end declare section */ +#line 110 "utext.pgc" + + +void print_utext(utext *utext_var) +{ + int i; + printf("======print utext_var content======\n"); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n======End utext_var content======\n"); +} + +void print_utext_size(utext *utext_var,int size) +{ + int i; + printf("======print utext_var content======\n"); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n======End utext_var content======\n"); +} + +void print_utext_ind(int utext_var_ind) +{ + printf("utext_var_ind = %d\n",utext_var_ind); +} + +void print_array() +{ + int i,j; + + for(i=0; iarray[%d]:\n", i); + + for(j=0; j6 && (j+1)%8==0) + printf("\n"); + } + printf("\n"); + } + + printf("\n"); +} + +int test_init() +{ + p_utext_var = (utext*)malloc(P_VAR_SIZE*sizeof(utext)); + if(!p_utext_var) + { + printf("Error: failed allco memory for p_utext_var. \n"); + return -1; + } + + + { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); } +#line 173 "utext.pgc" + + + { ECPGsetcommit(__LINE__, "on", NULL);} +#line 175 "utext.pgc" + + /* exec sql whenever sql_warning sqlprint ; */ +#line 176 "utext.pgc" + + /* exec sql whenever sqlerror sqlprint ; */ +#line 177 "utext.pgc" + + + + //initialization of test table + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table if not exists tb1 ( Item varchar , count integer )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 181 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 181 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 181 "utext.pgc" + + + init_table_value(); + + return 0; +} + +void test_finish() +{ + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table tb1", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 190 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 190 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 190 "utext.pgc" + + { ECPGdisconnect(__LINE__, "ALL"); +#line 191 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 191 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 191 "utext.pgc" + +} + +void init_table_value() +{ + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "truncate tb1", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 196 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 196 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 196 "utext.pgc" + + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into tb1 values ( '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' , 1 )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 198 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 198 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 198 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into tb1 values ( '足球篮球羽毛球乒乓球橄榄球棒球冰球' , 2 )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 199 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 199 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 199 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into tb1 values ( '世界杯每隔四年就会举行一次每次𠲖个球队' , 3 )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 200 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 200 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 200 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into tb1 values ( '亚洲欧洲非洲大洋洲北美洲南美洲南极洲没有北极洲' , 4 )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 201 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 201 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 201 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 5 )", + ECPGt_char,(char_var),(long)10,(long)1,(10)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 202 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 202 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 202 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into tb1 values ( '𠮷' , 6 )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 203 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 203 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 203 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into tb1 values ( '太𠮷' , 7 )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 204 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 204 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 204 "utext.pgc" + +} + +void init_var() +{ + count = 0; + memset(utext_var,'a',sizeof(utext_var)); + memset(utext_array,'a',sizeof(utext_array)); + memset(p_utext_var,'a',P_VAR_SIZE*sizeof(utext)); +} + +//simple select into utext var +void test_var_1() +{ + test("test_var_1: simple select into utext var"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT, ECPGt_EOLT); +#line 221 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 221 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 221 "utext.pgc" + + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 2", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT, ECPGt_EOLT); +#line 226 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 226 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 226 "utext.pgc" + + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT, ECPGt_EOLT); +#line 231 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 231 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 231 "utext.pgc" + + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 4", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT, ECPGt_EOLT); +#line 236 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 236 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 236 "utext.pgc" + + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); +} + + +//simple select using utext var +void test_var_2() +{ + test("test_var_2: simple select using utext var"); + init_var(); + + count = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 250 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 250 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 250 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count from tb1 where Item = $1 ", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 251 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 251 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 251 "utext.pgc" + + printf ("count=%d for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + count = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 255 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 255 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 255 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count from tb1 where Item = $1 ", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 256 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 256 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 256 "utext.pgc" + + printf ("count=%d for '世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); +} + +//simple update using utext var +void test_var_3() +{ + test("test_var_3: simple update using utext var"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 266 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 266 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 266 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update tb1 set Item = $1 where count = 2", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 267 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 267 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 267 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update tb1 set Item = $1 where count = 3", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 268 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 268 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 268 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 269 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 269 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 269 "utext.pgc" + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_table_value(); +} + +//simple delete using utext var +void test_var_4() +{ + test("test_var_4 : simple delete using utext var"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 281 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 281 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 281 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from tb1 where Item = $1 ", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 282 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 282 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 282 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 283 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 283 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 283 "utext.pgc" + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 286 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 286 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 286 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from tb1 where Item = $1 ", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 287 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 287 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 287 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 288 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 288 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 288 "utext.pgc" + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//simple insert using utext var +void test_var_5() +{ + test("test_var_5 : simple insert using utext"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 300 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 300 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 300 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 11 )", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 301 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 301 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 301 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 302 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 302 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 302 "utext.pgc" + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_var(); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 306 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 306 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 306 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 13 )", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 307 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 307 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 307 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 308 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 308 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 308 "utext.pgc" + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//prepared select into utext var +void test_var_6() +{ + test("test_var_6 : prepared select into utext var"); + init_var(); + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Item FROM tb1 WHERE Count=?"); +#line 320 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 320 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 320 "utext.pgc" + + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt", + ECPGt_const,"1",(long)1,(long)1,strlen("1"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 322 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 322 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 322 "utext.pgc" + + print_utext(utext_var); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt", + ECPGt_const,"3",(long)1,(long)1,strlen("3"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 325 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 325 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 325 "utext.pgc" + + print_utext(utext_var); + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 328 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 328 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 328 "utext.pgc" + +} + +//prepared select using utext var +void test_var_7() +{ + test("test_var_7 : prepared select using utext var"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 337 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 337 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 337 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Count FROM tb1 WHERE Item=?"); +#line 339 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 339 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 339 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 340 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 340 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 340 "utext.pgc" + + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 343 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 343 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 343 "utext.pgc" + +} + +//prepared update using utext var +void test_var_8() +{ + test("test_var_8 : prepared update using utext var"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 352 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 352 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 352 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "UPDATE tb1 SET Item=? WHERE Count=?"); +#line 354 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 354 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 354 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + 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, ECPGt_EOLT); +#line 355 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 355 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 355 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_const,"2",(long)1,(long)1,strlen("2"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 356 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 356 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 356 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 357 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 357 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 357 "utext.pgc" + + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 360 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 360 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 360 "utext.pgc" + + + init_table_value(); +} + +//prepared delete using utext var +void test_var_9() +{ + test("test_var_9 : prepared delete using utext var"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 371 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 371 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 371 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "DELETE FROM tb1 WHERE Item=?"); +#line 373 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 373 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 373 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 374 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 374 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 374 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 375 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 375 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 375 "utext.pgc" + + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 378 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 378 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 378 "utext.pgc" + + + init_table_value(); +} + +//prepared insert using utext var +void test_var_10() +{ + test("test_var_10 : prepared insert using utext var"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 389 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 389 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 389 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "INSERT INTO tb1 values (?, 13)"); +#line 391 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 391 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 391 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 392 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 392 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 392 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 393 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 393 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 393 "utext.pgc" + + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 396 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 396 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 396 "utext.pgc" + + + init_table_value(); +} + +//Open cursor using utext var +void test_var_11() +{ + test("test_var_11 : Open cursor using utext var"); + init_var(); + + { ECPGsetcommit(__LINE__, "off", NULL); +#line 407 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 407 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 407 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 408 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 408 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 408 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Count FROM tb1 WHERE Item=?"); +#line 410 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 410 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 410 "utext.pgc" + + /* declare cursor_var_11 cursor for $1 */ +#line 411 "utext.pgc" + + { ECPGopen("cursor_var_11", "stmt", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cursor_var_11 cursor for $1", + ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt", __LINE__)),(long)1,(long)1,(1)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 412 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 412 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 412 "utext.pgc" + + { ECPGfetch("cursor_var_11", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cursor_var_11", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 413 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 413 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 413 "utext.pgc" + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGclose("cursor_var_11", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cursor_var_11", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 415 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 415 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 415 "utext.pgc" + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 416 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 416 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 416 "utext.pgc" + + { ECPGsetcommit(__LINE__, "on", NULL); +#line 417 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 417 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 417 "utext.pgc" + +} + +//Fecth cursor into utext var +void test_var_12() +{ + test("test_var_12 : Fecth cursor into utext var"); + init_var(); + + { ECPGsetcommit(__LINE__, "off", NULL); +#line 426 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 426 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 426 "utext.pgc" + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Item FROM tb1 WHERE Count=1"); +#line 427 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 427 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 427 "utext.pgc" + + /* declare cursor_var_12 cursor for $1 */ +#line 428 "utext.pgc" + + { ECPGopen("cursor_var_12", "stmt", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cursor_var_12 cursor for $1", + ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt", __LINE__)),(long)1,(long)1,(1)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 429 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 429 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 429 "utext.pgc" + + { ECPGfetch("cursor_var_12", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cursor_var_12", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 430 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 430 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 430 "utext.pgc" + + { ECPGclose("cursor_var_12", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cursor_var_12", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 431 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 431 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 431 "utext.pgc" + + + print_utext(utext_var); + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 435 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 435 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 435 "utext.pgc" + + { ECPGsetcommit(__LINE__, "on", NULL); +#line 436 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 436 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 436 "utext.pgc" + +} + +//simple insert utext var with L string inited +void test_var_13() +{ +/* exec sql begin declare section */ + + +#line 443 "utext.pgc" + utext utext_local_var [] = _T ( "太𠮷" ) ; +/* exec sql end declare section */ +#line 444 "utext.pgc" + + test("test_var_13 : simple insert utext var with L string inited"); + init_var(); + + printf("---utext_local_var---\n"); + + for(i=0;i= 20", ECPGt_EOIT, + ECPGt_utext,(utext_array),(long)VAR_SIZE,(long)ARRAY_SIZE,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 696 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 696 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 696 "utext.pgc" + + print_array(); + init_table_value(); +} + +//simple select into utext pointer +void test_pvar_1() +{ + test("test_pvar_1 : simple select into utext pointer"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 705 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 705 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 705 "utext.pgc" + + print_utext(p_utext_var); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 2", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 709 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 709 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 709 "utext.pgc" + + print_utext(p_utext_var); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 713 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 713 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 713 "utext.pgc" + + print_utext(p_utext_var); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 4", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 717 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 717 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 717 "utext.pgc" + + print_utext(p_utext_var); + init_var(); + init_table_value(); +} + + +//simple select using utext pointer +void test_pvar_2() +{ + test("test_pvar_2 : simple select using utext pointer"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 730 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 730 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 730 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count from tb1 where Item = $1 ", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 731 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 731 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 731 "utext.pgc" + + printf ("count=%d for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_var(); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 735 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 735 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 735 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count from tb1 where Item = $1 ", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 736 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 736 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 736 "utext.pgc" + + printf ("count=%d for '世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); +} + + +//simple update using utext pointer +void test_pvar_3() +{ + test("test_pvar_3 : simple update using utext pointer"); + init_var(); + + count = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 748 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 748 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 748 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update tb1 set Item = $1 where count = 2", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 749 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 749 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 749 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update tb1 set Item = $1 where count = 3", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 750 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 750 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 750 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 751 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 751 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 751 "utext.pgc" + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_table_value(); +} + +//simple delete using utext pointer +void test_pvar_4() +{ + test("test_pvar_4 : simple delete using utext pointer"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 1", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 763 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 763 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 763 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from tb1 where Item = $1 ", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 764 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 764 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 764 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 765 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 765 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 765 "utext.pgc" + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_var(); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 769 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 769 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 769 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from tb1 where Item = $1 ", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 770 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 770 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 770 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 771 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 771 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 771 "utext.pgc" + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//simple insert using utext pointer +void test_pvar_5() +{ + test("test_pvar_5 : simple insert using utext pointer"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 783 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 783 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 783 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 13 )", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 784 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 784 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 784 "utext.pgc" + + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 786 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 786 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 786 "utext.pgc" + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//prepared select into utext pointer +void test_pvar_6() +{ + test("test_pvar_6 : prepared select into utext pointer"); + init_var(); + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Item FROM tb1 WHERE Count=?"); +#line 798 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 798 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 798 "utext.pgc" + + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt", + ECPGt_const,"1",(long)1,(long)1,strlen("1"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 800 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 800 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 800 "utext.pgc" + + print_utext(p_utext_var); + + init_var(); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt", + ECPGt_const,"3",(long)1,(long)1,strlen("3"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 804 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 804 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 804 "utext.pgc" + + print_utext(p_utext_var); + init_table_value(); + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 808 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 808 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 808 "utext.pgc" + + +} + +//prepared select using utext pointer +void test_pvar_7() +{ + test("test_pvar_7 : prepared select using utext pointer"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 818 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 818 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 818 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Count FROM tb1 WHERE Item=?"); +#line 820 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 820 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 820 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 821 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 821 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 821 "utext.pgc" + + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 824 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 824 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 824 "utext.pgc" + +} + +//prepared update using utext pointer +void test_pvar_8() +{ + test("test_pvar_8 : prepared update using utext pointer"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 833 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 833 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 833 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "UPDATE tb1 SET Item=? WHERE Count=?"); +#line 835 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 835 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 835 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + 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, ECPGt_EOLT); +#line 836 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 836 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 836 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_const,"2",(long)1,(long)1,strlen("2"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 837 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 837 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 837 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 838 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 838 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 838 "utext.pgc" + + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 841 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 841 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 841 "utext.pgc" + + + init_table_value(); +} + +//prepared delete using utext pointer +void test_pvar_9() +{ + test("test_pvar_9 : prepared delete using utext pointer"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 852 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 852 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 852 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "DELETE FROM tb1 WHERE Item=?"); +#line 854 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 854 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 854 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 855 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 855 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 855 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 856 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 856 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 856 "utext.pgc" + + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 859 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 859 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 859 "utext.pgc" + + + init_table_value(); +} + +//prepared insert using utext pointer +void test_pvar_10() +{ + test("test_pvar_10 : prepared insert using utext pointer"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 870 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 870 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 870 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "INSERT INTO tb1 values (?, 13)"); +#line 872 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 872 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 872 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt", + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 873 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 873 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 873 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1 where Item = '世界杯每隔四年就会举行一次每次𠲖个球队'", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 874 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 874 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 874 "utext.pgc" + + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 877 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 877 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 877 "utext.pgc" + + + init_table_value(); +} + +//Open cursor using utext pointer +void test_pvar_11() +{ + test("test_pvar_11 : Open cursor using utext pointer"); + init_var(); + + { ECPGsetcommit(__LINE__, "off", NULL); +#line 888 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 888 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 888 "utext.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 3", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 889 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 889 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 889 "utext.pgc" + + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Count FROM tb1 WHERE Item=?"); +#line 891 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 891 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 891 "utext.pgc" + + /* declare cursor_pvar_11 cursor for $1 */ +#line 892 "utext.pgc" + + { ECPGopen("cursor_pvar_11", "stmt", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cursor_pvar_11 cursor for $1", + ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt", __LINE__)),(long)1,(long)1,(1)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 893 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 893 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 893 "utext.pgc" + + { ECPGfetch("cursor_pvar_11", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cursor_pvar_11", ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 894 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 894 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 894 "utext.pgc" + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + { ECPGclose("cursor_pvar_11", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cursor_pvar_11", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 896 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 896 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 896 "utext.pgc" + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 897 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 897 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 897 "utext.pgc" + + { ECPGsetcommit(__LINE__, "on", NULL); +#line 898 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 898 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 898 "utext.pgc" + +} + +//Fecth cursor into utext pointer +void test_pvar_12() +{ + test("test_pvar_12 : Fecth cursor into utext pointer"); + init_var(); + + { ECPGsetcommit(__LINE__, "off", NULL); +#line 907 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 907 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 907 "utext.pgc" + + { ECPGprepare(__LINE__, NULL, 0, "stmt", "SELECT Item FROM tb1 WHERE Count=1"); +#line 908 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 908 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 908 "utext.pgc" + + /* declare cursor_pvar_12 cursor for $1 */ +#line 909 "utext.pgc" + + { ECPGopen("cursor_pvar_12", "stmt", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cursor_pvar_12 cursor for $1", + ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt", __LINE__)),(long)1,(long)1,(1)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 910 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 910 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 910 "utext.pgc" + + { ECPGfetch("cursor_pvar_12", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cursor_pvar_12", ECPGt_EOIT, + ECPGt_utext,&(p_utext_var),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 911 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 911 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 911 "utext.pgc" + + { ECPGclose("cursor_pvar_12", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cursor_pvar_12", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 912 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 912 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 912 "utext.pgc" + + + print_utext(p_utext_var); + + { ECPGdeallocate(__LINE__, 0, NULL, "stmt"); +#line 916 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 916 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 916 "utext.pgc" + + { ECPGsetcommit(__LINE__, "on", NULL); +#line 917 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 917 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 917 "utext.pgc" + +} + +//simple insert utext pointer with L string inited +void test_pvar_13() +{ +/* exec sql begin declare section */ + + +#line 924 "utext.pgc" + utext * utext_local_pvar = L"太𠮷" ; +/* exec sql end declare section */ +#line 925 "utext.pgc" + + test("test_pvar_13 : simple insert utext pointer with L string inited"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into tb1 values ( $1 , 16 )", + ECPGt_utext,&(utext_local_pvar),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 929 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 929 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 929 "utext.pgc" + + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count = 16", ECPGt_EOIT, + ECPGt_utext,(utext_var),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_int,&(utext_var_ind),(long)1,(long)1,sizeof(int), ECPGt_EORT, ECPGt_EOLT); +#line 931 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 931 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 931 "utext.pgc" + + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + init_table_value(); +} + +//Buck insert utext array into table +void test_buckinsert_1() +{ + test("test_buckinsert_1 : Buck insert utext array into table"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count <= 3", ECPGt_EOIT, + ECPGt_utext,(utext_array),(long)VAR_SIZE,(long)ARRAY_SIZE,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 944 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 944 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 944 "utext.pgc" + + + // truncate table + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "truncate tb1", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 947 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 947 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 947 "utext.pgc" + + + //buck insert + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "BULK_INSERT_V01_I0058R0000 insert into tb1 (Item , count) values ( $1 , $2 )", + ECPGt_utext,(utext_array),(long)VAR_SIZE,(long)ARRAY_SIZE,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_int,(count_array),(long)1,(long)4,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, + ECPGt_const,"3",(long)1,(long)1,strlen("3"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOLT); +#line 950 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 950 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 950 "utext.pgc" + + + //check the results + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1", ECPGt_EOIT, + ECPGt_int,&(total_tuples),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 953 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 953 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 953 "utext.pgc" + + printf ("Total tuples in tb1 = %d\n", total_tuples); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count from tb1 where Item = $1 ", + ECPGt_utext,(utext_array[0]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 956 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 956 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 956 "utext.pgc" + + printf ("count=%d for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count from tb1 where Item = $1 ", + ECPGt_utext,(utext_array[2]),(long)VAR_SIZE,(long)1,(VAR_SIZE)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 959 "utext.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 959 "utext.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 959 "utext.pgc" + + printf ("count=%d for '世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_var(); + init_table_value(); +} + +void test_all() +{ + test_var_1(); + test_var_2(); + test_var_3(); + test_var_4(); + test_var_5(); + test_var_6(); + test_var_7(); + test_var_8(); + test_var_9(); + test_var_10(); + test_var_11(); + test_var_12(); + test_var_13(); + test_array_1(); + test_array_2(); + test_array_3(); + test_array_4(); + test_array_5(); + test_array_6(); + test_array_7(); + test_array_8(); + test_array_9(); + test_array_10(); + test_array_11(); + test_array_12(); + test_array_13(); + test_pvar_1(); + test_pvar_2(); + test_pvar_3(); + test_pvar_4(); + test_pvar_5(); + test_pvar_6(); + test_pvar_7(); + test_pvar_8(); + test_pvar_9(); + test_pvar_10(); + test_pvar_11(); + test_pvar_12(); + test_pvar_13(); + test_buckinsert_1(); +} + +int main(int argc, char *argv[]) +{ + ECPGdebug(1, stderr); + if(test_init() !=0) + return -1; + + test_all(); + //test_var_13(); + //test_array_13(); + //test_pvar_13(); + + test_finish(); + + return 0; +} \ No newline at end of file diff --git a/src/interfaces/ecpg/test/unicode/expected/utext.ret b/src/interfaces/ecpg/test/unicode/expected/utext.ret new file mode 100644 index 0000000..19088ec --- /dev/null +++ b/src/interfaces/ecpg/test/unicode/expected/utext.ret @@ -0,0 +1,435 @@ +SQL error: + +test_var_1: simple select into utext var +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x00000000 0x00000000 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00004E9A 0x00006D32 0x00006B27 0x00006D32 0x0000975E 0x00006D32 0x00005927 0x00006D0B +0x00006D32 0x00005317 0x00007F8E 0x00006D32 0x00005357 0x00007F8E 0x00006D32 0x00005357 +0x00006781 0x00006D32 0x00006CA1 0x00006709 +======End utext_var content====== +utext_var_ind = 23 + +test_var_2: simple select using utext var +count=1 for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +count=3 for '世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_3: simple update using utext var +found 3 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_var_4 : simple delete using utext var +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 0 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_5 : simple insert using utext +found 2 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_6 : prepared select into utext var +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +======End utext_var content====== +======print utext_var content====== +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +======End utext_var content====== + +test_var_7 : prepared select using utext var +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_8 : prepared update using utext var +found 3 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_9 : prepared delete using utext var +found 0 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_10 : prepared insert using utext var +found 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_11 : Open cursor using utext var +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_12 : Fecth cursor into utext var +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +======End utext_var content====== + +test_var_13 : simple insert utext var with L string inited +======print utext_var_str content====== +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 +======End utext_var_str content====== +======print utext_var content====== +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +======End utext_var content====== +utext_var_ind = 0 + +test_var_14 : Open cursor using utext var directly in WHERE Clause +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_15 : Test utext_var working with NULL without indicator +======print utext_var content====== +0x00000000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +found 6 rows for Item being NULL + +test_var_16 : Test utext_var working with NULL with indicator +======print utext_var content====== +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +utext_var_ind = -1 +found 6 rows for Item being NULL + +test_array_1 : simple select into utext array +---->array[0]: +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +---->array[1]: +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x00000000 0x00000000 +---->array[2]: +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +---->array[3]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + +---->array[0]: +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +---->array[1]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[2]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[3]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + + +test_array_2 : simple select using array +count=1 for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +count=3 for '世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_3 : simple update using utext array +find 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +find 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_4 : simple delete using utext array +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 0 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_5 : simple insert using utext array +found 2 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_6 : prepared select SQL error: +into utext array +---->array[0]: +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +---->array[1]: +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x00000000 0x00000000 +---->array[2]: +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +---->array[3]: +0x00004E9A 0x00006D32 0x00006B27 0x00006D32 0x0000975E 0x00006D32 0x00005927 0x00006D0B +0x00006D32 0x00005317 0x00007F8E 0x00006D32 0x00005357 0x00007F8E 0x00006D32 0x00005357 +0x00006781 0x00006D32 0x00006CA1 0x00006709 + + +test_array_7 : prepared select using utext array +count=1 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_8 : prepared update using utext array +found 3 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_array_9 : prepared delete using utext array +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_array_10 : prepared insert using utext array +found 3 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_11 : Open cursor using utext array +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_12 : Fecth cursor into utext array +---->array[0]: +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +---->array[1]: +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x00000000 0x00000000 +---->array[2]: +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +---->array[3]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + + +test_array_13 : Insert array with L string inited +---->array[0]: +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +---->array[1]: +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x00000000 0x00000000 +---->array[2]: +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 + + +test_array_14 : Open cursor using utext array directly in WHERE Clause +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_15 : Test utext array working with NULL without using indicator +---->array[0]: +0x00000000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[1]: +0x00000000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[2]: +0x00000000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + +found 6 rows for Item being NULL + +test_array_16 : Test utext array working with NULL using indicator +---->array[0]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[1]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[2]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + +utext_var_ind = -1 +utext_var_ind = -1 +utext_var_ind = -1 +found 6 rows for Item being NULL + +test_pvar_1 : simple select into utext pointer +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x61616161 0x61616161 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00004E9A 0x00006D32 0x00006B27 0x00006D32 0x0000975E 0x00006D32 0x00005927 0x00006D0B +0x00006D32 0x00005317 0x00007F8E 0x00006D32 0x00005357 0x00007F8E 0x00006D32 0x00005357 +0x00006781 0x00006D32 0x00006CA1 0x00006709 +======End utext_var content====== +utext_var_ind = 0 + +test_pvar_2 : simple select using utext pointer +count=1 for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +count=0 for '世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_3 : simple update using utext pointer +found 3 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_pvar_4 : simple delete using utext pointer +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 1 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_5 : simple insert using utext pointer +found 1 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_6 : prepared select into utext pointer +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +======print utext_var content====== +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +======End utext_var content====== + +test_pvar_7 : prepared select using utext pointer +count=0 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_8 : prepared update using utext pointer +found 1 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_9 : prepared delete using utext pointer +found 1 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_10 : prepared insert using utext pointer +found 1 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_11 : Open cursor using utext pointer +count=0 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_12 : Fecth cursor into utext pointer +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== + +test_pvar_13 : simple insert utext pointer with L string inited +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +======End utext_var content====== +utext_var_ind = 0 + +test_pvar_14 : Open cursor using utext var directly in WHERE Clause +count=0 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_15 : Test utext pointer working with NULL without using indicator +======print utext_var content====== +0x00000000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +found 6 rows for Item being NULL + +test_pvar_16 : Test utext pointer working with NULL using indicator +======print utext_var content====== +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +utext_var_ind = -1 +found 6 rows for Item being NULL + +test_pvar_17 : Test utext uninitialized pointer getting and setting data +======print utext_var_str content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B +======End utext_var_str content====== +Find Item = 太𠮷𠜱平洋𠱓大西洋印度洋北冰洋 where Count=18 + +test_pvar_18 : Test utext uninitialized pointer working with NULL without using indicator +======print utext_var content====== +0x00000000 +======End utext_var content====== +found 6 rows for Item being NULL + +test_pvar_19 : Test utext uninitialized pointer working with NULL using indicator +======print utext_var content====== +0x00000000 +======End utext_var content====== +utext_var_ind = -1 +found 6 rows for Item being NULL + +test_pp_var_1 : Test pointer to pointer utext_var without initialize +======print utext_var_str content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B +======End utext_var_str content====== +utext_var_ind = 0 +======print utext_var_str content====== +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 +======End utext_var_str content====== +utext_var_ind = 0 +======print utext_var_str content====== +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F +======End utext_var_str content====== +utext_var_ind = 0 +足球篮球羽毛球乒乓球橄榄球棒球冰球 + +test_pp_var_2 : Test uninitialized pointer to pointer utext_var working with NULL without indicator +======print utext_var_str content====== + +======End utext_var_str content====== +======print utext_var_str content====== + +======End utext_var_str content====== +======print utext_var_str content====== + +======End utext_var_str content====== +found 6 rows for Item being NULL + +test_pp_var_2 : Test uninitialized pointer to pointer utext_var working with NULL without indicator +======print utext_var_str content====== + +======End utext_var_str content====== +utext_var_ind = -1 +======print utext_var_str content====== + +======End utext_var_str content====== +utext_var_ind = -1 +======print utext_var_str content====== + +======End utext_var_str content====== +utext_var_ind = -1 +found 6 rows for Item being NULL diff --git a/src/interfaces/ecpg/test/unicode/expected/utext_ex.c b/src/interfaces/ecpg/test/unicode/expected/utext_ex.c new file mode 100755 index 0000000..f4e44aa --- /dev/null +++ b/src/interfaces/ecpg/test/unicode/expected/utext_ex.c @@ -0,0 +1,521 @@ +/* Processed by ecpg (regression mode) */ +/* These include files are added by the preprocessor */ +#define ECPG_ENABLE_UTEXT 1 +#include +#include +#include +/* End of automatic include section */ +#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y)) + +#line 1 "utext_ex.pgc" +#include + + +#line 1 "./../regression.h" + + + + + + +#line 3 "utext_ex.pgc" + + +void print_utext(char *var_name, utext *utext_var, int var_size); +void print_utext_array(char *var_name, utext *utext_var, int var_size, int index); +void print_nchar(char *utext_var, int var_size); + +#define print_ret print_utext("employee",employee,40); \ +print_utext("address", address.arr, address.len) + +/* exec sql begin declare section */ + + + + + + + + + + + + +#line 13 "utext_ex.pgc" + char char_ename [ 3 ] [ 40 ] = { "test ok" , "测试 通过" , "太𠮷𠜱" } ; + +#line 15 "utext_ex.pgc" + char employee_1 [ 40 ] = "test ok" ; + +#line 16 "utext_ex.pgc" + char employee_2 [ 40 ] = "测试 通过" ; + +#line 17 "utext_ex.pgc" + char employee_3 [ 40 ] = "太𠮷𠜱" ; + +#line 19 "utext_ex.pgc" + char char_addr [ 3 ] [ 40 ] = { "1 sydney, NSW" , "澳大利亚悉尼1号" , "世界杯" } ; + +#line 21 "utext_ex.pgc" + char address_1 [ 40 ] = "1 sydney, NSW" ; + +#line 22 "utext_ex.pgc" + char address_2 [ 40 ] = "澳大利亚悉尼1号" ; + +#line 23 "utext_ex.pgc" + char address_3 [ 40 ] = "世界杯" ; +/* exec sql end declare section */ +#line 24 "utext_ex.pgc" + + +void print_utext(char *var_name, utext *utext_var, int var_size) +{ + int i; + printf("======print %s content======\n",var_name); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n"); +} + +void print_utext_array(char *var_name, utext *utext_var, int var_size, int index) +{ + int i; + printf("======print %s[%d] content======\n",var_name,index); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n"); +} + +void print_nchar(char *utext_var, int var_size) +{ + printf("nchar is : %s\n",utext_var); + int i; + printf("======print utext_var content======\n"); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n======End utext_var content======\n"); +} + +void create_table() +{ + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table if not exists emp ( id int , ename char ( 20 ) , address nvarchar ( 50 ) )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT);} +#line 68 "utext_ex.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "truncate table emp", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT);} +#line 69 "utext_ex.pgc" + + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table if not exists emp_bk ( id int , ename char ( 20 ) , address nvarchar ( 50 ) )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT);} +#line 71 "utext_ex.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "truncate table emp_bk", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT);} +#line 72 "utext_ex.pgc" + +} + +void init_table() +{ + /* UTF8 is the database character set */ + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp ( id , ename , address ) values ( 1 , 'test ok' , '1 sydney, NSW' )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT);} +#line 78 "utext_ex.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp ( id , ename , address ) values ( 2 , '测试 通过' , '澳大利亚悉尼1号' )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT);} +#line 79 "utext_ex.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp ( id , ename , address ) values ( 3 , '太𠮷𠜱' , '世界杯' )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT);} +#line 80 "utext_ex.pgc" + +} + +/* + Test utext host variable +*/ +void testcase1() +{ + /* exec sql begin declare section */ + + + + + /* define Unicode host variable */ + /* define a variable length Unicode host variable */ + +#line 89 "utext_ex.pgc" + int total_tuples = 0 ; + +#line 90 "utext_ex.pgc" + int i = 0 ; + +#line 91 "utext_ex.pgc" + int id = 0 ; + +#line 92 "utext_ex.pgc" + int id2 = 0 ; + +#line 93 "utext_ex.pgc" + utext employee [ 41 ] ; + +#line 94 "utext_ex.pgc" + struct uvarchar_1 { int len; utext arr[ 101 ]; } address ; +/* exec sql end declare section */ +#line 95 "utext_ex.pgc" + + + printf("\n**************Start testcase(%d)**************\n",1); + + memset(employee,'a',sizeof(employee)); + memset((void*)&address,'a',sizeof(address)); + address.len = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "truncate emp_bk", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT);} +#line 103 "utext_ex.pgc" + + + for(i=1;i<=3;i++) + { + /* Database character set converted to Unicode */ + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select ename , address from emp where id = $1 ", + ECPGt_int,&(i),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_utext,(employee),(long)41,(long)1,(41)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_uvarchar,&(address),(long)101,(long)1,sizeof(struct uvarchar_1), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT);} +#line 108 "utext_ex.pgc" + + print_ret; + /* Unicode converted to Database character */ + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp_bk ( id , ename , address ) values ( $1 , $2 , $3 )", + ECPGt_int,&(i),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_utext,(employee),(long)41,(long)1,(41)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_uvarchar,&(address),(long)101,(long)1,sizeof(struct uvarchar_1), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT);} +#line 111 "utext_ex.pgc" + + } + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from emp_bk", ECPGt_EOIT, + ECPGt_int,&(total_tuples),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT);} +#line 114 "utext_ex.pgc" + + printf("total_tuples = %d in emp_bk\n",total_tuples); + + + for(i=3;i>0;i--) + { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select ename , address from emp where id = $1 ", + ECPGt_int,&(i),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_utext,(employee),(long)41,(long)1,(41)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_uvarchar,&(address),(long)101,(long)1,sizeof(struct uvarchar_1), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT);} +#line 120 "utext_ex.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select id from emp_bk where ename = $1 and address = $2 ", + ECPGt_utext,(employee),(long)41,(long)1,(41)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_uvarchar,&(address),(long)101,(long)1,sizeof(struct uvarchar_1), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(id),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT);} +#line 121 "utext_ex.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select id from emp_bk where ename = $1 and address = $2 ", + ECPGt_char,(char_ename[i-1]),(long)40,(long)1,(40)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(char_addr[i-1]),(long)40,(long)1,(40)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(id2),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT);} +#line 122 "utext_ex.pgc" + + printf("id[%d] = id2[%d] in emp_bk\n",id,id2); + } +} + +/* + Test utext array +*/ +void testcase2() +{ + /* exec sql begin declare section */ + + + + + + /* define Unicode host variable */ + /* define a variable length Unicode host variable */ + +#line 133 "utext_ex.pgc" + int total_tuples = 0 ; + +#line 134 "utext_ex.pgc" + int i = 0 ; + +#line 135 "utext_ex.pgc" + int j = 0 ; + +#line 136 "utext_ex.pgc" + int id = 0 ; + +#line 137 "utext_ex.pgc" + int id2 = 0 ; + +#line 138 "utext_ex.pgc" + utext employee_array [ 3 ] [ 41 ] ; + +#line 139 "utext_ex.pgc" + struct uvarchar_2 { int len; utext arr[ 101 ]; } address_array [ 3 ] ; +/* exec sql end declare section */ +#line 140 "utext_ex.pgc" + + + printf("\n**************Start testcase(%d)**************\n",2); + + memset(employee_array,'a',sizeof(employee_array)); + + for(i=0;i<3;i++) + { + memset((void*)&address_array[i],'a',sizeof(address_array[0])); + address_array[i].len=0; + } + + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "truncate emp_bk", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT);} +#line 153 "utext_ex.pgc" + + + /* Database character set converted to Unicode */ + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select ename , address from emp", ECPGt_EOIT, + ECPGt_utext,(employee_array),(long)41,(long)3,(41)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_uvarchar,(address_array),(long)101,(long)3,sizeof(struct uvarchar_2), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT);} +#line 156 "utext_ex.pgc" + + + for(i=1;i<=3;i++) + { + print_utext_array("employee_array",employee_array[i-1],40,i-1); + print_utext_array("address_array",address_array[i-1].arr,address_array[i-1].len,i-1); + /* Unicode converted to Database character */ + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp_bk ( id , ename , address ) values ( $1 , $2 , $3 )", + ECPGt_int,&(i),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_utext,(employee_array[i-1]),(long)41,(long)1,(41)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_uvarchar,&(address_array[i-1]),(long)101,(long)1,sizeof(struct uvarchar_2), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT);} +#line 163 "utext_ex.pgc" + + } + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from emp_bk", ECPGt_EOIT, + ECPGt_int,&(total_tuples),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT);} +#line 166 "utext_ex.pgc" + + printf("total_tuples = %d in emp_bk\n",total_tuples); + + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select ename , address from emp", ECPGt_EOIT, + ECPGt_utext,(employee_array),(long)41,(long)3,(41)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_uvarchar,(address_array),(long)101,(long)3,sizeof(struct uvarchar_2), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT);} +#line 170 "utext_ex.pgc" + + for(i=3;i>0;i--) + { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select id from emp_bk where ename = $1 and address = $2 ", + ECPGt_utext,(employee_array[i-1]),(long)41,(long)1,(41)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_uvarchar,&(address_array[i-1]),(long)101,(long)1,sizeof(struct uvarchar_2), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(id),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT);} +#line 173 "utext_ex.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select id from emp_bk where ename = $1 and address = $2 ", + ECPGt_char,(char_ename[i-1]),(long)40,(long)1,(40)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(char_addr[i-1]),(long)40,(long)1,(40)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(id2),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT);} +#line 174 "utext_ex.pgc" + + printf("id[%d] = id2[%d] in emp_bk\n",id,id2); + } +} + + +/* + Test utext pointer +*/ +void testcase3() +{ + /* exec sql begin declare section */ + + + + + /* define Unicode host variable */ + + /* define a variable length Unicode host variable */ + +#line 186 "utext_ex.pgc" + int total_tuples = 0 ; + +#line 187 "utext_ex.pgc" + int i = 0 ; + +#line 188 "utext_ex.pgc" + int id = 0 ; + +#line 189 "utext_ex.pgc" + int id2 = 0 ; + +#line 190 "utext_ex.pgc" + utext * employee ; + +#line 191 "utext_ex.pgc" + int employee_len = 82 ; + +#line 192 "utext_ex.pgc" + struct uvarchar_3 { int len; utext arr[ 101 ]; } address ; +/* exec sql end declare section */ +#line 193 "utext_ex.pgc" + + + + printf("\n**************Start testcase(%d)**************\n",3); + + employee = malloc(employee_len); + + memset(employee,'a',employee_len); + memset((void*)&address,'a',sizeof(address)); + address.len = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "truncate emp_bk", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT);} +#line 204 "utext_ex.pgc" + + + for(i=1;i<=3;i++) + { + /* Database character set converted to Unicode */ + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select ename , address from emp where id = $1 ", + ECPGt_int,&(i),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_utext,&(employee),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_uvarchar,&(address),(long)101,(long)1,sizeof(struct uvarchar_3), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT);} +#line 209 "utext_ex.pgc" + + print_ret; + /* Unicode converted to Database character */ + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into emp_bk ( id , ename , address ) values ( $1 , $2 , $3 )", + ECPGt_int,&(i),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_utext,&(employee),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_uvarchar,&(address),(long)101,(long)1,sizeof(struct uvarchar_3), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT);} +#line 212 "utext_ex.pgc" + + } + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from emp_bk", ECPGt_EOIT, + ECPGt_int,&(total_tuples),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT);} +#line 215 "utext_ex.pgc" + + printf("total_tuples = %d in emp_bk\n",total_tuples); + + + for(i=3;i>0;i--) + { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select ename , address from emp where id = $1 ", + ECPGt_int,&(i),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_utext,&(employee),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_uvarchar,&(address),(long)101,(long)1,sizeof(struct uvarchar_3), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT);} +#line 221 "utext_ex.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select id from emp_bk where ename = $1 and address = $2 ", + ECPGt_utext,&(employee),(long)0,(long)1,(1)*sizeof(utext), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_uvarchar,&(address),(long)101,(long)1,sizeof(struct uvarchar_3), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(id),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT);} +#line 222 "utext_ex.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select id from emp_bk where ename = $1 and address = $2 ", + ECPGt_char,(char_ename[i-1]),(long)40,(long)1,(40)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(char_addr[i-1]),(long)40,(long)1,(40)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(id2),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT);} +#line 223 "utext_ex.pgc" + + printf("id[%d] = id2[%d] in emp_bk\n",id,id2); + } +} + +int main() { + { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); } +#line 229 "utext_ex.pgc" + + + { ECPGsetcommit(__LINE__, "on", NULL);} +#line 231 "utext_ex.pgc" + + /* exec sql whenever sql_warning sqlprint ; */ +#line 232 "utext_ex.pgc" + + /* exec sql whenever sqlerror sqlprint ; */ +#line 233 "utext_ex.pgc" + + create_table(); + init_table(); + + testcase1(); + testcase2(); + testcase3(); + + { ECPGdisconnect(__LINE__, "CURRENT"); +#line 241 "utext_ex.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 241 "utext_ex.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 241 "utext_ex.pgc" + + return 0; +} + + + diff --git a/src/interfaces/ecpg/test/unicode/expected/utext_ex.ret b/src/interfaces/ecpg/test/unicode/expected/utext_ex.ret new file mode 100755 index 0000000..b2aaeb0 --- /dev/null +++ b/src/interfaces/ecpg/test/unicode/expected/utext_ex.ret @@ -0,0 +1,105 @@ + +**************Start testcase(1)************** +======print employee content====== +0x0074 0x0065 0x0073 0x0074 0x0020 0x006F 0x006B 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0000 0x0000 0x0000 0x0000 +0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 +0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 + +======print address content====== +0x0031 0x0020 0x0073 0x0079 0x0064 0x006E 0x0065 0x0079 +0x002C 0x0020 0x004E 0x0053 0x0057 +======print employee content====== +0x6D4B 0x8BD5 0x0020 0x901A 0x8FC7 0x0020 0x0020 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0000 0x0000 0x0000 0x0000 +0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 +0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 + +======print address content====== +0x6FB3 0x5927 0x5229 0x4E9A 0x6089 0x5C3C 0x0031 0x53F7 + +======print employee content====== +0x592A 0xD842 0xDFB7 0xD841 0xDF31 0x0020 0x0020 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0000 0x0000 +0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 +0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 + +======print address content====== +0x4E16 0x754C 0x676F +total_tuples = 3 in emp_bk +id[3] = id2[3] in emp_bk +id[2] = id2[2] in emp_bk +id[1] = id2[1] in emp_bk + +**************Start testcase(2)************** +======print employee_array[0] content====== +0x0074 0x0065 0x0073 0x0074 0x0020 0x006F 0x006B 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0000 0x0000 0x0000 0x0000 +0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 +0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 + +======print address_array[0] content====== +0x0031 0x0020 0x0073 0x0079 0x0064 0x006E 0x0065 0x0079 +0x002C 0x0020 0x004E 0x0053 0x0057 +======print employee_array[1] content====== +0x6D4B 0x8BD5 0x0020 0x901A 0x8FC7 0x0020 0x0020 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0000 0x0000 0x0000 0x0000 +0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 +0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 + +======print address_array[1] content====== +0x6FB3 0x5927 0x5229 0x4E9A 0x6089 0x5C3C 0x0031 0x53F7 + +======print employee_array[2] content====== +0x592A 0xD842 0xDFB7 0xD841 0xDF31 0x0020 0x0020 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0000 0x0000 +0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 +0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 + +======print address_array[2] content====== +0x4E16 0x754C 0x676F +total_tuples = 3 in emp_bk +id[3] = id2[3] in emp_bk +id[2] = id2[2] in emp_bk +id[1] = id2[1] in emp_bk + +**************Start testcase(3)************** +======print employee content====== +0x0074 0x0065 0x0073 0x0074 0x0020 0x006F 0x006B 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0000 0x6161 0x6161 0x6161 +0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 +0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 + +======print address content====== +0x0031 0x0020 0x0073 0x0079 0x0064 0x006E 0x0065 0x0079 +0x002C 0x0020 0x004E 0x0053 0x0057 +======print employee content====== +0x6D4B 0x8BD5 0x0020 0x901A 0x8FC7 0x0020 0x0020 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0000 0x6161 0x6161 0x6161 +0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 +0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 + +======print address content====== +0x6FB3 0x5927 0x5229 0x4E9A 0x6089 0x5C3C 0x0031 0x53F7 + +======print employee content====== +0x592A 0xD842 0xDFB7 0xD841 0xDF31 0x0020 0x0020 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 +0x0020 0x0020 0x0020 0x0020 0x0020 0x0020 0x0000 0x6161 +0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 +0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 0x6161 + +======print address content====== +0x4E16 0x754C 0x676F +total_tuples = 3 in emp_bk +id[3] = id2[3] in emp_bk +id[2] = id2[2] in emp_bk +id[1] = id2[1] in emp_bk diff --git a/src/interfaces/ecpg/test/unicode/expected/uvarchar.c b/src/interfaces/ecpg/test/unicode/expected/uvarchar.c new file mode 100755 index 0000000..be42b60 --- /dev/null +++ b/src/interfaces/ecpg/test/unicode/expected/uvarchar.c @@ -0,0 +1,2195 @@ +/* Processed by ecpg (regression mode) */ +/* These include files are added by the preprocessor */ +#define ECPG_ENABLE_UTEXT 1 +#include +#include +#include +/* End of automatic include section */ +#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y)) + +#line 1 "uvarchar.pgc" +#include +#include +#include + + +#line 1 "./../regression.h" + + + + + + +#line 5 "uvarchar.pgc" + + +#define test(msg) printf("\n%s\n",msg) +#define VAR_SIZE 20 +#define ARRAY_SIZE 4 + +/* Following is UTF8 and UTF16 characters mapping table */ +/*太𠮷𠜱平洋𠱓大西洋印度洋北冰洋 +0x592A,0x5E73,0x6D0B,0x5927,0x897F,0x6D0B,0x5370,0x5EA6, +0x6D0B,0x5317,0x51B0,0x6D0B,0x548C,0x5357,0x51B0,0x6D0B, +0x0000,0x0000,0x0000,0x0000*/ + +/*足球篮球羽毛球乒乓球橄榄球棒球冰球 +0x8DB3,0x7403,0x7BEE,0x7403,0x7FBD,0x6BDB,0x7403,0x4E52, +0x4E53,0x7403,0x6A44,0x6984,0x7403,0x68D2,0x7403,0x51B0, +0x7403,0x0000,0x0000,0x0000 +*/ + +/*世界杯每隔四年就会举行一次每次𠲖个球队 +0x4E16,0x754C,0x676F,0x6BCF,0x9694,0x56DB,0x5E74,0x5C31, +0x4F1A,0x4E3E,0x884C,0x4E00,0x6B21,0x6BCF,0x6B21,0x0033, +0x0032,0x4E2A,0x7403,0x961F +*/ + +/* 亚洲欧洲非洲大洋洲北美洲南美洲南极洲没有北极洲 +0x4E9A,0x6D32,0x6B27,0x6D32,0x975E,0x6D32,0x5927,0x6D0B, +0x6D32,0x5317,0x7F8E,0x6D32,0x5357,0x7F8E,0x6D32,0x5357, +0x6781,0x6D32,0x6CA1,0x6709,0x5317,0x6781,0x6D32 +*/ + +/* exec sql begin declare section */ + + + + + + + + + +#line 36 "uvarchar.pgc" + struct uvarchar_1 { int len; utext arr[ VAR_SIZE ]; } uvarchar_var ; + +#line 37 "uvarchar.pgc" + struct uvarchar_2 { int len; utext arr[ VAR_SIZE ]; } uvarchar_array [ ARRAY_SIZE ] ; + +#line 39 "uvarchar.pgc" + int uvarchar_var_ind ; + +#line 41 "uvarchar.pgc" + int count ; + +#line 42 "uvarchar.pgc" + int count_array [ 4 ] = { 1 , 2 , 3 , 4 } ; + +#line 43 "uvarchar.pgc" + int total_tuples = 0 ; +/* exec sql end declare section */ +#line 44 "uvarchar.pgc" + + +void print_uvarchar(void); +void print_uvarchar_ind(int uvarchar_var_ind); +void print_array(void); +int test_init(void); +void test_finish(void); +void init_table_value(void); +void init_var(void); + +void test_var_1(void); +void test_var_2(void); +void test_var_3(void); +void test_var_4(void); +void test_var_5(void); +void test_var_6(void); +void test_var_7(void); +void test_var_8(void); +void test_var_9(void); +void test_var_10(void); +void test_var_11(void); +void test_var_12(void); +void test_var_13(void); +void test_array_1(void); +void test_array_2(void); +void test_array_3(void); +void test_array_4(void); +void test_array_5(void); +void test_array_6(void); +void test_array_7(void); +void test_array_8(void); +void test_array_9(void); +void test_array_10(void); +void test_array_11(void); +void test_array_12(void); +void test_array_13(void); +void test_buckinsert_1(void); + +void test_all(void); + +void print_uvarchar() +{ + int i; + + printf ("---->uvarchar variable,len=%d:\n",uvarchar_var.len); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n"); +} + +void print_uvarchar_ind(int uvarchar_var_ind) +{ + printf("uvarchar_var_ind = %d\n",uvarchar_var_ind); +} + +void print_array() +{ + int i,j; + + for(i=0; iuvarchar array[%d]:(len=%d)\n", i,uvarchar_array[i].len); + + for(j=0; j6 && (j+1)%8==0) + printf("\n"); + } + printf("\n"); + } + + printf("\n"); +} + +int test_init() +{ + { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); } +#line 125 "uvarchar.pgc" + + + { ECPGsetcommit(__LINE__, "on", NULL);} +#line 127 "uvarchar.pgc" + + /* exec sql whenever sql_warning sqlprint ; */ +#line 128 "uvarchar.pgc" + + /* exec sql whenever sqlerror sqlprint ; */ +#line 129 "uvarchar.pgc" + + + //initialization of test table + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table tb1 ( Item varchar , count integer )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 132 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 132 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 132 "uvarchar.pgc" + + + init_table_value(); + + return 0; +} + +void test_finish() +{ + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table tb1", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 141 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 141 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 141 "uvarchar.pgc" + + { ECPGdisconnect(__LINE__, "ALL"); +#line 142 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 142 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 142 "uvarchar.pgc" + +} + + +void init_table_value() +{ + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "truncate tb1", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 148 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 148 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 148 "uvarchar.pgc" + + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into tb1 values ( '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' , 1 )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 150 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 150 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 150 "uvarchar.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into tb1 values ( '足球篮球羽毛球乒乓球橄榄球棒球冰球' , 2 )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 151 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 151 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 151 "uvarchar.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into tb1 values ( '世界杯每隔四年就会举行一次每次𠲖个球队' , 3 )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 152 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 152 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 152 "uvarchar.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into tb1 values ( '亚洲欧洲非洲大洋洲北美洲南美洲南极洲没有北极洲' , 4 )", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 153 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 153 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 153 "uvarchar.pgc" + +} + +void init_var() +{ + int i; + memset((void*)&uvarchar_var,'a',sizeof(uvarchar_var)); + uvarchar_var.len = 0; + + memset((char*)uvarchar_array,'a',sizeof(uvarchar_array)*ARRAY_SIZE); + + for(i=0;i= 20", ECPGt_EOIT, + ECPGt_uvarchar,(uvarchar_array),(long)VAR_SIZE,(long)ARRAY_SIZE,sizeof(struct uvarchar_2), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 669 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 669 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 669 "uvarchar.pgc" + + print_array(); + init_table_value(); + +} + +//Buck insert uvarchar array into table +void test_buckinsert_1() +{ + test("test_buckinsert_1 : Buck insert uvarchar array into table"); + init_var(); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select Item from tb1 where count <= 3", ECPGt_EOIT, + ECPGt_uvarchar,(uvarchar_array),(long)VAR_SIZE,(long)ARRAY_SIZE,sizeof(struct uvarchar_2), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 681 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 681 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 681 "uvarchar.pgc" + + + // truncate table + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "truncate tb1", ECPGt_EOIT, ECPGt_EORT, ECPGt_EOLT); +#line 684 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 684 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 684 "uvarchar.pgc" + + + //buck insert + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "BULK_INSERT_V01_I0058R0000 insert into tb1 (Item , count) values ( $1 , $2 )", + ECPGt_uvarchar,(uvarchar_array),(long)VAR_SIZE,(long)ARRAY_SIZE,sizeof(struct uvarchar_2), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_int,(count_array),(long)1,(long)4,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT, + ECPGt_const,"3",(long)1,(long)1,strlen("3"), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOLT); +#line 687 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 687 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 687 "uvarchar.pgc" + + + //check the results + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from tb1", ECPGt_EOIT, + ECPGt_int,&(total_tuples),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 690 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 690 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 690 "uvarchar.pgc" + + printf ("Total tuples in tb1 = %d\n", total_tuples); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count from tb1 where Item = $1 ", + ECPGt_uvarchar,&(uvarchar_array[0]),(long)VAR_SIZE,(long)1,sizeof(struct uvarchar_2), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 693 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 693 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 693 "uvarchar.pgc" + + printf ("count=%d for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count from tb1 where Item = $1 ", + ECPGt_uvarchar,&(uvarchar_array[2]),(long)VAR_SIZE,(long)1,sizeof(struct uvarchar_2), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_int,&(count),(long)1,(long)1,sizeof(int), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT, ECPGt_EOLT); +#line 696 "uvarchar.pgc" + +if (sqlca.sqlwarn[0] == 'W') sqlprint(); +#line 696 "uvarchar.pgc" + +if (sqlca.sqlcode < 0) sqlprint();} +#line 696 "uvarchar.pgc" + + printf ("count=%d for '世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_var(); + init_table_value(); +} + +void test_all() +{ + test_var_1(); + test_var_2(); + test_var_3(); + test_var_4(); + test_var_5(); + test_var_6(); + test_var_7(); + test_var_8(); + test_var_9(); + test_var_10(); + test_var_11(); + test_var_12(); + test_var_13(); + test_array_1(); + test_array_2(); + test_array_3(); + test_array_4(); + test_array_5(); + test_array_6(); + test_array_7(); + test_array_8(); + test_array_9(); + test_array_10(); + test_array_11(); + test_array_12(); + test_array_13(); + test_buckinsert_1(); +} + +int main() +{ + ECPGdebug(1, stderr); + if(test_init() !=0) + return -1; + + test_all(); + //test_array_13(); + //test_var_1(); + test_finish(); + + return 0; +} diff --git a/src/interfaces/ecpg/test/unicode/expected/uvarchar.ret b/src/interfaces/ecpg/test/unicode/expected/uvarchar.ret new file mode 100644 index 0000000..35a03e5 --- /dev/null +++ b/src/interfaces/ecpg/test/unicode/expected/uvarchar.ret @@ -0,0 +1,253 @@ +SQL error: + +test_var_1 : simple select into uvarchar var +---->uvarchar variable,len=15: +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 +uvarchar_var_ind = 0 +---->uvarchar variable,len=17: +0x8DB3 0x7403 0x7BEE 0x7403 0x7FBD 0x6BDB 0x7403 0x4E52 +0x4E53 0x7403 0x6A44 0x6984 0x7403 0x68D2 0x7403 0x51B0 +0x7403 0x0000 0x0000 0x0000 +uvarchar_var_ind = 0 +---->uvarchar variable,len=19: +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0x20C96 +0x4E2A 0x7403 0x961F 0x0000 +uvarchar_var_ind = 0 +---->uvarchar variable,len=20: +0x4E9A 0x6D32 0x6B27 0x6D32 0x975E 0x6D32 0x5927 0x6D0B +0x6D32 0x5317 0x7F8E 0x6D32 0x5357 0x7F8E 0x6D32 0x5357 +0x6781 0x6D32 0x6CA1 0x6709 +uvarchar_var_ind = 23 + +test_var_2 : simple select using uvarchar var +count=1 for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +count=3 for '世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_3 : simple update using uvarchar +found 3 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_var_4 : simple delete using uvarchar var +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 0 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_5 : simple insert using uvarchar +found 2 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_6 : prepared select into uvarchar var +---->uvarchar variable,len=15: +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 +---->uvarchar variable,len=19: +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0x20C96 +0x4E2A 0x7403 0x961F 0x0000 + +test_var_7 : prepared select using uvarchar var +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_8 : prepared update using uvarchar var +found 3 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_9 : prepared delete using uvarchar var +found 0 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_10 : prepared insert using uvarchar var +found 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_11 : Open cursor using uvarchar var +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_12 : Fecth cursor into uvarchar var +---->uvarchar variable,len=15: +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 + +test_var_13 : simple insert using uvarchar with L string inited +uvarchar_local_var.len = 16 +found 2 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +---->uvarchar variable,len=15: +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 +uvarchar_var_ind = 0 + +test_var_14 : Open cursor using utext var directly in WHERE Clause +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_15 : Test uvarchar_var working with NULL without indicator +---->uvarchar variable,len=20: +0x0000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +found 6 rows for Item being NULL + +test_var_16 : Test uvarchar_var working with NULL with indicator +---->uvarchar variable,len=20: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +uvarchar_var_ind = -1 +found 6 rows for Item being NULL + +test_array_1 : simple select into uvarchar array +---->uvarchar array[0]:(len=15) +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 +---->uvarchar array[1]:(len=17) +0x8DB3 0x7403 0x7BEE 0x7403 0x7FBD 0x6BDB 0x7403 0x4E52 +0x4E53 0x7403 0x6A44 0x6984 0x7403 0x68D2 0x7403 0x51B0 +0x7403 0x0000 0x0000 0x0000 +---->uvarchar array[2]:(len=19) +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0x20C96 +0x4E2A 0x7403 0x961F 0x0000 +---->uvarchar array[3]:(len=0) +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + +---->uvarchar array[0]:(len=15) +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 +---->uvarchar array[1]:(len=0) +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->uvarchar array[2]:(len=0) +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->uvarchar array[3]:(len=0) +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + + +test_array_2 : simple select using uvarchar array +count=1 for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +count=3 for '世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_3 : simple update using uvarchar array +find 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +find 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_4 : simple delete using uvarchar array +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 0 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_5 : simple insert using uvarchar array +found 2 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_6 : prepared select into uvarchar array +---->uvarchar array[0]:(len=15) +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 +---->uvarchar array[1]:(len=17) +0x8DB3 0x7403 0x7BEE 0x7403 0x7FBD 0x6BDB 0x7403 0x4E52 +0x4E53 0x7403 0x6A44 0x6984 0x7403 0x68D2 0x7403 0x51B0 +0x7403 0x0000 0x0000 0x0000 +---->uvarchar array[2]:(len=19) +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0x20C96 +0x4E2A 0x7403 0x961F 0x0000 +---->uvarchar array[3]:(len=0) +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + + +test_array_7 : prepared select using uvarchar array +count=1 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_8 : prepared update using uvarchar array +found 2 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_array_9 : prepared delete using uvarchar array +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_array_10 : prepared insert using uvarchar array +found 3 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_11 : Open cursor using uvarchar array +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_12 : Fecth cursor into uvarchar array +---->uvarchar array[0]:(len=15) +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 +---->uvarchar array[1]:(len=17) +0x8DB3 0x7403 0x7BEE 0x7403 0x7FBD 0x6BDB 0x7403 0x4E52 +0x4E53 0x7403 0x6A44 0x6984 0x7403 0x68D2 0x7403 0x51B0 +0x7403 0x0000 0x0000 0x0000 +---->uvarchar array[2]:(len=19) +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0x20C96 +0x4E2A 0x7403 0x961F 0x0000 +---->uvarchar array[3]:(len=0) +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + + +test_array_13 : Insert array with L string inited +---->uvarchar array[0]:(len=15) +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B 0x0000 +0x0000 0x0000 0x0000 0x0000 +---->uvarchar array[1]:(len=17) +0x8DB3 0x7403 0x7BEE 0x7403 0x7FBD 0x6BDB 0x7403 0x4E52 +0x4E53 0x7403 0x6A44 0x6984 0x7403 0x68D2 0x7403 0x51B0 +0x7403 0x0000 0x0000 0x0000 +---->uvarchar array[2]:(len=19) +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0x20C96 +0x4E2A 0x7403 0x961F 0x0000 +---->uvarchar array[3]:(len=0) +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + + +test_array_15 : Test uvarchar array working with NULL without using indicator +---->uvarchar variable,len=20: +0x0000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->uvarchar variable,len=20: +0x0000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->uvarchar variable,len=20: +0x0000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +found 6 rows for Item being NULL + +test_array_16 : Test uvarchar array working with NULL using indicator +---->uvarchar variable,len=20: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->uvarchar variable,len=20: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->uvarchar variable,len=20: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +uvarchar_var_ind = -1 +uvarchar_var_ind = -1 +uvarchar_var_ind = -1 +found 6 rows for Item being NULL diff --git a/src/interfaces/ecpg/test/unicode/readme.txt b/src/interfaces/ecpg/test/unicode/readme.txt new file mode 100644 index 0000000..9b8570d --- /dev/null +++ b/src/interfaces/ecpg/test/unicode/readme.txt @@ -0,0 +1 @@ +This test case is used to test the utext/uvarchar on linux platform for communtiy version. diff --git a/src/interfaces/ecpg/test/unicode/results/utext.ret b/src/interfaces/ecpg/test/unicode/results/utext.ret new file mode 100644 index 0000000..7e89f6d --- /dev/null +++ b/src/interfaces/ecpg/test/unicode/results/utext.ret @@ -0,0 +1,435 @@ +SQL error: + +test_var_1: simple select into utext var +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x00000000 0x00000000 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00004E9A 0x00006D32 0x00006B27 0x00006D32 0x0000975E 0x00006D32 0x00005927 0x00006D0B +0x00006D32 0x00005317 0x00007F8E 0x00006D32 0x00005357 0x00007F8E 0x00006D32 0x00005357 +0x00006781 0x00006D32 0x00006CA1 0x00006709 +======End utext_var content====== +utext_var_ind = 23 + +test_var_2: simple select using utext var +count=1 for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +count=3 for '世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_3: simple update using utext var +found 3 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_var_4 : simple delete using utext var +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 0 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_5 : simple insert using utext +found 2 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_6 : prepared select into utext var +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +======End utext_var content====== +======print utext_var content====== +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +======End utext_var content====== + +test_var_7 : prepared select using utext var +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_8 : prepared update using utext var +found 3 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_9 : prepared delete using utext var +found 0 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_10 : prepared insert using utext var +found 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_11 : Open cursor using utext var +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_12 : Fecth cursor into utext var +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +======End utext_var content====== + +test_var_13 : simple insert utext var with L string inited +======print utext_var_str content====== +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 +======End utext_var_str content====== +======print utext_var content====== +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +======End utext_var content====== +utext_var_ind = 0 + +test_var_14 : Open cursor using utext var directly in WHERE Clause +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_var_15 : Test utext_var working with NULL without indicator +======print utext_var content====== +0x00000000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +found 6 rows for Item being NULL + +test_var_16 : Test utext_var working with NULL with indicator +======print utext_var content====== +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +utext_var_ind = -1 +found 6 rows for Item being NULL + +test_array_1 : simple select into utext array +---->array[0]: +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +---->array[1]: +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x00000000 0x00000000 +---->array[2]: +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +---->array[3]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + +---->array[0]: +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +---->array[1]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[2]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[3]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + + +test_array_2 : simple select using array +count=1 for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +count=3 for '世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_3 : simple update using utext array +find 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +find 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_4 : simple delete using utext array +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 0 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_5 : simple insert using utext array +found 2 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 2 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_6 : prepared select SQL error: +into utext array +---->array[0]: +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +---->array[1]: +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x00000000 0x00000000 +---->array[2]: +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +---->array[3]: +0x00004E9A 0x00006D32 0x00006B27 0x00006D32 0x0000975E 0x00006D32 0x00005927 0x00006D0B +0x00006D32 0x00005317 0x00007F8E 0x00006D32 0x00005357 0x00007F8E 0x00006D32 0x00005357 +0x00006781 0x00006D32 0x00006CA1 0x00006709 + + +test_array_7 : prepared select using utext array +count=1 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_8 : prepared update using utext array +found 3 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_array_9 : prepared delete using utext array +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_array_10 : prepared insert using utext array +found 3 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_11 : Open cursor using utext array +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_12 : Fecth cursor into utext array +---->array[0]: +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +---->array[1]: +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x00000000 0x00000000 +---->array[2]: +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +---->array[3]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + + +test_array_13 : Insert array with L string inited +---->array[0]: +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +---->array[1]: +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x00000000 0x00000000 +---->array[2]: +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00000000 0x00000000 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 + + +test_array_14 : Open cursor using utext array directly in WHERE Clause +count=3 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_array_15 : Test utext array working with NULL without using indicator +---->array[0]: +0x00000000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[1]: +0x00000000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[2]: +0x00000000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + +found 6 rows for Item being NULL + +test_array_16 : Test utext array working with NULL using indicator +---->array[0]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[1]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +---->array[2]: +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 + +utext_var_ind = -1 +utext_var_ind = -1 +utext_var_ind = -1 +found 6 rows for Item being NULL + +test_pvar_1 : simple select into utext pointer +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 0x00000000 0x61616161 0x61616161 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +======End utext_var content====== +utext_var_ind = 0 +======print utext_var content====== +0x00004E9A 0x00006D32 0x00006B27 0x00006D32 0x0000975E 0x00006D32 0x00005927 0x00006D0B +0x00006D32 0x00005317 0x00007F8E 0x00006D32 0x00005357 0x00007F8E 0x00006D32 0x00005357 +0x00006781 0x00006D32 0x00006CA1 0x00006709 +======End utext_var content====== +utext_var_ind = 0 + +test_pvar_2 : simple select using utext pointer +count=1 for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +count=0 for '世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_3 : simple update using utext pointer +found 3 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' + +test_pvar_4 : simple delete using utext pointer +found 0 rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋' +found 1 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_5 : simple insert using utext pointer +found 1 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_6 : prepared select into utext pointer +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +======print utext_var content====== +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F 0x00000000 +======End utext_var content====== + +test_pvar_7 : prepared select using utext pointer +count=0 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_8 : prepared update using utext pointer +found 1 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_9 : prepared delete using utext pointer +found 1 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_10 : prepared insert using utext pointer +found 1 rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_11 : Open cursor using utext pointer +count=0 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_12 : Fecth cursor into utext pointer +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== + +test_pvar_13 : simple insert utext pointer with L string inited +======print utext_var content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B 0x00000000 +0x00000000 0x00000000 0x00000000 0x00000000 +======End utext_var content====== +utext_var_ind = 0 + +test_pvar_14 : Open cursor using utext var directly in WHERE Clause +count=0 for Item='世界杯每隔四年就会举行一次每次𠲖个球队' + +test_pvar_15 : Test utext pointer working with NULL without using indicator +======print utext_var content====== +0x00000000 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +found 6 rows for Item being NULL + +test_pvar_16 : Test utext pointer working with NULL using indicator +======print utext_var content====== +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 0x61616161 +0x61616161 0x61616161 0x61616161 0x61616161 +======End utext_var content====== +utext_var_ind = -1 +found 6 rows for Item being NULL + +test_pvar_17 : Test utext uninitialized pointer getting and setting data +======print utext_var_str content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B +======End utext_var_str content====== +Find Item = 太𠮷𠜱平洋𠱓大西洋印度洋北冰洋 where Count=18 + +test_pvar_18 : Test utext uninitialized pointer working with NULL without using indicator +======print utext_var content====== +0x00000000 +======End utext_var content====== +found 6 rows for Item being NULL + +test_pvar_19 : Test utext uninitialized pointer working with NULL using indicator +======print utext_var content====== +0x00000000 +======End utext_var content====== +utext_var_ind = -1 +found 6 rows for Item being NULL + +test_pp_var_1 : Test pointer to pointer utext_var without initialize +======print utext_var_str content====== +0x0000592A 0x00020BB7 0x00020731 0x00005E73 0x00006D0B 0x00020C53 0x00005927 0x0000897F +0x00006D0B 0x00005370 0x00005EA6 0x00006D0B 0x00005317 0x000051B0 0x00006D0B +======End utext_var_str content====== +utext_var_ind = 0 +======print utext_var_str content====== +0x00008DB3 0x00007403 0x00007BEE 0x00007403 0x00007FBD 0x00006BDB 0x00007403 0x00004E52 +0x00004E53 0x00007403 0x00006A44 0x00006984 0x00007403 0x000068D2 0x00007403 0x000051B0 +0x00007403 +======End utext_var_str content====== +utext_var_ind = 0 +======print utext_var_str content====== +0x00004E16 0x0000754C 0x0000676F 0x00006BCF 0x00009694 0x000056DB 0x00005E74 0x00005C31 +0x00004F1A 0x00004E3E 0x0000884C 0x00004E00 0x00006B21 0x00006BCF 0x00006B21 0x00020C96 +0x00004E2A 0x00007403 0x0000961F +======End utext_var_str content====== +utext_var_ind = 0 +足球篮球羽毛球乒乓球橄榄球棒球冰球 + +test_pp_var_2 : Test uninitialized pointer to pointer utext_var working with NULL without indicator +======print utext_var_str content====== + +======End utext_var_str content====== +======print utext_var_str content====== + +======End utext_var_str content====== +======print utext_var_str content====== + +======End utext_var_str content====== +found 6 rows for Item being NULL + +test_pp_var_2 : Test uninitialized pointer to pointer utext_var working with NULL without indicator +======print utext_var_str content====== + +======End utext_var_str content====== +utext_var_ind = -1 +======print utext_var_str content====== + +======End utext_var_str content====== +utext_var_ind = -1 +======print utext_var_str content====== + +======End utext_var_str content====== +utext_var_ind = -1 +found 6 rows for Item being NULL diff --git a/src/interfaces/ecpg/test/unicode/results/utext_nor.ret b/src/interfaces/ecpg/test/unicode/results/utext_nor.ret new file mode 100644 index 0000000..e6ee570 --- /dev/null +++ b/src/interfaces/ecpg/test/unicode/results/utext_nor.ret @@ -0,0 +1 @@ +./utext_nor.sh: line 10: utext: command not found diff --git a/src/interfaces/ecpg/test/unicode/results/utext_with_no_indicator.ret b/src/interfaces/ecpg/test/unicode/results/utext_with_no_indicator.ret new file mode 100644 index 0000000..12913ef --- /dev/null +++ b/src/interfaces/ecpg/test/unicode/results/utext_with_no_indicator.ret @@ -0,0 +1 @@ +./utext.sh: line 12: utext: command not found diff --git a/src/interfaces/ecpg/test/unicode/unicode.pgc b/src/interfaces/ecpg/test/unicode/unicode.pgc new file mode 100755 index 0000000..bf9a177 --- /dev/null +++ b/src/interfaces/ecpg/test/unicode/unicode.pgc @@ -0,0 +1,246 @@ +#include + +EXEC SQL INCLUDE ../regression; + +void print_utext(char *var_name, utext *utext_var, int var_size); +void print_utext_array(char *var_name, utext *utext_var, int var_size, int index); +void print_nchar(char *utext_var, int var_size); + +#define print_ret print_utext("employee",employee,40); \ +print_utext("address", address.arr, address.len) + +EXEC SQL BEGIN DECLARE SECTION; +char char_ename[3][40] = {"test ok","测试 通过","太𠮷𠜱"}; + +char employee_1[40]= "test ok"; +char employee_2[40]= "测试 通过"; +char employee_3[40]= "太𠮷𠜱"; + +char char_addr[3][40] = {"1 sydney, NSW","澳大利亚悉尼1号","世界杯"}; + +char address_1[40]="1 sydney, NSW"; +char address_2[40]="澳大利亚悉尼1号"; +char address_3[40]="世界杯"; +EXEC SQL END DECLARE SECTION; + +void print_utext(char *var_name, utext *utext_var, int var_size) +{ + int i; + printf("======print %s content======\n",var_name); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n"); +} + +void print_utext_array(char *var_name, utext *utext_var, int var_size, int index) +{ + int i; + printf("======print %s[%d] content======\n",var_name,index); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n"); +} + +void print_nchar(char *utext_var, int var_size) +{ + printf("nchar is : %s\n",utext_var); + int i; + printf("======print utext_var content======\n"); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n======End utext_var content======\n"); +} + +void create_table() +{ + EXEC SQL CREATE TABLE IF NOT EXISTS emp (id int, ename CHAR(20), address nvarchar(50)); + EXEC SQL TRUNCATE TABLE emp; + + EXEC SQL CREATE TABLE IF NOT EXISTS emp_bk (id int, ename CHAR(20), address nvarchar(50)); + EXEC SQL TRUNCATE TABLE emp_bk; +} + +void init_table() +{ + /* UTF8 is the database character set */ + EXEC SQL INSERT INTO emp (id,ename,address) VALUES (1, 'test ok', '1 sydney, NSW') ; + EXEC SQL INSERT INTO emp (id,ename,address) VALUES (2, '测试 通过', '澳大利亚悉尼1号') ; + EXEC SQL INSERT INTO emp (id,ename,address) VALUES (3, '太𠮷𠜱', '世界杯') ; +} + +/* + Test utext host variable +*/ +void testcase1() +{ + EXEC SQL BEGIN DECLARE SECTION; + int total_tuples = 0; + int i = 0; + int id = 0; + int id2 = 0; + utext employee[41]; /* define Unicode host variable */ + uvarchar address[101] ; /* define a variable length Unicode host variable */ + EXEC SQL END DECLARE SECTION; + + printf("\n**************Start testcase(%d)**************\n",1); + + memset(employee,'a',sizeof(employee)); + memset((void*)&address,'a',sizeof(address)); + address.len = 0; + + EXEC SQL TRUNCATE emp_bk; + + for(i=1;i<=3;i++) + { + /* Database character set converted to Unicode */ + EXEC SQL SELECT ename,address INTO :employee, :address FROM emp where id =:i; + print_ret; + /* Unicode converted to Database character */ + EXEC SQL INSERT INTO emp_bk (id,ename,address) VALUES (:i,:employee, :address); + } + + EXEC SQL SELECT count(*) into :total_tuples from emp_bk; + printf("total_tuples = %d in emp_bk\n",total_tuples); + + + for(i=3;i>0;i--) + { + EXEC SQL SELECT ename,address INTO :employee, :address FROM emp where id =:i; + EXEC SQL SELECT id into :id from emp_bk WHERE ename=:employee and address = :address; + EXEC SQL SELECT id into :id2 from emp_bk WHERE ename=:char_ename[i-1] and address=:char_addr[i-1]; + printf("id[%d] = id2[%d] in emp_bk\n",id,id2); + } +} + +/* + Test utext array +*/ +void testcase2() +{ + EXEC SQL BEGIN DECLARE SECTION; + int total_tuples = 0; + int i = 0; + int j = 0; + int id = 0; + int id2 = 0; + utext employee_array[3][41]; /* define Unicode host variable */ + uvarchar address_array[3][101] ; /* define a variable length Unicode host variable */ + EXEC SQL END DECLARE SECTION; + + printf("\n**************Start testcase(%d)**************\n",2); + + memset(employee_array,'a',sizeof(employee_array)); + + for(i=0;i<3;i++) + { + memset((void*)&address_array[i],'a',sizeof(address_array[0])); + address_array[i].len=0; + } + + + EXEC SQL TRUNCATE emp_bk; + + /* Database character set converted to Unicode */ + EXEC SQL SELECT ename,address INTO :employee_array, :address_array FROM emp; + + for(i=1;i<=3;i++) + { + print_utext_array("employee_array",employee_array[i-1],40,i-1); + print_utext_array("address_array",address_array[i-1].arr,address_array[i-1].len,i-1); + /* Unicode converted to Database character */ + EXEC SQL INSERT INTO emp_bk (id,ename,address) VALUES (:i,:employee_array[i-1], :address_array[i-1]); + } + + EXEC SQL SELECT count(*) into :total_tuples from emp_bk; + printf("total_tuples = %d in emp_bk\n",total_tuples); + + + EXEC SQL SELECT ename,address INTO :employee_array, :address_array FROM emp; + for(i=3;i>0;i--) + { + EXEC SQL SELECT id into :id from emp_bk WHERE ename=:employee_array[i-1] and address = :address_array[i-1]; + EXEC SQL SELECT id into :id2 from emp_bk WHERE ename=:char_ename[i-1] and address=:char_addr[i-1]; + printf("id[%d] = id2[%d] in emp_bk\n",id,id2); + } +} + + +/* + Test utext pointer +*/ +void testcase3() +{ + EXEC SQL BEGIN DECLARE SECTION; + int total_tuples = 0; + int i = 0; + int id = 0; + int id2 = 0; + utext *employee; /* define Unicode host variable */ + int employee_len = 82; + uvarchar address[101] ; /* define a variable length Unicode host variable */ + EXEC SQL END DECLARE SECTION; + + + printf("\n**************Start testcase(%d)**************\n",3); + + employee = malloc(employee_len); + + memset(employee,'a',employee_len); + memset((void*)&address,'a',sizeof(address)); + address.len = 0; + + EXEC SQL TRUNCATE emp_bk; + + for(i=1;i<=3;i++) + { + /* Database character set converted to Unicode */ + EXEC SQL SELECT ename,address INTO :employee, :address FROM emp where id =:i; + print_ret; + /* Unicode converted to Database character */ + EXEC SQL INSERT INTO emp_bk (id,ename,address) VALUES (:i,:employee, :address); + } + + EXEC SQL SELECT count(*) into :total_tuples from emp_bk; + printf("total_tuples = %d in emp_bk\n",total_tuples); + + + for(i=3;i>0;i--) + { + EXEC SQL SELECT ename,address INTO :employee, :address FROM emp where id =:i; + EXEC SQL SELECT id into :id from emp_bk WHERE ename=:employee and address = :address; + EXEC SQL SELECT id into :id2 from emp_bk WHERE ename=:char_ename[i-1] and address=:char_addr[i-1]; + printf("id[%d] = id2[%d] in emp_bk\n",id,id2); + } +} + +int main() { + EXEC SQL CONNECT TO REGRESSDB1; + + EXEC SQL SET AUTOCOMMIT TO ON; + EXEC SQL WHENEVER SQLWARNING SQLPRINT; + EXEC SQL WHENEVER SQLERROR SQLPRINT; + create_table(); + init_table(); + + testcase1(); + testcase2(); + testcase3(); + + EXEC SQL DISCONNECT; + return 0; +} + + + diff --git a/src/interfaces/ecpg/test/unicode/unicode.sh b/src/interfaces/ecpg/test/unicode/unicode.sh new file mode 100755 index 0000000..c8eaa87 --- /dev/null +++ b/src/interfaces/ecpg/test/unicode/unicode.sh @@ -0,0 +1,8 @@ +echo "../../preproc/ecpg --regression --enable-utext -I./../../include -I. -o unicode.c unicode.pgc" + +../../preproc/ecpg --regression --enable-utext -I./../../include -I. -o unicode.c unicode.pgc + +gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O0 -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -I../../include -I../../../../../src/interfaces/ecpg/include -I../../../../../src/interfaces/libpq -I../../../../../src/include -DLINUX_OOM_SCORE_ADJ=0 -DLINUX_OOM_ADJ=0 -D_GNU_SOURCE -I/db/fep95ae/OUT/libxml2/64/include/libxml2 -I/db/fep95ae/SRC/pclmods/pclmods_rhel7_64/include -I/db/fep95ae/OUT/libedit/64/include -I/db/fep95ae/OUT/OpenLDAP/64/include -I/db/fep95ae/OUT/UUID/64/include -I/db/fep95ae/OUT/libxml2/64/include -I/db/fep95ae/OUT/libxslt/64/include -I/db/fep95ae/OUT/OpenSSL/64/include -I/db/fep95ae/OUT/Kerberos5/64/include -g -c -o unicode.o unicode.c +gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O0 -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS unicode.o -L../../ecpglib -L../../pgtypeslib -L../../../../../src/interfaces/libpq -L../../../../../src/port -L../../../../../src/common -L/db/fep95ae/OUT/libxml2/64/lib -L/db/fep95ae/SRC/pclmods/pclmods_rhel7_64/lib -L/db/fep95ae/OUT/libedit/64/lib -L/db/fep95ae/OUT/OpenLDAP/64/lib -L/db/fep95ae/OUT/UUID/64/lib -L/db/fep95ae/OUT/libxml2/64/lib -L/db/fep95ae/OUT/libxslt/64/lib -L/db/fep95ae/OUT/OpenSSL/64/lib -L/db/fep95ae/OUT/Kerberos5/64/lib -Wl,--as-needed -Wl,-rpath,'/db/fep95ae/TMP/postgres/lib',--enable-new-dtags -lecpg -lpgtypes -lpq -lpgcommon -lpgport -lselinux -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lz -ledit -lrt -lcrypt -ldl -lm -g -o unicode + + diff --git a/src/interfaces/ecpg/test/unicode/utext.pgc b/src/interfaces/ecpg/test/unicode/utext.pgc new file mode 100755 index 0000000..411de30 --- /dev/null +++ b/src/interfaces/ecpg/test/unicode/utext.pgc @@ -0,0 +1,1477 @@ +#include +#include +#include +#include +EXEC SQL INCLUDE ../regression; + +#define test(msg) printf("\n%s\n",msg) +#define VAR_SIZE 20 +#define ARRAY_SIZE 4 +#define P_VAR_SIZE 22 + + +/* Following is UTF8 and UTF16/UTF32 characters mapping table */ +/*太𠮷𠜱平洋𠱓大西洋印度洋北冰洋 +utf16 +0x592A 0xD842 0xDFB7 0xD841 0xDF31 0x5E73 0x6D0B 0xD843 +0xDC53 0x5927 0x897F 0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 +0x51B0 0x6D0B 0x0000,0x0000 + +utf32 +0x592A 0x20BB7 0x20731 0x5E73 0x6D0B 0x20C53 0x5927 0x897F +0x6D0B 0x5370 0x5EA6 0x6D0B 0x5317 0x51B0 0x6D0B +*/ + +/*足球篮球羽毛球乒乓球橄榄球棒球冰球 +utf16 +0x8DB3,0x7403,0x7BEE,0x7403,0x7FBD,0x6BDB,0x7403,0x4E52, +0x4E53,0x7403,0x6A44,0x6984,0x7403,0x68D2,0x7403,0x51B0, +0x7403,0x0000,0x0000,0x0000 + +utf32 +0x8DB3 0x7403 0x7BEE 0x7403 0x7FBD 0x6BDB 0x7403 0x4E52 +0x4E53 0x7403 0x6A44 0x6984 0x7403 0x68D2 0x7403 0x51B0 +0x7403 +*/ + +/*世界杯每隔四年就会举行一次每次𠲖个球队 +utf16 +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0xD843 +0xDC96 0x4E2A 0x7403 0x961F + +utf32 +0x4E16 0x754C 0x676F 0x6BCF 0x9694 0x56DB 0x5E74 0x5C31 +0x4F1A 0x4E3E 0x884C 0x4E00 0x6B21 0x6BCF 0x6B21 0x20C96 +0x4E2A 0x7403 0x961F +*/ + +/* 亚洲欧洲非洲大洋洲北美洲南美洲南极洲没有北极洲 +0x4E9A,0x6D32,0x6B27,0x6D32,0x975E,0x6D32,0x5927,0x6D0B, +0x6D32,0x5317,0x7F8E,0x6D32,0x5357,0x7F8E,0x6D32,0x5357, +0x6781,0x6D32,0x6CA1,0x6709,0x5317,0x6781,0x6D32 +*/ +/* 太𠮷 +0x592A 0xD842 0xDFB7 +*/ +void init_var(void); +void test_var_1(void); +void test_var_2(void); +void test_var_3(void); +void test_var_4(void); +void test_var_5(void); +void test_var_6(void); +void test_var_7(void); +void test_var_8(void); +void test_var_9(void); +void test_var_10(void); +void test_var_11(void); +void test_var_12(void); +void test_var_13(void); +void test_var_14(void); +void test_var_15(void); +void test_var_16(void); +void test_array_1(void); +void test_array_2(void); +void test_array_3(void); +void test_array_4(void); +void test_array_5(void); +void test_array_6(void); +void test_array_7(void); +void test_array_8(void); +void test_array_9(void); +void test_array_10(void); +void test_array_11(void); +void test_array_12(void); +void test_array_13(void); +void test_array_14(void); +void test_array_15(void); +void test_array_16(void); +void test_pvar_1(void); +void test_pvar_2(void); +void test_pvar_3(void); +void test_pvar_4(void); +void test_pvar_5(void); +void test_pvar_6(void); +void test_pvar_7(void); +void test_pvar_8(void); +void test_pvar_9(void); +void test_pvar_10(void); +void test_pvar_11(void); +void test_pvar_12(void); +void test_pvar_13(void); +void test_pvar_14(void); +void test_pvar_15(void); +void test_pvar_16(void); +void test_pvar_17(void); +void test_pvar_18(void); +void test_pvar_19(void); +void test_pp_var_1(void); +void test_pp_var_2(void); +void test_pp_var_3(void); +void test_desc_1(void); +void test_all(void); + +void print_utext(utext *utext_var); +void print_utext_str(utext *utext_var); +void print_utext_ind(int utext_var_ind); +void print_utext_size(utext *utext_var,int size); +void print_array(void *array, int array_size, int var_size); +void print_array_with_index(int index); +int test_init(void); +void test_finish(void); +void init_table_value(void); + +EXEC SQL BEGIN DECLARE SECTION; + int utext_var_size = 20; + int utext_array_size = 4; + int count=0; + int total_tuples = 0; + int i; + char char_var[10]={0xF0,0x90,0x90,0xB7}; + + utext utext_var[VAR_SIZE]; + utext utext_array[ARRAY_SIZE][VAR_SIZE]; + utext utext_input_var[20]={0x592a,0xd842, 0xdfb7, 0x0000}; + utext *p_utext_var = NULL; + + + int utext_var_ind; + int count_array[4]={1,2,3,4}; + +EXEC SQL END DECLARE SECTION; + +void print_utext(utext *utext_var) +{ + int i; + printf("======print utext_var content======\n"); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n======End utext_var content======\n"); +} + +void print_utext_str(utext *utext_var) +{ + int i=0; + printf("======print utext_var_str content======\n"); + if (utext_var==0) + { + printf("utext_var is NULL\n"); + printf("\n======End utext_var_str content======\n"); + return; + } + while(utext_var[i] != 0) + { + printf ("0x%08X ", utext_var[i]); + if(i>6 && (i+1)%8==0) + printf("\n"); + i++; + if(i>100) + break; + } + printf("\n======End utext_var_str content======\n"); +} + +void print_utext_size(utext *utext_var,int size) +{ + int i; + printf("======print utext_var content======\n"); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n======End utext_var content======\n"); +} + +void print_utext_ind(int utext_var_ind) +{ + printf("utext_var_ind = %d\n",utext_var_ind); +} +void print_array(void *array, int array_size, int var_size) +{ + int i,j; + + for(i=0; iarray[%d]:\n", i); + + for(j=0; j6 && (j+1)%8==0) + printf("\n"); + } + printf("\n"); + } + + printf("\n"); +} + +int test_init() +{ + p_utext_var = (utext*)malloc(P_VAR_SIZE*sizeof(utext)); + if(!p_utext_var) + { + printf("Error: failed allco memory for p_utext_var. \n"); + return -1; + } + + EXEC SQL CONNECT TO REGRESSDB1; + + EXEC SQL SET AUTOCOMMIT TO ON; + EXEC SQL WHENEVER SQLWARNING SQLPRINT; + EXEC SQL WHENEVER SQLERROR SQLPRINT; + + EXEC SQL SET client_encoding='UTF8'; + + //initialization of test table + EXEC SQL CREATE TABLE IF NOT EXISTS tb1 (Item varchar, Count integer); + + init_table_value(); + + return 0; +} + +void test_finish() +{ + EXEC SQL DROP TABLE tb1; + EXEC SQL DISCONNECT ALL; +} + +void init_table_value() +{ + EXEC SQL TRUNCATE tb1; + + EXEC SQL INSERT INTO tb1 VALUES ('太𠮷𠜱平洋𠱓大西洋印度洋北冰洋', 1); + EXEC SQL INSERT INTO tb1 VALUES ('足球篮球羽毛球乒乓球橄榄球棒球冰球', 2); + EXEC SQL INSERT INTO tb1 VALUES ('世界杯每隔四年就会举行一次每次𠲖个球队', 3); + EXEC SQL INSERT INTO tb1 VALUES ('亚洲欧洲非洲大洋洲北美洲南美洲南极洲没有北极洲', 4); + EXEC SQL INSERT INTO tb1 (Count) VALUES(8); + EXEC SQL INSERT INTO tb1 (Count) VALUES(9); + EXEC SQL INSERT INTO tb1 (Count) VALUES(10); +} + +void init_var() +{ + count = 0; + memset(utext_var,'a',sizeof(utext_var)); + memset(utext_array,'a',sizeof(utext_array)); + memset(p_utext_var,'a',P_VAR_SIZE*sizeof(utext)); +} + +//simple select into utext var +void test_var_1() +{ + test("test_var_1: simple select into utext var"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var:utext_var_ind FROM tb1 WHERE Count=1; + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var:utext_var_ind FROM tb1 WHERE Count=2; + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var:utext_var_ind FROM tb1 WHERE Count=3; + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var:utext_var_ind FROM tb1 WHERE Count=4; + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); +} + + +//simple select using utext var +void test_var_2() +{ + test("test_var_2: simple select using utext var"); + init_var(); + + count = 0; + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=1; + EXEC SQL SELECT Count INTO :count FROM tb1 WHERE Item=:utext_var; + printf ("count=%d for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + count = 0; + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=3; + EXEC SQL SELECT Count INTO :count FROM tb1 WHERE Item=:utext_var; + printf ("count=%d for '世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); +} + +//simple update using utext var +void test_var_3() +{ + test("test_var_3: simple update using utext var"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=1; + EXEC SQL UPDATE tb1 SET Item=:utext_var WHERE Count=2; + EXEC SQL UPDATE tb1 SET Item=:utext_var WHERE Count=3; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_table_value(); +} + +//simple delete using utext var +void test_var_4() +{ + test("test_var_4 : simple delete using utext var"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=1; + EXEC SQL DELETE FROM tb1 WHERE Item=:utext_var; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=3; + EXEC SQL DELETE FROM tb1 WHERE Item=:utext_var; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//simple insert using utext var +void test_var_5() +{ + test("test_var_5 : simple insert using utext"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=1; + EXEC SQL INSERT INTO tb1 values (:utext_var, 11); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_var(); + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=3; + EXEC SQL INSERT INTO tb1 values (:utext_var, 13); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//prepared select into utext var +void test_var_6() +{ + test("test_var_6 : prepared select into utext var"); + init_var(); + + EXEC SQL PREPARE stmt FROM "SELECT Item FROM tb1 WHERE Count=?"; + + EXEC SQL EXECUTE stmt INTO :utext_var USING 1; + print_utext(utext_var); + + EXEC SQL EXECUTE stmt INTO :utext_var USING 3; + print_utext(utext_var); + + EXEC SQL DEALLOCATE PREPARE stmt; +} + +//prepared select using utext var +void test_var_7() +{ + test("test_var_7 : prepared select using utext var"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "SELECT Count FROM tb1 WHERE Item=?"; + EXEC SQL EXECUTE stmt INTO :count USING :utext_var; + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; +} + +//prepared update using utext var +void test_var_8() +{ + test("test_var_8 : prepared update using utext var"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "UPDATE tb1 SET Item=? WHERE Count=?"; + EXEC SQL EXECUTE stmt USING :utext_var, 1; + EXEC SQL EXECUTE stmt USING :utext_var, 2; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//prepared delete using utext var +void test_var_9() +{ + test("test_var_9 : prepared delete using utext var"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "DELETE FROM tb1 WHERE Item=?"; + EXEC SQL EXECUTE stmt USING :utext_var; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//prepared insert using utext var +void test_var_10() +{ + test("test_var_10 : prepared insert using utext var"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "INSERT INTO tb1 values (?, 13)"; + EXEC SQL EXECUTE stmt USING :utext_var; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//Open cursor using utext var +void test_var_11() +{ + test("test_var_11 : Open cursor using utext var"); + init_var(); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL SELECT Item INTO :utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "SELECT Count FROM tb1 WHERE Item=?"; + EXEC SQL DECLARE cursor_var_11 CURSOR FOR stmt; + EXEC SQL OPEN cursor_var_11 USING :utext_var; + EXEC SQL FETCH cursor_var_11 INTO :count; + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL CLOSE cursor_var_11; + EXEC SQL DEALLOCATE PREPARE stmt; + EXEC SQL SET AUTOCOMMIT TO ON; +} + +//Fecth cursor into utext var +void test_var_12() +{ + test("test_var_12 : Fecth cursor into utext var"); + init_var(); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL PREPARE stmt FROM "SELECT Item FROM tb1 WHERE Count=1"; + EXEC SQL DECLARE cursor_var_12 CURSOR FOR stmt; + EXEC SQL OPEN cursor_var_12; + EXEC SQL FETCH cursor_var_12 INTO :utext_var; + EXEC SQL CLOSE cursor_var_12; + + print_utext(utext_var); + + EXEC SQL DEALLOCATE PREPARE stmt; + EXEC SQL SET AUTOCOMMIT TO ON; +} + +//simple insert utext var with L string inited +void test_var_13() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext utext_local_var[]=L"足球篮球羽毛球"; +EXEC SQL END DECLARE SECTION; + test("test_var_13 : simple insert utext var with L string inited"); + init_var(); + + print_utext_str(utext_local_var); + + EXEC SQL INSERT INTO tb1 values (:utext_local_var, 16); + + EXEC SQL SELECT Item INTO :utext_var:utext_var_ind FROM tb1 WHERE Count=16; + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + init_table_value(); +} + +//Open cursor using utext var directly in WHERE Clause +void test_var_14() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext utext_local_var[20+1]; +EXEC SQL END DECLARE SECTION; + memset(utext_local_var,'a',sizeof(utext_local_var)); + + test("test_var_14 : Open cursor using utext var directly in WHERE Clause"); + init_var(); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL SELECT Item INTO :utext_local_var FROM tb1 WHERE Count=3; + EXEC SQL DECLARE cursor_var_14 CURSOR FOR SELECT Count FROM tb1 WHERE Item=:utext_local_var; + EXEC SQL OPEN cursor_var_14; + EXEC SQL FETCH cursor_var_14 INTO :count; + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + EXEC SQL CLOSE cursor_var_14; + + EXEC SQL SET AUTOCOMMIT TO ON; +} + +//Test utext_var working with NULL without indicator +void test_var_15() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext utext_local_var[20+1]; +EXEC SQL END DECLARE SECTION; + test("test_var_15 : Test utext_var working with NULL without indicator"); + + memset(utext_local_var,'a',sizeof(utext_local_var)); + EXEC SQL SELECT Item INTO :utext_local_var FROM tb1 WHERE Count=8; + print_utext(utext_local_var); + + memset(utext_local_var,0x00,sizeof(utext_local_var)); + EXEC SQL INSERT INTO tb1 values (:utext_local_var, 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_var, 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_var, 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//utext_var working with NULL with indicator +void test_var_16() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext utext_local_var[20+1]; + int utext_var_ind=-1; +EXEC SQL END DECLARE SECTION; + test("test_var_16 : Test utext_var working with NULL with indicator"); + + memset(utext_local_var,'a',sizeof(utext_local_var)); + EXEC SQL SELECT Item INTO :utext_local_var:utext_var_ind FROM tb1 WHERE Count=8; + print_utext(utext_local_var); + print_utext_ind(utext_var_ind); + + memset(utext_local_var,0x00,sizeof(utext_local_var)); + EXEC SQL INSERT INTO tb1 values (:utext_local_var:utext_var_ind, 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_var:utext_var_ind, 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_var:utext_var_ind, 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + + +//simple select into utext array +void test_array_1() +{ + test("test_array_1 : simple select into utext array "); + init_var(); + + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + print_array(utext_array,ARRAY_SIZE,VAR_SIZE); + init_var(); + + EXEC SQL SELECT Item INTO :utext_array[0] FROM tb1 WHERE Count=1; + print_array(utext_array,ARRAY_SIZE,VAR_SIZE); + init_var(); +} + +//simple select using utext array +void test_array_2() +{ + test("test_array_2 : simple select using array"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + count = 0; + EXEC SQL SELECT Count INTO :count FROM tb1 WHERE Item=:utext_array[0]; + printf ("count=%d for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + count = 0; + EXEC SQL SELECT Count INTO :count FROM tb1 WHERE Item=:utext_array[2]; + printf ("count=%d for '世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); +} + +//simple update using utext array +void test_array_3() +{ + test("test_array_3 : simple update using utext array"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + EXEC SQL UPDATE tb1 SET Item=:utext_array[2] WHERE Count=1; + + count = 0; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + printf ("find %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + count = 0; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + printf ("find %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//simple delete using utext array +void test_array_4() +{ + test("test_array_4 : simple delete using utext array"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + count = 100; + EXEC SQL DELETE FROM tb1 WHERE Item=:utext_array[0]; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + count = 100; + EXEC SQL DELETE FROM tb1 WHERE Item=:utext_array[2]; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//simple insert using utext array +void test_array_5() +{ + test("test_array_5 : simple insert using utext array"); + init_var(); + + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + EXEC SQL INSERT INTO tb1 values (:utext_array[0], 11); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + EXEC SQL INSERT INTO tb1 values (:utext_array[2], 13); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//prepared select into utext array +void test_array_6() +{ + test("test_array_6 : prepared select into utext array"); + init_var(); + + EXEC SQL PREPARE stmt FROM "SELECT Item FROM tb1 WHERE Count<=?"; + + EXEC SQL EXECUTE stmt INTO :utext_array USING 4; + + print_array(utext_array,ARRAY_SIZE,VAR_SIZE); + + EXEC SQL DEALLOCATE PREPARE stmt; +} + +//prepared select using utext array +void test_array_7() +{ + test("test_array_7 : prepared select using utext array"); + init_var(); + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + count = 0; + EXEC SQL PREPARE stmt FROM "SELECT Count FROM tb1 WHERE Item=?"; + EXEC SQL EXECUTE stmt INTO :count USING :utext_array[0]; + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; +} + +//prepared update using utext array +void test_array_8() +{ + test("test_array_8 : prepared update using utext array"); + init_var(); + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + EXEC SQL PREPARE stmt FROM "UPDATE tb1 SET Item=? WHERE Count=?"; + EXEC SQL EXECUTE stmt USING :utext_array[0], 2; + EXEC SQL EXECUTE stmt USING :utext_array[0], 3; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//prepared delete using utext array +void test_array_9() +{ + test("test_array_9 : prepared delete using utext array"); + init_var(); + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + count = 0; + EXEC SQL PREPARE stmt FROM "DELETE FROM tb1 WHERE Item=?"; + EXEC SQL EXECUTE stmt USING :utext_array[0]; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//prepared insert using utext array +void test_array_10() +{ + test("test_array_10 : prepared insert using utext array"); + init_var(); + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + EXEC SQL PREPARE stmt FROM "INSERT INTO tb1 values (?, ?)"; + EXEC SQL EXECUTE stmt USING :utext_array[2], 13; + EXEC SQL EXECUTE stmt USING :utext_array[2], 15; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//Open cursor using utext array +void test_array_11() +{ + test("test_array_11 : Open cursor using utext array"); + init_var(); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=3; + + EXEC SQL PREPARE stmt FROM "SELECT Count FROM tb1 WHERE Item=?"; + EXEC SQL DECLARE cursor_array_11 CURSOR FOR stmt; + EXEC SQL OPEN cursor_array_11 USING :utext_array[2]; + EXEC SQL FETCH cursor_array_11 INTO :count; + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL CLOSE cursor_array_11; + EXEC SQL DEALLOCATE PREPARE stmt; + EXEC SQL SET AUTOCOMMIT TO ON; +} + +//Fecth cursor into utext array +void test_array_12() +{ + test("test_array_12 : Fecth cursor into utext array"); + init_var(); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL PREPARE stmt FROM "SELECT Item FROM tb1 WHERE Count<=3"; + EXEC SQL DECLARE cursor_array_12 CURSOR FOR stmt; + EXEC SQL OPEN cursor_array_12; + EXEC SQL FETCH cursor_array_12 INTO :utext_array[0]; + EXEC SQL FETCH cursor_array_12 INTO :utext_array[1]; + EXEC SQL FETCH cursor_array_12 INTO :utext_array[2]; + EXEC SQL CLOSE cursor_array_12; + + print_array(utext_array,ARRAY_SIZE,VAR_SIZE); + + EXEC SQL DEALLOCATE PREPARE stmt; + EXEC SQL SET AUTOCOMMIT TO ON; +} + +//Insert array with L string inited +void test_array_13() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext utext_array13[4][VAR_SIZE]={L"太𠮷𠜱平洋𠱓大西洋印度洋北冰洋",L"足球篮球羽毛球乒乓球橄榄球棒球冰球",L"世界杯每隔四年就会举行一次"}; +EXEC SQL END DECLARE SECTION; + + test("test_array_13 : Insert array with L string inited"); + init_var(); + + + EXEC SQL INSERT INTO tb1 values (:utext_array13[0], 20); + EXEC SQL INSERT INTO tb1 values (:utext_array13[1], 21); + EXEC SQL INSERT INTO tb1 values (:utext_array13[2], 22); + + init_var(); + EXEC SQL SELECT Item INTO :utext_array FROM tb1 WHERE Count<=22 AND Count>=20; + print_array(utext_array,3,VAR_SIZE); + init_table_value(); +} + +//Open cursor using utext array directly in WHERE Clause +void test_array_14() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext utext_local_array[4][20+1]; +EXEC SQL END DECLARE SECTION; + + test("test_array_14 : Open cursor using utext array directly in WHERE Clause"); + memset(utext_local_array,'a',sizeof(utext_local_array)); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL SELECT Item INTO :utext_local_array FROM tb1 WHERE Count<=3; + + EXEC SQL DECLARE cursor_array_14 CURSOR FOR SELECT Count FROM tb1 WHERE Item=:utext_local_array[2]; + EXEC SQL OPEN cursor_array_14; + EXEC SQL FETCH cursor_array_14 INTO :count; + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL CLOSE cursor_array_14; + + EXEC SQL SET AUTOCOMMIT TO ON; +} + + +//utext array working with NULL without using indicator +void test_array_15() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext utext_local_array[3][20]; +EXEC SQL END DECLARE SECTION; + test("test_array_15 : Test utext array working with NULL without using indicator"); + memset(utext_local_array,'a',sizeof(utext_local_array)); + + EXEC SQL SELECT Item INTO :utext_local_array FROM tb1 WHERE Count>=8 and Count<=10; + + print_array((void**)utext_local_array,3,20); + + memset(utext_local_array,0x00,sizeof(utext_local_array)); + EXEC SQL INSERT INTO tb1 values (:utext_local_array[0], 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_array[1], 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_array[2], 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//utext array working with NULL using indicator +void test_array_16() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext utext_local_array[3][20]; + int utext_array_ind[3]; +EXEC SQL END DECLARE SECTION; + test("test_array_16 : Test utext array working with NULL using indicator"); + memset(utext_local_array,'a',sizeof(utext_local_array)); + + EXEC SQL SELECT Item INTO :utext_local_array:utext_array_ind FROM tb1 WHERE Count>=8 and Count<=10; + + print_array((void**)utext_local_array,3,20); + print_utext_ind(utext_array_ind[0]); + print_utext_ind(utext_array_ind[1]); + print_utext_ind(utext_array_ind[2]); + + memset(utext_local_array,0x00,sizeof(utext_local_array)); + utext_array_ind[0]=-1; + utext_array_ind[1]=-1; + utext_array_ind[2]=-1; + EXEC SQL INSERT INTO tb1 values (:utext_local_array[0]:utext_array_ind[0], 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_array[1]:utext_array_ind[1], 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_array[2]:utext_array_ind[2], 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + + +//simple select into utext pointer +void test_pvar_1() +{ + test("test_pvar_1 : simple select into utext pointer"); + EXEC SQL SELECT Item INTO :p_utext_var:utext_var_ind FROM tb1 WHERE Count=1; + print_utext(p_utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var:utext_var_ind FROM tb1 WHERE Count=2; + print_utext(p_utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var:utext_var_ind FROM tb1 WHERE Count=3; + print_utext(p_utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var:utext_var_ind FROM tb1 WHERE Count=4; + print_utext(p_utext_var); + print_utext_ind(utext_var_ind); + init_var(); + + init_table_value(); +} + + +//simple select using utext pointer +void test_pvar_2() +{ + test("test_pvar_2 : simple select using utext pointer"); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=1; + EXEC SQL SELECT Count INTO :count FROM tb1 WHERE Item=:p_utext_var; + printf ("count=%d for '太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_var(); + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=3; + EXEC SQL SELECT Count INTO :count FROM tb1 WHERE Item=:p_utext_var; + printf ("count=%d for '世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); +} + + +//simple update using utext pointer +void test_pvar_3() +{ + test("test_pvar_3 : simple update using utext pointer"); + init_var(); + + count = 0; + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=1; + EXEC SQL UPDATE tb1 SET Item=:p_utext_var WHERE Count=2; + EXEC SQL UPDATE tb1 SET Item=:p_utext_var WHERE Count=3; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_table_value(); +} + +//simple delete using utext pointer +void test_pvar_4() +{ + test("test_pvar_4 : simple delete using utext pointer"); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=1; + EXEC SQL DELETE FROM tb1 WHERE Item=:p_utext_var; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'; + printf ("found %d rows for Item='太𠮷𠜱平洋𠱓大西洋印度洋北冰洋'\n", count); + + init_var(); + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=3; + EXEC SQL DELETE FROM tb1 WHERE Item=:p_utext_var; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//simple insert using utext pointer +void test_pvar_5() +{ + test("test_pvar_5 : simple insert using utext pointer"); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=3; + EXEC SQL INSERT INTO tb1 values (:p_utext_var, 13); + + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + + init_table_value(); +} + +//prepared select into utext pointer +void test_pvar_6() +{ + test("test_pvar_6 : prepared select into utext pointer"); + init_var(); + + EXEC SQL PREPARE stmt FROM "SELECT Item FROM tb1 WHERE Count=?"; + + EXEC SQL EXECUTE stmt INTO :p_utext_var USING 1; + print_utext(p_utext_var); + + init_var(); + EXEC SQL EXECUTE stmt INTO :p_utext_var USING 3; + print_utext(p_utext_var); + init_table_value(); + + EXEC SQL DEALLOCATE PREPARE stmt; + +} + +//prepared select using utext pointer +void test_pvar_7() +{ + test("test_pvar_7 : prepared select using utext pointer"); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "SELECT Count FROM tb1 WHERE Item=?"; + EXEC SQL EXECUTE stmt INTO :count USING :p_utext_var; + + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; +} + +//prepared update using utext pointer +void test_pvar_8() +{ + test("test_pvar_8 : prepared update using utext pointer"); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "UPDATE tb1 SET Item=? WHERE Count=?"; + EXEC SQL EXECUTE stmt USING :p_utext_var, 1; + EXEC SQL EXECUTE stmt USING :p_utext_var, 2; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//prepared delete using utext pointer +void test_pvar_9() +{ + test("test_pvar_9 : prepared delete using utext pointer"); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "DELETE FROM tb1 WHERE Item=?"; + EXEC SQL EXECUTE stmt USING :p_utext_var; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//prepared insert using utext pointer +void test_pvar_10() +{ + test("test_pvar_10 : prepared insert using utext pointer"); + init_var(); + + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "INSERT INTO tb1 values (?, 13)"; + EXEC SQL EXECUTE stmt USING :p_utext_var; + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item='世界杯每隔四年就会举行一次每次𠲖个球队'; + + printf ("found %d rows for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL DEALLOCATE PREPARE stmt; + + init_table_value(); +} + +//Open cursor using utext pointer +void test_pvar_11() +{ + test("test_pvar_11 : Open cursor using utext pointer"); + init_var(); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL SELECT Item INTO :p_utext_var FROM tb1 WHERE Count=3; + + EXEC SQL PREPARE stmt FROM "SELECT Count FROM tb1 WHERE Item=?"; + EXEC SQL DECLARE cursor_pvar_11 CURSOR FOR stmt; + EXEC SQL OPEN cursor_pvar_11 USING :p_utext_var; + EXEC SQL FETCH cursor_pvar_11 INTO :count; + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL CLOSE cursor_pvar_11; + EXEC SQL DEALLOCATE PREPARE stmt; + EXEC SQL SET AUTOCOMMIT TO ON; +} + +//Fecth cursor into utext pointer +void test_pvar_12() +{ + test("test_pvar_12 : Fecth cursor into utext pointer"); + init_var(); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL PREPARE stmt FROM "SELECT Item FROM tb1 WHERE Count=1"; + EXEC SQL DECLARE cursor_pvar_12 CURSOR FOR stmt; + EXEC SQL OPEN cursor_pvar_12; + EXEC SQL FETCH cursor_pvar_12 INTO :p_utext_var; + EXEC SQL CLOSE cursor_pvar_12; + + print_utext(p_utext_var); + + EXEC SQL DEALLOCATE PREPARE stmt; + EXEC SQL SET AUTOCOMMIT TO ON; +} + +//simple insert utext pointer with L string inited +void test_pvar_13() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext *utext_local_pvar=L"太𠮷𠜱平洋𠱓大西洋印度洋北冰洋"; +EXEC SQL END DECLARE SECTION; + test("test_pvar_13 : simple insert utext pointer with L string inited"); + init_var(); + + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar, 16); + + EXEC SQL SELECT Item INTO :utext_var:utext_var_ind FROM tb1 WHERE Count=16; + print_utext(utext_var); + print_utext_ind(utext_var_ind); + init_var(); + init_table_value(); +} + +//Open cursor using utext var directly in WHERE Clause +void test_pvar_14() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext *utext_local_pvar; +EXEC SQL END DECLARE SECTION; + utext_local_pvar = (utext*)malloc(P_VAR_SIZE*sizeof(utext)); + memset(utext_local_pvar,'a',P_VAR_SIZE*sizeof(utext)); + + test("test_pvar_14 : Open cursor using utext var directly in WHERE Clause"); + init_var(); + + EXEC SQL SET AUTOCOMMIT TO OFF; + EXEC SQL SELECT Item INTO :utext_local_pvar FROM tb1 WHERE Count=3; + + EXEC SQL DECLARE cursor_pvar_14 CURSOR FOR SELECT Count FROM tb1 WHERE Item=:utext_local_pvar; + EXEC SQL OPEN cursor_pvar_14; + EXEC SQL FETCH cursor_pvar_14 INTO :count; + printf ("count=%d for Item='世界杯每隔四年就会举行一次每次𠲖个球队'\n", count); + EXEC SQL CLOSE cursor_pvar_14; + + EXEC SQL SET AUTOCOMMIT TO ON; +} + + +//utext pointer working with NULL without using indicator +void test_pvar_15() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext *utext_local_pvar; +EXEC SQL END DECLARE SECTION; + utext_local_pvar = (utext*)malloc(P_VAR_SIZE*sizeof(utext)); + memset(utext_local_pvar,'a',P_VAR_SIZE*sizeof(utext)); + + test("test_pvar_15 : Test utext pointer working with NULL without using indicator"); + + EXEC SQL SELECT Item INTO :utext_local_pvar FROM tb1 WHERE Count=8; + + print_utext(utext_local_pvar); + + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar, 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar, 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar, 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//utext pointer working with NULL using indicator +void test_pvar_16() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext *utext_local_pvar; + int utext_pvar_ind = -1; +EXEC SQL END DECLARE SECTION; + utext_local_pvar = (utext*)malloc(P_VAR_SIZE*sizeof(utext)); + memset(utext_local_pvar,'a',P_VAR_SIZE*sizeof(utext)); + + test("test_pvar_16 : Test utext pointer working with NULL using indicator"); + + EXEC SQL SELECT Item INTO :utext_local_pvar:utext_pvar_ind FROM tb1 WHERE Count=8; + + print_utext(utext_local_pvar); + print_utext_ind(utext_pvar_ind); + + memset(utext_local_pvar,0,P_VAR_SIZE*sizeof(utext)); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar:utext_pvar_ind, 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar:utext_pvar_ind, 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar:utext_pvar_ind, 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//utext uninitialized pointer getting and setting data +void test_pvar_17() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext *utext_local_pvar=0; + char local_str[50]; +EXEC SQL END DECLARE SECTION; + + test("test_pvar_17 : Test utext uninitialized pointer getting and setting data"); + + EXEC SQL SELECT Item INTO :utext_local_pvar FROM tb1 WHERE Count=1; + + print_utext_str(utext_local_pvar); + + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar, 18); + EXEC SQL SELECT Item INTO :local_str FROM tb1 WHERE Count=18; + printf ("Find Item = %s where Count=18\n", local_str); + + init_table_value(); +} + +//utext uninitialized pointer working with NULL without using indicator +void test_pvar_18() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext *utext_local_pvar=0; +EXEC SQL END DECLARE SECTION; + + test("test_pvar_18 : Test utext uninitialized pointer working with NULL without using indicator"); + + EXEC SQL SELECT Item INTO :utext_local_pvar FROM tb1 WHERE Count=8; + + print_utext_size(utext_local_pvar,1); + + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar, 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar, 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar, 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//utext uninitialized pointer working with NULL using indicator +void test_pvar_19() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext *utext_local_pvar=0; + int utext_pvar_ind = -1; +EXEC SQL END DECLARE SECTION; + + test("test_pvar_19 : Test utext uninitialized pointer working with NULL using indicator"); + + EXEC SQL SELECT Item INTO :utext_local_pvar:utext_pvar_ind FROM tb1 WHERE Count=8; + + print_utext_size(utext_local_pvar,1); + print_utext_ind(utext_pvar_ind); + + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar:utext_pvar_ind, 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar:utext_pvar_ind, 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_pvar:utext_pvar_ind, 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//Test select into host varaibles from descriptor +void test_desc_1() +{ + EXEC SQL BEGIN DECLARE SECTION; + utext utext_local_var[20]; + utext *utext_local_pvar=0; + utext **utext_local_ppvar=0; + char desc1[8] = "outdesc"; + EXEC SQL END DECLARE SECTION; + +// ECPGdebug(1, stderr); + + EXEC SQL ALLOCATE DESCRIPTOR indesc; + EXEC SQL ALLOCATE DESCRIPTOR :desc1; + + EXEC SQL SELECT Item,Count INTO SQL DESCRIPTOR :desc1 FROM tb1 WHERE Count=1; + + EXEC SQL GET DESCRIPTOR :desc1 VALUE 1 :utext_local_var = DATA; + print_utext(utext_local_var); + + EXEC SQL GET DESCRIPTOR :desc1 VALUE 1 :utext_local_pvar = DATA; + print_utext_str(utext_local_pvar); + + + EXEC SQL SELECT Item,Count INTO SQL DESCRIPTOR :desc1 FROM tb1 WHERE Count<=3; + EXEC SQL GET DESCRIPTOR :desc1 VALUE 1 :utext_local_ppvar = DATA; + print_utext_str(utext_local_ppvar[0]); + print_utext_str(utext_local_ppvar[1]); + print_utext_str(utext_local_ppvar[2]); + + + EXEC SQL SELECT Item,Count INTO SQL DESCRIPTOR :desc1 FROM tb1 WHERE Count<=10 and Count>=8; + EXEC SQL GET DESCRIPTOR :desc1 VALUE 1 :utext_local_ppvar = DATA; + print_utext_str(utext_local_ppvar[0]); + print_utext_str(utext_local_ppvar[1]); + print_utext_str(utext_local_ppvar[2]); + + + EXEC SQL DEALLOCATE DESCRIPTOR indesc; + EXEC SQL DEALLOCATE DESCRIPTOR :desc1; +} + + +//Test uninitialized pointer to pointer utext_var without initialize +void test_pp_var_1() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext **utext_local_ppvar=0; + int *utext_local_ppvar_ind=0; + char utext_local_char[80]; +EXEC SQL END DECLARE SECTION; + test("test_pp_var_1 : Test pointer to pointer utext_var without initialize"); + + //memset(utext_local_var,'a',sizeof(utext_local_var)); + EXEC SQL SELECT Item INTO :utext_local_ppvar:utext_local_ppvar_ind FROM tb1 WHERE Count<=3; + print_utext_str(utext_local_ppvar[0]); + print_utext_ind(utext_local_ppvar_ind[0]); + + print_utext_str(utext_local_ppvar[1]); + print_utext_ind(utext_local_ppvar_ind[1]); + + print_utext_str(utext_local_ppvar[2]); + print_utext_ind(utext_local_ppvar_ind[2]); + + EXEC SQL INSERT INTO tb1 values (:utext_local_ppvar[1], 28); + EXEC SQL SELECT Item INTO :utext_local_char FROM tb1 WHERE Count=28; + printf("%s\n",utext_local_char); + + init_table_value(); +} + + +//Test uninitialized pointer to pointer utext_var working with NULL without indicator +void test_pp_var_2() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext **utext_local_ppvar=0; +EXEC SQL END DECLARE SECTION; + test("test_pp_var_2 : Test uninitialized pointer to pointer utext_var working with NULL without indicator"); + + //memset(utext_local_var,'a',sizeof(utext_local_var)); + EXEC SQL SELECT Item INTO :utext_local_ppvar FROM tb1 WHERE Count>=8 and Count<=10; + print_utext_str(utext_local_ppvar[0]); + print_utext_str(utext_local_ppvar[1]); + print_utext_str(utext_local_ppvar[2]); + + EXEC SQL INSERT INTO tb1 values (:utext_local_ppvar[0], 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_ppvar[1], 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_ppvar[2], 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//Test uninitialized pointer to pointer utext_var working with NULL with indicator +void test_pp_var_3() +{ +EXEC SQL BEGIN DECLARE SECTION; + utext **utext_local_ppvar=0; + int *utext_local_ppvar_ind=0; +EXEC SQL END DECLARE SECTION; + test("test_pp_var_2 : Test uninitialized pointer to pointer utext_var working with NULL without indicator"); + + //memset(utext_local_var,'a',sizeof(utext_local_var)); + EXEC SQL SELECT Item INTO :utext_local_ppvar:utext_local_ppvar_ind FROM tb1 WHERE Count>=8 and Count<=10; + print_utext_str(utext_local_ppvar[0]); + print_utext_ind(utext_local_ppvar_ind[0]); + + print_utext_str(utext_local_ppvar[1]); + print_utext_ind(utext_local_ppvar_ind[1]); + + print_utext_str(utext_local_ppvar[2]); + print_utext_ind(utext_local_ppvar_ind[2]); + + EXEC SQL INSERT INTO tb1 values (:utext_local_ppvar[0], 18); + EXEC SQL INSERT INTO tb1 values (:utext_local_ppvar[1], 19); + EXEC SQL INSERT INTO tb1 values (:utext_local_ppvar[2], 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +void test_all() +{ + test_var_1(); + test_var_2(); + test_var_3(); + test_var_4(); + test_var_5(); + test_var_6(); + test_var_7(); + test_var_8(); + test_var_9(); + test_var_10(); + test_var_11(); + test_var_12(); + test_var_13(); + test_var_14(); + test_var_15(); + test_var_16(); + test_array_1(); + test_array_2(); + test_array_3(); + test_array_4(); + test_array_5(); + test_array_6(); + test_array_7(); + test_array_8(); + test_array_9(); + test_array_10(); + test_array_11(); + test_array_12(); + test_array_13(); + test_array_14(); + test_array_15(); + test_array_16(); + test_pvar_1(); + test_pvar_2(); + test_pvar_3(); + test_pvar_4(); + test_pvar_5(); + test_pvar_6(); + test_pvar_7(); + test_pvar_8(); + test_pvar_9(); + test_pvar_10(); + test_pvar_11(); + test_pvar_12(); + test_pvar_13(); + test_pvar_14(); + test_pvar_15(); + test_pvar_16(); + test_pvar_17(); + test_pvar_18(); + test_pvar_19(); + test_pp_var_1(); + test_pp_var_2(); + test_pp_var_3(); +} + +int main(int argc, char *argv[]) +{ +// ECPGdebug(1, stderr); + if(test_init() !=0) + return -1; + + test_all(); + test_finish(); + + return 0; +} diff --git a/src/interfaces/ecpg/test/unicode/utext.sh b/src/interfaces/ecpg/test/unicode/utext.sh new file mode 100755 index 0000000..0ee49b2 --- /dev/null +++ b/src/interfaces/ecpg/test/unicode/utext.sh @@ -0,0 +1,16 @@ +#!/usr/bin/bash + +echo "../../preproc/ecpg --regression --enable-utext -I./../../include -I. -o utext.c utext.pgc" + +#../../preproc/ecpg --regression --enable-utext -I./../../include -I. -o utext.c utext.pgc + + +../../preproc/ecpg --regression -r no_indicator --enable-utext -I./../../include -I. -o utext.c utext.pgc + +gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O0 -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -I../../include -I../../../../../src/interfaces/ecpg/include -I../../../../../src/interfaces/libpq -I../../../../../src/include -DLINUX_OOM_SCORE_ADJ=0 -DLINUX_OOM_ADJ=0 -D_GNU_SOURCE -I/db/pgmaster/run/include -g -c -o utext.o utext.c + + +gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O0 -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS utext.o -L../../ecpglib -L../../pgtypeslib -L../../../../../src/interfaces/libpq -L../../../../../src/port -L../../../../../src/common -L/db/pgmaster/run/lib -Wl,--as-needed -Wl,-rpath,--enable-new-dtags -lecpg -lpgtypes -lpq -lpgcommon -lpgport -lselinux -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lz -lrt -lcrypt -ldl -lm -g -o utext + + +./utext >results/utext.ret 2>&1 diff --git a/src/interfaces/ecpg/test/unicode/uvarchar.pgc b/src/interfaces/ecpg/test/unicode/uvarchar.pgc new file mode 100755 index 0000000..4dd894a --- /dev/null +++ b/src/interfaces/ecpg/test/unicode/uvarchar.pgc @@ -0,0 +1,877 @@ +#include +#include +#include + +EXEC SQL INCLUDE ../regression; + +#define test(msg) printf("\n%s\n",msg) +#define VAR_SIZE 20 +#define ARRAY_SIZE 4 + +/* Following is UTF8 and UTF16 characters mapping table */ +/*太𠮷𠜱平洋𠱓大西洋印度洋北冰洋 +0x592A,0x5E73,0x6D0B,0x5927,0x897F,0x6D0B,0x5370,0x5EA6, +0x6D0B,0x5317,0x51B0,0x6D0B,0x548C,0x5357,0x51B0,0x6D0B, +0x0000,0x0000,0x0000,0x0000*/ + +/*足球篮球羽毛球乒乓球橄榄球棒球冰球 +0x8DB3,0x7403,0x7BEE,0x7403,0x7FBD,0x6BDB,0x7403,0x4E52, +0x4E53,0x7403,0x6A44,0x6984,0x7403,0x68D2,0x7403,0x51B0, +0x7403,0x0000,0x0000,0x0000 +*/ + +/*世界杯每隔四年就会举行一次每次𠲖个球队 +0x4E16,0x754C,0x676F,0x6BCF,0x9694,0x56DB,0x5E74,0x5C31, +0x4F1A,0x4E3E,0x884C,0x4E00,0x6B21,0x6BCF,0x6B21,0x0033, +0x0032,0x4E2A,0x7403,0x961F +*/ + +/* 亚洲欧洲非洲大洋洲北美洲南美洲南极洲没有北极洲 +0x4E9A,0x6D32,0x6B27,0x6D32,0x975E,0x6D32,0x5927,0x6D0B, +0x6D32,0x5317,0x7F8E,0x6D32,0x5357,0x7F8E,0x6D32,0x5357, +0x6781,0x6D32,0x6CA1,0x6709,0x5317,0x6781,0x6D32 +*/ + +EXEC SQL BEGIN DECLARE SECTION; + UVARCHAR uvarchar_var[VAR_SIZE]; + UVARCHAR uvarchar_array[ARRAY_SIZE][VAR_SIZE]; + + int uvarchar_var_ind; + + int count; + int count_array[4]={1,2,3,4}; + int total_tuples = 0; +EXEC SQL END DECLARE SECTION; + +void print_uvarchar(void); +void print_uvarchar_ind(int uvarchar_var_ind); +void print_local_uvarchar(utext *utext_var, int var_len); +void print_array(void); +int test_init(void); +void test_finish(void); +void init_table_value(void); +void init_var(void); + +void test_var_1(void); +void test_var_2(void); +void test_var_3(void); +void test_var_4(void); +void test_var_5(void); +void test_var_6(void); +void test_var_7(void); +void test_var_8(void); +void test_var_9(void); +void test_var_10(void); +void test_var_11(void); +void test_var_12(void); +void test_var_13(void); +void test_var_14(void); +void test_var_15(void); +void test_var_16(void); +void test_array_1(void); +void test_array_2(void); +void test_array_3(void); +void test_array_4(void); +void test_array_5(void); +void test_array_6(void); +void test_array_7(void); +void test_array_8(void); +void test_array_9(void); +void test_array_10(void); +void test_array_11(void); +void test_array_12(void); +void test_array_13(void); +void test_array_14(void); +void test_array_15(void); +void test_array_16(void); + +void test_all(void); + +void print_uvarchar() +{ + int i; + + printf ("---->uvarchar variable,len=%d:\n",uvarchar_var.len); + for(i=0; i6 && (i+1)%8==0) + printf("\n"); + } + printf("\n"); +} + +void print_uvarchar_ind(int uvarchar_var_ind) +{ + printf("uvarchar_var_ind = %d\n",uvarchar_var_ind); +} + +void print_local_uvarchar(utext *utext_var, int var_len) +{ + int i; + + printf ("---->uvarchar variable,len=%d:\n",var_len); + for(i=0; i<20; i++) + { + printf ("0x%04X ", utext_var[i]); + if(i>6 && (i+1)%8==0) + printf("\n"); + } + printf("\n"); +} + +void print_array() +{ + int i,j; + + for(i=0; iuvarchar array[%d]:(len=%d)\n", i,uvarchar_array[i].len); + + for(j=0; j6 && (j+1)%8==0) + printf("\n"); + } + printf("\n"); + } + + printf("\n"); +} + +int test_init() +{ + EXEC SQL CONNECT TO REGRESSDB1; + + EXEC SQL SET AUTOCOMMIT TO ON; + EXEC SQL WHENEVER SQLWARNING SQLPRINT; + EXEC SQL WHENEVER SQLERROR SQLPRINT; + + EXEC SQL SET client_encoding='UTF8'; + + //initialization of test table + EXEC SQL CREATE TABLE tb1 (Item varchar, Count integer); + + init_table_value(); + + return 0; +} + +void test_finish() +{ + EXEC SQL DROP TABLE tb1; + EXEC SQL DISCONNECT ALL; +} + + +void init_table_value() +{ + EXEC SQL TRUNCATE tb1; + + EXEC SQL INSERT INTO tb1 VALUES ('太𠮷𠜱平洋𠱓大西洋印度洋北冰洋', 1); + EXEC SQL INSERT INTO tb1 VALUES ('足球篮球羽毛球乒乓球橄榄球棒球冰球', 2); + EXEC SQL INSERT INTO tb1 VALUES ('世界杯每隔四年就会举行一次每次𠲖个球队', 3); + EXEC SQL INSERT INTO tb1 VALUES ('亚洲欧洲非洲大洋洲北美洲南美洲南极洲没有北极洲', 4); + + EXEC SQL INSERT INTO tb1 (Count) VALUES(8); + EXEC SQL INSERT INTO tb1 (Count) VALUES(9); + EXEC SQL INSERT INTO tb1 (Count) VALUES(10); +} + +void init_var() +{ + int i; + memset((void*)&uvarchar_var,'a',sizeof(uvarchar_var)); + uvarchar_var.len = 0; + + memset((char*)uvarchar_array,'a',sizeof(uvarchar_array)*ARRAY_SIZE); + + for(i=0;i=20; + print_array(); + init_table_value(); + +} + +//uvarchar array working with NULL without using indicator +void test_array_15() +{ +EXEC SQL BEGIN DECLARE SECTION; + uvarchar uvarchar_local_array[3][20]; +EXEC SQL END DECLARE SECTION; + test("test_array_15 : Test uvarchar array working with NULL without using indicator"); + memset(uvarchar_local_array,'a',sizeof(uvarchar_local_array)); + + EXEC SQL SELECT Item INTO :uvarchar_local_array FROM tb1 WHERE Count>=8 and Count<=10; + + print_local_uvarchar(uvarchar_local_array[0].arr, 20); + print_local_uvarchar(uvarchar_local_array[1].arr, 20); + print_local_uvarchar(uvarchar_local_array[2].arr, 20); + + + memset(uvarchar_local_array,0x00,sizeof(uvarchar_local_array)); + EXEC SQL INSERT INTO tb1 values (:uvarchar_local_array[0], 18); + EXEC SQL INSERT INTO tb1 values (:uvarchar_local_array[1], 19); + EXEC SQL INSERT INTO tb1 values (:uvarchar_local_array[2], 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +//uvarchar array working with NULL using indicator +void test_array_16() +{ +EXEC SQL BEGIN DECLARE SECTION; + uvarchar uvarchar_local_array[3][20]; + int uvarchar_array_ind[3]; +EXEC SQL END DECLARE SECTION; + test("test_array_16 : Test uvarchar array working with NULL using indicator"); + memset(uvarchar_local_array,'a',sizeof(uvarchar_local_array)); + + EXEC SQL SELECT Item INTO :uvarchar_local_array:uvarchar_array_ind FROM tb1 WHERE Count>=8 and Count<=10; + + + print_local_uvarchar(uvarchar_local_array[0].arr, 20); + print_local_uvarchar(uvarchar_local_array[1].arr, 20); + print_local_uvarchar(uvarchar_local_array[2].arr, 20); + + print_uvarchar_ind(uvarchar_array_ind[0]); + print_uvarchar_ind(uvarchar_array_ind[1]); + print_uvarchar_ind(uvarchar_array_ind[2]); + + memset(uvarchar_local_array,0x00,sizeof(uvarchar_local_array)); + uvarchar_array_ind[0]=-1; + EXEC SQL INSERT INTO tb1 values (:uvarchar_local_array[0]:uvarchar_array_ind[0], 18); + EXEC SQL INSERT INTO tb1 values (:uvarchar_local_array[1]:uvarchar_array_ind[0], 19); + EXEC SQL INSERT INTO tb1 values (:uvarchar_local_array[2]:uvarchar_array_ind[0], 20); + EXEC SQL SELECT count(*) INTO :count FROM tb1 WHERE Item is NULL; + printf ("found %d rows for Item being NULL\n", count); + + init_table_value(); +} + +void test_all() +{ + test_var_1(); + test_var_2(); + test_var_3(); + test_var_4(); + test_var_5(); + test_var_6(); + test_var_7(); + test_var_8(); + test_var_9(); + test_var_10(); + test_var_11(); + test_var_12(); + test_var_13(); + test_var_14(); + test_var_15(); + test_var_16(); + test_array_1(); + test_array_2(); + test_array_3(); + test_array_4(); + test_array_5(); + test_array_6(); + test_array_7(); + test_array_8(); + test_array_9(); + test_array_10(); + test_array_11(); + test_array_12(); + test_array_13(); + test_array_15(); + test_array_16(); +} + +int main() +{ +// ECPGdebug(1, stderr); + if(test_init() !=0) + return -1; + + test_all(); + test_finish(); + + return 0; +} diff --git a/src/interfaces/ecpg/test/unicode/uvarchar.sh b/src/interfaces/ecpg/test/unicode/uvarchar.sh new file mode 100755 index 0000000..4d05ed0 --- /dev/null +++ b/src/interfaces/ecpg/test/unicode/uvarchar.sh @@ -0,0 +1,11 @@ +echo "../../preproc/ecpg --regression --enable-uvarchar -I./../../include -I. -o uvarchar.c uvarchar.pgc" + +../../preproc/ecpg --regression -r no_indicator --enable-utext -I./../../include -I. -o uvarchar.c uvarchar.pgc + +gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O0 -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -I../../include -I../../../../../src/interfaces/ecpg/include -I../../../../../src/interfaces/libpq -I../../../../../src/include -DLINUX_OOM_SCORE_ADJ=0 -DLINUX_OOM_ADJ=0 -D_GNU_SOURCE -I/db/pgmaster/run/include -g -c -o uvarchar.o uvarchar.c + + +gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O0 -pthread -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS uvarchar.o -L../../ecpglib -L../../pgtypeslib -L../../../../../src/interfaces/libpq -L../../../../../src/port -L../../../../../src/common -L/db/pgmaster/run/lib -Wl,--as-needed -Wl,-rpath,--enable-new-dtags -lecpg -lpgtypes -lpq -lpgcommon -lpgport -lselinux -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lz -lrt -lcrypt -ldl -lm -g -o uvarchar + + +./uvarchar >results/uvarchar.ret 2>&1 diff --git a/src/interfaces/libpq/exports.txt b/src/interfaces/libpq/exports.txt index d6a38d0..8be711d 100644 --- a/src/interfaces/libpq/exports.txt +++ b/src/interfaces/libpq/exports.txt @@ -172,3 +172,8 @@ PQsslAttribute 169 PQsetErrorContextVisibility 170 PQresultVerboseErrorMessage 171 PQencryptPasswordConn 172 +PQGetEncodingFromPGres 173 +PQGetEncodingFromPGconn 174 +PQGetEncodingName 175 +PQGenEncodingMaxLen 176 + diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index c24bce6..3a1ca04 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -3813,3 +3813,54 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen) *retbuflen = buflen; return tmpbuf; } + +/* + * New added interface for ECOBPG NCHAR features + * to get client_encoding in src/interface/ecpg/ecpglib/data.c + * src/interface/ecpg/ecpglib/execute.c. + */ + +int +PQGetEncodingFromPGconn(const PGconn *conn) +{ + return conn->client_encoding; +} + +int +PQGetEncodingFromPGres(const PGresult *results) +{ + return results->client_encoding; +} + +int +PQGetencUTF8(void) +{ + return PG_UTF8; +} + +int +PQGetencEUCJP(void) +{ + return PG_EUC_JP; +} + +char * +PQGetEncodingName(int client_encoding) +{ + int i; + + for (i = 0; pg_enc2gettext_tbl[i].name != NULL; i++) + { + if (pg_enc2gettext_tbl[i].encoding == client_encoding) + return pg_enc2gettext_tbl[i].name; + } + + /* Should not go to here actually */ + return NULL; +} + +int +PQGenEncodingMaxLen(int client_encoding) +{ + return pg_encmaxlen_tbl[client_encoding].len; +} diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index 1d915e7..f5fcb6e 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -535,7 +535,23 @@ extern size_t PQescapeString(char *to, const char *from, size_t length); extern unsigned char *PQescapeBytea(const unsigned char *from, size_t from_length, size_t *to_length); +/* + * New added interface for ECOBPG NCHAR features + * to get client_encoding in src/interface/ecpg/ecpglib/data.c + * src/interface/ecpg/ecpglib/execute.c. + */ + +extern int PQGetEncodingFromPGconn(const PGconn *conn); + +extern int PQGetEncodingFromPGres(const PGresult *results); + +extern char *PQGetEncodingName(int client_encoding); + +extern int PQGenEncodingMaxLen(int client_encoding); + +extern int PQGetencUTF8(void); +extern int PQGetencEUCJP(void); /* === in fe-print.c === */