summaryrefslogtreecommitdiff
path: root/sql/sp_head.h
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2005-06-23 20:22:08 +0400
committerunknown <konstantin@mysql.com>2005-06-23 20:22:08 +0400
commit91180cb8ab4924fc9907ee16ba3479f88c309bc2 (patch)
tree2939d7b4b2b50f100273331463568fdfbab27116 /sql/sp_head.h
parent5ae3967c878ac7cfb8475eeeb50c2ebd81f39cf6 (diff)
downloadmariadb-git-91180cb8ab4924fc9907ee16ba3479f88c309bc2.tar.gz
- implement inheritance of sp_instr: public Query_arena.
We need every instruction to have its own arena, because we want to track instruction's state (INITIALIZED_FOR_SP -> EXECUTED). Because of `if' statements and other conditional instructions used in stored procedures, not every instruction of a stored procedure gets executed during the first (or even subsequent) execution of the procedure. So it's better if we track the execution state of every instruction independently. All instructions of a given procedure now also share sp_head's mem_root, but keep their own free_list. This simplifies juggling with free Item lists in sp_head::execute. - free_items() moved to be a member of Query_arena. - logic of 'backup_arena' debug member of Query_arena has been changed to support multi-backups. Until now, TRUE 'backup_arena' meant that there is exactly one active backup of the THD arena. Now it means simply that the arena is used for backup, so that we can't accidentally overwrite an existing backup. This allows doing multiple backups, e.g. in sp_head::execute and Cursor::fetch, when THD arena is already backed up but we want to set yet another arena (usually the 'permanent' arena, to save permanent transformations/optimizations of a parsed tree). sql/sp_head.cc: - use Query_arena support in sp_head::execute() as now sp_instr inherites from it. sql/sp_head.h: - inherite sp_instr from Query_arena sql/sql_class.cc: - changed the principle of Query_arena::backup_arena; free_items is now a member of Query_arena. sql/sql_class.h: - changed the principle of Query_arena::backup_arena; free_items is now a member of Query_arena. sql/sql_prepare.cc: free_items() is now a member of Query_arena. sql/sql_select.cc: free_items() now automatically sets free_list to zero.
Diffstat (limited to 'sql/sp_head.h')
-rw-r--r--sql/sp_head.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/sql/sp_head.h b/sql/sp_head.h
index 2c75a320f30..aaef5a3d50e 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -274,7 +274,7 @@ private:
// "Instructions"...
//
-class sp_instr : public Sql_alloc
+class sp_instr :public Query_arena, public Sql_alloc
{
sp_instr(const sp_instr &); /* Prevent use of these */
void operator=(sp_instr &);
@@ -282,17 +282,16 @@ class sp_instr : public Sql_alloc
public:
uint marked;
- Item *free_list; // My Items
uint m_ip; // My index
sp_pcontext *m_ctx; // My parse context
// Should give each a name or type code for debugging purposes?
sp_instr(uint ip, sp_pcontext *ctx)
- :Sql_alloc(), marked(0), free_list(0), m_ip(ip), m_ctx(ctx)
+ :Query_arena(0, INITIALIZED_FOR_SP), marked(0), m_ip(ip), m_ctx(ctx)
{}
virtual ~sp_instr()
- { free_items(free_list); }
+ { free_items(); }
// Execute this instrution. '*nextp' will be set to the index of the next
// instruction to execute. (For most instruction this will be the