-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.8 2009/11/11 20:31:26 alvherre Exp $ */
-
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.9 2009/11/26 15:06:47 meskes Exp $ */
ECPG: stmtClosePortalStmt block
{
if (INFORMIX_MODE)
}
ECPG: fetch_argscursor_name addon
add_additional_variables($1, false);
+ if ($1[0] == ':')
+ {
+ free($1);
+ $1 = make_str("$0");
+ }
ECPG: fetch_argsfrom_incursor_name addon
add_additional_variables($2, false);
+ if ($2[0] == ':')
+ {
+ free($2);
+ $2 = make_str("$0");
+ }
ECPG: fetch_argsNEXTopt_from_incursor_name addon
ECPG: fetch_argsPRIORopt_from_incursor_name addon
ECPG: fetch_argsFIRST_Popt_from_incursor_name addon
ECPG: fetch_argsLAST_Popt_from_incursor_name addon
ECPG: fetch_argsALLopt_from_incursor_name addon
-ECPG: fetch_argsFORWARDopt_from_incursor_name addon
-ECPG: fetch_argsBACKWARDopt_from_incursor_name addon
add_additional_variables($3, false);
+ if ($3[0] == ':')
+ {
+ free($3);
+ $3 = make_str("$0");
+ }
ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
add_additional_variables($3, false);
+ if ($3[0] == ':')
+ {
+ free($3);
+ $3 = make_str("$0");
+ }
if ($1[0] == '$')
{
free($1);
ECPG: fetch_argsFORWARDALLopt_from_incursor_name addon
ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
add_additional_variables($4, false);
+ if ($4[0] == ':')
+ {
+ free($4);
+ $4 = make_str("$0");
+ }
ECPG: fetch_argsABSOLUTE_PSignedIconstopt_from_incursor_name addon
ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_incursor_name addon
ECPG: fetch_argsFORWARDSignedIconstopt_from_incursor_name addon
ECPG: fetch_argsBACKWARDSignedIconstopt_from_incursor_name addon
add_additional_variables($4, false);
+ if ($4[0] == ':')
+ {
+ free($4);
+ $4 = make_str("$0");
+ }
if ($2[0] == '$')
{
free($2);
$2 = make_str("$0");
}
+ECPG: cursor_namename rule
+ | char_civar
+ {
+ char *curname = mm_alloc(strlen($1) + 2);
+ sprintf(curname, ":%s", $1);
+ free($1);
+ $1 = curname;
+ $$ = $1;
+ }
ECPG: PrepareStmtPREPAREprepared_nameprep_type_clauseASPreparableStmt block
{
$$.name = $2;
ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectStmt block
{
struct cursor *ptr, *this;
+ char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
char *comment;
for (ptr = cur; ptr != NULL; ptr = ptr->next)
this->name = $2;
this->connection = connection;
this->opened = false;
- this->command = cat_str(7, make_str("declare"), mm_strdup($2), $3, make_str("cursor"), $5, make_str("for"), $7);
+ this->command = cat_str(7, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for"), $7);
this->argsinsert = argsinsert;
this->argsresult = argsresult;
argsinsert = argsresult = NULL;
else
$$ = comment;
}
+ECPG: ClosePortalStmtCLOSEcursor_name block
+ {
+ char *cursor_marker = $2[0] == ':' ? make_str("$0") : $2;
+ $$ = cat2_str(make_str("close"), cursor_marker);
+ }
ECPG: opt_hold block
{
if (compat == ECPG_COMPAT_INFORMIX_SE && autocommit == true)
{
$$ = cat2_str(make_str("fetch"), $2);
}
+ | FETCH FORWARD cursor_name opt_ecpg_into
+ {
+ char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
+ add_additional_variables($3, false);
+ $$ = cat_str(2, make_str("fetch forward"), cursor_marker);
+ }
+ | FETCH FORWARD from_in cursor_name opt_ecpg_into
+ {
+ char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
+ add_additional_variables($4, false);
+ $$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
+ }
+ | FETCH BACKWARD cursor_name opt_ecpg_into
+ {
+ char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
+ add_additional_variables($3, false);
+ $$ = cat_str(2, make_str("fetch backward"), cursor_marker);
+ }
+ | FETCH BACKWARD from_in cursor_name opt_ecpg_into
+ {
+ char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
+ add_additional_variables($4, false);
+ $$ = cat_str(2, make_str("fetch backward from"), cursor_marker);
+ }
+ | MOVE FORWARD cursor_name
+ {
+ char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
+ add_additional_variables($3, false);
+ $$ = cat_str(2, make_str("move forward"), cursor_marker);
+ }
+ | MOVE FORWARD from_in cursor_name
+ {
+ char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
+ add_additional_variables($4, false);
+ $$ = cat_str(2, make_str("move forward from"), cursor_marker);
+ }
+ | MOVE BACKWARD cursor_name
+ {
+ char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
+ add_additional_variables($3, false);
+ $$ = cat_str(2, make_str("move backward"), cursor_marker);
+ }
+ | MOVE BACKWARD from_in cursor_name
+ {
+ char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
+ add_additional_variables($4, false);
+ $$ = cat_str(2, make_str("move backward from"), cursor_marker);
+ }
ECPG: select_limitLIMITselect_limit_value','select_offset_value block
{
mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.15 2009/11/21 05:44:05 tgl Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.16 2009/11/26 15:06:47 meskes Exp $ */
statements: /*EMPTY*/
| statements statement
ECPGCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared_name
{
struct cursor *ptr, *this;
+ char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
const char *con = connection ? connection : "NULL";
this->next = cur;
this->name = $2;
this->connection = connection;
- this->command = cat_str(6, make_str("declare"), mm_strdup($2), $3, make_str("cursor"), $5, make_str("for $1"));
+ this->command = cat_str(6, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for $1"));
this->argsresult = NULL;
thisquery->type = &ecpg_query;
sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);
this->argsinsert = NULL;
+ if ($2[0] == ':')
+ {
+ struct variable *var = find_variable($2 + 1);
+ remove_variable_from_list(&argsinsert, var);
+ add_variable_to_head(&(this->argsinsert), var, &no_indicator);
+ }
add_variable_to_head(&(this->argsinsert), thisquery, &no_indicator);
cur = this;
/*
* open is an open cursor, at the moment this has to be removed
*/
-ECPGOpen: SQL_OPEN cursor_name opt_ecpg_using { $$ = $2; };
+ECPGOpen: SQL_OPEN cursor_name opt_ecpg_using
+ {
+ if ($2[0] == ':')
+ remove_variable_from_list(&argsinsert, find_variable($2 + 1));
+ $$ = $2;
+ }
+ ;
opt_ecpg_using: /*EMPTY*/ { $$ = EMPTY; }
| ecpg_using { $$ = $1; }
}
;
+char_civar: char_variable
+ {
+ char *ptr = strstr($1, ".arr");
+
+ if (ptr) /* varchar, we need the struct name here, not the struct element */
+ *ptr = '\0';
+ add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
+ $$ = $1;
+ }
+ ;
+
civar: cvariable
{
add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
| into_descriptor { $$ = $1; }
;
+opt_ecpg_into: /* EMPTY */ { $$ = EMPTY; }
+ | ecpg_into { $$ = $1; }
+ ;
+
%%
void base_yyerror(const char *error)