Manual merge

mysql-test/mysql-test-run.sh:
  Auto merged
mysql-test/r/ctype_utf8.result:
  Auto merged
mysql-test/r/func_str.result:
  Auto merged
mysql-test/r/insert_select.result:
  Auto merged
mysql-test/r/key.result:
  Auto merged
mysql-test/r/myisam.result:
  Auto merged
mysql-test/r/sp-prelocking.result:
  Auto merged
mysql-test/r/sp.result:
  Auto merged
mysql-test/r/view_grant.result:
  Auto merged
mysql-test/t/func_time.test:
  Auto merged
mysql-test/t/key.test:
  Auto merged
mysql-test/valgrind.supp:
  Auto merged
mysql-test/t/myisam.test:
  Auto merged
mysql-test/t/select.test:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
mysql-test/t/view_grant.test:
  Auto merged
mysys/Makefile.am:
  Auto merged
sql/field.cc:
  Auto merged
sql/field.h:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/item_strfunc.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/opt_sum.cc:
  Auto merged
sql/slave.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp:
  Auto merged
storage/ndb/src/ndbapi/ndberror.c:
  Auto merged
strings/ctype-mb.c:
  Auto merged
This commit is contained in:
unknown 2006-06-25 01:32:13 +04:00
commit e79cff33aa
36 changed files with 494 additions and 86 deletions

View File

@ -32,7 +32,8 @@ noinst_HEADERS = config-win.h config-netware.h \
thr_lock.h t_ctype.h violite.h md5.h base64.h \
mysql_version.h.in my_handler.h my_time.h decimal.h \
my_vle.h my_user.h my_atomic.h atomic/nolock.h \
atomic/rwlock.h atomic/x86-gcc.h atomic/x86-msvc.h
atomic/rwlock.h atomic/x86-gcc.h atomic/x86-msvc.h \
my_libwrap.h
# mysql_version.h are generated
CLEANFILES = mysql_version.h my_config.h readline openssl

28
include/my_libwrap.h Normal file
View File

@ -0,0 +1,28 @@
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef HAVE_LIBWRAP
#include <tcpd.h>
#include <syslog.h>
#ifdef NEED_SYS_SYSLOG_H
#include <sys/syslog.h>
#endif /* NEED_SYS_SYSLOG_H */
extern void my_fromhost(struct request_info *req);
extern int my_hosts_access(struct request_info *req);
extern char *my_eval_client(struct request_info *req);
#endif /* HAVE_LIBWRAP */

View File

@ -794,10 +794,17 @@ select f1 from t1 where makedate(2006,2) between date(f1) and date(f3);
f1
2006-01-02
drop table t1;
select now() - now() + 0, curtime() - curtime() + 0,
create table t1 select now() - now(), curtime() - curtime(),
sec_to_time(1) + 0, from_unixtime(1) + 0;
now() - now() + 0 curtime() - curtime() + 0 sec_to_time(1) + 0 from_unixtime(1) + 0
0.000000 0.000000 1.000000 19700101030001.000000
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`now() - now()` double(23,6) NOT NULL default '0.000000',
`curtime() - curtime()` double(23,6) NOT NULL default '0.000000',
`sec_to_time(1) + 0` double(23,6) default NULL,
`from_unixtime(1) + 0` double(23,6) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
End of 4.1 tests
explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2;

View File

@ -686,3 +686,12 @@ ERROR 42S22: Unknown column 'z' in 'field list'
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x);
ERROR 42S22: Unknown column 't2.x' in 'field list'
drop table t1,t2;
CREATE TABLE t1 (a int PRIMARY KEY);
INSERT INTO t1 values (1), (2);
INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
DROP TABLE t1;
CREATE TABLE t1 (x int, y int);
CREATE TABLE t2 (z int, y int);
CREATE TABLE t3 (a int, b int);
INSERT INTO t3 (SELECT x, y FROM t1 JOIN t2 USING (y) WHERE z = 1);
DROP TABLE IF EXISTS t1,t2,t3;

View File

@ -330,6 +330,16 @@ alter table t1 add key (c1,c1,c2);
ERROR 42S21: Duplicate column name 'c1'
drop table t1;
create table t1 (
i1 INT NOT NULL,
i2 INT NOT NULL,
UNIQUE i1idx (i1),
UNIQUE i2idx (i2));
desc t1;
Field Type Null Key Default Extra
i1 int(11) NO UNI
i2 int(11) NO UNI
drop table t1;
create table t1 (
c1 int,
c2 varchar(20) not null,
primary key (c1),

View File

@ -747,6 +747,19 @@ select count(id1) from t1 where id2 = 10;
count(id1)
5
drop table t1;
CREATE TABLE t1(a TINYINT, KEY(a)) ENGINE=MyISAM;
INSERT INTO t1 VALUES(1);
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
MAX(a)
1
ALTER TABLE t1 DISABLE KEYS;
SELECT MAX(a) FROM t1;
MAX(a)
1
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
MAX(a)
1
DROP TABLE t1;
CREATE TABLE t1(a CHAR(9), b VARCHAR(7)) ENGINE=MyISAM;
INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx');
UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb';

View File

@ -2730,6 +2730,12 @@ ERROR 42000: Key 'a' doesn't exist in table 't1'
EXPLAIN SELECT * FROM t1 FORCE INDEX (a);
ERROR 42000: Key 'a' doesn't exist in table 't1'
DROP TABLE t1;
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
INSERT INTO t1 VALUES (10);
SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1;
i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01')
0 1 1 1
DROP TABLE t1;
CREATE TABLE t1 (
K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '',
K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000',

View File

@ -237,3 +237,21 @@ deallocate prepare stmt;
drop table t1;
drop view v1, v2, v3;
drop function bug15683;
drop table if exists t1, t2, t3;
drop function if exists bug19634;
create table t1 (id int, data int);
create table t2 (id int);
create table t3 (data int);
create function bug19634() returns int return (select count(*) from t3);
prepare stmt from "delete t1 from t1, t2 where t1.id = t2.id and bug19634()";
execute stmt;
execute stmt;
deallocate prepare stmt;
create trigger t1_bi before delete on t1 for each row insert into t3 values (old.data);
prepare stmt from "delete t1 from t1, t2 where t1.id = t2.id";
execute stmt;
execute stmt;
deallocate prepare stmt;
drop function bug19634;
drop table t1, t2, t3;
End of 5.0 tests

View File

@ -5000,4 +5000,25 @@ CALL bug18037_p2()|
DROP FUNCTION bug18037_f1|
DROP PROCEDURE bug18037_p1|
DROP PROCEDURE bug18037_p2|
drop table if exists t3|
drop procedure if exists bug15217|
create table t3 as select 1|
create procedure bug15217()
begin
declare var1 char(255);
declare cur1 cursor for select * from t3;
open cur1;
fetch cur1 into var1;
select concat('data was: /', var1, '/');
close cur1;
end |
call bug15217()|
concat('data was: /', var1, '/')
data was: /1/
flush tables |
call bug15217()|
concat('data was: /', var1, '/')
data was: /1/
drop table t3|
drop procedure bug15217|
drop table t1,t2;

View File

@ -649,3 +649,15 @@ DROP VIEW mysqltest_db1.view1;
DROP TABLE mysqltest_db1.t1;
DROP SCHEMA mysqltest_db1;
DROP USER mysqltest_db1@localhost;
CREATE DATABASE test1;
CREATE DATABASE test2;
CREATE TABLE test1.t0 (a VARCHAR(20));
CREATE TABLE test2.t1 (a VARCHAR(20));
CREATE VIEW test2.t3 AS SELECT * FROM test1.t0;
CREATE OR REPLACE VIEW test.v1 AS
SELECT ta.a AS col1, tb.a AS col2 FROM test2.t3 ta, test2.t1 tb;
DROP VIEW test.v1;
DROP VIEW test2.t3;
DROP TABLE test2.t1, test1.t0;
DROP DATABASE test2;
DROP DATABASE test1;

View File

@ -392,8 +392,10 @@ drop table t1;
# Bug #16546
#
select now() - now() + 0, curtime() - curtime() + 0,
sec_to_time(1) + 0, from_unixtime(1) + 0;
create table t1 select now() - now(), curtime() - curtime(),
sec_to_time(1) + 0, from_unixtime(1) + 0;
show create table t1;
drop table t1;
--echo End of 4.1 tests

View File

@ -224,4 +224,26 @@ insert into t1(x,y) select x,z from t2 on duplicate key update x=values(z);
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x);
drop table t1,t2;
#
# Bug #9676: INSERT INTO x SELECT .. FROM x LIMIT 1; slows down with big
# tables
#
#Note: not an exsaustive test : just a check of the code path.
CREATE TABLE t1 (a int PRIMARY KEY);
INSERT INTO t1 values (1), (2);
INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
DROP TABLE t1;
# End of 4.1 tests
#
# Bug #18080: INSERT ... SELECT ... JOIN results in ambiguous field list error
#
CREATE TABLE t1 (x int, y int);
CREATE TABLE t2 (z int, y int);
CREATE TABLE t3 (a int, b int);
INSERT INTO t3 (SELECT x, y FROM t1 JOIN t2 USING (y) WHERE z = 1);
DROP TABLE IF EXISTS t1,t2,t3;

View File

@ -325,6 +325,17 @@ alter table t1 add key (c1,c2,c1);
alter table t1 add key (c1,c1,c2);
drop table t1;
#
# Bug#11228: DESC shows arbitrary column as "PRI"
#
create table t1 (
i1 INT NOT NULL,
i2 INT NOT NULL,
UNIQUE i1idx (i1),
UNIQUE i2idx (i2));
desc t1;
drop table t1;
#
# Bug#12565 - ERROR 1034 when running simple UPDATE or DELETE
# on large MyISAM table

View File

@ -697,6 +697,18 @@ select count(*) from t1 where id2 = 10;
select count(id1) from t1 where id2 = 10;
drop table t1;
#
# BUG##20357 - Got error 124 from storage engine using MIN and MAX functions
# in queries
#
CREATE TABLE t1(a TINYINT, KEY(a)) ENGINE=MyISAM;
INSERT INTO t1 VALUES(1);
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
ALTER TABLE t1 DISABLE KEYS;
SELECT MAX(a) FROM t1;
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
DROP TABLE t1;
#
# BUG#18036 - update of table joined to self reports table as crashed
#

View File

@ -2285,6 +2285,25 @@ EXPLAIN SELECT * FROM t1 FORCE INDEX (a);
DROP TABLE t1;
#
# Bug #18759 "Incorrect string to numeric conversion"
#
# This test is here so that the behavior will not be changed to 4.1
# and not to 5.0 either. In 4.1 and 5.0 sending an integer as a string
# will be converted internally to real (double) value and it is not
# as accurate as bigint (longlong) for integers. Thus the results may
# vary. In 5.1 internally it is decimal, which is a string type and
# will be more accurate. Due to rather big changes needed to fix this
# in 4.1 or 5.0 it is not desired to do it in the stable versions.
#
# This test is here only to make sure that behavior is not changed in
# 4.1 and 5.0
#
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
INSERT INTO t1 VALUES (10);
SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1;
DROP TABLE t1;
# End of 4.1 tests
#

View File

@ -271,6 +271,34 @@ deallocate prepare stmt;
drop table t1;
drop view v1, v2, v3;
drop function bug15683;
#
# End of 5.0 tests
# Bug#19634 "Re-execution of multi-delete which involve trigger/stored
# function crashes server"
#
--disable_warnings
drop table if exists t1, t2, t3;
drop function if exists bug19634;
--enable_warnings
create table t1 (id int, data int);
create table t2 (id int);
create table t3 (data int);
create function bug19634() returns int return (select count(*) from t3);
prepare stmt from "delete t1 from t1, t2 where t1.id = t2.id and bug19634()";
# This should not crash server
execute stmt;
execute stmt;
deallocate prepare stmt;
create trigger t1_bi before delete on t1 for each row insert into t3 values (old.data);
prepare stmt from "delete t1 from t1, t2 where t1.id = t2.id";
execute stmt;
execute stmt;
deallocate prepare stmt;
drop function bug19634;
drop table t1, t2, t3;
--echo End of 5.0 tests

View File

@ -5893,6 +5893,33 @@ DROP FUNCTION bug18037_f1|
DROP PROCEDURE bug18037_p1|
DROP PROCEDURE bug18037_p2|
#
# Bug#15217 "Using a SP cursor on a table created with PREPARE fails with
# weird error". Check that the code that is supposed to work at
# the first execution of a stored procedure actually works for
# sp_instr_copen.
--disable_warnings
drop table if exists t3|
drop procedure if exists bug15217|
--enable_warnings
create table t3 as select 1|
create procedure bug15217()
begin
declare var1 char(255);
declare cur1 cursor for select * from t3;
open cur1;
fetch cur1 into var1;
select concat('data was: /', var1, '/');
close cur1;
end |
# Returns expected result
call bug15217()|
flush tables |
# Returns error with garbage as column name
call bug15217()|
drop table t3|
drop procedure bug15217|
#
# BUG#NNNN: New bug synopsis

View File

@ -852,3 +852,23 @@ DROP VIEW mysqltest_db1.view1;
DROP TABLE mysqltest_db1.t1;
DROP SCHEMA mysqltest_db1;
DROP USER mysqltest_db1@localhost;
#
# BUG#20482: failure on Create join view with sources views/tables
# in different schemas
#
--disable_warnings
CREATE DATABASE test1;
CREATE DATABASE test2;
--enable_warnings
CREATE TABLE test1.t0 (a VARCHAR(20));
CREATE TABLE test2.t1 (a VARCHAR(20));
CREATE VIEW test2.t3 AS SELECT * FROM test1.t0;
CREATE OR REPLACE VIEW test.v1 AS
SELECT ta.a AS col1, tb.a AS col2 FROM test2.t3 ta, test2.t1 tb;
DROP VIEW test.v1;
DROP VIEW test2.t3;
DROP TABLE test2.t1, test1.t0;
DROP DATABASE test2;
DROP DATABASE test1;

View File

@ -248,6 +248,18 @@
fun:_dl_relocate_object
}
#
# Warning from my_thread_init becasue mysqld dies before kill thread exists
#
{
my_thread_init kill thread memory loss second
Memcheck:Leak
fun:calloc
fun:my_thread_init
fun:kill_server_thread
}
#
# Leaks reported in _dl_* internal functions on Linux amd64 / glibc2.3.2.
#

View File

@ -53,7 +53,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
my_gethostbyname.c rijndael.c my_aes.c sha1.c \
my_handler.c my_netware.c my_largepage.c \
my_memmem.c \
my_windac.c my_access.c base64.c
my_windac.c my_access.c base64.c my_libwrap.c
EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
thr_mutex.c thr_rwlock.c \
CMakeLists.txt mf_soundex.c \

42
mysys/my_libwrap.c Normal file
View File

@ -0,0 +1,42 @@
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
This is needed to be able to compile with original libwrap header
files that don't have the prototypes
*/
#include <my_global.h>
#include <my_libwrap.h>
#ifdef HAVE_LIBWRAP
void my_fromhost(struct request_info *req)
{
fromhost(req);
}
int my_hosts_access(struct request_info *req)
{
hosts_access(req);
}
char *my_eval_client(struct request_info *req)
{
eval_client(req);
}
#endif /* HAVE_LIBWRAP */

View File

@ -4640,7 +4640,7 @@ int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs)
}
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
int4store(ptr,tmp);
}
@ -4707,7 +4707,7 @@ int Field_timestamp::store(longlong nr, bool unsigned_val)
nr, MYSQL_TIMESTAMP_DATETIME, 1);
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
int4store(ptr,timestamp);
}
@ -4733,7 +4733,7 @@ longlong Field_timestamp::val_int(void)
THD *thd= table ? table->in_use : current_thd;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
temp=uint4korr(ptr);
else
#endif
@ -4764,7 +4764,7 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr)
val_buffer->length(field_length);
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
temp=uint4korr(ptr);
else
#endif
@ -4829,7 +4829,7 @@ bool Field_timestamp::get_date(TIME *ltime, uint fuzzydate)
long temp;
THD *thd= table ? table->in_use : current_thd;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
temp=uint4korr(ptr);
else
#endif
@ -4866,7 +4866,7 @@ int Field_timestamp::cmp(const char *a_ptr, const char *b_ptr)
{
int32 a,b;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
a=sint4korr(a_ptr);
b=sint4korr(b_ptr);
@ -4884,7 +4884,7 @@ int Field_timestamp::cmp(const char *a_ptr, const char *b_ptr)
void Field_timestamp::sort_string(char *to,uint length __attribute__((unused)))
{
#ifdef WORDS_BIGENDIAN
if (!table->s->db_low_byte_first)
if (!table || !table->s->db_low_byte_first)
{
to[0] = ptr[0];
to[1] = ptr[1];
@ -4914,7 +4914,7 @@ void Field_timestamp::set_time()
long tmp= (long) thd->query_start();
set_notnull();
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
int4store(ptr,tmp);
}
@ -5326,7 +5326,7 @@ int Field_date::store(const char *from, uint len,CHARSET_INFO *cs)
from, len, MYSQL_TIMESTAMP_DATE, 1);
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
int4store(ptr,tmp);
}
@ -5388,7 +5388,7 @@ int Field_date::store(longlong nr, bool unsigned_val)
MYSQL_TIMESTAMP_DATETIME, 1);
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
int4store(ptr, nr);
}
@ -5415,7 +5415,7 @@ double Field_date::val_real(void)
ASSERT_COLUMN_MARKED_FOR_READ;
int32 j;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
j=sint4korr(ptr);
else
#endif
@ -5429,7 +5429,7 @@ longlong Field_date::val_int(void)
ASSERT_COLUMN_MARKED_FOR_READ;
int32 j;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
j=sint4korr(ptr);
else
#endif
@ -5446,7 +5446,7 @@ String *Field_date::val_str(String *val_buffer,
val_buffer->alloc(field_length);
int32 tmp;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
tmp=sint4korr(ptr);
else
#endif
@ -5464,7 +5464,7 @@ int Field_date::cmp(const char *a_ptr, const char *b_ptr)
{
int32 a,b;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
a=sint4korr(a_ptr);
b=sint4korr(b_ptr);
@ -5482,7 +5482,7 @@ int Field_date::cmp(const char *a_ptr, const char *b_ptr)
void Field_date::sort_string(char *to,uint length __attribute__((unused)))
{
#ifdef WORDS_BIGENDIAN
if (!table->s->db_low_byte_first)
if (!table || !table->s->db_low_byte_first)
{
to[0] = ptr[0];
to[1] = ptr[1];
@ -5729,7 +5729,7 @@ int Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs)
from, len, MYSQL_TIMESTAMP_DATETIME, 1);
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
int8store(ptr,tmp);
}
@ -5783,7 +5783,7 @@ int Field_datetime::store(longlong nr, bool unsigned_val)
MYSQL_TIMESTAMP_DATETIME, 1);
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
int8store(ptr,nr);
}
@ -5813,7 +5813,7 @@ int Field_datetime::store_time(TIME *ltime,timestamp_type type)
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
}
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
int8store(ptr,tmp);
}
@ -5841,7 +5841,7 @@ longlong Field_datetime::val_int(void)
ASSERT_COLUMN_MARKED_FOR_READ;
longlong j;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
j=sint8korr(ptr);
else
#endif
@ -5862,7 +5862,7 @@ String *Field_datetime::val_str(String *val_buffer,
int part3;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
tmp=sint8korr(ptr);
else
#endif
@ -5927,7 +5927,7 @@ int Field_datetime::cmp(const char *a_ptr, const char *b_ptr)
{
longlong a,b;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
{
a=sint8korr(a_ptr);
b=sint8korr(b_ptr);
@ -5945,7 +5945,7 @@ int Field_datetime::cmp(const char *a_ptr, const char *b_ptr)
void Field_datetime::sort_string(char *to,uint length __attribute__((unused)))
{
#ifdef WORDS_BIGENDIAN
if (!table->s->db_low_byte_first)
if (!table || !table->s->db_low_byte_first)
{
to[0] = ptr[0];
to[1] = ptr[1];

View File

@ -822,7 +822,7 @@ public:
if ((*null_value= is_null()))
return 0;
#ifdef WORDS_BIGENDIAN
if (table->s->db_low_byte_first)
if (table && table->s->db_low_byte_first)
return sint4korr(ptr);
#endif
long tmp;

View File

@ -138,7 +138,8 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems)
}
continue;
}
if ((res= items[i]->real_item()->type()) == Item::FIELD_ITEM)
if ((res= items[i]->real_item()->type()) == Item::FIELD_ITEM &&
items[i]->result_type() != INT_RESULT)
{
field= ((Item_field *)items[i]->real_item())->field;
break;

View File

@ -532,6 +532,8 @@ void cleanup_items(Item *item);
class THD;
void close_thread_tables(THD *thd, bool locked=0, bool skip_derived=0);
bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables);
bool check_single_table_access(THD *thd, ulong privilege,
TABLE_LIST *tables);
bool check_routine_access(THD *thd,ulong want_access,char *db,char *name,
bool is_proc, bool no_errors);
bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table);

View File

@ -116,16 +116,7 @@ extern "C" { // Because of SCO 3.2V4.2
#include <sys/utsname.h>
#endif /* __WIN__ */
#ifdef HAVE_LIBWRAP
#include <tcpd.h>
#include <syslog.h>
#ifdef NEED_SYS_SYSLOG_H
#include <sys/syslog.h>
#endif /* NEED_SYS_SYSLOG_H */
int allow_severity = LOG_INFO;
int deny_severity = LOG_WARNING;
#endif /* HAVE_LIBWRAP */
#include <my_libwrap.h>
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
@ -687,6 +678,8 @@ static const char* default_dbug_option;
#endif
#ifdef HAVE_LIBWRAP
const char *libwrapName= NULL;
int allow_severity = LOG_INFO;
int deny_severity = LOG_WARNING;
#endif
#ifdef HAVE_QUERY_CACHE
static ulong query_cache_limit= 0;
@ -4239,8 +4232,8 @@ pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused)))
struct request_info req;
signal(SIGCHLD, SIG_DFL);
request_init(&req, RQ_DAEMON, libwrapName, RQ_FILE, new_sock, NULL);
fromhost(&req);
if (!hosts_access(&req))
my_fromhost(&req);
if (!my_hosts_access(&req))
{
/*
This may be stupid but refuse() includes an exit(0)
@ -4248,7 +4241,7 @@ pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused)))
clean_exit() - same stupid thing ...
*/
syslog(deny_severity, "refused connect from %s",
eval_client(&req));
my_eval_client(&req));
/*
C++ sucks (the gibberish in front just translates the supplied

View File

@ -744,6 +744,12 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
{
KEY_PART_INFO *part,*part_end;
key_part_map key_part_to_use= 0;
/*
Perform a check if index is not disabled by ALTER TABLE
or IGNORE INDEX.
*/
if (!table->keys_in_use_for_query.is_set(idx))
continue;
uint jdx= 0;
*prefix_len= 0;
for (part= keyinfo->key_part, part_end= part+keyinfo->key_parts ;

View File

@ -1419,6 +1419,15 @@ int fetch_master_table(THD *thd, const char *db_name, const char *table_name,
if (connect_to_master(thd, mysql, mi))
{
my_error(ER_CONNECT_TO_MASTER, MYF(0), mysql_error(mysql));
/*
We need to clear the active VIO since, theoretically, somebody
might issue an awake() on this thread. If we are then in the
middle of closing and destroying the VIO inside the
mysql_close(), we will have a problem.
*/
#ifdef SIGNAL_WITH_VIO_CLOSE
thd->clear_active_vio();
#endif
mysql_close(mysql);
DBUG_RETURN(1);
}
@ -3507,6 +3516,17 @@ err:
VOID(pthread_mutex_unlock(&LOCK_thread_count));
if (mysql)
{
/*
Here we need to clear the active VIO before closing the
connection with the master. The reason is that THD::awake()
might be called from terminate_slave_thread() because somebody
issued a STOP SLAVE. If that happends, the close_active_vio()
can be called in the middle of closing the VIO associated with
the 'mysql' object, causing a crash.
*/
#ifdef SIGNAL_WITH_VIO_CLOSE
thd->clear_active_vio();
#endif
mysql_close(mysql);
mi->mysql=0;
}

View File

@ -1091,7 +1091,6 @@ sp_head::execute(THD *thd)
thd->net.no_send_error= 0;
if (i->free_list)
cleanup_items(i->free_list);
i->state= Query_arena::EXECUTED;
/*
If we've set thd->user_var_events_alloc to mem_root of this SP
@ -2252,6 +2251,9 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp,
m_lex->mark_as_requiring_prelocking(NULL);
}
thd->rollback_item_tree_changes();
/* Update the state of the active arena. */
thd->stmt_arena->state= Query_arena::EXECUTED;
/*
Unlike for PS we should not call Item's destructors for newly created

View File

@ -5471,7 +5471,7 @@ bool setup_tables_and_check_access(THD *thd,
for (; leaves_tmp; leaves_tmp= leaves_tmp->next_leaf)
{
if (leaves_tmp->belong_to_view &&
check_one_table_access(thd, want_access, leaves_tmp))
check_single_table_access(thd, want_access, leaves_tmp))
{
tables->hide_view_error(thd);
return TRUE;

View File

@ -1941,15 +1941,10 @@ bool select_dumpvar::send_data(List<Item> &items)
Item_func_set_user_var *xx;
Item_splocal *yy;
my_var *zz;
DBUG_ENTER("send_data");
if (unit->offset_limit_cnt)
{ // using limit offset,count
unit->offset_limit_cnt--;
DBUG_RETURN(0);
}
DBUG_ENTER("select_dumpvar::send_data");
if (unit->offset_limit_cnt)
{ // Using limit offset,count
{ // using limit offset,count
unit->offset_limit_cnt--;
DBUG_RETURN(0);
}

View File

@ -3381,15 +3381,6 @@ end_with_restore_list:
&lex->value_list,
lex->duplicates, lex->ignore)))
{
/*
Skip first table, which is the table we are inserting in.
Below we set context.table_list again because the call above to
mysql_insert_select_prepare() calls resolve_in_table_list_only(),
which in turn resets context.table_list and
context.first_name_resolution_table.
*/
select_lex->context.table_list=
select_lex->context.first_name_resolution_table= second_table;
res= handle_select(thd, lex, result, OPTION_SETUP_TABLES_DONE);
/*
Invalidate the table in the query cache if something changed
@ -5243,11 +5234,10 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
/*
Check grants for commands which work only with one table and all other
tables belonging to subselects or implicitly opened tables.
Check grants for commands which work only with one table.
SYNOPSIS
check_one_table_access()
check_single_table_access()
thd Thread handler
privilege requested privilege
all_tables global table list of query
@ -5257,7 +5247,8 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
1 - access denied, error is sent to client
*/
bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *all_tables)
bool check_single_table_access(THD *thd, ulong privilege,
TABLE_LIST *all_tables)
{
Security_context * backup_ctx= thd->security_ctx;
@ -5282,19 +5273,41 @@ bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *all_tables)
goto deny;
thd->security_ctx= backup_ctx;
return 0;
deny:
thd->security_ctx= backup_ctx;
return 1;
}
/*
Check grants for commands which work only with one table and all other
tables belonging to subselects or implicitly opened tables.
SYNOPSIS
check_one_table_access()
thd Thread handler
privilege requested privilege
all_tables global table list of query
RETURN
0 - OK
1 - access denied, error is sent to client
*/
bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *all_tables)
{
if (check_single_table_access (thd,privilege,all_tables))
return 1;
/* Check rights on tables of subselects and implictly opened tables */
TABLE_LIST *subselects_tables;
if ((subselects_tables= all_tables->next_global))
{
if ((check_table_access(thd, SELECT_ACL, subselects_tables, 0)))
goto deny;
return 1;
}
return 0;
deny:
thd->security_ctx= backup_ctx;
return 1;
}
@ -5463,8 +5476,26 @@ bool check_global_access(THD *thd, ulong want_access)
/*
Check the privilege for all used tables. Table privileges are cached
in the table list for GRANT checking
Check the privilege for all used tables.
SYNOPSYS
check_table_access()
thd Thread context
want_access Privileges requested
tables List of tables to be checked
no_errors FALSE/TRUE - report/don't report error to
the client (using my_error() call).
NOTES
Table privileges are cached in the table list for GRANT checking.
This functions assumes that table list used and
thd->lex->query_tables_own_last value correspond to each other
(the latter should be either 0 or point to next_global member
of one of elements of this table list).
RETURN VALUE
FALSE - OK
TRUE - Access denied
*/
bool
@ -7377,14 +7408,28 @@ bool multi_delete_precheck(THD *thd, TABLE_LIST *tables)
SELECT_LEX *select_lex= &thd->lex->select_lex;
TABLE_LIST *aux_tables=
(TABLE_LIST *)thd->lex->auxilliary_table_list.first;
TABLE_LIST **save_query_tables_own_last= thd->lex->query_tables_own_last;
DBUG_ENTER("multi_delete_precheck");
/* sql_yacc guarantees that tables and aux_tables are not zero */
DBUG_ASSERT(aux_tables != 0);
if (check_db_used(thd, tables) || check_db_used(thd,aux_tables) ||
check_table_access(thd,SELECT_ACL, tables,0) ||
check_table_access(thd,DELETE_ACL, aux_tables,0))
check_table_access(thd, SELECT_ACL, tables, 0))
DBUG_RETURN(TRUE);
/*
Since aux_tables list is not part of LEX::query_tables list we
have to juggle with LEX::query_tables_own_last value to be able
call check_table_access() safely.
*/
thd->lex->query_tables_own_last= 0;
if (check_table_access(thd, DELETE_ACL, aux_tables, 0))
{
thd->lex->query_tables_own_last= save_query_tables_own_last;
DBUG_RETURN(TRUE);
}
thd->lex->query_tables_own_last= save_query_tables_own_last;
if ((thd->options & OPTION_SAFE_UPDATES) && !select_lex->where)
{
my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE,

View File

@ -1071,8 +1071,9 @@ JOIN::optimize()
group_list ? 0 : select_distinct,
group_list && simple_group,
select_options,
(order == 0 || skip_sort_order) ? select_limit :
HA_POS_ERROR,
(order == 0 || skip_sort_order ||
test(select_options & OPTION_BUFFER_RESULT)) ?
select_limit : HA_POS_ERROR,
(char *) "")))
DBUG_RETURN(1);
@ -8894,6 +8895,11 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
keyinfo->key_length+= key_part_info->length;
}
}
else
{
set_if_smaller(table->s->max_rows, rows_limit);
param->end_write_records= rows_limit;
}
if (distinct && field_count != param->hidden_field_count)
{

View File

@ -1046,6 +1046,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
}
}
for (i=0 ; i < keyinfo->key_parts ; key_part++,i++)
{
Field *field;

View File

@ -24,12 +24,12 @@
void my_caseup_str_mb(CHARSET_INFO * cs, char *str)
{
register uint32 l;
register char *end=str+strlen(str); /* BAR TODO: remove strlen() call */
register uchar *map=cs->to_upper;
while (*str)
{
if ((l=my_ismbchar(cs, str,end)))
/* Pointing after the '\0' is safe here. */
if ((l=my_ismbchar(cs, str, str + cs->mbmaxlen)))
str+=l;
else
{
@ -42,12 +42,12 @@ void my_caseup_str_mb(CHARSET_INFO * cs, char *str)
void my_casedn_str_mb(CHARSET_INFO * cs, char *str)
{
register uint32 l;
register char *end=str+strlen(str);
register uchar *map=cs->to_lower;
while (*str)
{
if ((l=my_ismbchar(cs, str,end)))
/* Pointing after the '\0' is safe here. */
if ((l=my_ismbchar(cs, str, str + cs->mbmaxlen)))
str+=l;
else
{
@ -101,15 +101,18 @@ uint my_casedn_mb(CHARSET_INFO * cs, char *src, uint srclen,
return srclen;
}
/*
my_strcasecmp_mb() returns 0 if strings are equal, non-zero otherwise.
*/
int my_strcasecmp_mb(CHARSET_INFO * cs,const char *s, const char *t)
{
register uint32 l;
register const char *end=s+strlen(s);
register uchar *map=cs->to_upper;
while (s<end)
while (*s && *t)
{
if ((l=my_ismbchar(cs, s,end)))
/* Pointing after the '\0' is safe here. */
if ((l=my_ismbchar(cs, s, s + cs->mbmaxlen)))
{
while (l--)
if (*s++ != *t++)
@ -120,7 +123,8 @@ int my_strcasecmp_mb(CHARSET_INFO * cs,const char *s, const char *t)
else if (map[(uchar) *s++] != map[(uchar) *t++])
return 1;
}
return *t;
/* At least one of '*s' and '*t' is zero here. */
return (*t != *s);
}

View File

@ -148,6 +148,19 @@ They should be used with caution.
%{see_base}
%package bench
Requires: %{name}-client perl-DBI perl
Summary: MySQL - Benchmarks and test system
Group: Applications/Databases
Provides: mysql-bench
Obsoletes: mysql-bench
AutoReqProv: no
%description bench
This package contains MySQL benchmark scripts and data.
%{see_base}
%package devel
Summary: MySQL - Development header files and libraries
Group: Applications/Databases