mirror of
https://github.com/MariaDB/server.git
synced 2025-12-06 20:35:45 +01:00
This split from MDEV-32294, discovered when inspecting how Item_subselect::used_tables_cache gets recalculated during 1st and 2nd executions of prepared statements. We build a list of outer references resolved against each select_lex. This list is not reset at the end of a prepared statement, so each element in this must be allocated on statement memory. Because of this we rely on MDEV-30073, as prior to this patch, some outer references are freed at the end of prepared statement execution. We use this list to recalculate Item_subselect::used_tables_cache There are a number of additional processing steps that need to happen during query merges. A derived table merge will leave a mix of SELECT_LEX::nest_base_level pointers in our query structure. Some Item::*processors will search for items that 'belong' only to the 'unit' being searched. We need to update this and nest_level when merging. We update SELECT_LEX::outer_references_resolved_here, in case an Item in a subquery is no longer an outer reference. We introduce a number tests in main.outer_reference, along with a way of wrapping each select to be executed in a number of different ways. TODO, check that the result of each of these different ways of execution is identical. We could wrap this into client/mysqltest and perhaps allow stacking of each execution method, such as --view (to create a view from our test statement and then select from the view) and --ps (to prepare our test statement, now selecting from a view, and compare data output from first and second executions). Name resolution fixes related to prepared statement execution. We no longer call fix_outer_field after the first execution, we now rely on the attribute depended_from, populated during the first execution. Code is added to Item_field::fix_fields to compensate. We allocate view field substituions on statement memory. When run as a prepared statement, this happens during the first execution. table_map fixes related to prepared statement and view processing. In setup_fields, during the 2nd execution of a prepared statement, we can call used_tables() prior to any caches being set up. This can result in incorrect processing. We also ban execution of EXPLAIN EXTENDED statements during mtr ps protocol runs as the generation of warnings varies due to the fact that some Item select_transformers cannot be run during execution of the prepare statement, so we would normally expect a different warning output.
152 lines
3.6 KiB
Text
152 lines
3.6 KiB
Text
# Testing of feature statistics
|
|
|
|
-- source include/have_geometry.inc
|
|
-- source include/protocol.inc
|
|
|
|
--disable_warnings
|
|
drop table if exists t1;
|
|
--enable_warnings
|
|
|
|
set sql_mode="";
|
|
|
|
--disable_ps2_protocol
|
|
|
|
flush status;
|
|
|
|
show status like "feature%";
|
|
|
|
--echo #
|
|
--echo # Feature GIS
|
|
--echo #
|
|
|
|
CREATE TABLE t1 (g POINT);
|
|
SHOW FIELDS FROM t1;
|
|
INSERT INTO t1 VALUES
|
|
(PointFromText('POINT(10 10)')),
|
|
(PointFromText('POINT(20 10)')),
|
|
(PointFromText('POINT(20 20)')),
|
|
(PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
|
|
drop table t1;
|
|
|
|
show status like "feature_gis";
|
|
|
|
--echo #
|
|
--echo # Feature dynamic columns
|
|
--echo #
|
|
set @a= COLUMN_CREATE(1, 1212 AS int);
|
|
set @b= column_add(@a, 2, 1212 as integer);
|
|
select column_get(@b, 2 as integer);
|
|
|
|
show status like "feature_dynamic_columns";
|
|
|
|
--echo #
|
|
--echo # Feature fulltext
|
|
--echo #
|
|
|
|
CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b)) engine=myisam;
|
|
INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
|
|
('Full-text indexes', 'are called collections'),
|
|
('Only MyISAM tables','support collections'),
|
|
('Function MATCH ... AGAINST()','is used to do a search'),
|
|
('Full-text search in MySQL', 'implements vector space model');
|
|
select * from t1 where MATCH(a,b) AGAINST ("collections");
|
|
select * from t1 where MATCH(a,b) AGAINST ("indexes");
|
|
drop table t1;
|
|
|
|
# We need the following when running with --ps-protocol
|
|
--replace_result 4 2
|
|
show status like "feature_fulltext";
|
|
|
|
|
|
--echo #
|
|
--echo # Feature locale
|
|
--echo #
|
|
|
|
SET lc_messages=sr_RS;
|
|
SET lc_messages=en_US;
|
|
show status like "feature_locale";
|
|
|
|
--echo #
|
|
--echo # Feature subquery
|
|
--echo #
|
|
|
|
select (select 2);
|
|
SELECT (SELECT 1) UNION SELECT (SELECT 2);
|
|
|
|
create table t1 (a int);
|
|
insert into t1 values (2);
|
|
select (select a from t1 where t1.a=t2.a), a from t1 as t2;
|
|
drop table t1;
|
|
--replace_result 8 5
|
|
show status like "feature_subquery";
|
|
|
|
--echo #
|
|
--echo # Feature timezone
|
|
--echo #
|
|
|
|
SELECT FROM_UNIXTIME(unix_timestamp()) > "1970-01-01";
|
|
set time_zone="+03:00";
|
|
SELECT FROM_UNIXTIME(unix_timestamp()) > "1970-01-01";
|
|
set time_zone= @@global.time_zone;
|
|
show status like "feature_timezone";
|
|
|
|
--echo #
|
|
--echo # Feature triggers
|
|
--echo #
|
|
|
|
create table t1 (i int);
|
|
--echo # let us test some very simple trigger
|
|
create trigger trg before insert on t1 for each row set @a:=1;
|
|
set @a:=0;
|
|
select @a;
|
|
insert into t1 values (1),(2);
|
|
select @a;
|
|
--replace_column 6 #
|
|
SHOW TRIGGERS IN test like 't1';
|
|
drop trigger trg;
|
|
drop table t1;
|
|
|
|
show status like "%trigger%";
|
|
|
|
--echo #
|
|
--echo # Feature xml
|
|
--echo #
|
|
SET @xml='<a aa1="aa1" aa2="aa2">a1<b ba1="ba1">b1<c>c1</c>b2</b>a2</a>';
|
|
SELECT extractValue(@xml,'/a');
|
|
select updatexml('<div><div><span>1</span><span>2</span></div></div>',
|
|
'/','<tr><td>1</td><td>2</td></tr>') as upd1;
|
|
--replace_result 4 2
|
|
show status like "feature_xml";
|
|
--enable_ps2_protocol
|
|
|
|
--echo #
|
|
--echo # Feature delayed_keys
|
|
--echo #
|
|
|
|
create table t1 (a int, key(a)) engine=myisam delay_key_write=1;
|
|
insert into t1 values(1);
|
|
insert into t1 values(2);
|
|
drop table t1;
|
|
|
|
create table t1 (a int, key(a)) engine=aria delay_key_write=1;
|
|
insert into t1 values(1);
|
|
insert into t1 values(2);
|
|
drop table t1;
|
|
|
|
show status like "feature_delay_key_write";
|
|
|
|
--echo #
|
|
--echo # Feature CHECK CONSTRAINT
|
|
--echo #
|
|
create table t1 (a int check (a > 5));
|
|
create table t2 (b int, constraint foo check (b < 10));
|
|
drop table t1, t2;
|
|
show status like "feature_check_constraint";
|
|
|
|
--echo #
|
|
--echo # Feature insert...returning
|
|
--echo #
|
|
create table t1(id1 int);
|
|
insert into t1 values (1),(2) returning *;
|
|
drop table t1;
|
|
show status like "feature_insert_returning";
|