summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorJacob Mathew <jacob.mathew@mariadb.com>2018-09-13 13:27:03 -0700
committerJacob Mathew <jacob.mathew@mariadb.com>2018-09-13 13:27:03 -0700
commit6c47c1c45696affc5e4b1ecb1b8e941c70dfde8a (patch)
tree52109d3ee96769be3169d87da8a8d8179f06577e /sql
parentc9d6728c36831ee4e1ba0b105652922faa4a3aee (diff)
downloadmariadb-git-6c47c1c45696affc5e4b1ecb1b8e941c70dfde8a.tar.gz
MDEV-16912: Spider Order By column[datatime] limit 5 returns 3 rows
The problem occurs in 10.2 and earlier releases of MariaDB Server because the Partition Engine was not pushing the engine conditions to the underlying storage engine of each partition. This caused Spider to return the first 5 rows in the table with the data provided by the customer. 2 of the 5 rows did not qualify the WHERE clause, so they were removed from the result set by the server. To fix the problem, I have back-ported support for engine condition pushdown in the Partition Engine from MariaDB Server 10.3. Author: Jacob Mathew. Reviewer: Kentoku Shiba. Cherry-Picked: Commit eb2ca3d on branch bb-10.2-MDEV-16912
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_partition.cc50
-rw-r--r--sql/ha_partition.h8
2 files changed, 58 insertions, 0 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 7444d61b3fc..549fbe4cdfb 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -9131,6 +9131,56 @@ int ha_partition::check_for_upgrade(HA_CHECK_OPT *check_opt)
}
+/**
+ Push an engine condition to the condition stack of the storage engine
+ for each partition.
+
+ @param cond Pointer to the engine condition to be pushed.
+
+ @return NULL Underlying engine will not return rows that
+ do not match the passed condition.
+ <> NULL 'Remainder' condition that the caller must use
+ to filter out records.
+*/
+
+const COND *ha_partition::cond_push(const COND *cond)
+{
+ handler **file= m_file;
+ COND *res_cond= NULL;
+ DBUG_ENTER("ha_partition::cond_push");
+
+ do
+ {
+ if ((*file)->pushed_cond != cond)
+ {
+ if ((*file)->cond_push(cond))
+ res_cond= (COND *) cond;
+ else
+ (*file)->pushed_cond= cond;
+ }
+ } while (*(++file));
+ DBUG_RETURN(res_cond);
+}
+
+
+/**
+ Pop the top condition from the condition stack of the storage engine
+ for each partition.
+*/
+
+void ha_partition::cond_pop()
+{
+ handler **file= m_file;
+ DBUG_ENTER("ha_partition::cond_pop");
+
+ do
+ {
+ (*file)->cond_pop();
+ } while (*(++file));
+ DBUG_VOID_RETURN;
+}
+
+
struct st_mysql_storage_engine partition_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
diff --git a/sql/ha_partition.h b/sql/ha_partition.h
index 11e34e1ebb0..4770d64b815 100644
--- a/sql/ha_partition.h
+++ b/sql/ha_partition.h
@@ -1213,6 +1213,14 @@ public:
virtual bool is_crashed() const;
virtual int check_for_upgrade(HA_CHECK_OPT *check_opt);
+ /*
+ -----------------------------------------------------------------------
+ MODULE condition pushdown
+ -----------------------------------------------------------------------
+ */
+ virtual const COND *cond_push(const COND *cond);
+ virtual void cond_pop();
+
private:
int handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, uint flags);
int handle_opt_part(THD *thd, HA_CHECK_OPT *check_opt, uint part_id,