Skip to content

Commit 01bc761

Browse files
author
konstantin@bodhi.netgear
committed
Merge bodhi.netgear:/opt/local/work/tmp_merge
into bodhi.netgear:/opt/local/work/mysql-5.1-runtime-merge-with-5.0
2 parents f22a50a + e29ea3f commit 01bc761

31 files changed

+648
-305
lines changed

include/my_sys.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags);
163163
extern void my_no_flags_free(gptr ptr);
164164
extern gptr my_memdup(const byte *from,uint length,myf MyFlags);
165165
extern char *my_strdup(const char *from,myf MyFlags);
166-
extern char *my_strndup(const byte *from, uint length,
166+
extern char *my_strndup(const char *from, uint length,
167167
myf MyFlags);
168168
/* we do use FG (as a no-op) in below so that a typo on FG is caught */
169169
#define my_free(PTR,FG) ((void)FG,my_no_flags_free(PTR))

mysql-test/r/create.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ create database mysqltest;
620620
use mysqltest;
621621
drop database mysqltest;
622622
create table test.t1 like x;
623-
ERROR 42000: Incorrect database name 'NULL'
623+
ERROR 3D000: No database selected
624624
drop table if exists test.t1;
625625
create database mysqltest;
626626
use mysqltest;

mysql-test/r/ps.result

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,3 +1158,108 @@ Warnings:
11581158
Error 1146 Table 'test.t4' doesn't exist
11591159
deallocate prepare stmt;
11601160
drop table t1, t2, t3;
1161+
create database mysqltest_long_database_name_to_thrash_heap;
1162+
use test;
1163+
create table t1 (i int);
1164+
prepare stmt from "alter table test.t1 rename t1";
1165+
use mysqltest_long_database_name_to_thrash_heap;
1166+
execute stmt;
1167+
show tables like 't1';
1168+
Tables_in_mysqltest_long_database_name_to_thrash_heap (t1)
1169+
prepare stmt from "alter table test.t1 rename t1";
1170+
use test;
1171+
execute stmt;
1172+
show tables like 't1';
1173+
Tables_in_test (t1)
1174+
use mysqltest_long_database_name_to_thrash_heap;
1175+
show tables like 't1';
1176+
Tables_in_mysqltest_long_database_name_to_thrash_heap (t1)
1177+
t1
1178+
deallocate prepare stmt;
1179+
use mysqltest_long_database_name_to_thrash_heap;
1180+
prepare stmt_create from "create table t1 (i int)";
1181+
prepare stmt_insert from "insert into t1 (i) values (1)";
1182+
prepare stmt_update from "update t1 set i=2";
1183+
prepare stmt_delete from "delete from t1 where i=2";
1184+
prepare stmt_select from "select * from t1";
1185+
prepare stmt_alter from "alter table t1 add column (b int)";
1186+
prepare stmt_alter1 from "alter table t1 drop column b";
1187+
prepare stmt_analyze from "analyze table t1";
1188+
prepare stmt_optimize from "optimize table t1";
1189+
prepare stmt_show from "show tables like 't1'";
1190+
prepare stmt_truncate from "truncate table t1";
1191+
prepare stmt_drop from "drop table t1";
1192+
drop table t1;
1193+
use test;
1194+
execute stmt_create;
1195+
show tables like 't1';
1196+
Tables_in_test (t1)
1197+
use mysqltest_long_database_name_to_thrash_heap;
1198+
show tables like 't1';
1199+
Tables_in_mysqltest_long_database_name_to_thrash_heap (t1)
1200+
t1
1201+
use test;
1202+
execute stmt_insert;
1203+
select * from mysqltest_long_database_name_to_thrash_heap.t1;
1204+
i
1205+
1
1206+
execute stmt_update;
1207+
select * from mysqltest_long_database_name_to_thrash_heap.t1;
1208+
i
1209+
2
1210+
execute stmt_delete;
1211+
execute stmt_select;
1212+
i
1213+
execute stmt_alter;
1214+
show columns from mysqltest_long_database_name_to_thrash_heap.t1;
1215+
Field Type Null Key Default Extra
1216+
i int(11) YES NULL
1217+
b int(11) YES NULL
1218+
execute stmt_alter1;
1219+
show columns from mysqltest_long_database_name_to_thrash_heap.t1;
1220+
Field Type Null Key Default Extra
1221+
i int(11) YES NULL
1222+
execute stmt_analyze;
1223+
Table Op Msg_type Msg_text
1224+
mysqltest_long_database_name_to_thrash_heap.t1 analyze status Table is already up to date
1225+
execute stmt_optimize;
1226+
Table Op Msg_type Msg_text
1227+
mysqltest_long_database_name_to_thrash_heap.t1 optimize status Table is already up to date
1228+
execute stmt_show;
1229+
Tables_in_mysqltest_long_database_name_to_thrash_heap (t1)
1230+
t1
1231+
execute stmt_truncate;
1232+
execute stmt_drop;
1233+
show tables like 't1';
1234+
Tables_in_test (t1)
1235+
use mysqltest_long_database_name_to_thrash_heap;
1236+
show tables like 't1';
1237+
Tables_in_mysqltest_long_database_name_to_thrash_heap (t1)
1238+
drop database mysqltest_long_database_name_to_thrash_heap;
1239+
prepare stmt_create from "create table t1 (i int)";
1240+
ERROR 3D000: No database selected
1241+
prepare stmt_insert from "insert into t1 (i) values (1)";
1242+
ERROR 3D000: No database selected
1243+
prepare stmt_update from "update t1 set i=2";
1244+
ERROR 3D000: No database selected
1245+
prepare stmt_delete from "delete from t1 where i=2";
1246+
ERROR 3D000: No database selected
1247+
prepare stmt_select from "select * from t1";
1248+
ERROR 3D000: No database selected
1249+
prepare stmt_alter from "alter table t1 add column (b int)";
1250+
ERROR 3D000: No database selected
1251+
prepare stmt_alter1 from "alter table t1 drop column b";
1252+
ERROR 3D000: No database selected
1253+
prepare stmt_analyze from "analyze table t1";
1254+
ERROR 3D000: No database selected
1255+
prepare stmt_optimize from "optimize table t1";
1256+
ERROR 3D000: No database selected
1257+
prepare stmt_show from "show tables like 't1'";
1258+
ERROR 3D000: No database selected
1259+
prepare stmt_truncate from "truncate table t1";
1260+
ERROR 3D000: No database selected
1261+
prepare stmt_drop from "drop table t1";
1262+
ERROR 3D000: No database selected
1263+
create temporary table t1 (i int);
1264+
ERROR 3D000: No database selected
1265+
use test;

mysql-test/r/sp.result

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5000,6 +5000,52 @@ CALL bug18037_p2()|
50005000
DROP FUNCTION bug18037_f1|
50015001
DROP PROCEDURE bug18037_p1|
50025002
DROP PROCEDURE bug18037_p2|
5003+
use test|
5004+
create table t3 (i int)|
5005+
insert into t3 values (1), (2)|
5006+
create database mysqltest1|
5007+
use mysqltest1|
5008+
create function bug17199() returns varchar(2) deterministic return 'ok'|
5009+
use test|
5010+
select *, mysqltest1.bug17199() from t3|
5011+
i mysqltest1.bug17199()
5012+
1 ok
5013+
2 ok
5014+
use mysqltest1|
5015+
create function bug18444(i int) returns int no sql deterministic return i + 1|
5016+
use test|
5017+
select mysqltest1.bug18444(i) from t3|
5018+
mysqltest1.bug18444(i)
5019+
2
5020+
3
5021+
drop database mysqltest1|
5022+
create database mysqltest1 charset=utf8|
5023+
create database mysqltest2 charset=utf8|
5024+
create procedure mysqltest1.p1()
5025+
begin
5026+
-- alters the default collation of database test
5027+
alter database character set koi8r;
5028+
end|
5029+
use mysqltest1|
5030+
call p1()|
5031+
show create database mysqltest1|
5032+
Database Create Database
5033+
mysqltest1 CREATE DATABASE `mysqltest1` /*!40100 DEFAULT CHARACTER SET koi8r */
5034+
show create database mysqltest2|
5035+
Database Create Database
5036+
mysqltest2 CREATE DATABASE `mysqltest2` /*!40100 DEFAULT CHARACTER SET utf8 */
5037+
alter database mysqltest1 character set utf8|
5038+
use mysqltest2|
5039+
call mysqltest1.p1()|
5040+
show create database mysqltest1|
5041+
Database Create Database
5042+
mysqltest1 CREATE DATABASE `mysqltest1` /*!40100 DEFAULT CHARACTER SET koi8r */
5043+
show create database mysqltest2|
5044+
Database Create Database
5045+
mysqltest2 CREATE DATABASE `mysqltest2` /*!40100 DEFAULT CHARACTER SET utf8 */
5046+
drop database mysqltest1|
5047+
drop database mysqltest2|
5048+
use test|
50035049
drop table if exists t3|
50045050
drop procedure if exists bug15217|
50055051
create table t3 as select 1|

mysql-test/t/create.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ DROP TABLE t12913;
521521
create database mysqltest;
522522
use mysqltest;
523523
drop database mysqltest;
524-
--error 1102
524+
--error ER_NO_DB_ERROR
525525
create table test.t1 like x;
526526
--disable_warnings
527527
drop table if exists test.t1;

mysql-test/t/ps.test

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,4 +1146,122 @@ execute stmt;
11461146
execute stmt;
11471147
deallocate prepare stmt;
11481148
drop table t1, t2, t3;
1149+
1150+
#
1151+
# Bug#17199 "Table not found" error occurs if the query contains a call
1152+
# to a function from another database.
1153+
# Test prepared statements- related behaviour.
1154+
#
1155+
#
1156+
# ALTER TABLE RENAME and Prepared Statements: wrong DB name buffer was used
1157+
# in ALTER ... RENAME which caused memory corruption in prepared statements.
1158+
# No need to fix this problem in 4.1 as ALTER TABLE is not allowed in
1159+
# Prepared Statements in 4.1.
1160+
#
1161+
create database mysqltest_long_database_name_to_thrash_heap;
1162+
use test;
1163+
create table t1 (i int);
1164+
prepare stmt from "alter table test.t1 rename t1";
1165+
use mysqltest_long_database_name_to_thrash_heap;
1166+
execute stmt;
1167+
show tables like 't1';
1168+
prepare stmt from "alter table test.t1 rename t1";
1169+
use test;
1170+
execute stmt;
1171+
show tables like 't1';
1172+
use mysqltest_long_database_name_to_thrash_heap;
1173+
show tables like 't1';
1174+
deallocate prepare stmt;
1175+
#
1176+
# Check that a prepared statement initializes its current database at
1177+
# PREPARE, and then works correctly even if the current database has been
1178+
# changed.
1179+
#
1180+
use mysqltest_long_database_name_to_thrash_heap;
1181+
# Necessary for preparation of INSERT/UPDATE/DELETE to succeed
1182+
prepare stmt_create from "create table t1 (i int)";
1183+
prepare stmt_insert from "insert into t1 (i) values (1)";
1184+
prepare stmt_update from "update t1 set i=2";
1185+
prepare stmt_delete from "delete from t1 where i=2";
1186+
prepare stmt_select from "select * from t1";
1187+
prepare stmt_alter from "alter table t1 add column (b int)";
1188+
prepare stmt_alter1 from "alter table t1 drop column b";
1189+
prepare stmt_analyze from "analyze table t1";
1190+
prepare stmt_optimize from "optimize table t1";
1191+
prepare stmt_show from "show tables like 't1'";
1192+
prepare stmt_truncate from "truncate table t1";
1193+
prepare stmt_drop from "drop table t1";
1194+
# Drop the table that was used to prepare INSERT/UPDATE/DELETE: we will
1195+
# create a new one by executing stmt_create
1196+
drop table t1;
1197+
# Switch the current database
1198+
use test;
1199+
# Check that all prepared statements operate on the database that was
1200+
# active at PREPARE
1201+
execute stmt_create;
1202+
# should return empty set
1203+
show tables like 't1';
1204+
use mysqltest_long_database_name_to_thrash_heap;
1205+
show tables like 't1';
1206+
use test;
1207+
execute stmt_insert;
1208+
select * from mysqltest_long_database_name_to_thrash_heap.t1;
1209+
execute stmt_update;
1210+
select * from mysqltest_long_database_name_to_thrash_heap.t1;
1211+
execute stmt_delete;
1212+
execute stmt_select;
1213+
execute stmt_alter;
1214+
show columns from mysqltest_long_database_name_to_thrash_heap.t1;
1215+
execute stmt_alter1;
1216+
show columns from mysqltest_long_database_name_to_thrash_heap.t1;
1217+
execute stmt_analyze;
1218+
execute stmt_optimize;
1219+
execute stmt_show;
1220+
execute stmt_truncate;
1221+
execute stmt_drop;
1222+
show tables like 't1';
1223+
use mysqltest_long_database_name_to_thrash_heap;
1224+
show tables like 't1';
1225+
#
1226+
# Attempt a statement PREPARE when there is no current database:
1227+
# is expected to return an error.
1228+
#
1229+
drop database mysqltest_long_database_name_to_thrash_heap;
1230+
--error ER_NO_DB_ERROR
1231+
prepare stmt_create from "create table t1 (i int)";
1232+
--error ER_NO_DB_ERROR
1233+
prepare stmt_insert from "insert into t1 (i) values (1)";
1234+
--error ER_NO_DB_ERROR
1235+
prepare stmt_update from "update t1 set i=2";
1236+
--error ER_NO_DB_ERROR
1237+
prepare stmt_delete from "delete from t1 where i=2";
1238+
--error ER_NO_DB_ERROR
1239+
prepare stmt_select from "select * from t1";
1240+
--error ER_NO_DB_ERROR
1241+
prepare stmt_alter from "alter table t1 add column (b int)";
1242+
--error ER_NO_DB_ERROR
1243+
prepare stmt_alter1 from "alter table t1 drop column b";
1244+
--error ER_NO_DB_ERROR
1245+
prepare stmt_analyze from "analyze table t1";
1246+
--error ER_NO_DB_ERROR
1247+
prepare stmt_optimize from "optimize table t1";
1248+
--error ER_NO_DB_ERROR
1249+
prepare stmt_show from "show tables like 't1'";
1250+
--error ER_NO_DB_ERROR
1251+
prepare stmt_truncate from "truncate table t1";
1252+
--error ER_NO_DB_ERROR
1253+
prepare stmt_drop from "drop table t1";
1254+
#
1255+
# The above has automatically deallocated all our statements.
1256+
#
1257+
# Attempt to CREATE a temporary table when no DB used: it should fail
1258+
# This proves that no table can be used without explicit specification of
1259+
# its database if there is no current database.
1260+
#
1261+
--error ER_NO_DB_ERROR
1262+
create temporary table t1 (i int);
1263+
#
1264+
# Restore the old environemnt
1265+
#
1266+
use test;
11491267
# End of 5.0 tests

mysql-test/t/sp.test

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5893,6 +5893,52 @@ DROP FUNCTION bug18037_f1|
58935893
DROP PROCEDURE bug18037_p1|
58945894
DROP PROCEDURE bug18037_p2|
58955895

5896+
#
5897+
# Bug#17199: "Table not found" error occurs if the query contains a call
5898+
# to a function from another database.
5899+
# See also ps.test for an additional test case for this bug.
5900+
#
5901+
use test|
5902+
create table t3 (i int)|
5903+
insert into t3 values (1), (2)|
5904+
create database mysqltest1|
5905+
use mysqltest1|
5906+
create function bug17199() returns varchar(2) deterministic return 'ok'|
5907+
use test|
5908+
select *, mysqltest1.bug17199() from t3|
5909+
#
5910+
# Bug#18444: Fully qualified stored function names don't work correctly
5911+
# in select statements
5912+
#
5913+
use mysqltest1|
5914+
create function bug18444(i int) returns int no sql deterministic return i + 1|
5915+
use test|
5916+
select mysqltest1.bug18444(i) from t3|
5917+
drop database mysqltest1|
5918+
#
5919+
# Check that current database has no influence to a stored procedure
5920+
#
5921+
create database mysqltest1 charset=utf8|
5922+
create database mysqltest2 charset=utf8|
5923+
create procedure mysqltest1.p1()
5924+
begin
5925+
-- alters the default collation of database test
5926+
alter database character set koi8r;
5927+
end|
5928+
use mysqltest1|
5929+
call p1()|
5930+
show create database mysqltest1|
5931+
show create database mysqltest2|
5932+
alter database mysqltest1 character set utf8|
5933+
use mysqltest2|
5934+
call mysqltest1.p1()|
5935+
show create database mysqltest1|
5936+
show create database mysqltest2|
5937+
drop database mysqltest1|
5938+
drop database mysqltest2|
5939+
#
5940+
# Restore the old environemnt
5941+
use test|
58965942
#
58975943
# Bug#15217 "Using a SP cursor on a table created with PREPARE fails with
58985944
# weird error". Check that the code that is supposed to work at

mysys/my_malloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ char *my_strdup(const char *from, myf my_flags)
8383
}
8484

8585

86-
char *my_strndup(const byte *from, uint length, myf my_flags)
86+
char *my_strndup(const char *from, uint length, myf my_flags)
8787
{
8888
gptr ptr;
8989
if ((ptr=my_malloc(length+1,my_flags)) != 0)

mysys/safemalloc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,8 @@ char *_my_strdup(const char *from, const char *filename, uint lineno,
525525
} /* _my_strdup */
526526

527527

528-
char *_my_strndup(const byte *from, uint length,
529-
const char *filename, uint lineno,
530-
myf MyFlags)
528+
char *_my_strndup(const char *from, uint length, const char *filename,
529+
uint lineno, myf MyFlags)
531530
{
532531
gptr ptr;
533532
if ((ptr=_mymalloc(length+1,filename,lineno,MyFlags)) != 0)

sql/ha_federated.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,8 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table,
629629
DBUG_PRINT("info", ("Length: %d", table->s->connect_string.length));
630630
DBUG_PRINT("info", ("String: '%.*s'", table->s->connect_string.length,
631631
table->s->connect_string.str));
632-
share->scheme= my_strndup((const byte*)table->s->
633-
connect_string.str,
634-
table->s->connect_string.length,
635-
MYF(0));
632+
share->scheme= my_strndup(table->s->connect_string.str,
633+
table->s->connect_string.length, MYF(0));
636634

637635
// Add a null for later termination of table name
638636
share->scheme[table->s->connect_string.length]= 0;

0 commit comments

Comments
 (0)