mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-5.0
into sanja.is.com.ua:/home/bell/mysql/bk/work-merge1-5.0
This commit is contained in:
@ -850,6 +850,31 @@ group_concat(a)
|
|||||||
set group_concat_max_len=default;
|
set group_concat_max_len=default;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
create table t1 (a int);
|
create table t1 (a int);
|
||||||
|
flush status;
|
||||||
|
(select a from t1) union (select a from t1);
|
||||||
|
a
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_queries_in_cache 1
|
||||||
|
show status like "Qcache_inserts";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_inserts 1
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_hits 0
|
||||||
|
(select a from t1) union (select a from t1);
|
||||||
|
a
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_queries_in_cache 1
|
||||||
|
show status like "Qcache_inserts";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_inserts 1
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_hits 1
|
||||||
|
drop table t1;
|
||||||
|
create table t1 (a int);
|
||||||
show status like "Qcache_queries_in_cache";
|
show status like "Qcache_queries_in_cache";
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
Qcache_queries_in_cache 0
|
Qcache_queries_in_cache 0
|
||||||
|
@ -2424,3 +2424,18 @@ f1 sum(f2)
|
|||||||
NULL 12
|
NULL 12
|
||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
CREATE VIEW v1 AS SELECT 42 AS Meaning;
|
||||||
|
DROP FUNCTION IF EXISTS f1;
|
||||||
|
CREATE FUNCTION f1() RETURNS INTEGER
|
||||||
|
BEGIN
|
||||||
|
DECLARE retn INTEGER;
|
||||||
|
SELECT Meaning FROM v1 INTO retn;
|
||||||
|
RETURN retn;
|
||||||
|
END
|
||||||
|
//
|
||||||
|
CREATE VIEW v2 AS SELECT f1();
|
||||||
|
select * from v2;
|
||||||
|
f1()
|
||||||
|
42
|
||||||
|
drop view v2,v1;
|
||||||
|
drop function f1;
|
||||||
|
@ -132,4 +132,65 @@ unlock tables;
|
|||||||
set query_cache_wlock_invalidate=default;
|
set query_cache_wlock_invalidate=default;
|
||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
flush status;
|
||||||
|
create table t1 (a int, b int);
|
||||||
|
create algorithm=temptable view v1 as select * from t1;
|
||||||
|
select * from v1;
|
||||||
|
a b
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_queries_in_cache 1
|
||||||
|
show status like "Qcache_inserts";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_inserts 1
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_hits 0
|
||||||
|
select * from v1;
|
||||||
|
a b
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_queries_in_cache 1
|
||||||
|
show status like "Qcache_inserts";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_inserts 1
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_hits 1
|
||||||
|
insert into t1 values (1,1);
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_queries_in_cache 0
|
||||||
|
show status like "Qcache_inserts";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_inserts 1
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_hits 1
|
||||||
|
select * from v1;
|
||||||
|
a b
|
||||||
|
1 1
|
||||||
|
select * from v1;
|
||||||
|
a b
|
||||||
|
1 1
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_queries_in_cache 1
|
||||||
|
show status like "Qcache_inserts";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_inserts 2
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_hits 2
|
||||||
|
drop view v1;
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_queries_in_cache 0
|
||||||
|
show status like "Qcache_inserts";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_inserts 2
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
Variable_name Value
|
||||||
|
Qcache_hits 2
|
||||||
|
drop table t1;
|
||||||
set GLOBAL query_cache_size=default;
|
set GLOBAL query_cache_size=default;
|
||||||
|
@ -742,6 +742,21 @@ show status like "Qcache_inserts";
|
|||||||
show status like "Qcache_hits";
|
show status like "Qcache_hits";
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# BUG#14652: Queries with leading '(' characters.
|
||||||
|
#
|
||||||
|
create table t1 (a int);
|
||||||
|
flush status;
|
||||||
|
(select a from t1) union (select a from t1);
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
show status like "Qcache_inserts";
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
(select a from t1) union (select a from t1);
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
show status like "Qcache_inserts";
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
drop table t1;
|
||||||
|
|
||||||
#
|
#
|
||||||
# SP cursors and selects with query cache (BUG#9715)
|
# SP cursors and selects with query cache (BUG#9715)
|
||||||
#
|
#
|
||||||
|
@ -2280,3 +2280,24 @@ create view v1 as select * from t1;
|
|||||||
select f1, sum(f2) from v1 group by f1;
|
select f1, sum(f2) from v1 group by f1;
|
||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# BUG#15096: using function with view for view creation
|
||||||
|
#
|
||||||
|
CREATE VIEW v1 AS SELECT 42 AS Meaning;
|
||||||
|
--disable_warnings
|
||||||
|
DROP FUNCTION IF EXISTS f1;
|
||||||
|
--enable_warnings
|
||||||
|
DELIMITER //;
|
||||||
|
CREATE FUNCTION f1() RETURNS INTEGER
|
||||||
|
BEGIN
|
||||||
|
DECLARE retn INTEGER;
|
||||||
|
SELECT Meaning FROM v1 INTO retn;
|
||||||
|
RETURN retn;
|
||||||
|
END
|
||||||
|
//
|
||||||
|
DELIMITER ;//
|
||||||
|
CREATE VIEW v2 AS SELECT f1();
|
||||||
|
select * from v2;
|
||||||
|
drop view v2,v1;
|
||||||
|
drop function f1;
|
||||||
|
@ -96,4 +96,35 @@ unlock tables;
|
|||||||
set query_cache_wlock_invalidate=default;
|
set query_cache_wlock_invalidate=default;
|
||||||
drop view v1;
|
drop view v1;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# BUG#15119: returning temptable view from the query cache.
|
||||||
|
#
|
||||||
|
flush status;
|
||||||
|
create table t1 (a int, b int);
|
||||||
|
create algorithm=temptable view v1 as select * from t1;
|
||||||
|
select * from v1;
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
show status like "Qcache_inserts";
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
select * from v1;
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
show status like "Qcache_inserts";
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
insert into t1 values (1,1);
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
show status like "Qcache_inserts";
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
select * from v1;
|
||||||
|
select * from v1;
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
show status like "Qcache_inserts";
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
drop view v1;
|
||||||
|
show status like "Qcache_queries_in_cache";
|
||||||
|
show status like "Qcache_inserts";
|
||||||
|
show status like "Qcache_hits";
|
||||||
|
drop table t1;
|
||||||
|
|
||||||
|
# Reset default environment.
|
||||||
set GLOBAL query_cache_size=default;
|
set GLOBAL query_cache_size=default;
|
||||||
|
@ -977,21 +977,31 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Test if the query is a SELECT
|
|
||||||
(pre-space is removed in dispatch_command).
|
|
||||||
|
|
||||||
First '/' looks like comment before command it is not
|
|
||||||
frequently appeared in real lihe, consequently we can
|
|
||||||
check all such queries, too.
|
|
||||||
*/
|
|
||||||
if ((my_toupper(system_charset_info, sql[0]) != 'S' ||
|
|
||||||
my_toupper(system_charset_info, sql[1]) != 'E' ||
|
|
||||||
my_toupper(system_charset_info,sql[2]) !='L') &&
|
|
||||||
sql[0] != '/')
|
|
||||||
{
|
{
|
||||||
DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached"));
|
uint i= 0;
|
||||||
goto err;
|
/*
|
||||||
|
Skip '(' characters in queries like following:
|
||||||
|
(select a from t1) union (select a from t1);
|
||||||
|
*/
|
||||||
|
while (sql[i]=='(')
|
||||||
|
i++;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Test if the query is a SELECT
|
||||||
|
(pre-space is removed in dispatch_command)
|
||||||
|
|
||||||
|
First '/' looks like comment before command it is not
|
||||||
|
frequently appeared in real lihe, consequently we can
|
||||||
|
check all such queries, too.
|
||||||
|
*/
|
||||||
|
if ((my_toupper(system_charset_info, sql[i]) != 'S' ||
|
||||||
|
my_toupper(system_charset_info, sql[i + 1]) != 'E' ||
|
||||||
|
my_toupper(system_charset_info, sql[i + 2]) != 'L') &&
|
||||||
|
sql[i] != '/')
|
||||||
|
{
|
||||||
|
DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached"));
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STRUCT_LOCK(&structure_guard_mutex);
|
STRUCT_LOCK(&structure_guard_mutex);
|
||||||
@ -2184,7 +2194,7 @@ Query_cache::register_tables_from_list(TABLE_LIST *tables_used,
|
|||||||
tables_used;
|
tables_used;
|
||||||
tables_used= tables_used->next_global, n++, block_table++)
|
tables_used= tables_used->next_global, n++, block_table++)
|
||||||
{
|
{
|
||||||
if (tables_used->derived)
|
if (tables_used->derived && !tables_used->view)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("qcache", ("derived table skipped"));
|
DBUG_PRINT("qcache", ("derived table skipped"));
|
||||||
n--;
|
n--;
|
||||||
|
@ -350,15 +350,6 @@ bool mysql_create_view(THD *thd,
|
|||||||
*/
|
*/
|
||||||
for (tbl= lex->query_tables; tbl; tbl= tbl->next_global)
|
for (tbl= lex->query_tables; tbl; tbl= tbl->next_global)
|
||||||
{
|
{
|
||||||
/* is this table temporary and is not view? */
|
|
||||||
if (tbl->table->s->tmp_table != NO_TMP_TABLE && !tbl->view &&
|
|
||||||
!tbl->schema_table)
|
|
||||||
{
|
|
||||||
my_error(ER_VIEW_SELECT_TMPTABLE, MYF(0), tbl->alias);
|
|
||||||
res= TRUE;
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* is this table view and the same view which we creates now? */
|
/* is this table view and the same view which we creates now? */
|
||||||
if (tbl->view &&
|
if (tbl->view &&
|
||||||
strcmp(tbl->view_db.str, view->db) == 0 &&
|
strcmp(tbl->view_db.str, view->db) == 0 &&
|
||||||
@ -370,11 +361,29 @@ bool mysql_create_view(THD *thd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copy the privileges of the underlying VIEWs which were filled by
|
tbl->table can be NULL when tbl is a placeholder for a view
|
||||||
fill_effective_table_privileges
|
that is indirectly referenced via a stored function from the
|
||||||
(they were not copied at derived tables processing)
|
view being created. We don't check these indirectly
|
||||||
|
referenced views in CREATE VIEW so they don't have table
|
||||||
|
object.
|
||||||
*/
|
*/
|
||||||
tbl->table->grant.privilege= tbl->grant.privilege;
|
if (tbl->table)
|
||||||
|
{
|
||||||
|
/* is this table temporary and is not view? */
|
||||||
|
if (tbl->table->s->tmp_table != NO_TMP_TABLE && !tbl->view &&
|
||||||
|
!tbl->schema_table)
|
||||||
|
{
|
||||||
|
my_error(ER_VIEW_SELECT_TMPTABLE, MYF(0), tbl->alias);
|
||||||
|
res= TRUE;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
Copy the privileges of the underlying VIEWs which were filled by
|
||||||
|
fill_effective_table_privileges
|
||||||
|
(they were not copied at derived tables processing)
|
||||||
|
*/
|
||||||
|
tbl->table->grant.privilege= tbl->grant.privilege;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* prepare select to resolve all fields */
|
/* prepare select to resolve all fields */
|
||||||
|
Reference in New Issue
Block a user