PL/SQL parser
(MDEV-10142)
|
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Parser, Stored routines |
| Affects Version/s: | None |
| Fix Version/s: | 10.3.0 |
| Type: | Technical task | Priority: | Major |
| Reporter: | Alexander Barkov | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Compatibility | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Sprint: | 10.2.2-3, 10.2.2-1, 10.2.2-2, 10.2.2-4, 10.1.18 | ||||||||||||||||||||||||
| Description |
|
When running in sql_mode=ORACLE, MariaDB should support %TYPE in variable declarations, in function and procedure parameter delcarations, and function RETURN clauses:
The above statement declares a variable that has the same data type with the column a in the table t1. Example:
Scope of this taskThis task will implement %TYPE only for local variables and parameters. Using %TYPE in stored function RETURN clause will be done under terms of MDEV-11210. Oracle behavior1. %TYPE and missing tables during routine CREATE timeOracle checks if the referenced table exists during the routine CREATE time. If the referenced table does not exists, a warning is issued, but the routine is created.
The routine created with a missing identifier warning can be used as soon as the referenced table is created:
Notice, the CALL statement inserted 123 into t1. 2. Dropping the referenced table before the routine execution leads to an error on CALL
3. Dropping the referenced table during the routine execution does not affect %TYPE variables
Notice, the variable was declared after DROP TABLE. MariaDB behaviorTo make MariaDB reproduce Oracle's behavior as close as possible, we'll assing data type to %TYPE variables at sp_rcontext::create() time. Like Oracle, we'll not require the referenced tables to exists at the routine CREATE time. Unlike Oracle, we won't check the referenced tables and won't generate warnings. |
| Comments |
| Comment by Alexander Barkov [ 2017-04-06 ] | ||
|
Oracle's %TYPE syntax is similar to:
|