Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
4c308dd2
Commit
4c308dd2
authored
Mar 04, 2020
by
Roman Nozdrin
Committed by
Sergei Petrunia
Mar 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CLX-14 This commit adds support for pushed conditions for table API.
parent
f2994aaf
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
128 additions
and
6 deletions
+128
-6
mysql-test/suite/xpand/pushdown_conditions.result
mysql-test/suite/xpand/pushdown_conditions.result
+47
-0
mysql-test/suite/xpand/pushdown_conditions.test
mysql-test/suite/xpand/pushdown_conditions.test
+34
-0
storage/xpand/ha_xpand.cc
storage/xpand/ha_xpand.cc
+26
-2
storage/xpand/ha_xpand.h
storage/xpand/ha_xpand.h
+2
-0
storage/xpand/xpand_connection.cc
storage/xpand/xpand_connection.cc
+18
-3
storage/xpand/xpand_connection.h
storage/xpand/xpand_connection.h
+1
-1
No files found.
mysql-test/suite/xpand/pushdown_conditions.result
0 → 100644
View file @
4c308dd2
CREATE DATABASE xpd;
USE xpd;
DROP TABLE IF EXISTS cx1;
CREATE TABLE cx1(i BIGINT, i2 BIGINT, t TEXT)ENGINE=xpand;
INSERT INTO cx1 VALUES (41, 43, 'some1'), (42, 42, 'some2'), (43, 41, 'some3');
SELECT * FROM cx1 ORDER BY i;
i i2 t
41 43 some1
42 42 some2
43 41 some3
SET xpand_select_handler=OFF;
SELECT * FROM cx1 WHERE i>41 AND i2>41;
i i2 t
42 42 some2
EXPLAIN SELECT * FROM cx1 WHERE i>41 AND i2>41;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cx1 ALL NULL NULL NULL NULL 10000 Using where with pushed condition
SELECT * FROM cx1 WHERE i>41 AND i2>41 AND t='some2';
i i2 t
42 42 some2
EXPLAIN SELECT * FROM cx1 WHERE i>41 AND i2>41 AND t='some2';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cx1 ALL NULL NULL NULL NULL 10000 Using where with pushed condition
SELECT * FROM cx1 WHERE i>i2+1;
i i2 t
43 41 some3
EXPLAIN SELECT * FROM cx1 WHERE i>i2+1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cx1 ALL NULL NULL NULL NULL 10000 Using where with pushed condition
SET @@optimizer_switch='derived_merge=OFF';
SELECT * FROM (SELECT * FROM cx1 WHERE i>i2+1) a1 ORDER BY i;
i i2 t
43 41 some3
EXPLAIN SELECT * FROM (SELECT * FROM cx1 WHERE i>i2+1) a1 ORDER BY i;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 10000 Using filesort
2 PUSHED DERIVED NULL NULL NULL NULL NULL NULL NULL NULL
SET xpand_derived_handler=OFF;
SELECT * FROM (SELECT * FROM cx1 WHERE i>i2+1) a1 ORDER BY i;
i i2 t
43 41 some3
EXPLAIN SELECT * FROM (SELECT * FROM cx1 WHERE i>i2+1) a1 ORDER BY i;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 10000 Using filesort
2 DERIVED cx1 ALL NULL NULL NULL NULL 10000 Using where with pushed condition
USE test;
DROP DATABASE xpd;
mysql-test/suite/xpand/pushdown_conditions.test
0 → 100644
View file @
4c308dd2
CREATE
DATABASE
xpd
;
USE
xpd
;
--
disable_warnings
DROP
TABLE
IF
EXISTS
cx1
;
--
enable_warnings
CREATE
TABLE
cx1
(
i
BIGINT
,
i2
BIGINT
,
t
TEXT
)
ENGINE
=
xpand
;
INSERT
INTO
cx1
VALUES
(
41
,
43
,
'some1'
),
(
42
,
42
,
'some2'
),
(
43
,
41
,
'some3'
);
SELECT
*
FROM
cx1
ORDER
BY
i
;
SET
xpand_select_handler
=
OFF
;
SELECT
*
FROM
cx1
WHERE
i
>
41
AND
i2
>
41
;
EXPLAIN
SELECT
*
FROM
cx1
WHERE
i
>
41
AND
i2
>
41
;
SELECT
*
FROM
cx1
WHERE
i
>
41
AND
i2
>
41
AND
t
=
'some2'
;
EXPLAIN
SELECT
*
FROM
cx1
WHERE
i
>
41
AND
i2
>
41
AND
t
=
'some2'
;
SELECT
*
FROM
cx1
WHERE
i
>
i2
+
1
;
EXPLAIN
SELECT
*
FROM
cx1
WHERE
i
>
i2
+
1
;
# The plugin doesn't use pushdown conditions for DH as of 10.5.1
# but it is worth to test memory leaks.
SET
@@
optimizer_switch
=
'derived_merge=OFF'
;
SELECT
*
FROM
(
SELECT
*
FROM
cx1
WHERE
i
>
i2
+
1
)
a1
ORDER
BY
i
;
EXPLAIN
SELECT
*
FROM
(
SELECT
*
FROM
cx1
WHERE
i
>
i2
+
1
)
a1
ORDER
BY
i
;
SET
xpand_derived_handler
=
OFF
;
SELECT
*
FROM
(
SELECT
*
FROM
cx1
WHERE
i
>
i2
+
1
)
a1
ORDER
BY
i
;
EXPLAIN
SELECT
*
FROM
(
SELECT
*
FROM
cx1
WHERE
i
>
i2
+
1
)
a1
ORDER
BY
i
;
# SELECT * FROM (SELECT i FROM cx1 WHERE i=42)a1,(SELECT i FROM cx1 WHERE i =42)a2 WHERE a1.i=a2.i;
# EXPLAIN SELECT * FROM (SELECT i FROM cx1 WHERE i=42)a1,(SELECT i FROM cx1 WHERE i =42)a2 WHERE a1.i=a2.i;
USE
test
;
DROP
DATABASE
xpd
;
storage/xpand/ha_xpand.cc
View file @
4c308dd2
...
...
@@ -593,6 +593,7 @@ int ha_xpand::reset()
upsert_flag
&=
~
XPAND_HAS_UPSERT
;
upsert_flag
&=
~
XPAND_UPSERT_SENT
;
xpd_lock_type
=
XPAND_NO_LOCKS
;
pushdown_cond_list
.
empty
();
return
0
;
}
...
...
@@ -1079,8 +1080,25 @@ int ha_xpand::rnd_init(bool scan)
bitmap_set_all
(
&
scan_fields
);
#endif
String
*
pushdown_cond_sql
=
nullptr
;
if
(
pushdown_cond_list
.
elements
)
{
pushdown_cond_sql
=
new
String
();
while
(
pushdown_cond_list
.
elements
>
0
)
{
COND
*
cond
=
pushdown_cond_list
.
pop
();
String
sql_predicate
;
cond
->
print_for_table_def
(
&
sql_predicate
);
pushdown_cond_sql
->
append
(
sql_predicate
);
if
(
pushdown_cond_list
.
elements
>
0
)
pushdown_cond_sql
->
append
(
" AND "
);
}
}
error_code
=
trx
->
scan_table
(
xpand_table_oid
,
xpd_lock_type
,
&
scan_fields
,
THDVAR
(
thd
,
row_buffer
),
&
scan_cur
);
THDVAR
(
thd
,
row_buffer
),
&
scan_cur
,
pushdown_cond_sql
);
if
(
pushdown_cond_sql
!=
nullptr
)
delete
pushdown_cond_sql
;
if
(
error_code
==
HA_ERR_TABLE_DEF_CHANGED
)
xpand_mark_table_for_discovery
(
table
);
...
...
@@ -1255,11 +1273,17 @@ int ha_xpand::external_lock(THD *thd, int lock_type)
const
COND
*
ha_xpand
::
cond_push
(
const
COND
*
cond
)
{
return
cond
;
THD
*
thd
=
ha_thd
();
if
(
!
thd
->
lex
->
describe
)
{
pushdown_cond_list
.
push_front
(
const_cast
<
COND
*>
(
cond
));
}
return
NULL
;
}
void
ha_xpand
::
cond_pop
()
{
pushdown_cond_list
.
pop
();
}
int
ha_xpand
::
info_push
(
uint
info_type
,
void
*
info
)
...
...
storage/xpand/ha_xpand.h
View file @
4c308dd2
...
...
@@ -68,6 +68,8 @@ class ha_xpand : public handler
}
xpd_upsert_flags_t
;
int
upsert_flag
;
List
<
COND
>
pushdown_cond_list
;
Xpand_share
*
get_share
();
///< Get the share
public:
...
...
storage/xpand/xpand_connection.cc
View file @
4c308dd2
...
...
@@ -83,6 +83,7 @@ enum xpand_commands {
XPAND_UPDATE_QUERY
,
XPAND_COMMIT
,
XPAND_ROLLBACK
,
XPAND_SCAN_TABLE_COND
,
};
/****************************************************************************
...
...
@@ -732,7 +733,8 @@ int xpand_connection::allocate_cursor(MYSQL *xpand_net, ulong buffer_size,
int
xpand_connection
::
scan_table
(
ulonglong
xpand_table_oid
,
xpand_lock_mode_t
lock_mode
,
MY_BITMAP
*
read_set
,
ushort
row_req
,
xpand_connection_cursor
**
scan
)
xpand_connection_cursor
**
scan
,
String
*
pushdown_cond_sql
)
{
int
error_code
;
command_length
=
0
;
...
...
@@ -741,8 +743,13 @@ int xpand_connection::scan_table(ulonglong xpand_table_oid,
if
(
trans_flags
&
XPAND_TRANS_AUTOCOMMIT
)
return
HA_ERR_INTERNAL_ERROR
;
if
((
error_code
=
begin_command
(
XPAND_SCAN_TABLE
)))
if
(
pushdown_cond_sql
!=
nullptr
)
{
if
((
error_code
=
begin_command
(
XPAND_SCAN_TABLE_COND
)))
return
error_code
;
}
else
{
if
((
error_code
=
begin_command
(
XPAND_SCAN_TABLE
)))
return
error_code
;
}
if
((
error_code
=
add_command_operand_ushort
(
row_req
)))
return
error_code
;
...
...
@@ -756,6 +763,14 @@ int xpand_connection::scan_table(ulonglong xpand_table_oid,
if
((
error_code
=
add_command_operand_bitmap
(
read_set
)))
return
error_code
;
if
(
pushdown_cond_sql
!=
nullptr
)
{
if
((
error_code
=
add_command_operand_str
(
reinterpret_cast
<
const
uchar
*>
(
pushdown_cond_sql
->
ptr
()),
pushdown_cond_sql
->
length
())))
{
return
error_code
;
}
}
if
((
error_code
=
send_command
()))
return
error_code
;
...
...
storage/xpand/xpand_connection.h
View file @
4c308dd2
...
...
@@ -91,7 +91,7 @@ class xpand_connection
int
scan_table
(
ulonglong
xpand_table_oid
,
xpand_lock_mode_t
lock_mode
,
MY_BITMAP
*
read_set
,
ushort
row_req
,
xpand_connection_cursor
**
scan
);
xpand_connection_cursor
**
scan
,
String
*
pushdown_cond_sql
);
int
scan_query
(
String
&
stmt
,
uchar
*
fieldtype
,
uint
fields
,
uchar
*
null_bits
,
uint
null_bits_size
,
uchar
*
field_metadata
,
uint
field_metadata_size
,
ushort
row_req
,
ulonglong
*
oids
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment