summaryrefslogtreecommitdiff
path: root/sql/ha_partition.cc
diff options
context:
space:
mode:
authorJacob Mathew <jacob.mathew@mariadb.com>2018-09-11 16:29:44 -0700
committerJacob Mathew <jacob.mathew@mariadb.com>2018-09-11 16:29:44 -0700
commiteb2ca3d44586ebfb887ee54ea5e5275ee4b25623 (patch)
treecd9be9a3dfd3aaa2c948bc639a361b69988996a8 /sql/ha_partition.cc
parente76c4c06f18c0d09a296a60b6d00332620e98e53 (diff)
downloadmariadb-git-bb-10.2-MDEV-16912.tar.gz
MDEV-16912: Spider Order By column[datatime] limit 5 returns 3 rowsbb-10.2-MDEV-16912
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.
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r--sql/ha_partition.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index d4ecc0d3970..43f936cf200 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -9130,6 +9130,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 };