mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-02-02 08:00:39 +01:00
Reworked syntax for new error context vars, based on feedback from the other devs.
This commit is contained in:
parent
246f8a817d
commit
cd8b6e0a41
@ -170,20 +170,30 @@ SQLSTATE (FB 2.5)
|
|||||||
1. SQLSTATE always evaluates to NULL outside the exception handling block.
|
1. SQLSTATE always evaluates to NULL outside the exception handling block.
|
||||||
|
|
||||||
|
|
||||||
EXCEPTION (FB 4.0)
|
RDB$ERROR (FB 4.0)
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
Function:
|
Function:
|
||||||
Returns name of the active user-defined exception.
|
Returns specific context of the active exception.
|
||||||
|
|
||||||
Author:
|
Author:
|
||||||
Dmitry Yemanov <dimitr@firebirdsql.org>
|
Dmitry Yemanov <dimitr@firebirdsql.org>
|
||||||
|
|
||||||
Syntax rules:
|
Syntax rules:
|
||||||
EXCEPTION
|
RDB$ERROR ( context )
|
||||||
|
context ::= { GDSCODE | SQLCODE | SQLSTATE | EXCEPTION | MESSAGE }
|
||||||
|
|
||||||
|
GDSCODE, SQLCODE, SQLSTATE - see above
|
||||||
|
|
||||||
|
EXCEPTION : VARCHAR(63) CHARACTER SET UTF8
|
||||||
|
Returns name of the active user-defined exception
|
||||||
|
or NULL if active exception is a system one
|
||||||
|
|
||||||
|
MESSAGE : VARCHAR(1024) CHARACTER SET UTF8
|
||||||
|
Returns interpreted text for the active exception
|
||||||
|
|
||||||
Type:
|
Type:
|
||||||
VARCHAR(63) CHARACTER SET UTF8
|
Depends on context
|
||||||
|
|
||||||
Scope:
|
Scope:
|
||||||
PSQL, context of the exception handling block.
|
PSQL, context of the exception handling block.
|
||||||
@ -192,41 +202,8 @@ EXCEPTION (FB 4.0)
|
|||||||
BEGIN
|
BEGIN
|
||||||
...
|
...
|
||||||
WHEN ANY DO
|
WHEN ANY DO
|
||||||
IF (EXCEPTION IS NOT NULL)
|
EXECUTE PROCEDURE P_LOG_EXCEPTION(RDB$ERROR(MESSAGE));
|
||||||
EXECUTE PROCEDURE P_USR_EXCEPTION(EXCEPTION);
|
|
||||||
ELSE
|
|
||||||
EXECUTE PROCEDURE P_SYS_EXCEPTION;
|
|
||||||
END
|
END
|
||||||
|
|
||||||
Note(s):
|
Note(s):
|
||||||
1. EXCEPTION always contains NULL outside the exception handling block.
|
RDB$ERROR always contains NULL outside the exception handling block.
|
||||||
2. If system exception is thrown, EXCEPTION also contains NULL.
|
|
||||||
|
|
||||||
|
|
||||||
ERROR_MESSAGE (FB 4.0)
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
Function:
|
|
||||||
Returns interpreted text for the active exception.
|
|
||||||
|
|
||||||
Author:
|
|
||||||
Dmitry Yemanov <dimitr@firebirdsql.org>
|
|
||||||
|
|
||||||
Syntax rules:
|
|
||||||
ERROR_MESSAGE
|
|
||||||
|
|
||||||
Type:
|
|
||||||
VARCHAR(1024) CHARACTER SET UTF8
|
|
||||||
|
|
||||||
Scope:
|
|
||||||
PSQL, context of the exception handling block.
|
|
||||||
|
|
||||||
Example(s):
|
|
||||||
BEGIN
|
|
||||||
...
|
|
||||||
WHEN ANY DO
|
|
||||||
EXECUTE PROCEDURE P_LOG_EXCEPTION(ERROR_MESSAGE);
|
|
||||||
END
|
|
||||||
|
|
||||||
Note(s):
|
|
||||||
1. ERROR_MESSAGE always contains NULL outside the exception handling block.
|
|
||||||
|
@ -6125,7 +6125,9 @@ const InternalInfoNode::InfoAttr InternalInfoNode::INFO_TYPE_ATTRIBUTES[MAX_INFO
|
|||||||
{"SQLCODE", DsqlCompilerScratch::FLAG_BLOCK},
|
{"SQLCODE", DsqlCompilerScratch::FLAG_BLOCK},
|
||||||
{"ROW_COUNT", DsqlCompilerScratch::FLAG_BLOCK},
|
{"ROW_COUNT", DsqlCompilerScratch::FLAG_BLOCK},
|
||||||
{"INSERTING/UPDATING/DELETING", DsqlCompilerScratch::FLAG_TRIGGER},
|
{"INSERTING/UPDATING/DELETING", DsqlCompilerScratch::FLAG_TRIGGER},
|
||||||
{"SQLSTATE", DsqlCompilerScratch::FLAG_BLOCK}
|
{"SQLSTATE", DsqlCompilerScratch::FLAG_BLOCK},
|
||||||
|
{"EXCEPTION", DsqlCompilerScratch::FLAG_BLOCK},
|
||||||
|
{"MESSAGE", DsqlCompilerScratch::FLAG_BLOCK}
|
||||||
};
|
};
|
||||||
|
|
||||||
InternalInfoNode::InternalInfoNode(MemoryPool& pool, ValueExprNode* aArg)
|
InternalInfoNode::InternalInfoNode(MemoryPool& pool, ValueExprNode* aArg)
|
||||||
|
@ -1 +1 @@
|
|||||||
44 shift/reduce conflicts, 583 reduce/reduce conflicts.
|
44 shift/reduce conflicts, 17 reduce/reduce conflicts.
|
||||||
|
@ -593,7 +593,7 @@ using namespace Firebird;
|
|||||||
|
|
||||||
%token <metaNamePtr> CUME_DIST
|
%token <metaNamePtr> CUME_DIST
|
||||||
%token <metaNamePtr> DEFINER
|
%token <metaNamePtr> DEFINER
|
||||||
%token <metaNamePtr> ERROR_MESSAGE
|
%token <metaNamePtr> MESSAGE
|
||||||
%token <metaNamePtr> EXCLUDE
|
%token <metaNamePtr> EXCLUDE
|
||||||
%token <metaNamePtr> FOLLOWING
|
%token <metaNamePtr> FOLLOWING
|
||||||
%token <metaNamePtr> INVOKER
|
%token <metaNamePtr> INVOKER
|
||||||
@ -603,6 +603,7 @@ using namespace Firebird;
|
|||||||
%token <metaNamePtr> PRECEDING
|
%token <metaNamePtr> PRECEDING
|
||||||
%token <metaNamePtr> PRIVILEGE
|
%token <metaNamePtr> PRIVILEGE
|
||||||
%token <metaNamePtr> RANGE
|
%token <metaNamePtr> RANGE
|
||||||
|
%token <metaNamePtr> RDB_ERROR
|
||||||
%token <metaNamePtr> RDB_ROLE_IN_USE
|
%token <metaNamePtr> RDB_ROLE_IN_USE
|
||||||
%token <metaNamePtr> RDB_SYSTEM_PRIVILEGE
|
%token <metaNamePtr> RDB_SYSTEM_PRIVILEGE
|
||||||
%token <metaNamePtr> SECURITY
|
%token <metaNamePtr> SECURITY
|
||||||
@ -6952,12 +6953,25 @@ internal_info
|
|||||||
{ $$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_SQLSTATE)); }
|
{ $$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_SQLSTATE)); }
|
||||||
| ROW_COUNT
|
| ROW_COUNT
|
||||||
{ $$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_ROWS_AFFECTED)); }
|
{ $$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_ROWS_AFFECTED)); }
|
||||||
| EXCEPTION
|
| RDB_ERROR '(' error_context ')'
|
||||||
{ $$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_EXCEPTION)); }
|
{ $$ = newNode<InternalInfoNode>(MAKE_const_slong($3)); }
|
||||||
| ERROR_MESSAGE
|
|
||||||
{ $$ = newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_ERROR_MSG)); }
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
%type <int32Val> error_context
|
||||||
|
error_context
|
||||||
|
: GDSCODE
|
||||||
|
{ $$ = INFO_TYPE_GDSCODE; }
|
||||||
|
| SQLCODE
|
||||||
|
{ $$ = INFO_TYPE_SQLCODE; }
|
||||||
|
| SQLSTATE
|
||||||
|
{ $$ = INFO_TYPE_SQLSTATE; }
|
||||||
|
| EXCEPTION
|
||||||
|
{ $$ = INFO_TYPE_EXCEPTION; }
|
||||||
|
| MESSAGE
|
||||||
|
{ $$ = INFO_TYPE_ERROR_MSG; }
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
%type <intlStringPtr> sql_string
|
%type <intlStringPtr> sql_string
|
||||||
sql_string
|
sql_string
|
||||||
: STRING // string in current charset
|
: STRING // string in current charset
|
||||||
@ -8088,16 +8102,17 @@ non_reserved_word
|
|||||||
| TRUSTED
|
| TRUSTED
|
||||||
| CUME_DIST // added in FB 4.0
|
| CUME_DIST // added in FB 4.0
|
||||||
| DEFINER
|
| DEFINER
|
||||||
| ERROR_MESSAGE
|
|
||||||
| EXCLUDE
|
| EXCLUDE
|
||||||
| FOLLOWING
|
| FOLLOWING
|
||||||
| INVOKER
|
| INVOKER
|
||||||
|
| MESSAGE
|
||||||
| NTILE
|
| NTILE
|
||||||
| OTHERS
|
| OTHERS
|
||||||
| PERCENT_RANK
|
| PERCENT_RANK
|
||||||
| PRECEDING
|
| PRECEDING
|
||||||
| PRIVILEGE
|
| PRIVILEGE
|
||||||
| RANGE
|
| RANGE
|
||||||
|
| RDB_ERROR
|
||||||
| RDB_ROLE_IN_USE
|
| RDB_ROLE_IN_USE
|
||||||
| RDB_SYSTEM_PRIVILEGE
|
| RDB_SYSTEM_PRIVILEGE
|
||||||
| SECURITY
|
| SECURITY
|
||||||
|
@ -182,7 +182,6 @@ static const TOK tokens[] =
|
|||||||
{TOK_END, "END", false},
|
{TOK_END, "END", false},
|
||||||
{TOK_ENGINE, "ENGINE", true},
|
{TOK_ENGINE, "ENGINE", true},
|
||||||
{TOK_ENTRY_POINT, "ENTRY_POINT", false},
|
{TOK_ENTRY_POINT, "ENTRY_POINT", false},
|
||||||
{TOK_ERROR_MESSAGE, "ERROR_MESSAGE", true},
|
|
||||||
{TOK_ESCAPE, "ESCAPE", false},
|
{TOK_ESCAPE, "ESCAPE", false},
|
||||||
{TOK_EXCEPTION, "EXCEPTION", false},
|
{TOK_EXCEPTION, "EXCEPTION", false},
|
||||||
{TOK_EXCLUDE, "EXCLUDE", false},
|
{TOK_EXCLUDE, "EXCLUDE", false},
|
||||||
@ -269,6 +268,7 @@ static const TOK tokens[] =
|
|||||||
{TOK_MAXIMUM, "MAX", false},
|
{TOK_MAXIMUM, "MAX", false},
|
||||||
{TOK_MAXVALUE, "MAXVALUE", false},
|
{TOK_MAXVALUE, "MAXVALUE", false},
|
||||||
{TOK_MERGE, "MERGE", false},
|
{TOK_MERGE, "MERGE", false},
|
||||||
|
{TOK_MESSAGE, "MESSAGE", true},
|
||||||
{TOK_MILLISECOND, "MILLISECOND", false},
|
{TOK_MILLISECOND, "MILLISECOND", false},
|
||||||
{TOK_MIDDLENAME, "MIDDLENAME", false},
|
{TOK_MIDDLENAME, "MIDDLENAME", false},
|
||||||
{TOK_MINIMUM, "MIN", false},
|
{TOK_MINIMUM, "MIN", false},
|
||||||
@ -336,6 +336,7 @@ static const TOK tokens[] =
|
|||||||
{TOK_RANGE, "RANGE", false},
|
{TOK_RANGE, "RANGE", false},
|
||||||
{TOK_RANK, "RANK", false},
|
{TOK_RANK, "RANK", false},
|
||||||
{TOK_DB_KEY, "RDB$DB_KEY", false},
|
{TOK_DB_KEY, "RDB$DB_KEY", false},
|
||||||
|
{TOK_RDB_ERROR, "RDB$ERROR", true},
|
||||||
{TOK_RDB_GET_CONTEXT, "RDB$GET_CONTEXT", true},
|
{TOK_RDB_GET_CONTEXT, "RDB$GET_CONTEXT", true},
|
||||||
{TOK_RDB_RECORD_VERSION, "RDB$RECORD_VERSION", false},
|
{TOK_RDB_RECORD_VERSION, "RDB$RECORD_VERSION", false},
|
||||||
{TOK_RDB_ROLE_IN_USE, "RDB$ROLE_IN_USE", true},
|
{TOK_RDB_ROLE_IN_USE, "RDB$ROLE_IN_USE", true},
|
||||||
|
Loading…
Reference in New Issue
Block a user