1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-06 07:49:08 +03:00
See attached file. Now accepts "exec sql whenever sqlwarning".
This commit is contained in:
Marc G. Fournier
1999-01-21 20:01:34 +00:00
parent 1f37905681
commit cdbaec771c
6 changed files with 51 additions and 18 deletions

View File

@@ -38,6 +38,7 @@ static ScanKeyword ScanKeywords[] = {
{"section", SQL_SECTION},
{"sqlerror", SQL_SQLERROR},
{"sqlprint", SQL_SQLPRINT},
{"sqlwarning", SQL_SQLWARNING},
{"stop", SQL_STOP},
{"whenever", SQL_WHENEVER},
};

View File

@@ -45,7 +45,7 @@ output_line_number()
/*
* store the whenever action here
*/
static struct when when_error, when_nf;
static struct when when_error, when_nf, when_warn;
static void
print_action(struct when *w)
@@ -76,6 +76,12 @@ whenever_action(int mode)
fprintf(yyout, "\nif (sqlca.sqlcode == ECPG_NOT_FOUND) ");
print_action(&when_nf);
}
if (when_warn.code != W_NOTHING)
{
output_line_number();
fprintf(yyout, "\nif (sqlca.sqlwarn[0] == 'W') ");
print_action(&when_warn);
}
if (when_error.code != W_NOTHING)
{
output_line_number();
@@ -517,7 +523,7 @@ output_statement(char * stmt, int mode)
%token SQL_DISCONNECT SQL_FOUND SQL_GO SQL_GOTO
%token SQL_IDENTIFIED SQL_IMMEDIATE SQL_INDICATOR SQL_OPEN SQL_RELEASE
%token SQL_SECTION SQL_SEMI SQL_SQLERROR SQL_SQLPRINT SQL_START
%token SQL_STOP SQL_WHENEVER
%token SQL_STOP SQL_WHENEVER SQL_SQLWARNING
/* C token */
%token S_ANYTHING S_AUTO S_BOOL S_CHAR S_CONST S_DOUBLE S_ENUM S_EXTERN
@@ -4630,9 +4636,7 @@ ECPGSetConnection: SET SQL_CONNECTION connection_object
}
/*
* whenever statement: decide what to do in case of error/no data found
* according to SQL standards we miss: SQLSTATE, CONSTRAINT, SQLEXCEPTION
* and SQLWARNING
* according to SQL standards we lack: SQLSTATE, CONSTRAINT and SQLEXCEPTION
*/
ECPGWhenever: SQL_WHENEVER SQL_SQLERROR action {
when_error.code = $<action>3.code;
@@ -4644,6 +4648,11 @@ ECPGWhenever: SQL_WHENEVER SQL_SQLERROR action {
when_nf.command = $<action>4.command;
$$ = cat3_str(make1_str("/* exec sql whenever not found "), $4.str, make1_str("; */\n"));
}
| SQL_WHENEVER SQL_SQLWARNING action {
when_warn.code = $<action>3.code;
when_warn.command = $<action>3.command;
$$ = cat3_str(make1_str("/* exec sql whenever sql_warning "), $3.str, make1_str("; */\n"));
}
action : SQL_CONTINUE {
$<action>$.code = W_NOTHING;