[MDEV-12461] TYPE OF and ROW TYPE OF anchored data types for stored routine variables Created: 2017-04-06 Updated: 2017-08-18 Resolved: 2017-04-07 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Parser, Stored routines |
| Fix Version/s: | 10.3.0 |
| Type: | Task | Priority: | Major |
| Reporter: | Alexander Barkov | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Compatibility, datatype | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||
| Description |
|
This task will port a few tasks that were previously done for sql_mode=ORACLE, now for sql_mode=DEFAULT. See the list of "is blocked by" tasks for the list. Under terms of this task we'll add a new syntax in SP variable declarations:
This non-standard syntax will provide the functionality available in some other databases, often referenced to as anchored data type:
Example: using TYPE OF to in combination with MAX() and MIN()
Example: Using TYPE OF variables with a cursor
Example: using ROW TYPE OF for a cursor
Using ROW TYPE OF for a table
Scope of this taskThis task will implement anchored types only for local variables and parameters. Using TYPE OF in a stored function RETURNS clause will be done separately (similar to Variables declared with ROW TYPE OF will have the same features with implicit ROW variables (see Real data type instantiationThe real data type of TYPE OF and ROW TYPE OF table_name will become known at the very beginning of the stored routine call, namely during the sp_rcontext::create() call. ALTER TABLE or DROP TABLE done inside the current routine on the tables that appear in anchors won't affect the data type of the anchored variables, even if the variable is declare after a ALTER TABLE or DROP TABLE statement. The real data type of a ROW TYPE OF cursor_name variable will become known when execution enters into the block where the variable is declared. Data type instantiation will happen only one time. In a cursor ROW TYPE OF variable is declared inside a loop, its data type will become known on the very first iteration and won't change on further loop iterations. Referenced tables existenceThe tables referenced in TYPE OF and ROW TYPE OF declarations will be checked for existence at the beginning of the stored routine call. CREATE PROCEDURE or CREATE FUNCTION will not check the referenced tables for existence. |
| Comments |
| Comment by Alexander Barkov [ 2017-04-07 ] |
|
Pushed to bb-10.2-ext and 10.3. |