1
0
mirror of https://github.com/MariaDB/server.git synced 2025-11-09 11:41:36 +03:00
Files
mariadb/sql
Alexander Barkov f429b5a834 MDEV-12011 sql_mode=ORACLE: cursor%ROWTYPE in variable declarations
Implementing cursor%ROWTYPE variables, according to the task description.

This patch includes a refactoring in how sp_instr_cpush and sp_instr_copen
work. This is needed to implement MDEV-10598 later easier, to allow variable
declarations go after cursor declarations (which is currently not allowed).

Before this patch, sp_instr_cpush worked as a Query_arena associated with
the cursor. sp_instr_copen::execute() switched to the sp_instr_cpush's
Query_arena when executing the cursor SELECT statement.

Now the Query_arena associated with the cursor is stored inside an instance
of a new class sp_lex_cursor (a LEX descendand) that contains the cursor SELECT
statement.

This simplifies the implementation, because:
- It's easier to follow the code when everything related to execution
  of the cursor SELECT statement is stored inside the same sp_lex_cursor
  object (rather than distributed between LEX and sp_instr_cpush).
- It's easier to link an sp_instr_cursor_copy_struct to
  sp_lex_cursor rather than to sp_instr_cpush.
- Also, it allows to perform sp_instr_cursor_copy_struct::exec_core()
  without having a pointer to sp_instr_cpush, using a pointer to sp_lex_cursor
  instead. This will be important for MDEV-10598, because sp_instr_cpush will
  happen *after* sp_instr_cursor_copy_struct.

After MDEV-10598 is done, this declaration:

DECLARE
  CURSOR cur IS SELECT * FROM t1;
  rec cur%ROWTYPE;
BEGIN
  OPEN cur;
  FETCH cur INTO rec;
  CLOSE cur;
END;

will generate about this code:

+-----+--------------------------+
| Pos | Instruction              |
+-----+--------------------------+
|   0 | cursor_copy_struct rec@0 | Points to sp_cursor_lex through m_lex_keeper
|   1 | set rec@0 NULL           |
|   2 | cpush cur@0              | Points to sp_cursor_lex through m_lex_keeper
|   3 | copen cur@0              | Points to sp_cursor_lex through m_cursor
|   4 | cfetch cur@0 rec@0       |
|   5 | cclose cur@0             |
|   6 | cpop 1                   |
+-----+--------------------------+

Notice, "cursor_copy_struct" and "set" will go before "cpush".
Instructions at positions 0, 2, 3 point to the same sp_cursor_lex instance.
2017-04-05 15:02:59 +04:00
..
2017-03-30 12:48:42 +02:00
2017-01-11 09:18:35 +02:00
2017-03-10 18:21:29 +01:00
2017-03-30 12:48:42 +02:00
2016-06-30 16:38:05 +02:00
2016-08-25 12:40:09 +02:00
2016-06-04 09:06:00 +02:00
2015-11-19 15:52:14 +01:00
2017-03-10 18:21:29 +01:00
2017-03-10 18:21:29 +01:00
2017-03-10 18:21:29 +01:00
2017-03-10 18:21:29 +01:00
2017-03-10 18:21:29 +01:00
2017-03-10 18:21:29 +01:00
2017-03-30 12:48:42 +02:00
2016-12-29 13:23:18 +01:00
2016-10-19 14:10:03 +04:00
2016-10-19 14:10:03 +04:00
2017-03-30 12:48:42 +02:00
2017-03-30 12:48:42 +02:00
2017-03-07 19:07:27 +02:00
2017-03-30 12:48:42 +02:00
2017-03-30 12:48:42 +02:00
2017-03-07 19:07:27 +02:00
2017-03-30 12:48:42 +02:00
2017-03-10 18:21:29 +01:00
2017-03-10 18:21:29 +01:00
2017-03-10 18:21:29 +01:00
2017-03-10 18:21:29 +01:00
2017-03-10 18:21:29 +01:00
2017-03-10 18:21:29 +01:00
2017-03-10 18:21:29 +01:00
2016-12-29 13:23:18 +01:00
2017-03-10 18:21:29 +01:00
2017-03-10 18:21:29 +01:00
2017-03-10 18:21:29 +01:00
2017-02-13 18:12:05 +01:00
2016-09-28 17:55:28 +02:00
2017-03-30 12:48:42 +02:00
2017-03-10 18:21:29 +01:00
2017-02-13 18:12:15 +01:00
2016-12-11 09:53:42 +01:00
2016-12-29 13:23:18 +01:00
2015-11-19 15:52:14 +01:00
2017-03-30 12:48:42 +02:00
2017-03-03 13:27:12 +02:00
2017-03-30 12:48:42 +02:00
2017-03-03 13:27:12 +02:00
2017-01-05 10:48:03 +02:00
2016-02-15 22:50:59 +01:00
2017-03-30 12:48:42 +02:00
2017-03-30 12:48:42 +02:00
2016-02-25 18:19:55 +01:00
2016-06-04 09:06:00 +02:00
2017-03-30 12:48:42 +02:00
2017-03-30 12:48:42 +02:00
2017-03-31 14:26:43 +04:00
2017-03-30 12:48:42 +02:00
2017-03-07 19:07:27 +02:00
2016-06-30 11:43:02 +02:00
2017-03-30 12:48:42 +02:00
2016-11-24 17:36:02 +03:00
2017-03-07 19:07:27 +02:00
2016-10-05 01:11:08 +03:00
2017-03-30 12:48:42 +02:00
2016-12-29 13:23:18 +01:00
2017-03-30 12:48:42 +02:00
2017-03-26 23:00:28 -07:00
2017-03-10 18:21:29 +01:00
2017-03-10 18:21:29 +01:00
2016-10-05 01:11:08 +03:00
2017-03-30 12:48:42 +02:00
2017-03-10 18:21:29 +01:00
2017-03-10 18:21:29 +01:00
2017-01-16 03:18:14 +02:00
2016-05-04 15:23:26 +02:00
2016-06-30 16:38:05 +02:00
2016-12-12 20:27:33 +01:00
2017-03-30 12:48:42 +02:00
2017-03-07 19:07:27 +02:00
2017-03-30 12:48:42 +02:00
2017-03-30 12:48:42 +02:00
2016-09-09 08:33:08 +02:00
2017-03-30 12:48:42 +02:00
2016-12-29 13:23:18 +01:00
2017-02-10 17:01:45 +01:00
2017-03-07 19:07:27 +02:00
2017-03-30 12:48:42 +02:00
2015-12-21 21:24:22 +01:00
2016-09-30 17:40:40 -07:00
2017-03-30 12:48:42 +02:00
2017-02-10 17:01:45 +01:00
2016-12-29 13:23:18 +01:00
2017-03-30 12:48:42 +02:00
2016-09-08 22:41:50 +02:00
2016-09-08 22:41:50 +02:00
2016-06-04 09:06:00 +02:00
2017-03-10 18:21:29 +01:00
2017-03-10 18:21:29 +01:00
2016-12-29 13:23:18 +01:00
2017-03-10 18:21:29 +01:00
2016-12-29 13:23:18 +01:00
2017-03-30 12:48:42 +02:00
2017-03-30 12:48:42 +02:00
2017-03-30 12:48:42 +02:00
2017-03-30 12:48:42 +02:00
2017-03-30 12:48:42 +02:00
2017-03-30 12:48:42 +02:00
2017-03-30 12:48:42 +02:00
2016-06-30 16:38:05 +02:00
2017-03-30 12:48:42 +02:00
2016-09-09 08:33:08 +02:00
2017-03-30 12:48:42 +02:00