summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-09-07 12:23:58 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2017-09-07 12:23:58 +0300
commita82ed92a6a721f45f23e210c132d5b33d3dccd21 (patch)
treebb4c240cdc3dea2c4772a9fb2112054082ad0640 /sql
parent9f580bbc0e674bcb4b99a39767311539464b39d6 (diff)
parentd26fb96a9f225e53941fad5feb21abddbbf99a95 (diff)
downloadmariadb-git-a82ed92a6a721f45f23e210c132d5b33d3dccd21.tar.gz
Merge 10.2 into bb-10.2-ext
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_partition.cc2
-rw-r--r--sql/sp.cc1
-rw-r--r--sql/sp_head.cc20
-rw-r--r--sql/sp_head.h3
-rw-r--r--sql/sql_class.cc1
-rw-r--r--sql/sql_table.cc1
6 files changed, 26 insertions, 2 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 2bb43ec794f..12ca31ad50e 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -7910,7 +7910,7 @@ uint32 ha_partition::calculate_key_hash_value(Field **field_array)
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_GEOMETRY:
- /* fall through. */
+ /* fall through */
default:
DBUG_ASSERT(0); // New type?
/* Fall through for default hashing (5.5). */
diff --git a/sql/sp.cc b/sql/sp.cc
index 015e2f77b21..32adb3f7195 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -807,6 +807,7 @@ static sp_head *sp_compile(THD *thd, String *defstr, sql_mode_t sql_mode,
else
{
sp= thd->lex->sphead;
+ sp->set_select_number(thd->select_number);
}
thd->pop_internal_handler();
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 2ea40e37754..b83195b8c71 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -558,7 +558,7 @@ sp_head::sp_head(const Sp_handler *sph)
m_defstr(null_clex_str),
m_sp_cache_version(0),
m_creation_ctx(0),
- unsafe_flags(0),
+ unsafe_flags(0), m_select_number(1),
m_created(0),
m_modified(0),
m_recursion_level(0),
@@ -2028,8 +2028,26 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
if (!err_status)
{
+ /*
+ Normally the counter is not reset between parsing and first execution,
+ but it is possible in case of error to have parsing on one CALL and
+ first execution (where VIEW will be parsed and added). So we store the
+ counter after parsing and restore it before execution just to avoid
+ repeating SELECT numbers.
+ */
+ thd->select_number= m_select_number;
+
err_status= execute(thd, TRUE);
DBUG_PRINT("info", ("execute returned %d", (int) err_status));
+ /*
+ This execution of the SP was aborted with an error (e.g. "Table not
+ found"). However it might still have consumed some numbers from the
+ thd->select_number counter. The next sp->exec() call must not use the
+ consumed numbers, so we remember the first free number (We know that
+ nobody will use it as this execution has stopped with an error).
+ */
+ if (err_status)
+ set_select_number(thd->select_number);
}
if (save_log_general)
diff --git a/sql/sp_head.h b/sql/sp_head.h
index c3dab609823..207d41f74fd 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -236,6 +236,7 @@ private:
*/
uint32 unsafe_flags;
+ uint m_select_number;
public:
inline Stored_program_creation_ctx *get_creation_ctx()
{
@@ -818,6 +819,8 @@ public:
sp_pcontext *get_parse_context() { return m_pcont; }
+ void set_select_number(uint num) { m_select_number= num; }
+
bool check_execute_access(THD *thd) const;
private:
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 6adadf8f377..f4f67ab9244 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -716,6 +716,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
/* statement id */ 0),
rli_fake(0), rgi_fake(0), rgi_slave(NULL),
protocol_text(this), protocol_binary(this),
+ m_current_stage_key(0),
in_sub_stmt(0), log_all_errors(0),
binlog_unsafe_warning_flags(0),
binlog_table_maps(0),
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 8d4789d0efe..a5e833f4a7e 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1173,6 +1173,7 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry)
action in the log entry by stepping up the phase.
*/
}
+ /* fall through */
case DDL_LOG_RENAME_ACTION:
{
error= TRUE;