@ -22,7 +22,9 @@ ECPG: stmtDeallocateStmt block
output_deallocate_prepare_statement($1);
output_deallocate_prepare_statement($1);
}
}
ECPG: stmtDeclareCursorStmt block
ECPG: stmtDeclareCursorStmt block
{ output_simple_statement($1, (strncmp($1, "ECPGset_var", strlen("ECPGset_var")) == 0) ? 4 : 0); }
{
output_simple_statement($1, (strncmp($1, "ECPGset_var", strlen("ECPGset_var")) == 0) ? 4 : 0);
}
ECPG: stmtDiscardStmt block
ECPG: stmtDiscardStmt block
ECPG: stmtFetchStmt block
ECPG: stmtFetchStmt block
{ output_statement($1, 1, ECPGst_normal); }
{ output_statement($1, 1, ECPGst_normal); }
@ -47,7 +49,10 @@ ECPG: stmtExecuteStmt block
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *str = mm_strdup($1.name + 1);
char *str = mm_strdup($1.name + 1);
/* It must be cut off double quotation because new_variable() double-quotes. */
/*
* It must be cut off double quotation because new_variable()
* double-quotes.
*/
str[strlen(str) - 1] = '\0';
str[strlen(str) - 1] = '\0';
sprintf(length, "%zu", strlen(str));
sprintf(length, "%zu", strlen(str));
add_variable_to_tail(&argsinsert, new_variable(str, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator);
add_variable_to_tail(&argsinsert, new_variable(str, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator);
@ -63,6 +68,7 @@ ECPG: stmtPrepareStmt block
else if (strlen($1.type) == 0)
else if (strlen($1.type) == 0)
{
{
char *stmt = cat_str(3, mm_strdup("\""), $1.stmt, mm_strdup("\""));
char *stmt = cat_str(3, mm_strdup("\""), $1.stmt, mm_strdup("\""));
output_prepare_statement($1.name, stmt);
output_prepare_statement($1.name, stmt);
}
}
else
else
@ -75,7 +81,10 @@ ECPG: stmtPrepareStmt block
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *str = mm_strdup($1.name + 1);
char *str = mm_strdup($1.name + 1);
/* It must be cut off double quotation because new_variable() double-quotes. */
/*
* It must be cut off double quotation because new_variable()
* double-quotes.
*/
str[strlen(str) - 1] = '\0';
str[strlen(str) - 1] = '\0';
sprintf(length, "%zu", strlen(str));
sprintf(length, "%zu", strlen(str));
add_variable_to_tail(&argsinsert, new_variable(str, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator);
add_variable_to_tail(&argsinsert, new_variable(str, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator);
@ -152,7 +161,10 @@ ECPG: stmtViewStmt rule
whenever_action(2);
whenever_action(2);
free($1);
free($1);
}
}
| ECPGExecuteImmediateStmt { output_statement($1, 0, ECPGst_exec_immediate); }
| ECPGExecuteImmediateStmt
{
output_statement($1, 0, ECPGst_exec_immediate);
}
| ECPGFree
| ECPGFree
{
{
const char *con = connection ? connection : "NULL";
const char *con = connection ? connection : "NULL";
@ -245,6 +257,7 @@ ECPG: stmtViewStmt rule
ECPG: where_or_current_clauseWHERECURRENT_POFcursor_name block
ECPG: where_or_current_clauseWHERECURRENT_POFcursor_name block
{
{
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
$$ = cat_str(2, mm_strdup("where current of"), cursor_marker);
$$ = cat_str(2, mm_strdup("where current of"), cursor_marker);
}
}
ECPG: CopyStmtCOPYopt_binaryqualified_nameopt_column_listcopy_fromopt_programcopy_file_namecopy_delimiteropt_withcopy_optionswhere_clause addon
ECPG: CopyStmtCOPYopt_binaryqualified_nameopt_column_listcopy_fromopt_programcopy_file_namecopy_delimiteropt_withcopy_optionswhere_clause addon
@ -259,9 +272,9 @@ ECPG: var_valueNumericOnly addon
}
}
ECPG: fetch_argscursor_name addon
ECPG: fetch_argscursor_name addon
struct cursor *ptr = add_additional_variables($1, false);
struct cursor *ptr = add_additional_variables($1, false);
if (ptr->connection)
if (ptr->connection)
connection = mm_strdup(ptr->connection);
connection = mm_strdup(ptr->connection);
if ($1[0] == ':')
if ($1[0] == ':')
{
{
free($1);
free($1);
@ -269,9 +282,9 @@ ECPG: fetch_argscursor_name addon
}
}
ECPG: fetch_argsfrom_incursor_name addon
ECPG: fetch_argsfrom_incursor_name addon
struct cursor *ptr = add_additional_variables($2, false);
struct cursor *ptr = add_additional_variables($2, false);
if (ptr->connection)
if (ptr->connection)
connection = mm_strdup(ptr->connection);
connection = mm_strdup(ptr->connection);
if ($2[0] == ':')
if ($2[0] == ':')
{
{
free($2);
free($2);
@ -283,9 +296,9 @@ ECPG: fetch_argsFIRST_Popt_from_incursor_name addon
ECPG: fetch_argsLAST_Popt_from_incursor_name addon
ECPG: fetch_argsLAST_Popt_from_incursor_name addon
ECPG: fetch_argsALLopt_from_incursor_name addon
ECPG: fetch_argsALLopt_from_incursor_name addon
struct cursor *ptr = add_additional_variables($3, false);
struct cursor *ptr = add_additional_variables($3, false);
if (ptr->connection)
if (ptr->connection)
connection = mm_strdup(ptr->connection);
connection = mm_strdup(ptr->connection);
if ($3[0] == ':')
if ($3[0] == ':')
{
{
free($3);
free($3);
@ -293,9 +306,9 @@ ECPG: fetch_argsALLopt_from_incursor_name addon
}
}
ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
struct cursor *ptr = add_additional_variables($3, false);
struct cursor *ptr = add_additional_variables($3, false);
if (ptr->connection)
if (ptr->connection)
connection = mm_strdup(ptr->connection);
connection = mm_strdup(ptr->connection);
if ($3[0] == ':')
if ($3[0] == ':')
{
{
free($3);
free($3);
@ -309,9 +322,9 @@ ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
ECPG: fetch_argsFORWARDALLopt_from_incursor_name addon
ECPG: fetch_argsFORWARDALLopt_from_incursor_name addon
ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
struct cursor *ptr = add_additional_variables($4, false);
struct cursor *ptr = add_additional_variables($4, false);
if (ptr->connection)
if (ptr->connection)
connection = mm_strdup(ptr->connection);
connection = mm_strdup(ptr->connection);
if ($4[0] == ':')
if ($4[0] == ':')
{
{
free($4);
free($4);
@ -322,9 +335,9 @@ ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_incursor_name addon
ECPG: fetch_argsFORWARDSignedIconstopt_from_incursor_name addon
ECPG: fetch_argsFORWARDSignedIconstopt_from_incursor_name addon
ECPG: fetch_argsBACKWARDSignedIconstopt_from_incursor_name addon
ECPG: fetch_argsBACKWARDSignedIconstopt_from_incursor_name addon
struct cursor *ptr = add_additional_variables($4, false);
struct cursor *ptr = add_additional_variables($4, false);
if (ptr->connection)
if (ptr->connection)
connection = mm_strdup(ptr->connection);
connection = mm_strdup(ptr->connection);
if ($4[0] == ':')
if ($4[0] == ':')
{
{
free($4);
free($4);
@ -339,6 +352,7 @@ ECPG: cursor_namename rule
| char_civar
| char_civar
{
{
char *curname = mm_alloc(strlen($1) + 2);
char *curname = mm_alloc(strlen($1) + 2);
sprintf(curname, ":%s", $1);
sprintf(curname, ":%s", $1);
free($1);
free($1);
$1 = curname;
$1 = curname;
@ -375,9 +389,12 @@ ECPG: ExecuteStmtCREATEOptTempTABLEIF_PNOTEXISTScreate_as_targetASEXECUTEprepare
}
}
ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectStmt block
ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectStmt block
{
{
struct cursor *ptr, *this;
struct cursor *ptr,
*this;
char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : mm_strdup($2);
char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : mm_strdup($2);
char *comment, *c1, *c2;
char *comment,
*c1,
*c2;
int (*strcmp_fn) (const char *, const char *) = (($2[0] == ':' || $2[0] == '"') ? strcmp : pg_strcasecmp);
int (*strcmp_fn) (const char *, const char *) = (($2[0] == ':' || $2[0] == '"') ? strcmp : pg_strcasecmp);
if (INFORMIX_MODE && pg_strcasecmp($2, "database") == 0)
if (INFORMIX_MODE && pg_strcasecmp($2, "database") == 0)
@ -424,13 +441,13 @@ ECPG: ClosePortalStmtCLOSEcursor_name block
{
{
char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : $2;
char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : $2;
struct cursor *ptr = NULL;
struct cursor *ptr = NULL;
for (ptr = cur; ptr != NULL; ptr = ptr->next)
for (ptr = cur; ptr != NULL; ptr = ptr->next)
{
{
if (strcmp($2, ptr->name) == 0)
if (strcmp($2, ptr->name) == 0)
{
{
if (ptr->connection)
if (ptr->connection)
connection = mm_strdup(ptr->connection);
connection = mm_strdup(ptr->connection);
break;
break;
}
}
}
}
@ -448,11 +465,18 @@ ECPG: into_clauseINTOOptTempTableName block
FoundInto = 1;
FoundInto = 1;
$$ = cat2_str(mm_strdup("into"), $2);
$$ = cat2_str(mm_strdup("into"), $2);
}
}
| ecpg_into { $$ = EMPTY; }
| ecpg_into
{
$$ = EMPTY;
}
ECPG: TypenameSimpleTypenameopt_array_bounds block
ECPG: TypenameSimpleTypenameopt_array_bounds block
{ $$ = cat2_str($1, $2.str); }
{
$$ = cat2_str($1, $2.str);
}
ECPG: TypenameSETOFSimpleTypenameopt_array_bounds block
ECPG: TypenameSETOFSimpleTypenameopt_array_bounds block
{ $$ = cat_str(3, mm_strdup("setof"), $2, $3.str); }
{
$$ = cat_str(3, mm_strdup("setof"), $2, $3.str);
}
ECPG: opt_array_boundsopt_array_bounds'['']' block
ECPG: opt_array_boundsopt_array_bounds'['']' block
{
{
$$.index1 = $1.index1;
$$.index1 = $1.index1;
@ -480,7 +504,9 @@ ECPG: opt_array_bounds
$$.str = EMPTY;
$$.str = EMPTY;
}
}
ECPG: IconstICONST block
ECPG: IconstICONST block
{ $$ = make_name(); }
{
$$ = make_name();
}
ECPG: AexprConstNULL_P rule
ECPG: AexprConstNULL_P rule
| civar { $$ = $1; }
| civar { $$ = $1; }
| civarind { $$ = $1; }
| civarind { $$ = $1; }
@ -507,6 +533,7 @@ ECPG: FetchStmtMOVEfetch_args rule
{
{
char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
struct cursor *ptr = add_additional_variables($3, false);
struct cursor *ptr = add_additional_variables($3, false);
if (ptr->connection)
if (ptr->connection)
connection = mm_strdup(ptr->connection);
connection = mm_strdup(ptr->connection);
@ -516,6 +543,7 @@ ECPG: FetchStmtMOVEfetch_args rule
{
{
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
struct cursor *ptr = add_additional_variables($4, false);
struct cursor *ptr = add_additional_variables($4, false);
if (ptr->connection)
if (ptr->connection)
connection = mm_strdup(ptr->connection);
connection = mm_strdup(ptr->connection);
@ -525,6 +553,7 @@ ECPG: FetchStmtMOVEfetch_args rule
{
{
char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
struct cursor *ptr = add_additional_variables($3, false);
struct cursor *ptr = add_additional_variables($3, false);
if (ptr->connection)
if (ptr->connection)
connection = mm_strdup(ptr->connection);
connection = mm_strdup(ptr->connection);
@ -534,6 +563,7 @@ ECPG: FetchStmtMOVEfetch_args rule
{
{
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
struct cursor *ptr = add_additional_variables($4, false);
struct cursor *ptr = add_additional_variables($4, false);
if (ptr->connection)
if (ptr->connection)
connection = mm_strdup(ptr->connection);
connection = mm_strdup(ptr->connection);
@ -543,6 +573,7 @@ ECPG: FetchStmtMOVEfetch_args rule
{
{
char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
struct cursor *ptr = add_additional_variables($3, false);
struct cursor *ptr = add_additional_variables($3, false);
if (ptr->connection)
if (ptr->connection)
connection = mm_strdup(ptr->connection);
connection = mm_strdup(ptr->connection);
@ -552,6 +583,7 @@ ECPG: FetchStmtMOVEfetch_args rule
{
{
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
struct cursor *ptr = add_additional_variables($4, false);
struct cursor *ptr = add_additional_variables($4, false);
if (ptr->connection)
if (ptr->connection)
connection = mm_strdup(ptr->connection);
connection = mm_strdup(ptr->connection);
@ -561,6 +593,7 @@ ECPG: FetchStmtMOVEfetch_args rule
{
{
char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
struct cursor *ptr = add_additional_variables($3, false);
struct cursor *ptr = add_additional_variables($3, false);
if (ptr->connection)
if (ptr->connection)
connection = mm_strdup(ptr->connection);
connection = mm_strdup(ptr->connection);
@ -570,6 +603,7 @@ ECPG: FetchStmtMOVEfetch_args rule
{
{
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
struct cursor *ptr = add_additional_variables($4, false);
struct cursor *ptr = add_additional_variables($4, false);
if (ptr->connection)
if (ptr->connection)
connection = mm_strdup(ptr->connection);
connection = mm_strdup(ptr->connection);
@ -581,4 +615,7 @@ ECPG: limit_clauseLIMITselect_limit_value','select_offset_value block
$$ = cat_str(4, mm_strdup("limit"), $2, mm_strdup(","), $4);
$$ = cat_str(4, mm_strdup("limit"), $2, mm_strdup(","), $4);
}
}
ECPG: SignedIconstIconst rule
ECPG: SignedIconstIconst rule
| civar { $$ = $1; }
| civar
{
$$ = $1;
}