1- /* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.8 2009/11/11 20:31:26 alvherre Exp $ */
2-
1+ /* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.9 2009/11/26 15:06:47 meskes Exp $ */
32ECPG: stmtClosePortalStmt block
43{
54if (INFORMIX_MODE)
@@ -213,18 +212,36 @@ ECPG: var_valueNumericOnly addon
213212}
214213ECPG: fetch_argscursor_name addon
215214add_additional_variables($1, false);
215+ if ($1[0] == ':')
216+ {
217+ free($1);
218+ $1 = make_str("$0");
219+ }
216220ECPG: fetch_argsfrom_incursor_name addon
217221add_additional_variables($2, false);
222+ if ($2[0] == ':')
223+ {
224+ free($2);
225+ $2 = make_str("$0");
226+ }
218227ECPG: fetch_argsNEXTopt_from_incursor_name addon
219228ECPG: fetch_argsPRIORopt_from_incursor_name addon
220229ECPG: fetch_argsFIRST_Popt_from_incursor_name addon
221230ECPG: fetch_argsLAST_Popt_from_incursor_name addon
222231ECPG: fetch_argsALLopt_from_incursor_name addon
223- ECPG: fetch_argsFORWARDopt_from_incursor_name addon
224- ECPG: fetch_argsBACKWARDopt_from_incursor_name addon
225232add_additional_variables($3, false);
233+ if ($3[0] == ':')
234+ {
235+ free($3);
236+ $3 = make_str("$0");
237+ }
226238ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
227239add_additional_variables($3, false);
240+ if ($3[0] == ':')
241+ {
242+ free($3);
243+ $3 = make_str("$0");
244+ }
228245if ($1[0] == '$')
229246{
230247free($1);
@@ -233,16 +250,35 @@ ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
233250ECPG: fetch_argsFORWARDALLopt_from_incursor_name addon
234251ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
235252add_additional_variables($4, false);
253+ if ($4[0] == ':')
254+ {
255+ free($4);
256+ $4 = make_str("$0");
257+ }
236258ECPG: fetch_argsABSOLUTE_PSignedIconstopt_from_incursor_name addon
237259ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_incursor_name addon
238260ECPG: fetch_argsFORWARDSignedIconstopt_from_incursor_name addon
239261ECPG: fetch_argsBACKWARDSignedIconstopt_from_incursor_name addon
240262add_additional_variables($4, false);
263+ if ($4[0] == ':')
264+ {
265+ free($4);
266+ $4 = make_str("$0");
267+ }
241268if ($2[0] == '$')
242269{
243270free($2);
244271$2 = make_str("$0");
245272}
273+ ECPG: cursor_namename rule
274+ | char_civar
275+ {
276+ char *curname = mm_alloc(strlen($1) + 2);
277+ sprintf(curname, ":%s", $1);
278+ free($1);
279+ $1 = curname;
280+ $$ = $1;
281+ }
246282ECPG: PrepareStmtPREPAREprepared_nameprep_type_clauseASPreparableStmt block
247283{
248284$$.name = $2;
@@ -260,6 +296,7 @@ ECPG: ExecuteStmtEXECUTEprepared_nameexecute_param_clauseexecute_rest block
260296ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectStmt block
261297{
262298struct cursor *ptr, *this;
299+ char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
263300char *comment;
264301
265302for (ptr = cur; ptr != NULL; ptr = ptr->next)
@@ -274,7 +311,7 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
274311this->name = $2;
275312this->connection = connection;
276313this->opened = false;
277- this->command = cat_str(7, make_str("declare"),mm_strdup($2) , $3, make_str("cursor"), $5, make_str("for"), $7);
314+ this->command = cat_str(7, make_str("declare"),cursor_marker , $3, make_str("cursor"), $5, make_str("for"), $7);
278315this->argsinsert = argsinsert;
279316this->argsresult = argsresult;
280317argsinsert = argsresult = NULL;
@@ -294,6 +331,11 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
294331else
295332$$ = comment;
296333}
334+ ECPG: ClosePortalStmtCLOSEcursor_name block
335+ {
336+ char *cursor_marker = $2[0] == ':' ? make_str("$0") : $2;
337+ $$ = cat2_str(make_str("close"), cursor_marker);
338+ }
297339ECPG: opt_hold block
298340{
299341if (compat == ECPG_COMPAT_INFORMIX_SE && autocommit == true)
@@ -363,6 +405,54 @@ ECPG: FetchStmtMOVEfetch_args rule
363405{
364406$$ = cat2_str(make_str("fetch"), $2);
365407}
408+ | FETCH FORWARD cursor_name opt_ecpg_into
409+ {
410+ char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
411+ add_additional_variables($3, false);
412+ $$ = cat_str(2, make_str("fetch forward"), cursor_marker);
413+ }
414+ | FETCH FORWARD from_in cursor_name opt_ecpg_into
415+ {
416+ char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
417+ add_additional_variables($4, false);
418+ $$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
419+ }
420+ | FETCH BACKWARD cursor_name opt_ecpg_into
421+ {
422+ char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
423+ add_additional_variables($3, false);
424+ $$ = cat_str(2, make_str("fetch backward"), cursor_marker);
425+ }
426+ | FETCH BACKWARD from_in cursor_name opt_ecpg_into
427+ {
428+ char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
429+ add_additional_variables($4, false);
430+ $$ = cat_str(2, make_str("fetch backward from"), cursor_marker);
431+ }
432+ | MOVE FORWARD cursor_name
433+ {
434+ char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
435+ add_additional_variables($3, false);
436+ $$ = cat_str(2, make_str("move forward"), cursor_marker);
437+ }
438+ | MOVE FORWARD from_in cursor_name
439+ {
440+ char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
441+ add_additional_variables($4, false);
442+ $$ = cat_str(2, make_str("move forward from"), cursor_marker);
443+ }
444+ | MOVE BACKWARD cursor_name
445+ {
446+ char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
447+ add_additional_variables($3, false);
448+ $$ = cat_str(2, make_str("move backward"), cursor_marker);
449+ }
450+ | MOVE BACKWARD from_in cursor_name
451+ {
452+ char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
453+ add_additional_variables($4, false);
454+ $$ = cat_str(2, make_str("move backward from"), cursor_marker);
455+ }
366456ECPG: select_limitLIMITselect_limit_value','select_offset_value block
367457 {
368458 mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");