summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <igor@olga.mysql.com>2007-06-04 03:16:17 -0700
committerunknown <igor@olga.mysql.com>2007-06-04 03:16:17 -0700
commit5a19274ea8af855214d25069fc65fd15668e4dc6 (patch)
treec0603a0ced48aa5d4991dea80ff63566636c96fc
parente65eb0e44791b9ecc6457d5bec25e148eaee48e2 (diff)
parente409a8a5c0402859ec0754e5d060e3ae06df4c6e (diff)
downloadmariadb-git-5a19274ea8af855214d25069fc65fd15668e4dc6.tar.gz
Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into olga.mysql.com:/home/igor/mysql-5.1-opt-merge include/thr_lock.h: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/r/sp.result: Auto merged mysql-test/r/trigger.result: Auto merged mysql-test/t/sp.test: Auto merged mysql-test/t/strict.test: Auto merged mysql-test/t/subselect3.test: Auto merged mysql-test/t/trigger.test: Auto merged sql/mysqld.cc: Auto merged sql/set_var.cc: Auto merged sql/sp_head.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_select.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/udf_example.c: Auto merged mysql-test/r/subselect.result: Manual merge. mysql-test/t/subselect.test: Manual merge. sql/sql_view.cc: Manual merge.
-rw-r--r--include/thr_lock.h5
-rwxr-xr-xmysql-test/mysql-test-run.pl11
-rw-r--r--mysql-test/r/subselect.result10
-rw-r--r--mysql-test/r/trigger.result24
-rw-r--r--mysql-test/t/subselect.test14
-rw-r--r--mysql-test/t/trigger.test55
-rw-r--r--sql/set_var.cc6
-rw-r--r--sql/sql_base.cc7
-rw-r--r--sql/sql_select.cc11
-rw-r--r--sql/sql_view.cc3
-rw-r--r--sql/sql_yacc.yy12
-rw-r--r--sql/udf_example.c3
12 files changed, 152 insertions, 9 deletions
diff --git a/include/thr_lock.h b/include/thr_lock.h
index 9bd7c22aa92..74d65c2fa7a 100644
--- a/include/thr_lock.h
+++ b/include/thr_lock.h
@@ -54,6 +54,11 @@ enum thr_lock_type { TL_IGNORE=-1,
TL_WRITE_CONCURRENT_INSERT,
/* Write used by INSERT DELAYED. Allows READ locks */
TL_WRITE_DELAYED,
+ /*
+ parser only! Late bound low_priority flag.
+ At open_tables() becomes thd->update_lock_default.
+ */
+ TL_WRITE_DEFAULT,
/* WRITE lock that has lower priority than TL_READ */
TL_WRITE_LOW_PRIORITY,
/* Normal WRITE lock */
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 50edcecbfa9..088b4677251 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -1796,6 +1796,17 @@ sub environment_setup () {
split(':', $ENV{'DYLD_LIBRARY_PATH'}) : ());
mtr_debug("DYLD_LIBRARY_PATH: $ENV{'DYLD_LIBRARY_PATH'}");
+ # The environment variable used for shared libs on AIX
+ $ENV{'SHLIB_PATH'}= join(":", @ld_library_paths,
+ $ENV{'SHLIB_PATH'} ?
+ split(':', $ENV{'SHLIB_PATH'}) : ());
+ mtr_debug("SHLIB_PATH: $ENV{'SHLIB_PATH'}");
+
+ # The environment variable used for shared libs on hp-ux
+ $ENV{'LIBPATH'}= join(":", @ld_library_paths,
+ $ENV{'LIBPATH'} ?
+ split(':', $ENV{'LIBPATH'}) : ());
+ mtr_debug("LIBPATH: $ENV{'LIBPATH'}");
# --------------------------------------------------------------------------
# Also command lines in .opt files may contain env vars
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 1ad47a3c465..c9b502a7e8e 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -4071,6 +4071,16 @@ id st
2 GA
4 FL
DROP TABLE t1,t2;
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (1), (2);
+EXPLAIN EXTENDED
+SELECT * FROM (SELECT count(*) FROM t1 GROUP BY a) as res;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
+2 DERIVED t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
+Warnings:
+Note 1003 select `res`.`count(*)` AS `count(*)` from (select count(0) AS `count(*)` from `test`.`t1` group by `test`.`t1`.`a`) `res`
+DROP TABLE t1;
End of 5.0 tests.
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (2,22),(1,11),(2,22);
diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result
index 9eef19eb83a..1b4e0decb62 100644
--- a/mysql-test/r/trigger.result
+++ b/mysql-test/r/trigger.result
@@ -1449,4 +1449,28 @@ isave
1
2
drop table t1, t2, t3;
+CREATE TABLE t1 (id INTEGER);
+CREATE TABLE t2 (id INTEGER);
+INSERT INTO t2 VALUES (1),(2);
+CREATE TRIGGER t1_test AFTER INSERT ON t1 FOR EACH ROW
+INSERT INTO t2 VALUES (new.id);
+SELECT GET_LOCK('B26162',20);
+GET_LOCK('B26162',20)
+1
+SELECT 'rl_acquirer', GET_LOCK('B26162',5), id FROM t2 WHERE id = 1;
+SET SESSION LOW_PRIORITY_UPDATES=1;
+SET GLOBAL LOW_PRIORITY_UPDATES=1;
+INSERT INTO t1 VALUES (5);
+SELECT 'rl_contender', id FROM t2 WHERE id > 1;
+SELECT RELEASE_LOCK('B26162');
+RELEASE_LOCK('B26162')
+0
+rl_acquirer GET_LOCK('B26162',5) id
+rl_acquirer 0 1
+rl_contender id
+rl_contender 2
+DROP TRIGGER t1_test;
+DROP TABLE t1,t2;
+SET SESSION LOW_PRIORITY_UPDATES=DEFAULT;
+SET GLOBAL LOW_PRIORITY_UPDATES=DEFAULT;
End of 5.0 tests
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 12e2e4f1f25..0d1b71d8707 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -2906,6 +2906,20 @@ SELECT id, st FROM t1
DROP TABLE t1,t2;
+#
+# Bug #28728: crash with EXPLAIN EXTENDED for a query with a derived table
+# over a grouping subselect
+#
+
+CREATE TABLE t1 (a int);
+
+INSERT INTO t1 VALUES (1), (2);
+
+EXPLAIN EXTENDED
+SELECT * FROM (SELECT count(*) FROM t1 GROUP BY a) as res;
+
+DROP TABLE t1;
+
--echo End of 5.0 tests.
#
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test
index e63417809cc..31739f6c41b 100644
--- a/mysql-test/t/trigger.test
+++ b/mysql-test/t/trigger.test
@@ -1763,4 +1763,59 @@ select * from t1;
select * from t3;
drop table t1, t2, t3;
+#
+# Bug #26162: Trigger DML ignores low_priority_updates setting
+#
+CREATE TABLE t1 (id INTEGER);
+CREATE TABLE t2 (id INTEGER);
+
+INSERT INTO t2 VALUES (1),(2);
+
+# trigger that produces the high priority insert, but should be low, adding
+# LOW_PRIORITY fixes this
+CREATE TRIGGER t1_test AFTER INSERT ON t1 FOR EACH ROW
+ INSERT INTO t2 VALUES (new.id);
+
+CONNECT (rl_acquirer, localhost, root,,);
+CONNECT (wl_acquirer, localhost, root,,);
+CONNECT (rl_contender, localhost, root,,);
+
+SELECT GET_LOCK('B26162',20);
+
+CONNECTION rl_acquirer;
+--send
+SELECT 'rl_acquirer', GET_LOCK('B26162',5), id FROM t2 WHERE id = 1;
+
+CONNECTION wl_acquirer;
+SET SESSION LOW_PRIORITY_UPDATES=1;
+SET GLOBAL LOW_PRIORITY_UPDATES=1;
+--send
+INSERT INTO t1 VALUES (5);
+
+CONNECTION rl_contender;
+# must not "see" the row inserted by the INSERT (as it must run before the
+# INSERT)
+--send
+SELECT 'rl_contender', id FROM t2 WHERE id > 1;
+
+CONNECTION default;
+SELECT RELEASE_LOCK('B26162');
+
+CONNECTION wl_acquirer;
+--reap
+CONNECTION rl_acquirer;
+--reap
+CONNECTION rl_contender;
+--reap
+
+CONNECTION default;
+DISCONNECT rl_acquirer;
+DISCONNECT wl_acquirer;
+DISCONNECT rl_contender;
+
+DROP TRIGGER t1_test;
+DROP TABLE t1,t2;
+SET SESSION LOW_PRIORITY_UPDATES=DEFAULT;
+SET GLOBAL LOW_PRIORITY_UPDATES=DEFAULT;
+
--echo End of 5.0 tests
diff --git a/sql/set_var.cc b/sql/set_var.cc
index a057945d977..e794f708bad 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -824,7 +824,11 @@ static void sys_default_ftb_syntax(THD *thd, enum_var_type type)
static void fix_low_priority_updates(THD *thd, enum_var_type type)
{
- if (type != OPT_GLOBAL)
+ if (type == OPT_GLOBAL)
+ thr_upgraded_concurrent_insert_lock=
+ (global_system_variables.low_priority_updates ?
+ TL_WRITE_LOW_PRIORITY : TL_WRITE);
+ else
thd->update_lock_default= (thd->variables.low_priority_updates ?
TL_WRITE_LOW_PRIORITY : TL_WRITE);
}
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 26d23d1ea57..b798106082a 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2226,6 +2226,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
HASH_SEARCH_STATE state;
DBUG_ENTER("open_table");
+ DBUG_ASSERT (table_list->lock_type != TL_WRITE_DEFAULT);
/* find a unused table in the open table cache */
if (refresh)
*refresh=0;
@@ -3531,6 +3532,12 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
for (tables= *start; tables ;tables= tables->next_global)
{
safe_to_ignore_table= FALSE; // 'FALSE', as per coding style
+
+ if (tables->lock_type == TL_WRITE_DEFAULT)
+ {
+ tables->lock_type= thd->update_lock_default;
+ DBUG_ASSERT (tables->lock_type >= TL_WRITE_ALLOW_WRITE);
+ }
/*
Ignore placeholders for derived tables. After derived tables
processing, link to created temporary table will be put here.
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index cb988049b4c..bdd70de35d8 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2104,6 +2104,17 @@ JOIN::exec()
thd->examined_row_count+= curr_join->examined_rows;
DBUG_PRINT("counts", ("thd->examined_row_count: %lu",
(ulong) thd->examined_row_count));
+
+ /*
+ With EXPLAIN EXTENDED we have to restore original ref_array
+ for a derived table which is always materialized.
+ Otherwise we would not be able to print the query correctly.
+ */
+ if (items0 &&
+ (thd->lex->describe & DESCRIBE_EXTENDED) &&
+ select_lex->linkage == DERIVED_TABLE_TYPE)
+ set_items_ref_array(items0);
+
DBUG_VOID_RETURN;
}
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index d95c1ec752d..c1e4006555f 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -816,7 +816,7 @@ loop_out:
}
}
else
- {
+ {
if (mode == VIEW_ALTER)
{
my_error(ER_NO_SUCH_TABLE, MYF(0), view->db, view->alias);
@@ -825,6 +825,7 @@ loop_out:
}
}
}
+
/*
Check that table of main select do not used in subqueries.
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 7875b4244a8..2b256070276 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -8295,7 +8295,7 @@ insert_lock_option:
insert visible only after the table unlocking but everyone can
read table.
*/
- $$= (Lex->sphead ? TL_WRITE :TL_WRITE_CONCURRENT_INSERT);
+ $$= (Lex->sphead ? TL_WRITE_DEFAULT : TL_WRITE_CONCURRENT_INSERT);
#else
$$= TL_WRITE_CONCURRENT_INSERT;
#endif
@@ -8473,7 +8473,7 @@ insert_update_elem:
};
opt_low_priority:
- /* empty */ { $$= YYTHD->update_lock_default; }
+ /* empty */ { $$= TL_WRITE_DEFAULT; }
| LOW_PRIORITY { $$= TL_WRITE_LOW_PRIORITY; };
/* Delete rows from a table */
@@ -8484,7 +8484,7 @@ delete:
LEX *lex= Lex;
lex->sql_command= SQLCOM_DELETE;
mysql_init_select(lex);
- lex->lock_option= lex->thd->update_lock_default;
+ lex->lock_option= TL_WRITE_DEFAULT;
lex->ignore= 0;
lex->select_lex.init_order();
}
@@ -9176,7 +9176,7 @@ opt_local:
| LOCAL_SYM { $$=1;};
load_data_lock:
- /* empty */ { $$= YYTHD->update_lock_default; }
+ /* empty */ { $$= TL_WRITE_DEFAULT; }
| CONCURRENT
{
#ifdef HAVE_QUERY_CACHE
@@ -9184,7 +9184,7 @@ load_data_lock:
Ignore this option in SP to avoid problem with query cache
*/
if (Lex->sphead != 0)
- $$= YYTHD->update_lock_default;
+ $$= TL_WRITE_DEFAULT;
else
#endif
$$= TL_WRITE_CONCURRENT_INSERT;
@@ -10546,7 +10546,7 @@ table_lock:
lock_option:
READ_SYM { $$=TL_READ_NO_INSERT; }
- | WRITE_SYM { $$=YYTHD->update_lock_default; }
+ | WRITE_SYM { $$=TL_WRITE_DEFAULT; }
| LOW_PRIORITY WRITE_SYM { $$=TL_WRITE_LOW_PRIORITY; }
| READ_SYM LOCAL_SYM { $$= TL_READ; }
;
diff --git a/sql/udf_example.c b/sql/udf_example.c
index d37c6505ced..b603464568e 100644
--- a/sql/udf_example.c
+++ b/sql/udf_example.c
@@ -130,7 +130,8 @@ typedef long long longlong;
#include <m_string.h> /* To get strmov() */
#else
/* when compiled as standalone */
-#define strmov(a,b) strcpy(a,b)
+#include <string.h>
+#define strmov(a,b) stpcpy(a,b)
#define bzero(a,b) memset(a,0,b)
#define memcpy_fixed(a,b,c) memcpy(a,b,c)
#endif