diff options
author | Michael Meskes <meskes@postgresql.org> | 2003-06-20 12:00:59 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2003-06-20 12:00:59 +0000 |
commit | abd310a3b1bace1177ce7d9f94120785deccab1a (patch) | |
tree | 556e14cea3ef5234871c5c94ee6dc93e6bba63f6 /src/interfaces/ecpg/preproc | |
parent | 5fc9f3d5747b446158f02e6652a4afebfbe54257 (diff) |
Allow constants in using clauses.
Diffstat (limited to 'src/interfaces/ecpg/preproc')
-rw-r--r-- | src/interfaces/ecpg/preproc/preproc.y | 18 | ||||
-rw-r--r-- | src/interfaces/ecpg/preproc/type.c | 11 |
2 files changed, 26 insertions, 3 deletions
diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y index d096dd220ba..107d84251f5 100644 --- a/src/interfaces/ecpg/preproc/preproc.y +++ b/src/interfaces/ecpg/preproc/preproc.y @@ -1,4 +1,4 @@ -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.234 2003/06/19 09:52:11 meskes Exp $ */ +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.235 2003/06/20 12:00:59 meskes Exp $ */ /* Copyright comment */ %{ @@ -475,7 +475,7 @@ adjust_informix(struct arguments *list) %type <str> ECPGGetDescriptorHeader ECPGColLabel single_var_declaration %type <str> reserved_keyword unreserved_keyword ecpg_interval opt_ecpg_using %type <str> col_name_keyword func_name_keyword precision opt_scale -%type <str> ECPGTypeName using_list ECPGColLabelCommon +%type <str> ECPGTypeName using_list ECPGColLabelCommon UsingConst %type <str> inf_val_list inf_col_list using_descriptor into_descriptor %type <str> ecpg_into_using @@ -5196,7 +5196,19 @@ ecpg_into: INTO into_list { $$ = EMPTY; } | into_descriptor { $$ = $1; } ; -using_list: civar | civar ',' using_list; +using_list: UsingConst | UsingConst ',' using_list; + +UsingConst: AllConst + { + if ($1[1] != '?') /* found a constant */ + { + char *length = mm_alloc(sizeof("INT_MAX")+1); + + sprintf(length, "%d", strlen($1)); + add_variable(&argsinsert, new_variable($1, ECPGmake_simple_type(ECPGt_const, length), 0), &no_indicator); + } + } + ; /* * As long as the prepare statement is not supported by the backend, we will diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c index 7ac5c55a289..5f2dd86bb55 100644 --- a/src/interfaces/ecpg/preproc/type.c +++ b/src/interfaces/ecpg/preproc/type.c @@ -169,6 +169,9 @@ get_type(enum ECPGttype type) * quoted */ return ("ECPGt_char_variable"); break; + case ECPGt_const: /* constant string quoted */ + return ("ECPGt_const"); + break; case ECPGt_numeric: return ("ECPGt_numeric"); break; @@ -381,6 +384,14 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type, sprintf(variable, "&(%s%s)", prefix ? prefix : "", name); sprintf(offset, "sizeof(Date)"); break; + case ECPGt_const: + + /* + * just dump the const as string + */ + sprintf(variable, "\"%s\"", name); + sprintf(offset, "strlen(\"%s\")", name); + break; default: /* |