struct ECPGtype ecpg_query = {ECPGt_char_variable, 0L, {NULL}};
+enum errortype {ET_WARN, ET_ERROR, ET_FATAL};
+
+/*
+ * Handle parsing errors and warnings
+ */
+static void
+mmerror(enum errortype type, char * error)
+{
+
+ switch(type)
+ {
+ case ET_WARN:
+ fprintf(stderr, "%s:%d: WARNING: %s\n", input_filename, yylineno, error);
+ break;
+ case ET_ERROR:
+ fprintf(stderr, "%s:%d: ERROR: %s\n", input_filename, yylineno, error);
+ ret_value = PARSE_ERROR;
+ break;
+ case ET_FATAL:
+ fprintf(stderr, "%s:%d: ERROR: %s\n", input_filename, yylineno, error);
+ exit(PARSE_ERROR);
+ }
+}
+
/*
* Handle the filename and line numbering.
*/
if (p->type->typ != ECPGt_struct && p->type->typ != ECPGt_union)
{
sprintf(errortext, "variable %s is not a pointer", name);
- yyerror (errortext);
+ mmerror(ET_FATAL, errortext);
}
if (p->type->u.element->typ != ECPGt_struct && p->type->u.element->typ != ECPGt_union)
{
sprintf(errortext, "variable %s is not a pointer to a structure or a union", name);
- yyerror (errortext);
+ mmerror(ET_FATAL, errortext);
}
/* restore the name, we will need it later on */
if (p->type->typ != ECPGt_struct && p->type->typ != ECPGt_union)
{
sprintf(errortext, "variable %s is neither a structure nor a union", name);
- yyerror (errortext);
+ mmerror(ET_FATAL, errortext);
}
/* restore the name, we will need it later on */
if (p == NULL)
{
sprintf(errortext, "The variable %s is not declared", name);
- yyerror(errortext);
+ mmerror(ET_FATAL, errortext);
}
return(p);
check_indicator(var->u.element);
break;
default:
- yyerror ("indicator variable must be integer type");
+ mmerror(ET_ERROR, "indicator variable must be integer type");
break;
}
}
if (!this)
{
sprintf(errortext, "invalid datatype '%s'", name);
- yyerror(errortext);
+ mmerror(ET_FATAL, errortext);
}
return(this);
if (type_index >= 0)
{
if (*length >= 0)
- yyerror("No multi-dimensional array support");
+ mmerror(ET_FATAL, "No multi-dimensional array support");
*length = type_index;
}
if (type_dimension >= 0)
{
if (*dimension >= 0 && *length >= 0)
- yyerror("No multi-dimensional array support");
+ mmerror(ET_FATAL, "No multi-dimensional array support");
if (*dimension >= 0)
*length = *dimension;
}
if (*length >= 0 && *dimension >= 0 && pointer)
- yyerror("No multi-dimensional array support");
+ mmerror(ET_FATAL, "No multi-dimensional array support");
switch (type_enum)
{
}
if (*length >= 0)
- yyerror("No multi-dimensional array support for structures");
+ mmerror(ET_FATAL, "No multi-dimensional array support for structures");
break;
case ECPGt_varchar:
}
if (*length >= 0)
- yyerror("No multi-dimensional array support for simple data types");
+ mmerror(ET_FATAL, "No multi-dimensional array support for simple data types");
break;
}
NEW, NOCREATEDB, NOCREATEUSER, NONE, NOTHING, NOTIFY, NOTNULL,
OFFSET, OIDS, OPERATOR, PASSWORD, PROCEDURAL,
RENAME, RESET, RETURNS, ROW, RULE,
- SERIAL, SEQUENCE, SETOF, SHARE, SHOW, START, STATEMENT, STDIN, STDOUT,
+ SEQUENCE, SERIAL, SETOF, SHARE, SHOW, START, STATEMENT, STDIN, STDOUT, SYSID
TRUNCATE, TRUSTED,
UNLISTEN, UNTIL, VACUUM, VALID, VERBOSE, VERSION
%type <str> def_elem def_list definition def_name def_type DefineStmt
%type <str> opt_instead event event_object RuleActionList opt_using
%type <str> RuleActionStmtOrEmpty RuleActionMulti join_list func_as
-%type <str> RuleStmt opt_column opt_name oper_argtypes
+%type <str> RuleStmt opt_column opt_name oper_argtypes sysid_clause
%type <str> MathOp RemoveFuncStmt aggr_argtype for_update_clause
%type <str> RemoveAggrStmt remove_type RemoveStmt ExtendStmt
%type <str> RemoveOperStmt RenameStmt all_Op user_valid_clause
%type <str> select_offset_value table_list using_expr join_expr
%type <str> using_list from_expr table_expr join_clause join_type
%type <str> join_qual update_list join_clause join_clause_with_union
-%type <str> opt_level opt_lock lock_type OptConstrTrigDeferrable,
-%type <str> OptConstrTrigInitdeferred OptConstrFromTable comment_op
+%type <str> opt_level opt_lock lock_type,
+%type <str> OptConstrFromTable comment_op ConstraintAttributeSpec
%type <str> constraints_set_list constraints_set_namelist comment_fn
%type <str> constraints_set_mode comment_type comment_cl comment_ag
+%type <str> ConstraintDeferrabilitySpec ConstraintTimeSpec
%type <str> ECPGWhenever ECPGConnect connection_target ECPGOpen
%type <str> indicator ECPGExecute ECPGPrepare ecpg_using
| ConstraintsSetStmt { output_statement($1, 0); }
| ECPGConnect {
if (connection)
- yyerror("no at option for connect statement.\n");
+ mmerror(ET_ERROR, "no at option for connect statement.\n");
fprintf(yyout, "{ ECPGconnect(__LINE__, %s, %d);", $1, autocommit);
whenever_action(2);
}
| ECPGDeallocate {
if (connection)
- yyerror("no at option for connect statement.\n");
+ mmerror(ET_ERROR, "no at option for connect statement.\n");
fputc('{', yyout);
fputs($1, yyout);
}
| ECPGDisconnect {
if (connection)
- yyerror("no at option for disconnect statement.\n");
+ mmerror(ET_ERROR, "no at option for disconnect statement.\n");
fprintf(yyout, "{ ECPGdisconnect(__LINE__, \"%s\");", $1);
whenever_action(2);
output_statement($1, 0);
}
| ECPGFree {
- fprintf(yyout, "{ ECPGdeallocate(__LINE__, \"%s\");", $1);
+ fprintf(yyout, "{ ECPGdeallocate(__LINE__, %s, \"%s\");", connection ? connection : "NULL", $1);
whenever_action(2);
free($1);
}
if (ptr == NULL)
{
sprintf(errortext, "trying to open undeclared cursor %s\n", $1);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
fprintf(yyout, "{ ECPGdo(__LINE__, %s, \"%s\",", ptr->connection ? ptr->connection : "NULL", ptr->command);
}
| ECPGPrepare {
if (connection)
- yyerror("no at option for set connection statement.\n");
+ mmerror(ET_ERROR, "no at option for set connection statement.\n");
fprintf(yyout, "{ ECPGprepare(__LINE__, %s);", $1);
whenever_action(2);
}
| ECPGSetConnection {
if (connection)
- yyerror("no at option for set connection statement.\n");
+ mmerror(ET_ERROR, "no at option for set connection statement.\n");
fprintf(yyout, "{ ECPGsetconn(__LINE__, %s);", $1);
whenever_action(2);
}
| ECPGTypedef {
if (connection)
- yyerror("no at option for typedef statement.\n");
+ mmerror(ET_ERROR, "no at option for typedef statement.\n");
output_simple_statement($1);
}
| ECPGVar {
if (connection)
- yyerror("no at option for var statement.\n");
+ mmerror(ET_ERROR, "no at option for var statement.\n");
output_simple_statement($1);
}
| ECPGWhenever {
if (connection)
- yyerror("no at option for whenever statement.\n");
+ mmerror(ET_ERROR, "no at option for whenever statement.\n");
output_simple_statement($1);
}
*
*****************************************************************************/
-CreateUserStmt: CREATE USER UserId user_passwd_clause user_createdb_clause
- user_createuser_clause user_group_clause user_valid_clause
+CreateUserStmt: CREATE USER UserId
+ user_createdb_clause user_createuser_clause user_group_clause
+ user_valid_clause
{
- $$ = cat3_str(cat5_str(make1_str("create user"), $3, $4, $5, $6), $7, $8);
+ $$ = cat2_str(cat5_str(make1_str("create user"), $3, $4, $5, $6), $7);
}
+ | CREATE USER UserId WITH sysid_clause user_passwd_clause
+ user_createdb_clause user_createuser_clause user_group_clause
+ user_valid_clause
+ {
+ $$ = cat5_str(cat5_str(make1_str("create user"), $3, make1_str("with"), $5, $6), $7, $8, $9, $10);
+ }
;
/*****************************************************************************
*
*****************************************************************************/
-AlterUserStmt: ALTER USER UserId user_passwd_clause user_createdb_clause
- user_createuser_clause user_group_clause user_valid_clause
+AlterUserStmt: ALTER USER UserId user_createdb_clause
+ user_createuser_clause user_group_clause user_valid_clause
{
- $$ = cat3_str(cat5_str(make1_str("alter user"), $3, $4, $5, $6), $7, $8);
+ $$ = cat2_str(cat5_str(make1_str("alter user"), $3, $4, $5, $6), $7);
+ }
+ |ALTER USER UserId WITH sysid_clause user_passwd_clause
+ user_createdb_clause user_createuser_clause user_group_clause
+ user_valid_clause
+ {
+ $$ = cat5_str(cat5_str(make1_str("alter user"), $3, make1_str("with"), $5, $6), $7, $8, $9, $10);
}
;
}
;
-user_passwd_clause: WITH PASSWORD UserId { $$ = cat2_str(make1_str("with password") , $3); }
- | /*EMPTY*/ { $$ = EMPTY; }
+user_passwd_clause: PASSWORD UserId { $$ = cat2_str(make1_str("password") , $2); }
+ | /*EMPTY*/ { $$ = EMPTY; }
;
+sysid_clause: SYSID Iconst { $$ = cat2_str(make1_str("sysid"), $2); }
+ | /*EMPTY*/ { $$ = EMPTY; }
+ ;
+
user_createdb_clause: CREATEDB
{
$$ = make1_str("createdb");
}
;
-user_group_clause: IN GROUP user_group_list { $$ = cat2_str(make1_str("in group"), $3); }
+user_group_clause: IN GROUP user_group_list
+ {
+ /* the backend doesn't actually process this,
+ * so an warning message is probably fairer */
+ mmerror(ET_WARN, "IN GROUP is not implemented");
+
+ $$ = cat2_str(make1_str("in group"), $3);
+ }
| /*EMPTY*/ { $$ = EMPTY; }
;
#ifdef MULTIBYTE
$$ = cat2_str(make1_str("set names"), $3);
#else
- yyerror("SET NAMES is not supported");
+ mmerror(ET_ERROR, "SET NAMES is not supported");
#endif
}
;
$$ = make3_str(make1_str("add("), $3, make1_str(")"));
}
| DROP opt_column ColId
- { yyerror("ALTER TABLE/DROP COLUMN not yet implemented"); }
+ { mmerror(ET_ERROR, "ALTER TABLE/DROP COLUMN not yet implemented"); }
| ALTER opt_column ColId SET DEFAULT a_expr
- { yyerror("ALTER TABLE/ALTER COLUMN/SET DEFAULT not yet implemented"); }
+ { mmerror(ET_ERROR, "ALTER TABLE/ALTER COLUMN/SET DEFAULT not yet implemented"); }
| ALTER opt_column ColId DROP DEFAULT
- { yyerror("ALTER TABLE/ALTER COLUMN/DROP DEFAULT not yet implemented"); }
+ { mmerror(ET_ERROR, "ALTER TABLE/ALTER COLUMN/DROP DEFAULT not yet implemented"); }
| ADD ConstraintElem
- { yyerror("ALTER TABLE/ADD CONSTRAINT not yet implemented"); }
+ { mmerror(ET_ERROR, "ALTER TABLE/ADD CONSTRAINT not yet implemented"); }
;
/*****************************************************************************
OptTempScope: GLOBAL
{
- yyerror("GLOBAL TEMPORARY TABLE is not currently supported");
+ mmerror(ET_ERROR, "GLOBAL TEMPORARY TABLE is not currently supported");
$$ = make1_str("global");
}
| LOCAL { $$ = make1_str("local"); }
}
| REFERENCES ColId opt_column_list key_match key_actions
{
- fprintf(stderr, "CREATE TABLE/FOREIGN KEY clause ignored; not yet implemented");
- $$ = EMPTY;
+ $$ = cat5_str(make1_str("references"), $2, $3, $4, $5);
}
;
}
| FOREIGN KEY '(' columnList ')' REFERENCES ColId opt_column_list key_match key_actions
{
- fprintf(stderr, "CREATE TABLE/FOREIGN KEY clause ignored; not yet implemented");
- $$ = "";
+ $$ = cat3_str(cat5_str(make1_str("foreign key("), $4, make1_str(") references"), $7, $8), $9, $10);
}
;
-key_match: MATCH FULL { $$ = make1_str("match full"); }
- | MATCH PARTIAL { $$ = make1_str("match partial"); }
- | /*EMPTY*/ { $$ = EMPTY; }
+key_match: MATCH FULL
+ {
+ $$ = make1_str("match full");
+ }
+ | MATCH PARTIAL
+ {
+ mmerror(ET_WARN, "FOREIGN KEY match type PARTIAL not implemented yet");
+ $$ = make1_str("match partial");
+ }
+ | /*EMPTY*/
+ {
+ mmerror(ET_WARN, "FOREIGN KEY match type UNSPECIFIED not implemented yet");
+ $$ = EMPTY;
+ }
;
-key_actions: key_action key_action { $$ = cat2_str($1, $2); }
- | key_action { $$ = $1; }
- | /*EMPTY*/ { $$ = EMPTY; }
+key_actions: key_action key_action { $$ = cat2_str($1, $2); }
+ | key_action { $$ = $1; }
+ | /*EMPTY*/ { $$ = EMPTY; }
;
key_action: ON DELETE key_reference { $$ = cat2_str(make1_str("on delete"), $3); }
;
key_reference: NO ACTION { $$ = make1_str("no action"); }
+ | RESTRICT { $$ = make1_str("restrict"); }
| CASCADE { $$ = make1_str("cascade"); }
| SET DEFAULT { $$ = make1_str("set default"); }
| SET NULL_P { $$ = make1_str("set null"); }
CreateAsStmt: CREATE OptTemp TABLE relation_name OptCreateAs AS SelectStmt
{
if (FoundInto == 1)
- yyerror("CREATE TABLE/AS SELECT may not specify INTO");
+ mmerror(ET_ERROR, "CREATE TABLE/AS SELECT may not specify INTO");
$$ = cat5_str(cat3_str(make1_str("create"), $2, make1_str("table")), $4, $5, make1_str("as"), $7);
}
}
| CREATE CONSTRAINT TRIGGER name AFTER TriggerOneEvent ON
relation_name OptConstrFromTable
- OptConstrTrigDeferrable OptConstrTrigInitdeferred
+ ConstraintAttributeSpec
FOR EACH ROW EXECUTE PROCEDURE
name '(' TriggerFuncArgs ')'
{
- $$ = cat2_str(cat5_str(cat5_str(cat5_str(make1_str("create constraint trigger"), $4, make1_str("after"), $6, make1_str("on")), $8, $9, $10, $11), make1_str("for each row execute procedure"), $17, make1_str("("), $19), make1_str(")"));
+ $$ = cat5_str(cat5_str(cat5_str(make1_str("create constraint trigger"), $4, make1_str("after"), $6, make1_str("on")), $8, $9, $10, make1_str("for each row execute procedure")), $16, make1_str("("), $18, make1_str(")"));
}
;
}
;
-OptConstrTrigDeferrable: /* Empty */
+ConstraintAttributeSpec: /* Empty */
+ { $$ = EMPTY; }
+ | ConstraintDeferrabilitySpec
+ { $$ = $1; }
+ | ConstraintDeferrabilitySpec ConstraintTimeSpec
+ {
+ if (strcmp($1, "deferrable") != 0 && strcmp($2, "initially deferrable") == 0 )
+ mmerror(ET_ERROR, "INITIALLY DEFERRED constraint must be DEFERRABLE");
+
+ $$ = cat2_str($1, $2);
+ }
+ | ConstraintTimeSpec
+ { $$ = $1; }
+ | ConstraintTimeSpec ConstraintDeferrabilitySpec
+ {
+ if (strcmp($2, "deferrable") != 0 && strcmp($1, "initially deferrable") == 0 )
+ mmerror(ET_ERROR, "INITIALLY DEFERRED constraint must be DEFERRABLE");
+
+ $$ = cat2_str($1, $2);
+ }
+ ;
+
+ConstraintDeferrabilitySpec: NOT DEFERRABLE
{
- $$ = EMPTY;
+ $$ = make1_str("not deferrable");
}
| DEFERRABLE
{
$$ = make1_str("deferrable");
}
- | NOT DEFERRABLE
- {
- $$ = make1_str("not deferrable");
- }
;
-OptConstrTrigInitdeferred: /* Empty */
+ConstraintTimeSpec: INITIALLY IMMEDIATE
{
- $$ = EMPTY;
+ $$ = make1_str("initially immediate");
}
| INITIALLY DEFERRED
{
$$ = make1_str("initially deferrable");
}
- | INITIALLY IMMEDIATE
- {
- $$ = make1_str("initially immediate");
- }
;
-
DropTrigStmt: DROP TRIGGER name ON relation_name
{
$$ = cat4_str(make1_str("drop trigger"), $3, make1_str("on"), $5);
FetchStmt: FETCH opt_direction fetch_how_many opt_portal_name INTO into_list
{
- if (strncmp($2, "relative", strlen("relative")) == 0 && atol($3) == 0L)
- yyerror("FETCH/RELATIVE at current position is not supported");
+ if (strcmp($2, "relative") == 0 && atol($3) == 0L)
+ mmerror(ET_ERROR, "FETCH/RELATIVE at current position is not supported");
$$ = cat4_str(make1_str("fetch"), $2, $3, $4);
}
| RELATIVE { $$ = make1_str("relative"); }
| ABSOLUTE
{
- fprintf(stderr, "FETCH/ABSOLUTE not supported, using RELATIVE");
+ mmerror(ET_WARN, "FETCH/ABSOLUTE not supported, backend will use RELATIVE");
$$ = make1_str("absolute");
}
| /*EMPTY*/ { $$ = EMPTY; /* default */ }
opt_with_grant: WITH GRANT OPTION
{
- yyerror("WITH GRANT OPTION is not supported. Only relation owners can set privileges");
+ mmerror(ET_ERROR, "WITH GRANT OPTION is not supported. Only relation owners can set privileges");
}
| /*EMPTY*/
;
oper_argtypes: name
{
- yyerror("parser: argument type missing (use NONE for unary operators)");
+ mmerror(ET_ERROR, "parser: argument type missing (use NONE for unary operators)");
}
| name ',' name
{ $$ = cat3_str($1, make1_str(","), $3); }
CreatedbStmt: CREATE DATABASE database_name WITH opt_database1 opt_database2
{
if (strlen($5) == 0 || strlen($6) == 0)
- yyerror("CREATE DATABASE WITH requires at least an option");
+ mmerror(ET_ERROR, "CREATE DATABASE WITH requires at least an option");
#ifndef MULTIBYTE
if (strlen($6) != 0)
- yyerror("WITH ENCODING is not supported");
+ mmerror(ET_ERROR, "WITH ENCODING is not supported");
#endif
$$ = cat5_str(make1_str("create database"), $3, make1_str("with"), $5, $6);
}
| VACUUM opt_verbose opt_analyze relation_name opt_va_list
{
if ( strlen($5) > 0 && strlen($4) == 0 )
- yyerror("parser: syntax error at or near \"(\"");
+ mmerror(ET_ERROR, "parser: syntax error at or near \"(\"");
$$ = cat5_str(make1_str("vacuum"), $2, $3, $4, $5);
}
;
{
/* re-definition is a bug */
sprintf(errortext, "cursor %s already defined", $2);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
}
SelectStmt: select_clause sort_clause for_update_clause opt_select_limit
{
if (strlen($3) > 0 && ForUpdateNotAllowed != 0)
- yyerror("FOR UPDATE is not allowed in this context");
+ mmerror(ET_ERROR, "FOR UPDATE is not allowed in this context");
ForUpdateNotAllowed = 0;
$$ = cat4_str($1, $2, $3, $4);
join_clause_with_union: join_clause
{ $$ = $1; }
| table_expr UNION JOIN table_expr
- { yyerror("UNION JOIN not yet implemented"); }
+ { mmerror(ET_ERROR, "UNION JOIN not yet implemented"); }
;
join_clause: table_expr join_list
join_type: FULL join_outer
{
$$ = cat2_str(make1_str("full"), $2);
- fprintf(stderr,"FULL OUTER JOIN not yet implemented\n");
+ mmerror(ET_WARN, "FULL OUTER JOIN not yet implemented");
}
| LEFT join_outer
{
$$ = cat2_str(make1_str("left"), $2);
- fprintf(stderr,"LEFT OUTER JOIN not yet implemented\n");
+ mmerror(ET_WARN, "LEFT OUTER JOIN not yet implemented");
}
| RIGHT join_outer
{
$$ = cat2_str(make1_str("right"), $2);
- fprintf(stderr,"RIGHT OUTER JOIN not yet implemented\n");
+ mmerror(ET_WARN, "RIGHT OUTER JOIN not yet implemented");
}
| OUTER_P
{
$$ = make1_str("outer");
- fprintf(stderr,"OUTER JOIN not yet implemented\n");
+ mmerror(ET_WARN, "OUTER JOIN not yet implemented");
}
| INNER_P
{
opt_float: '(' Iconst ')'
{
if (atol($2) < 1)
- yyerror("precision for FLOAT must be at least 1");
+ mmerror(ET_ERROR, "precision for FLOAT must be at least 1");
else if (atol($2) >= 16)
- yyerror("precision for FLOAT must be less than 16");
+ mmerror(ET_ERROR, "precision for FLOAT must be less than 16");
$$ = make3_str(make1_str("("), $2, make1_str(")"));
}
| /*EMPTY*/
{
if (atol($2) < 1 || atol($2) > NUMERIC_MAX_PRECISION) {
sprintf(errortext, "NUMERIC precision %s must be between 1 and %d", $2, NUMERIC_MAX_PRECISION);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
if (atol($4) < 0 || atol($4) > atol($2)) {
sprintf(errortext, "NUMERIC scale %s must be between 0 and precision %s", $4, $2);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
$$ = cat3_str(make2_str(make1_str("("), $2), make1_str(","), make2_str($4, make1_str(")")));
}
{
if (atol($2) < 1 || atol($2) > NUMERIC_MAX_PRECISION) {
sprintf(errortext, "NUMERIC precision %s must be between 1 and %d", $2, NUMERIC_MAX_PRECISION);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
$$ = make3_str(make1_str("("), $2, make1_str(")"));
}
{
if (atol($2) < 1 || atol($2) > NUMERIC_MAX_PRECISION) {
sprintf(errortext, "NUMERIC precision %s must be between 1 and %d", $2, NUMERIC_MAX_PRECISION);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
if (atol($4) < 0 || atol($4) > atol($2)) {
sprintf(errortext, "NUMERIC scale %s must be between 0 and precision %s", $4, $2);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
$$ = cat3_str(make2_str(make1_str("("), $2), make1_str(","), make2_str($4, make1_str(")")));
}
{
if (atol($2) < 1 || atol($2) > NUMERIC_MAX_PRECISION) {
sprintf(errortext, "NUMERIC precision %s must be between 1 and %d", $2, NUMERIC_MAX_PRECISION);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
$$ = make3_str(make1_str("("), $2, make1_str(")"));
}
Character: character '(' Iconst ')'
{
if (strncasecmp($1, "char", strlen("char")) && strncasecmp($1, "varchar", strlen("varchar")))
- yyerror("internal parsing error; unrecognized character type");
- if (atol($3) < 1) {
+ mmerror(ET_ERROR, "internal parsing error; unrecognized character type");
+ if (atol($3) < 1)
+ {
sprintf(errortext, "length for '%s' type must be at least 1",$1);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
- else if (atol($3) > MaxAttrSize) {
+ else if (atol($3) > MaxAttrSize)
+ {
sprintf(errortext, "length for type '%s' cannot exceed %ld", $1, MaxAttrSize);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
$$ = cat2_str($1, make3_str(make1_str("("), $3, make1_str(")")));
character: CHARACTER opt_varying opt_charset opt_collate
{
- if (strlen($4) > 0)
- fprintf(stderr, "COLLATE %s not yet implemented",$4);
+ if (strlen($4) > 0)
+ {
+ sprintf(errortext, "COLLATE %s not yet implemented", $4);
+ mmerror(ET_WARN, errortext);
+ }
$$ = cat4_str(make1_str("character"), $2, $3, $4);
}
| CURRENT_TIME '(' Iconst ')'
{
if (atol($3) != 0)
- fprintf(stderr,"CURRENT_TIME(%s) precision not implemented; zero used instead", $3);
+ {
+ sprintf(errortext, "CURRENT_TIME(%s) precision not implemented; backend will use zero instead", $3);
+ mmerror(ET_WARN, errortext);
+ }
+
$$ = make1_str("current_time");
}
| CURRENT_TIMESTAMP
| CURRENT_TIMESTAMP '(' Iconst ')'
{
if (atol($3) != 0)
- fprintf(stderr,"CURRENT_TIMESTAMP(%s) precision not implemented; zero used instead",$3);
+ {
+ sprintf(errortext, "CURRENT_TIMESTAMP(%s) precision not implemented; backend will use zero instead", $3);
+ mmerror(ET_WARN, errortext);
+ }
+
$$ = make1_str("current_timestamp");
}
| CURRENT_USER
{
$$ = cat5_str(make1_str("nullif("), $3, make1_str(","), $5, make1_str(")"));
- fprintf(stderr, "NULLIF() not yet fully implemented");
+ mmerror(ET_WARN, "NULLIF() not yet fully implemented");
}
| COALESCE '(' expr_list ')'
{
if (strcmp(LogRelationName, $1) == 0
|| strcmp(VariableRelationName, $1) == 0) {
sprintf(errortext, make1_str("%s cannot be accessed by users"),$1);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
else
$$ = $1;
| STATEMENT { $$ = make1_str("statement"); }
| STDIN { $$ = make1_str("stdin"); }
| STDOUT { $$ = make1_str("stdout"); }
+ | SYSID { $$ = make1_str("sysid"); }
| TIME { $$ = make1_str("time"); }
| TIMESTAMP { $$ = make1_str("timestamp"); }
| TIMEZONE_HOUR { $$ = make1_str("timezone_hour"); }
if (QueryIsRule)
$$ = make1_str("current");
else
- yyerror("CURRENT used in non-rule query");
+ mmerror(ET_ERROR, "CURRENT used in non-rule query");
}
| NEW
{
if (QueryIsRule)
$$ = make1_str("new");
else
- yyerror("NEW used in non-rule query");
+ mmerror(ET_ERROR, "NEW used in non-rule query");
}
;
if (strlen($2) > 0 && *($2) != '@')
{
sprintf(errortext, "parse error at or near '%s'", $2);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
$$ = make5_str(make1_str("\""), $1, $2, $3, make1_str("\""));
| db_prefix server opt_port '/' database_name opt_options
{
/* new style: <tcp|unix>:postgresql://server[:port][/dbname] */
- if (strncmp($2, "://", 3) != 0)
+ if (strncmp($2, "://", strlen("://")) != 0)
{
sprintf(errortext, "parse error at or near '%s'", $2);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
- if (strncmp($1, "unix", 4) == 0 && strncmp($2 + 3, "localhost", 9) != 0)
+ if (strncmp($1, "unix", strlen("unix")) == 0 && strncmp($2 + strlen("://"), "localhost", strlen("localhost")) != 0)
{
sprintf(errortext, "unix domain sockets only work on 'localhost' but not on '%9.9s'", $2);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
- if (strncmp($1, "unix", 4) != 0 && strncmp($1, "tcp", 3) != 0)
+ if (strncmp($1, "unix", strlen("unix")) != 0 && strncmp($1, "tcp", strlen("tcp")) != 0)
{
sprintf(errortext, "only protocols 'tcp' and 'unix' are supported");
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
$$ = make4_str(make5_str(make1_str("\""), $1, $2, $3, make1_str("/")), $5, $6, make1_str("\""));
if (strcmp($2, "postgresql") != 0 && strcmp($2, "postgres") != 0)
{
sprintf(errortext, "parse error at or near '%s'", $2);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
if (strcmp($1, "tcp") != 0 && strcmp($1, "unix") != 0)
{
sprintf(errortext, "Illegal connection type %s", $1);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
$$ = make3_str($1, make1_str(":"), $2);
if (strcmp($1, "@") != 0 && strcmp($1, "://") != 0)
{
sprintf(errortext, "parse error at or near '%s'", $1);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
$$ = make2_str($1, $2);
$$ = make2_str($1, make1_str(".arr"));
break;
default:
- yyerror("invalid datatype");
+ mmerror(ET_ERROR, "invalid datatype");
break;
}
}
opt_options: Op ColId
{
if (strlen($1) == 0)
- yyerror("parse error");
+ mmerror(ET_ERROR, "parse error");
if (strcmp($1, "?") != 0)
{
sprintf(errortext, "parse error at or near %s", $1);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
$$ = make2_str(make1_str("?"), $2);
{
/* re-definition is a bug */
sprintf(errortext, "cursor %s already defined", $2);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
}
{
struct_member_list[struct_level++] = NULL;
if (struct_level >= STRUCT_DEPTH)
- yyerror("Too many levels in nested structure definition");
+ mmerror(ET_ERROR, "Too many levels in nested structure definition");
$$ = cat2_str(make1_str("struct"), $2);
}
{
struct_member_list[struct_level++] = NULL;
if (struct_level >= STRUCT_DEPTH)
- yyerror("Too many levels in nested structure definition");
+ mmerror(ET_ERROR, "Too many levels in nested structure definition");
$$ = cat2_str(make1_str("union"), $2);
}
sprintf(ascii_len, "%d", length);
if (length == 0)
- yyerror ("pointer to varchar are not implemented");
+ mmerror(ET_ERROR, "pointer to varchar are not implemented");
if (dimension == 0)
$$ = make4_str(make5_str(mm_strdup(actual_storage[struct_level]), make1_str(" struct varchar_"), mm_strdup($2), make1_str(" { int len; char arr["), mm_strdup(ascii_len)), make1_str("]; } *"), mm_strdup($2), $4);
ecpg_using: /* empty */ { $$ = EMPTY; }
| USING variablelist {
- /* yyerror ("open cursor with variables not implemented yet"); */
+ /* mmerror ("open cursor with variables not implemented yet"); */
$$ = EMPTY;
}
ECPGRelease: TransactionStmt SQL_RELEASE
{
- if (strncmp($1, "begin", 5) == 0)
- yyerror("RELEASE does not make sense when beginning a transaction");
+ if (strcmp($1, "begin") == 0)
+ mmerror(ET_ERROR, "RELEASE does not make sense when beginning a transaction");
fprintf(yyout, "ECPGtrans(__LINE__, %s, \"%s\");",
connection ? connection : "NULL", $1);
{
/* re-definition is a bug */
sprintf(errortext, "type %s already defined", $2);
- yyerror(errortext);
+ mmerror(ET_ERROR, errortext);
}
}
$4.type_enum != ECPGt_char &&
$4.type_enum != ECPGt_unsigned_char &&
this->type->type_index >= 0)
- yyerror("No multi-dimensional array support for simple data types");
+ mmerror(ET_ERROR, "No multi-dimensional array support for simple data types");
types = this;
{
struct_member_list[struct_level++] = NULL;
if (struct_level >= STRUCT_DEPTH)
- yyerror("Too many levels in nested structure definition");
+ mmerror(ET_ERROR, "Too many levels in nested structure definition");
} '{' sql_variable_declarations '}'
{
ECPGfree_struct_member(struct_member_list[struct_level--]);
{
struct_member_list[struct_level++] = NULL;
if (struct_level >= STRUCT_DEPTH)
- yyerror("Too many levels in nested structure definition");
+ mmerror(ET_ERROR, "Too many levels in nested structure definition");
} '{' sql_variable_declarations '}'
{
ECPGfree_struct_member(struct_member_list[struct_level--]);
break;
default:
if (length >= 0)
- yyerror("No multi-dimensional array support for simple data types");
+ mmerror(ET_ERROR, "No multi-dimensional array support for simple data types");
if (dimension < 0)
type = ECPGmake_simple_type(actual_type[struct_level].type_enum, 1);
break;
default:
if (length >= 0)
- yyerror("No multi-dimensional array support for simple data types");
+ mmerror(ET_ERROR, "No multi-dimensional array support for simple data types");
if (dimension < 0)
type = ECPGmake_simple_type($4.type_enum, 1);
void yyerror(char * error)
{
- fprintf(stderr, "%s:%d: %s\n", input_filename, yylineno, error);
- exit(PARSE_ERROR);
+ mmerror(ET_ERROR, error);
}