diff options
author | Michael Meskes <meskes@postgresql.org> | 2009-08-07 10:51:21 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2009-08-07 10:51:21 +0000 |
commit | 5d34af421d99ec2c709c67ffbaee10f8c4ce822e (patch) | |
tree | 1ed07bc27deb21b918d6fee0ab36548b19797941 /src/interfaces/ecpg/preproc | |
parent | 06f1f53ea9bbbcdebc228d8422182dc9da75ec73 (diff) |
Added STRING datatype for Informix compatibility mode. This work is
based on a patch send in by Böszörményi Zoltán <zb@cybertec.at>.
Diffstat (limited to 'src/interfaces/ecpg/preproc')
-rw-r--r-- | src/interfaces/ecpg/preproc/ecpg.header | 9 | ||||
-rw-r--r-- | src/interfaces/ecpg/preproc/ecpg.trailer | 13 | ||||
-rw-r--r-- | src/interfaces/ecpg/preproc/type.c | 6 | ||||
-rw-r--r-- | src/interfaces/ecpg/preproc/variable.c | 5 |
4 files changed, 26 insertions, 7 deletions
diff --git a/src/interfaces/ecpg/preproc/ecpg.header b/src/interfaces/ecpg/preproc/ecpg.header index c2091d28293..fae9e76e0a8 100644 --- a/src/interfaces/ecpg/preproc/ecpg.header +++ b/src/interfaces/ecpg/preproc/ecpg.header @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.header,v 1.7 2009/06/10 23:11:52 petere Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.header,v 1.8 2009/08/07 10:51:20 meskes Exp $ */ /* Copyright comment */ %{ @@ -256,12 +256,12 @@ adjust_informix(struct arguments *list) original_var = ptr->variable->name; sprintf(temp, "%d))", ecpg_informix_var); - if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char) && atoi(ptr->variable->type->size) > 1) + 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) && atoi(ptr->variable->type->size) > 1) { ptr->variable = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str("1"), ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0); sprintf(temp, "%d, (", ecpg_informix_var++); } - else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char) && atoi(ptr->variable->type->size) > 1) + 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) && atoi(ptr->variable->type->size) > 1) { ptr->variable = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0); sprintf(temp, "%d, (", ecpg_informix_var++); @@ -343,6 +343,8 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu type_enum == ECPGt_union) && initializer == 1) mmerror(PARSE_ERROR, ET_ERROR, "initializer not allowed in type definition"); + else if (INFORMIX_MODE && strcmp(name, "string") == 0) + mmerror(PARSE_ERROR, ET_ERROR, "type name \"string\" is reserved in Informix mode"); else { for (ptr = types; ptr != NULL; ptr = ptr->next) @@ -371,6 +373,7 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu if (type_enum != ECPGt_varchar && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char && + type_enum != ECPGt_string && 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.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer index 1b287e4c65d..3b5d660fc41 100644 --- a/src/interfaces/ecpg/preproc/ecpg.trailer +++ b/src/interfaces/ecpg/preproc/ecpg.trailer @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.9 2009/06/10 23:11:52 petere Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.10 2009/08/07 10:51:20 meskes Exp $ */ statements: /*EMPTY*/ | statements statement @@ -213,6 +213,7 @@ char_variable: cvariable { case ECPGt_char: case ECPGt_unsigned_char: + case ECPGt_string: $$ = $1; break; case ECPGt_varchar: @@ -587,6 +588,14 @@ var_type: simple_type $$.type_index = make_str("-1"); $$.type_sizeof = NULL; } + else if ((strcmp($1, "string") == 0) && INFORMIX_MODE) + { + $$.type_enum = ECPGt_string; + $$.type_str = make_str("char"); + $$.type_dimension = make_str("-1"); + $$.type_index = make_str("-1"); + $$.type_sizeof = NULL; + } else { /* this is for typedef'ed types */ @@ -849,6 +858,7 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize case ECPGt_char: case ECPGt_unsigned_char: + case ECPGt_string: if (atoi(dimension) == -1) { int i = strlen($5); @@ -1269,6 +1279,7 @@ ECPGVar: SQL_VAR case ECPGt_char: case ECPGt_unsigned_char: + case ECPGt_string: if (atoi(dimension) == -1) type = ECPGmake_simple_type($5.type_enum, length, 0); else diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c index 49caa32f26c..0465762f8d1 100644 --- a/src/interfaces/ecpg/preproc/type.c +++ b/src/interfaces/ecpg/preproc/type.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.83 2009/06/11 14:49:13 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.84 2009/08/07 10:51:20 meskes Exp $ */ #include "postgres_fe.h" @@ -200,6 +200,9 @@ get_type(enum ECPGttype type) case ECPGt_timestamp: return ("ECPGt_timestamp"); break; + case ECPGt_string: + return ("ECPGt_string"); + break; default: mmerror(PARSE_ERROR, ET_ERROR, "unrecognized variable type code %d", type); } @@ -366,6 +369,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type, case ECPGt_char: case ECPGt_unsigned_char: case ECPGt_char_variable: + case ECPGt_string: /* * we have to use the pointer except for arrays with given diff --git a/src/interfaces/ecpg/preproc/variable.c b/src/interfaces/ecpg/preproc/variable.c index 307490465ed..9d29f340b63 100644 --- a/src/interfaces/ecpg/preproc/variable.c +++ b/src/interfaces/ecpg/preproc/variable.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.49 2009/06/11 14:49:13 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.50 2009/08/07 10:51:20 meskes Exp $ */ #include "postgres_fe.h" @@ -500,7 +500,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) + if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char && type_enum != ECPGt_string) mmerror(PARSE_ERROR, ET_FATAL, "pointer to pointer is not supported for this data type"); if (pointer_len > 1 && (atoi(*length) >= 0 || atoi(*dimension) >= 0)) @@ -539,6 +539,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty break; case ECPGt_char: case ECPGt_unsigned_char: + case ECPGt_string: /* char ** */ if (pointer_len == 2) { |