Commit 4eabbff7 authored by unknown's avatar unknown

Merge mysql.com:/home/jonas/src/mysql-5.0

into mysql.com:/home/jonas/src/mysql-5.0-ndb


mysql-test/r/ndb_index_unique.result:
  Auto merged
mysql-test/t/ndb_index_unique.test:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
parents c9b20854 6603f7a8
......@@ -25,7 +25,10 @@ Any other options will be passed directly to configure.
Note: this script is intended for internal use by MySQL developers.
EOF
--with-debug=full ) full_debug="=full"; shift ;;
* ) break ;;
* )
echo "Unknown option '$1'"
exit 1
break ;;
esac
done
......@@ -62,6 +65,7 @@ fast_cflags="-O3 -fno-omit-frame-pointer"
reckless_cflags="-O3 -fomit-frame-pointer "
debug_cflags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS -DSAFEMALLOC -DPEDANTIC_SAFEMALLOC -DSAFE_MUTEX"
debug_extra_cflags="-O1 -Wuninitialized"
base_cxxflags="-felide-constructors -fno-exceptions -fno-rtti"
amd64_cxxflags="-DBIG_TABLES"
......@@ -80,7 +84,7 @@ local_infile_configs="--enable-local-infile"
debug_configs="--with-debug$full_debug"
if [ -z "$full_debug" ]
then
debug_cflags="$debug_cflags -O1 -Wuninitialized"
debug_cflags="$debug_cflags $debug_extra_cflags"
fi
if gmake --version > /dev/null 2>&1
......
#! /bin/sh
path=`dirname $0`
. "$path/SETUP.sh"
. "$path/SETUP.sh" $@ --with-debug=full
extra_flags="$pentium64_cflags $debug_cflags"
c_warnings="$c_warnings $debug_extra_warnings"
......
......@@ -172,6 +172,7 @@ nick@nick.leippe.com
papa@gbichot.local
patg@krsna.patg.net
patg@patrick-galbraiths-computer.local
patg@pc248.lfp.kcls.org
paul@central.snake.net
paul@frost.snake.net
paul@ice.local
......
......@@ -1678,12 +1678,12 @@ if test "$with_debug" = "yes"
then
# Medium debug.
CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC -DDBUG_ON -DSAFE_MUTEX $CFLAGS"
CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DSAFE_MUTEX $CXXFLAGS"
CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DDBUG_ON -DSAFE_MUTEX $CXXFLAGS"
elif test "$with_debug" = "full"
then
# Full debug. Very slow in some cases
CFLAGS="$DEBUG_CFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS"
CXXFLAGS="$DEBUG_CXXFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS"
CFLAGS="$DEBUG_CFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC -DUNIV_DEBUG $CFLAGS"
CXXFLAGS="$DEBUG_CXXFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC -DUNIV_DEBUG $CXXFLAGS"
else
# Optimized version. No debug
CFLAGS="$OPTIMIZE_CFLAGS -DDBUG_OFF $CFLAGS"
......
......@@ -259,6 +259,8 @@ extern char wild_many,wild_one,wild_prefix;
extern const char *charsets_dir;
extern char *defaults_extra_file;
extern my_bool timed_mutexes;
typedef struct wild_file_pack /* Struct to hold info when selecting files */
{
uint wilds; /* How many wildcards */
......
......@@ -80,6 +80,10 @@ memory is read outside the allocated blocks. */
/* Make a non-inline debug version */
#ifdef DBUG_ON
#define UNIV_DEBUG
#endif /* DBUG_ON */
/*
#define UNIV_DEBUG
#define UNIV_MEM_DEBUG
......
-- require r/have_federated_db.require
disable_query_log;
show variables like "have_federated_db";
show variables like "have_federated_engine";
enable_query_log;
#################### include/testdb_only.inc ######################
# #
# We must prevent to work on databases created by customers, #
# because we DROP/CREATE/MODIFY objects with sometimes common #
# names like STAFF, EMPLOYEE etc. #
# #
# Therefore we check the environment variable USE_RUNNING_SERVER. #
# USE_RUNNING_SERVER is exported by "mysql-test-run" and could #
# contain the following values: #
# 0 -- mysql-test-run was started without the --extern option #
# That means the test will be performed within the test #
# area 'mysql-test/var/...' . #
# 1 -- mysql-test-run was started with the --extern option #
# That means the test will be performed by an already #
# running server and data modifications will most probably #
# outside of the common test area 'mysql-test/var/...' . #
# #
# If USE_RUNNING_SERVER is not 0 the test will be skipped. #
# #
###################################################################
--disable_query_log
eval set @USE_RUNNING_SERVER= '$USE_RUNNING_SERVER';
--require r/testdb_only.require
SELECT 'use extern server'
AS "Variable_name ",
IF(@USE_RUNNING_SERVER= '1','YES',
IF(@USE_RUNNING_SERVER= '0','NO','UNEXPECTED'))
AS "Value" ;
--enable_query_log
......@@ -224,7 +224,7 @@ EXTRA_MASTER_OPT=""
EXTRA_MYSQL_TEST_OPT=""
EXTRA_MYSQLDUMP_OPT=""
EXTRA_MYSQLBINLOG_OPT=""
USE_RUNNING_SERVER=""
USE_RUNNING_SERVER=0
USE_NDBCLUSTER=""
USE_RUNNING_NDBCLUSTER=""
DO_GCOV=""
......@@ -255,7 +255,7 @@ NDBD_EXTRA_OPTS=
while test $# -gt 0; do
case "$1" in
--embedded-server) USE_EMBEDDED_SERVER=1 USE_MANAGER=0 NO_SLAVE=1 ; \
USE_RUNNING_SERVER="" RESULT_EXT=".es" TEST_MODE="embedded" ;;
USE_RUNNING_SERVER=0 RESULT_EXT=".es" TEST_MODE="embedded" ;;
--user=*) DBUSER=`$ECHO "$1" | $SED -e "s;--user=;;"` ;;
--force) FORCE=1 ;;
--timer) USE_TIMER=1 ;;
......@@ -265,8 +265,8 @@ while test $# -gt 0; do
MASTER_MYSQLD=`$ECHO "$1" | $SED -e "s;--master-binary=;;"` ;;
--slave-binary=*)
SLAVE_MYSQLD=`$ECHO "$1" | $SED -e "s;--slave-binary=;;"` ;;
--local) USE_RUNNING_SERVER="" ;;
--extern) USE_RUNNING_SERVER="1" ;;
--local) USE_RUNNING_SERVER=0 ;;
--extern) USE_RUNNING_SERVER=1 ;;
--with-ndbcluster)
USE_NDBCLUSTER="--ndbcluster" ;;
--ndb-connectstring=*)
......@@ -303,7 +303,7 @@ while test $# -gt 0; do
--no-manager | --skip-manager) USE_MANAGER=0 ;;
--manager)
USE_MANAGER=1
USE_RUNNING_SERVER=
USE_RUNNING_SERVER=0
;;
--start-and-exit)
START_AND_EXIT=1
......@@ -372,7 +372,7 @@ while test $# -gt 0; do
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --gdb"
# This needs to be checked properly
# USE_MANAGER=1
USE_RUNNING_SERVER=""
USE_RUNNING_SERVER=0
;;
--client-gdb )
if [ x$BINARY_DIST = x1 ] ; then
......@@ -385,7 +385,7 @@ while test $# -gt 0; do
--manual-gdb )
DO_GDB=1
MANUAL_GDB=1
USE_RUNNING_SERVER=""
USE_RUNNING_SERVER=0
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --gdb"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --gdb"
;;
......@@ -394,7 +394,7 @@ while test $# -gt 0; do
$ECHO "Note: you will get more meaningful output on a source distribution compiled with debugging option when running tests with --ddd option"
fi
DO_DDD=1
USE_RUNNING_SERVER=""
USE_RUNNING_SERVER=0
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --gdb"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --gdb"
;;
......@@ -412,7 +412,7 @@ while test $# -gt 0; do
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc --skip-bdb"
SLEEP_TIME_AFTER_RESTART=10
SLEEP_TIME_FOR_DELETE=60
USE_RUNNING_SERVER=""
USE_RUNNING_SERVER=0
if test "$1" = "--valgrind-all"
then
VALGRIND="$VALGRIND -v --show-reachable=yes"
......@@ -627,9 +627,9 @@ fi
if [ -z "$1" ]
then
USE_RUNNING_SERVER=""
USE_RUNNING_SERVER=0
fi
if [ -n "$USE_RUNNING_SERVER" ]
if [ $USE_RUNNING_SERVER -eq 1 ]
then
MASTER_MYSOCK=$LOCAL_SOCKET;
DBUSER=${DBUSER:-test}
......@@ -801,7 +801,7 @@ report_stats () {
$ECHO "http://www.mysql.com/doc/en/MySQL_test_suite.html"
fi
if test -z "$USE_RUNNING_SERVER"
if [ $USE_RUNNING_SERVER -eq 0 ]
then
# Report if there was any fatal warnings/errors in the log files
......@@ -1511,7 +1511,7 @@ run_testcase ()
done
fi
if [ -z "$USE_RUNNING_SERVER" ] ;
if [ $USE_RUNNING_SERVER -eq 0 ] ;
then
if [ -f $master_opt_file ] ;
then
......@@ -1655,7 +1655,7 @@ run_testcase ()
if [ x$FORCE != x1 ] ; then
$ECHO "Aborting: $tname failed in $TEST_MODE mode. To continue, re-run with '--force'."
$ECHO
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && \
if [ -z "$DO_GDB" ] && [ $USE_RUNNING_SERVER -eq 0 ] && \
[ -z "$DO_DDD" ] && [ -z "$USE_EMBEDDED_SERVER" ]
then
mysql_stop
......@@ -1664,7 +1664,7 @@ run_testcase ()
exit 1
fi
FAILED_CASES="$FAILED_CASES $tname"
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && \
if [ -z "$DO_GDB" ] && [ $USE_RUNNING_SERVER -eq 0 ] && \
[ -z "$DO_DDD" ] && [ -z "$USE_EMBEDDED_SERVER" ]
then
mysql_restart
......@@ -1683,7 +1683,7 @@ run_testcase ()
[ "$DO_GCOV" ] && gcov_prepare
[ "$DO_GPROF" ] && gprof_prepare
if [ -z "$USE_RUNNING_SERVER" ]
if [ $USE_RUNNING_SERVER -eq 0 ]
then
if [ -z "$FAST_START" ]
then
......@@ -1744,6 +1744,9 @@ fi
$ECHO "Starting Tests"
# Some test cases need USE_RUNNING_SERVER
export USE_RUNNING_SERVER
#
# This can probably be deleted
#
......@@ -1816,7 +1819,7 @@ fi
$ECHO $DASH72
$ECHO
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ]
if [ -z "$DO_GDB" ] && [ $USE_RUNNING_SERVER -eq 0 ] && [ -z "$DO_DDD" ]
then
mysql_stop
fi
......
This diff is collapsed.
Variable_name Value
have_federated_db YES
have_federated_engine YES
......@@ -778,3 +778,20 @@ sid wnid
39560 01019090000
37994 01019090000
drop table t1;
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (2), (1), (1), (2), (1);
SELECT a FROM t1 ORDER BY a;
a
1
1
1
2
2
(SELECT a FROM t1) ORDER BY a;
a
1
1
1
2
2
DROP TABLE t1;
Variable_name Value
use extern server NO
......@@ -6,6 +6,7 @@ delete from mysql.tables_priv where user like 'mysqltest\_%';
delete from mysql.columns_priv where user like 'mysqltest\_%';
flush privileges;
grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 2;
flush user_resources;
select * from t1;
i
select * from t1;
......@@ -16,6 +17,7 @@ select * from t1;
ERROR 42000: User 'mysqltest_1' has exceeded the 'max_questions' resource (current value: 2)
drop user mysqltest_1@localhost;
grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 2;
flush user_resources;
select * from t1;
i
select * from t1;
......@@ -34,6 +36,7 @@ select * from t1;
i
drop user mysqltest_1@localhost;
grant usage on *.* to mysqltest_1@localhost with max_connections_per_hour 2;
flush user_resources;
select * from t1;
i
select * from t1;
......@@ -47,6 +50,7 @@ ERROR 42000: User 'mysqltest_1' has exceeded the 'max_connections' resource (cur
drop user mysqltest_1@localhost;
flush privileges;
grant usage on *.* to mysqltest_1@localhost with max_user_connections 2;
flush user_resources;
select * from t1;
i
select * from t1;
......@@ -56,6 +60,7 @@ ERROR 42000: User 'mysqltest_1' has exceeded the 'max_user_connections' resource
select * from t1;
i
grant usage on *.* to mysqltest_1@localhost with max_user_connections 3;
flush user_resources;
select * from t1;
i
connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK);
......@@ -71,6 +76,7 @@ select @@session.max_user_connections, @@global.max_user_connections;
@@session.max_user_connections @@global.max_user_connections
2 2
grant usage on *.* to mysqltest_1@localhost;
flush user_resources;
select @@session.max_user_connections, @@global.max_user_connections;
@@session.max_user_connections @@global.max_user_connections
2 2
......@@ -79,6 +85,7 @@ i
connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK);
ERROR 42000: User mysqltest_1 already has more than 'max_user_connections' active connections
grant usage on *.* to mysqltest_1@localhost with max_user_connections 3;
flush user_resources;
select @@session.max_user_connections, @@global.max_user_connections;
@@session.max_user_connections @@global.max_user_connections
3 2
......
......@@ -68,12 +68,14 @@ select * from federated.t1 where id = 5;
delete from federated.t1;
select * from federated.t1 where id = 5;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
connection slave;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) );
connection master;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, other) values ('First Name', 11111);
insert into federated.t1 (name, other) values ('Second Name', NULL);
insert into federated.t1 (name, other) values ('Third Name', 33333);
......@@ -90,19 +92,78 @@ select * from federated.t1 where name IS NULL;
select * from federated.t1 where name IS NULL and other IS NULL;
select * from federated.t1 where name IS NULL or other IS NULL;
update federated.t1 set name = 'Fourth Name', other = 'four four four' where name IS NULL and other IS NULL;
update federated.t1 set other = 'two two two two' where name = 'Secend Name';
update federated.t1 set other = 'two two two two' where name = 'Second Name';
update federated.t1 set other = 'seven seven' where name like 'Sec%';
update federated.t1 set other = 'seven seven' where name = 'Seventh Name';
update federated.t1 set name = 'Tenth Name' where other like 'fee fie%';
select * from federated.t1 where name IS NULL or other IS NULL ;
select * from federated.t1;
# test multi-keys
connection slave;
drop table if exists federated.t1;
CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) DEFAULT CHARSET=latin1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name`
varchar(32) NOT NULL DEFAULT '', `other` varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (`id`), key nameoth (name, other) );
connection master;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `name` varchar(32) NOT NULL DEFAULT '', `other` varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (`id`), key nameoth (name, other)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, other) values ('First Name', '1111');
insert into federated.t1 (name, other) values ('Second Name', '2222');
insert into federated.t1 (name, other) values ('Third Name', '3333');
select * from federated.t1 where name = 'Second Name';
select * from federated.t1 where other = '2222';
select * from federated.t1 where name = 'Third Name';
select * from federated.t1 where name = 'Third Name' and other = '3333';
connection slave;
drop table if exists federated.t1;
CREATE TABLE federated.t1
(id int NOT NULL auto_increment,
name char(32) NOT NULL DEFAULT '',
bincol binary(4) NOT NULL,
floatval decimal(5,2) NOT NULL DEFAULT 0.0,
other int NOT NULL DEFAULT 0,
primary key(id),
key nameoth(name, other),
key bincol(bincol),
key floatval(floatval));
# test other types of indexes
connection master;
drop table if exists federated.t1;
CREATE TABLE federated.t1
(id int NOT NULL auto_increment,
name char(32) NOT NULL DEFAULT '',
bincol binary(4) NOT NULL,
floatval decimal(5,2) NOT NULL DEFAULT 0.0,
other int NOT NULL DEFAULT 0,
primary key(id),
key nameoth(name,other),
key bincol(bincol),
key floatval(floatval))
ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, bincol, floatval, other) values ('first', 0x65, 11.11, 1111);
insert into federated.t1 (name, bincol, floatval, other) values ('second', 0x66, 22.22, 2222);
insert into federated.t1 (name, bincol, floatval, other) values ('third', 'g', 22.22, 2222);
select * from federated.t1;
select * from federated.t1 where name = 'second';
select * from federated.t1 where bincol= 'f';
select * from federated.t1 where bincol= 0x66;
select * from federated.t1 where bincol= 0x67;
select * from federated.t1 where bincol= 'g';
select * from federated.t1 where floatval=11.11;
select * from federated.t1 where name='third';
select * from federated.t1 where other=2222;
select * from federated.t1 where name='third' and other=2222;
# test NULLs
connection slave;
drop table if exists federated.t1;
CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) DEFAULT CHARSET=latin1;
connection master;
drop table if exists federated.t1;
CREATE TABLE federated.t1 (id int, name varchar(32), floatval float, other int) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
# these both should be the same
......@@ -452,15 +513,17 @@ select * from federated.t1;
connection slave;
drop table if exists federated.t1;
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code)) DEFAULT CHARSET=latin1;
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob NOT NULL, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code), index(fileguts(10))) DEFAULT CHARSET=latin1;
connection master;
drop table if exists federated.t1;
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
create table federated.t1 (id int NOT NULL auto_increment, code char(20) NOT NULL, fileguts blob NOT NULL, creation_date datetime, entered_time datetime default '2004-04-04 04:04:04', primary key(id), index(code), index(fileguts(10))) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (code, fileguts, creation_date) values ('ASDFWERQWETWETAWETA', '*()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#<S-F8>*<S-F8><S-F8><S-F8>#<S-F8>#<S-F8>#<S-F8>[[', '2003-03-03 03:03:03');
insert into federated.t1 (code, fileguts, creation_date) values ('DEUEUEUEUEUEUEUEUEU', '*()w*09*$()*#)(*09*^90*d)(*s()d8g)(s*ned)(*)(s*d)(*hn(d*)(*sbn)D((#$*(#*%%&#&^$#&#&#&#&^&#*&*#$*&^*(&#(&Q*&&(*!&!(*&*(#&*(%&#<S-F8>*<S-F8><S-F8><S-F8>#<S-F8>#<S-F8>#<S-F8>[[', '2004-04-04 04:04:04');
insert into federated.t1 (code, fileguts, creation_date) values ('DEUEUEUEUEUEUEUEUEU', 'jimbob', '2004-04-04 04:04:04');
select * from federated.t1;
drop table if exists federated.t1;
select * from federated.t1 where fileguts = 'jimbob';
# test blob indexes
# TODO
#
......@@ -490,11 +553,36 @@ drop table if exists federated.t1;
# drop table if exists federated.t1;
#
# test joins with non-federated table
connection slave;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `country_id` int(20) NOT NULL DEFAULT 0, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`), key (country_id));
connection master;
drop table if exists federated.t1;
CREATE TABLE federated.t1 ( `id` int(20) NOT NULL auto_increment, `country_id` int(20) NOT NULL DEFAULT 0, `name` varchar(32), `other` varchar(20), PRIMARY KEY (`id`), key (country_id) ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:9308/federated/t1';
insert into federated.t1 (name, country_id, other) values ('Kumar', 1, 11111);
insert into federated.t1 (name, country_id, other) values ('Lenz', 2, 22222);
insert into federated.t1 (name, country_id, other) values ('Marizio', 3, 33333);
insert into federated.t1 (name, country_id, other) values ('Monty', 4, 33333);
insert into federated.t1 (name, country_id, other) values ('Sanja', 5, 33333);
drop table if exists federated.countries;
CREATE TABLE federated.countries ( `id` int(20) NOT NULL auto_increment, `country` varchar(32), primary key (id));
insert into federated.countries (country) values ('India');
insert into federated.countries (country) values ('Germany');
insert into federated.countries (country) values ('Italy');
insert into federated.countries (country) values ('Finland');
insert into federated.countries (country) values ('Ukraine');
select federated.t1.*, federated.countries.country from federated.t1 left join federated.countries on federated.t1.country_id = federated.countries.id;
drop table federated.countries;
connection master;
--disable_warnings
drop table if exists federated.t1;
drop database if exists federated;
--enable_warnings
......
......@@ -539,3 +539,13 @@ explain select * from t1 where wnid like '0101%' order by wnid;
select * from t1 where wnid like '0101%' order by wnid;
drop table t1;
#
# Bug #7672 - a wrong result for a select query in braces followed by order by
#
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (2), (1), (1), (2), (1);
SELECT a FROM t1 ORDER BY a;
(SELECT a FROM t1) ORDER BY a;
DROP TABLE t1;
......@@ -19,6 +19,8 @@ flush privileges;
# Test of MAX_QUERIES_PER_HOUR limit
grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 2;
# This ensures that counters are reset and makes test scheduling independent
flush user_resources;
connect (mqph, localhost, mysqltest_1,,);
connection mqph;
select * from t1;
......@@ -37,6 +39,7 @@ disconnect mqph2;
# Test of MAX_UPDATES_PER_HOUR limit
grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 2;
flush user_resources;
connect (muph, localhost, mysqltest_1,,);
connection muph;
select * from t1;
......@@ -60,6 +63,7 @@ disconnect muph2;
# Test of MAX_CONNECTIONS_PER_HOUR limit
grant usage on *.* to mysqltest_1@localhost with max_connections_per_hour 2;
flush user_resources;
connect (mcph1, localhost, mysqltest_1,,);
connection mcph1;
select * from t1;
......@@ -86,6 +90,7 @@ drop user mysqltest_1@localhost;
# We need this to reset internal mqh_used variable
flush privileges;
grant usage on *.* to mysqltest_1@localhost with max_user_connections 2;
flush user_resources;
connect (muc1, localhost, mysqltest_1,,);
connection muc1;
select * from t1;
......@@ -102,6 +107,7 @@ select * from t1;
# Changing of limit should also help (and immediately)
connection default;
grant usage on *.* to mysqltest_1@localhost with max_user_connections 3;
flush user_resources;
connect (muc4, localhost, mysqltest_1,,);
connection muc4;
select * from t1;
......@@ -127,6 +133,7 @@ set global max_user_connections= 2;
select @@session.max_user_connections, @@global.max_user_connections;
# Let us check that global limit works
grant usage on *.* to mysqltest_1@localhost;
flush user_resources;
connect (muca1, localhost, mysqltest_1,,);
connection muca1;
select @@session.max_user_connections, @@global.max_user_connections;
......@@ -139,6 +146,7 @@ connect (muca3, localhost, mysqltest_1,,);
# Now we are testing that per-account limit prevails over gloabl limit
connection default;
grant usage on *.* to mysqltest_1@localhost with max_user_connections 3;
flush user_resources;
connect (muca3, localhost, mysqltest_1,,);
connection muca3;
select @@session.max_user_connections, @@global.max_user_connections;
......
......@@ -25,6 +25,8 @@
#include "my_alarm.h"
#endif
my_bool timed_mutexes= 0;
/* from my_init */
my_string home_dir=0,my_progname=0;
char NEAR curr_dir[FN_REFLEN]= {0},
......
......@@ -524,6 +524,115 @@ Field *Field::new_key_field(MEM_ROOT *root, struct st_table *new_table,
return tmp;
}
/*
SYNOPSIS
Field::quote_data()
unquoted_string Pointer pointing to the value of a field
DESCRIPTION
Simple method that passes the field type to the method "type_quote"
To get a true/false value as to whether the value in string1 needs
to be enclosed with quotes. This ensures that values in the final
sql statement to be passed to the remote server will be quoted properly
RETURN_VALUE
void Immediately - if string doesn't need quote
void Upon prepending/appending quotes on each side of variable
*/
bool Field::quote_data(String *unquoted_string)
{
char escaped_string[IO_SIZE];
char *unquoted_string_buffer= (char *)(unquoted_string->ptr());
uint need_quotes;
DBUG_ENTER("Field::quote_data");
// this is the same call that mysql_real_escape_string() calls
escape_string_for_mysql(&my_charset_bin, (char *)escaped_string,
unquoted_string->ptr(), unquoted_string->length());
if (is_null())
DBUG_RETURN(0);
need_quotes= needs_quotes();
if (need_quotes == 0)
{
DBUG_RETURN(0);
}
else
{
// reset string, then re-append with quotes and escaped values
unquoted_string->length(0);
if (unquoted_string->append("'"))
DBUG_RETURN(1);
if (unquoted_string->append((char *)escaped_string))
DBUG_RETURN(1);
if (unquoted_string->append("'"))
DBUG_RETURN(1);
}
//DBUG_PRINT("Field::quote_data",
// ("FINAL quote_flag %d unquoted_string %s escaped_string %s",
//needs_quotes, unquoted_string->c_ptr_quick(), escaped_string));
DBUG_RETURN(0);
}
/*
Quote a field type if needed
SYNOPSIS
Field::type_quote
DESCRIPTION
Simple method to give true/false whether a field should be quoted.
Used when constructing INSERT and UPDATE queries to the remote server
see write_row and update_row
RETURN VALUE
0 if value is of type NOT needing quotes
1 if value is of type needing quotes
*/
bool Field::needs_quotes(void)
{
DBUG_ENTER("Field::type_quote");
switch(type()) {
//FIX this when kernel is fixed
case MYSQL_TYPE_VARCHAR :
case FIELD_TYPE_STRING :
case FIELD_TYPE_VAR_STRING :
case FIELD_TYPE_YEAR :
case FIELD_TYPE_NEWDATE :
case FIELD_TYPE_TIME :
case FIELD_TYPE_TIMESTAMP :
case FIELD_TYPE_DATE :
case FIELD_TYPE_DATETIME :
case FIELD_TYPE_TINY_BLOB :
case FIELD_TYPE_BLOB :
case FIELD_TYPE_MEDIUM_BLOB :
case FIELD_TYPE_LONG_BLOB :
case FIELD_TYPE_GEOMETRY :
DBUG_RETURN(1);
case FIELD_TYPE_DECIMAL :
case FIELD_TYPE_TINY :
case FIELD_TYPE_SHORT :
case FIELD_TYPE_INT24 :
case FIELD_TYPE_LONG :
case FIELD_TYPE_FLOAT :
case FIELD_TYPE_DOUBLE :
case FIELD_TYPE_LONGLONG :
case FIELD_TYPE_NULL :
case FIELD_TYPE_SET :
case FIELD_TYPE_ENUM :
DBUG_RETURN(0);
default: DBUG_RETURN(0);
}
DBUG_RETURN(0);
}
/****************************************************************************
Field_null, a field that always return NULL
......
......@@ -228,6 +228,8 @@ public:
ptr= old_ptr;
return str;
}
bool quote_data(String *unquoted_string);
bool needs_quotes(void);
virtual bool send_binary(Protocol *protocol);
virtual char *pack(char* to, const char *from, uint max_length=~(uint) 0)
{
......
This diff is collapsed.
......@@ -71,10 +71,8 @@ private:
return 0 on success
return errorcode otherwise
*/
//FIX
uint convert_row_to_internal_format(byte *buf, MYSQL_ROW row);
uint type_quote(int type);
void quote_data(String *string1, Field *field);
bool ha_federated::create_where_from_key(String *to, KEY *key_info, const byte *key, uint key_length);
public:
ha_federated(TABLE *table): handler(table),
......@@ -104,7 +102,7 @@ public:
{
return (HA_TABLE_SCAN_ON_INDEX | HA_NOT_EXACT_COUNT |
HA_PRIMARY_KEY_IN_READ_INDEX | HA_FILE_BASED | HA_AUTO_PART_KEY |
HA_TABLE_SCAN_ON_INDEX);
HA_TABLE_SCAN_ON_INDEX | HA_CAN_INDEX_BLOBS);
}
/*
This is a bitmap of flags that says how the storage engine
......@@ -132,7 +130,7 @@ public:
/*
The next method will never be called if you do not implement indexes.
*/
virtual double read_time(ha_rows rows) { return (double) rows / 20.0+1; }
virtual double read_time(uint index, uint ranges, ha_rows rows) { return (double) rows / 20.0+1; }
/*
Everything below are methods that we implment in ha_federated.cc.
......
......@@ -712,6 +712,10 @@ void free_des_key_file();
/* sql_do.cc */
bool mysql_do(THD *thd, List<Item> &values);
/* sql_analyse.h */
bool append_escaped(String *to_str, String *from_str);
bool append_escaped(String *to_str, char *from, uint from_len);
/* sql_show.cc */
bool mysqld_show_open_tables(THD *thd,const char *wild);
bool mysqld_show_logs(THD *thd);
......@@ -1001,8 +1005,7 @@ extern ulong ha_read_count, ha_discover_count;
extern ulong table_cache_size;
extern ulong max_connections,max_connect_errors, connect_timeout;
extern ulong slave_net_timeout;
extern ulong max_user_connections;
extern my_bool timed_mutexes;
extern uint max_user_connections;
extern ulong what_to_log,flush_time;
extern ulong query_buff_size, thread_stack,thread_stack_min;
extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit;
......
......@@ -333,9 +333,9 @@ ulong delayed_insert_errors,flush_time, thread_created;
ulong specialflag=0;
ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
ulong max_connections,max_used_connections,
max_connect_errors, max_user_connections = 0;
max_connect_errors;
uint max_user_connections= 0;
ulong thread_id=1L,current_pid;
my_bool timed_mutexes= 0;
ulong slow_launch_threads = 0, sync_binlog_period;
ulong expire_logs_days = 0;
ulong rpl_recovery_rank=0;
......@@ -5254,8 +5254,8 @@ The minimum value for this variable is 4096.",
REQUIRED_ARG, 32, 1, ~0L, 0, 1, 0},
{"max_user_connections", OPT_MAX_USER_CONNECTIONS,
"The maximum number of active connections for a single user (0 = no limit).",
(gptr*) &max_user_connections, (gptr*) &max_user_connections, 0, GET_ULONG,
REQUIRED_ARG, 0, 1, ~0L, 0, 1, 0},
(gptr*) &max_user_connections, (gptr*) &max_user_connections, 0, GET_UINT,
REQUIRED_ARG, 0, 1, ~0, 0, 1, 0},
{"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT,
"After this many write locks, allow some read locks to run in between.",
(gptr*) &max_write_lock_count, (gptr*) &max_write_lock_count, 0, GET_ULONG,
......
......@@ -732,7 +732,7 @@ struct show_var_st init_vars[]= {
{"have_crypt", (char*) &have_crypt, SHOW_HAVE},
{"have_csv", (char*) &have_csv_db, SHOW_HAVE},
{"have_example_engine", (char*) &have_example_db, SHOW_HAVE},
{"have_federated_db", (char*) &have_federated_db, SHOW_HAVE},
{"have_federated_engine", (char*) &have_federated_db, SHOW_HAVE},
{"have_geometry", (char*) &have_geometry, SHOW_HAVE},
{"have_innodb", (char*) &have_innodb, SHOW_HAVE},
{"have_isam", (char*) &have_isam, SHOW_HAVE},
......@@ -1599,6 +1599,14 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base)
var_type= OPT_GLOBAL;
}
switch (type()) {
case SHOW_INT:
{
uint value;
pthread_mutex_lock(&LOCK_global_system_variables);
value= *(uint*) value_ptr(thd, var_type, base);
pthread_mutex_unlock(&LOCK_global_system_variables);
return new Item_uint((int32) value);
}
case SHOW_LONG:
{
ulong value;
......
......@@ -740,7 +740,7 @@ public:
return type != OPT_GLOBAL || !option_limits;
}
void set_default(THD *thd, enum_var_type type);
SHOW_TYPE type() { return SHOW_LONG; }
SHOW_TYPE type() { return SHOW_INT; }
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
};
......
......@@ -59,7 +59,8 @@ int compare_ulonglong2(void* cmp_arg __attribute__((unused)),
return compare_ulonglong(s,t);
}
static bool append_escaped(String *to_str, String *from_str);
bool append_escaped(String *to_str, String *from_str);
bool append_escaped(String *to_str, char *from, uint from_len);
Procedure *
proc_analyse_init(THD *thd, ORDER *param, select_result *result,
......@@ -1052,7 +1053,7 @@ uint check_ulonglong(const char *str, uint length)
1 Out of memory
*/
static bool append_escaped(String *to_str, String *from_str)
bool append_escaped(String *to_str, String *from_str)
{
char *from, *end, c;
......@@ -1086,3 +1087,38 @@ static bool append_escaped(String *to_str, String *from_str)
}
return 0;
}
bool append_escaped(String *to_str, char *from, uint from_len)
{
char *end, c;
if (to_str->realloc(to_str->length() + from_len))
return 1;
end= from + from_len;
for (; from < end; from++)
{
c= *from;
switch (c) {
case '\0':
c= '0';
break;
case '\032':
c= 'Z';
break;
case '\\':
case '\'':
break;
default:
goto normal_character;
}
if (to_str->append('\\'))
return 1;
normal_character:
if (to_str->append(c))
return 1;
}
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment