|
1 |
| -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.230 2003/06/11 06:39:12 meskes Exp $ */ |
| 1 | +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.231 2003/06/13 10:50:57 meskes Exp $ */ |
2 | 2 |
|
3 | 3 | /* Copyright comment */
|
4 | 4 | %{
|
|
11 | 11 | */
|
12 | 12 | int struct_level = 0;
|
13 | 13 | int braces_open; /* brace level counter */
|
| 14 | +int ecpg_informix_var = 0; |
14 | 15 | char errortext[128];
|
15 | 16 | char *connection = NULL;
|
16 | 17 | char *input_filename = NULL;
|
@@ -141,6 +142,7 @@ make3_str(char *str1, char *str2, char *str3)
|
141 | 142 | return(res_str);
|
142 | 143 | }
|
143 | 144 |
|
| 145 | +/* and the rest */ |
144 | 146 | static char *
|
145 | 147 | make_name(void)
|
146 | 148 | {
|
@@ -186,6 +188,36 @@ create_questionmarks(char *name, bool array)
|
186 | 188 | return(result);
|
187 | 189 | }
|
188 | 190 |
|
| 191 | +static char * |
| 192 | +adjust_informix(struct arguments *list) |
| 193 | +{ |
| 194 | + /* Informix accepts DECLARE with variables that are out of scope when OPEN is called. |
| 195 | + * This breaks standard and leads to some very dangerous programming. |
| 196 | + * Since they do, we have to work around and accept their syntax as well. |
| 197 | + * But we will do so ONLY in Informix mode. |
| 198 | + * We have to change the variables to our own struct and just store the pointer instead of the variable */ |
| 199 | + |
| 200 | + struct arguments *ptr; |
| 201 | + char *result = make_str(""); |
| 202 | + |
| 203 | + for (ptr = list; ptr != NULL; ptr = ptr->next) |
| 204 | + { |
| 205 | + char temp[sizeof(int)+sizeof(", &()")]; |
| 206 | + char *original_var; |
| 207 | + |
| 208 | + /* change variable name to "ECPG_informix_get_var(<counter>)" */ |
| 209 | + original_var = ptr->variable->name; |
| 210 | + sprintf(temp, "%d))", ecpg_informix_var); |
| 211 | + ptr->variable = new_variable(cat_str(4, make_str("*("), mm_strdup(ECPGtype_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), 0); |
| 212 | + |
| 213 | + /* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */ |
| 214 | + sprintf(temp, "%d, &(", ecpg_informix_var++); |
| 215 | + result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n")); |
| 216 | + } |
| 217 | + |
| 218 | + return result; |
| 219 | +} |
| 220 | + |
189 | 221 | %}
|
190 | 222 |
|
191 | 223 | %union {
|
@@ -1098,7 +1130,10 @@ opt_drop_behavior: CASCADE { $$ = make_str("cascade"); }
|
1098 | 1130 | *
|
1099 | 1131 | *****************************************************************************/
|
1100 | 1132 |
|
1101 |
| -ClosePortalStmt: CLOSE name { $$ = cat2_str(make_str("close"), $2); } |
| 1133 | +ClosePortalStmt: CLOSE name |
| 1134 | + { |
| 1135 | + $$ = cat2_str(make_str("close"), $2); |
| 1136 | + } |
1102 | 1137 | ;
|
1103 | 1138 |
|
1104 | 1139 | /*****************************************************************************
|
@@ -1734,6 +1769,10 @@ FetchStmt: FETCH fetch_direction from_in name ecpg_into_using
|
1734 | 1769 | { $$ = cat_str(4, make_str("fetch"), $2, $3, $4); }
|
1735 | 1770 | | FETCH name ecpg_into_using
|
1736 | 1771 | { $$ = cat2_str(make_str("fetch"), $2); }
|
| 1772 | + | FETCH fetch_direction from_in name |
| 1773 | + { $$ = cat_str(4, make_str("fetch"), $2, $3, $4); } |
| 1774 | + | FETCH name |
| 1775 | + { $$ = cat2_str(make_str("fetch"), $2); } |
1737 | 1776 | | MOVE fetch_direction from_in name
|
1738 | 1777 | { $$ = cat_str(4, make_str("move"), $2, $3, $4); }
|
1739 | 1778 | | MOVE name
|
@@ -2630,10 +2669,12 @@ DeclareCursorStmt: DECLARE name cursor_options CURSOR opt_hold FOR SelectStmt
|
2630 | 2669 | this->argsinsert = argsinsert;
|
2631 | 2670 | this->argsresult = argsresult;
|
2632 | 2671 | argsinsert = argsresult = NULL;
|
2633 |
| - |
2634 | 2672 | cur = this;
|
2635 | 2673 |
|
2636 |
| - $$ = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/")); |
| 2674 | + if (compat == ECPG_COMPAT_INFORMIX) |
| 2675 | + $$ = cat_str(5, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), make_str("/*"), mm_strdup(this->command), make_str("*/")); |
| 2676 | + else |
| 2677 | + $$ = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/")); |
2637 | 2678 | }
|
2638 | 2679 | ;
|
2639 | 2680 |
|
|
0 commit comments