Commit 06432eac authored by monty@mysql.com's avatar monty@mysql.com

Added --compact to mysqlbinlog

Fixed output from mysqlbinlog when using --skip-comments
Fixed warnings from valgrind
Fixed ref_length when used with HEAP tables
More efficent need_conversion()
Fixed error handling in UPDATE with not updateable tables
Fixed bug in null handling in CAST to signed/unsigned
parent 480b082c
......@@ -26,18 +26,21 @@
/* We have to define 'enum options' identical in all files to keep OS2 happy */
enum options_client { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET,
OPT_PAGER, OPT_NOPAGER, OPT_TEE, OPT_NOTEE,
OPT_LOW_PRIORITY, OPT_AUTO_REPAIR, OPT_COMPRESS,
OPT_DROP, OPT_LOCKS, OPT_KEYWORDS, OPT_DELAYED, OPT_OPTIMIZE,
OPT_FTB, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC, OPT_TABLES,
OPT_MASTER_DATA, OPT_AUTOCOMMIT, OPT_AUTO_REHASH,
OPT_LINE_NUMBERS, OPT_COLUMN_NAMES, OPT_CONNECT_TIMEOUT,
OPT_MAX_ALLOWED_PACKET, OPT_NET_BUFFER_LENGTH,
OPT_SELECT_LIMIT, OPT_MAX_JOIN_SIZE, OPT_SSL_SSL,
OPT_SSL_KEY, OPT_SSL_CERT, OPT_SSL_CA, OPT_SSL_CAPATH,
OPT_SSL_CIPHER, OPT_SHUTDOWN_TIMEOUT, OPT_LOCAL_INFILE,
OPT_DELETE_MASTER_LOGS,
OPT_PROMPT, OPT_IGN_LINES,OPT_TRANSACTION,OPT_MYSQL_PROTOCOL,
OPT_SHARED_MEMORY_BASE_NAME, OPT_FRM, OPT_SKIP_OPTIMIZATION,
OPT_COMPATIBLE, OPT_RECONNECT, OPT_DELIMITER, OPT_SECURE_AUTH };
enum options_client
{
OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET,
OPT_PAGER, OPT_NOPAGER, OPT_TEE, OPT_NOTEE,
OPT_LOW_PRIORITY, OPT_AUTO_REPAIR, OPT_COMPRESS,
OPT_DROP, OPT_LOCKS, OPT_KEYWORDS, OPT_DELAYED, OPT_OPTIMIZE,
OPT_FTB, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC, OPT_TABLES,
OPT_MASTER_DATA, OPT_AUTOCOMMIT, OPT_AUTO_REHASH,
OPT_LINE_NUMBERS, OPT_COLUMN_NAMES, OPT_CONNECT_TIMEOUT,
OPT_MAX_ALLOWED_PACKET, OPT_NET_BUFFER_LENGTH,
OPT_SELECT_LIMIT, OPT_MAX_JOIN_SIZE, OPT_SSL_SSL,
OPT_SSL_KEY, OPT_SSL_CERT, OPT_SSL_CA, OPT_SSL_CAPATH,
OPT_SSL_CIPHER, OPT_SHUTDOWN_TIMEOUT, OPT_LOCAL_INFILE,
OPT_DELETE_MASTER_LOGS, OPT_COMPACT,
OPT_PROMPT, OPT_IGN_LINES,OPT_TRANSACTION,OPT_MYSQL_PROTOCOL,
OPT_SHARED_MEMORY_BASE_NAME, OPT_FRM, OPT_SKIP_OPTIMIZATION,
OPT_COMPATIBLE, OPT_RECONNECT, OPT_DELIMITER, OPT_SECURE_AUTH,
};
......@@ -81,7 +81,7 @@ static my_bool verbose=0,tFlag=0,cFlag=0,dFlag=0,quick= 1, extended_insert= 1,
opt_alldbs=0,opt_create_db=0,opt_first_slave=0,opt_set_names=0,
opt_autocommit=0,opt_master_data,opt_disable_keys=1,opt_xml=0,
opt_delete_master_logs=0, tty_password=0,
opt_single_transaction=0, opt_comments= 0;
opt_single_transaction=0, opt_comments= 0, opt_compact= 0;
static MYSQL mysql_connection,*sock=0;
static char insert_pat[12 * 1024],*opt_password=0,*current_user=0,
*current_host=0,*path=0,*fields_terminated=0,
......@@ -140,6 +140,10 @@ static struct my_option my_long_options[] =
"Change the dump to be compatible with a given mode. By default tables are dumped without any restrictions. Legal modes are: ansi, mysql323, mysql40, postgresql, oracle, mssql, db2, maxdb, no_key_options, no_table_options, no_field_options. One can use several modes separated by commas. Note: Requires MySQL server version 4.1.0 or higher. This option does a no operation on earlier server versions.",
(gptr*) &opt_compatible_mode_str, (gptr*) &opt_compatible_mode_str, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"compact", OPT_COMPACT,
"Give less verbose output (useful for debugging). Disables structure comments and header/footer constructs. Enables options --skip-add-drop-table --no-set-names --skip-disable-keys --skip-lock-tables",
(gptr*) &opt_compact, (gptr*) &opt_compact, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0},
{"complete-insert", 'c', "Use complete insert statements.", (gptr*) &cFlag,
(gptr*) &cFlag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"compress", 'C', "Use compression in server/client protocol.",
......@@ -347,15 +351,19 @@ static void write_header(FILE *sql_file, char *db_name)
fputs("<?xml version=\"1.0\"?>\n", sql_file);
fputs("<mysqldump>\n", sql_file);
}
else if (opt_comments)
else if (!opt_compact)
{
fprintf(sql_file, "-- MySQL dump %s\n--\n", DUMP_VERSION);
fprintf(sql_file, "-- Host: %s Database: %s\n",
current_host ? current_host : "localhost", db_name ? db_name : "");
fputs("-- ------------------------------------------------------\n",
sql_file);
fprintf(sql_file, "-- Server version\t%s\n",
mysql_get_server_info(&mysql_connection));
if (opt_comments)
{
fprintf(sql_file, "-- MySQL dump %s\n--\n", DUMP_VERSION);
fprintf(sql_file, "-- Host: %s Database: %s\n",
current_host ? current_host : "localhost", db_name ? db_name :
"");
fputs("-- ------------------------------------------------------\n",
sql_file);
fprintf(sql_file, "-- Server version\t%s\n",
mysql_get_server_info(&mysql_connection));
}
if (!opt_set_names)
fprintf(sql_file,"\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT, CHARACTER_SET_CLIENT=%s */;\n",default_charset);
fprintf(md_result_file,"\
......@@ -371,17 +379,18 @@ static void write_header(FILE *sql_file, char *db_name)
static void write_footer(FILE *sql_file)
{
if (opt_xml)
fputs("</mysqldump>", sql_file);
else
fputs("</mysqldump>\n", sql_file);
else if (!opt_compact)
{
fprintf(md_result_file,"\n\
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;\n\
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;\n\
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;\n\
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n\
");
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;\n");
if (!opt_set_names)
fprintf(md_result_file,
"/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n");
fputs("\n", sql_file);
}
fputs("\n", sql_file);
} /* write_footer */
......@@ -448,6 +457,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
extended_insert= opt_drop= opt_lock= quick= create_options=
opt_disable_keys= lock_tables= 0;
break;
case (int) OPT_COMPACT:
if (opt_compact)
{
opt_comments= opt_drop= opt_disable_keys= opt_lock= 0;
opt_set_names= 1;
}
case (int) OPT_TABLES:
opt_databases=0;
break;
......@@ -1270,7 +1285,7 @@ static void dumpTable(uint numFields, char *table)
fprintf(md_result_file,"-- WHERE: %s\n",where);
strxmov(strend(query), " WHERE ",where,NullS);
}
if (!opt_xml)
if (!opt_xml && !opt_compact)
fputs("\n", md_result_file);
if (mysql_query(sock, query))
{
......
......@@ -24,6 +24,12 @@ Note 1003 select high_priority ~(5) AS `~5`,cast(~(5) as signed) AS `cast(~5 as
select cast(5 as unsigned) -6.0;
cast(5 as unsigned) -6.0
-1.0
select cast(NULL as signed), cast(1/0 as signed);
cast(NULL as signed) cast(1/0 as signed)
NULL NULL
select cast(NULL as unsigned), cast(1/0 as unsigned);
cast(NULL as unsigned) cast(1/0 as unsigned)
NULL NULL
select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A";
cast("A" as binary) = "a" cast(BINARY "a" as CHAR) = "A"
0 1
......@@ -36,6 +42,21 @@ cast("1:2:3" as TIME)
select CONVERT("2004-01-22 21:45:33",DATE);
CONVERT("2004-01-22 21:45:33",DATE)
2004-01-22
select CONVERT(DATE "2004-01-22 21:45:33" USING latin1);
CONVERT(DATE "2004-01-22 21:45:33" USING latin1)
2004-01-22 21:45:33
select CONVERT(DATE "2004-01-22 21:45:33",CHAR);
CONVERT(DATE "2004-01-22 21:45:33",CHAR)
2004-01-22 21:45:33
select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4));
CONVERT(DATE "2004-01-22 21:45:33",CHAR(4))
2004
select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4) BINARY);
CONVERT(DATE "2004-01-22 21:45:33",CHAR(4) BINARY)
2004
select CAST(DATE "2004-01-22 21:45:33" AS CHAR(4) BINARY);
CAST(DATE "2004-01-22 21:45:33" AS CHAR(4) BINARY)
2004
set names binary;
select cast(_latin1'test' as char character set latin2);
cast(_latin1'test' as char character set latin2)
......@@ -43,6 +64,12 @@ test
select cast(_koi8r'' as char character set cp1251);
cast(_koi8r'' as char character set cp1251)
select convert(_latin1'test', "latin1_german1_ci", "latin1_swedish_ci");
convert(_latin1'test', "latin1_german1_ci", "latin1_swedish_ci")
test
select convert(_koi8r'', "koi8r_general_ci", "cp1251_general_ci");
convert(_koi8r'', "koi8r_general_ci", "cp1251_general_ci")
create table t1 select cast(_koi8r'' as char character set cp1251) as t;
show create table t1;
Table Create Table
......
......@@ -252,9 +252,7 @@ drop table t1;
CREATE TABLE `t1` (
`N` int(11) unsigned NOT NULL default '0',
`M` tinyint(1) default '0',
) TYPE=MyISAM DEFAULT CHARSET=latin1;
Warnings:
Warning 1286 'TYPE=storage_engine' is deprecated. Use 'ENGINE=storage_engine' instead.
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `t1` (N, M) VALUES (1, 0),(1, 0),(1, 0),(2, 0),(2, 0),(3, 0);
UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2;
select * from t1;
......@@ -279,9 +277,7 @@ OBJECTID int(11) NOT NULL default '0',
SORTORDER int(11) NOT NULL auto_increment,
KEY t1_SortIndex (SORTORDER),
KEY t1_IdIndex (OBJECTID)
) TYPE=MyISAM DEFAULT CHARSET=latin1;
Warnings:
Warning 1286 'TYPE=storage_engine' is deprecated. Use 'ENGINE=storage_engine' instead.
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE t2 (
ID int(11) default NULL,
PARID int(11) default NULL,
......
......@@ -21,6 +21,11 @@ DROP TABLE t1;
CREATE TABLE t1 (a decimal(240, 20));
INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"),
("0987654321098765432109876543210987654321");
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT, CHARACTER_SET_CLIENT=utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=NO_AUTO_VALUE_ON_ZERO */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` decimal(240,20) default NULL
......@@ -41,6 +46,11 @@ UNLOCK TABLES;
DROP TABLE t1;
CREATE TABLE t1 (a double);
INSERT INTO t1 VALUES (-9e999999);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT, CHARACTER_SET_CLIENT=utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=NO_AUTO_VALUE_ON_ZERO */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` double default NULL
......@@ -105,6 +115,11 @@ INSERT INTO t1 VALUES ("1\""), ("\"2");
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET koi8r;
INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5');
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT, CHARACTER_SET_CLIENT=utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=NO_AUTO_VALUE_ON_ZERO */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` varchar(255) default NULL
......@@ -125,6 +140,9 @@ UNLOCK TABLES;
DROP TABLE t1;
CREATE TABLE t1 (a int) ENGINE=MYISAM;
INSERT INTO t1 VALUES (1), (2);
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=NO_AUTO_VALUE_ON_ZERO */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` int(11) default NULL
......@@ -140,8 +158,10 @@ UNLOCK TABLES;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=NO_AUTO_VALUE_ON_ZERO */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` int(11) default NULL
......@@ -157,6 +177,5 @@ UNLOCK TABLES;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
DROP TABLE t1;
......@@ -696,17 +696,22 @@ word
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
load data infile '../../std_data/words.dat' into table t1;
load data infile 'TEST_DIR/std_data/words.dat' into table t1;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
select count(*) from t1;
count(*)
70
drop table t1;
create table t1 (a int);
insert into t1 values (1),(2),(3);
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
select * from t1 into outfile "query_caceh.out.file";
select * from t1 into outfile "query_cache.out.file";
select * from t1 into outfile "query_cache.out.file";
ERROR HY000: File 'query_cache.out.file' already exists
select * from t1 limit 1 into dumpfile "query_cache.dump.file";
show status like "Qcache_queries_in_cache";
Variable_name Value
......
......@@ -55,7 +55,7 @@ stop slave;
start slave until master_log_file='master-bin.000001', master_log_pos=561;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes No 0 0 561 # Master master-bin.000001 561 No #
# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 # master-bin.000001 Yes # 0 0 561 # Master master-bin.000001 561 No #
start slave until master_log_file='master-bin', master_log_pos=561;
ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL
start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12;
......
......@@ -70,7 +70,7 @@ t1 CREATE TABLE `t1` (
`email` varchar(60) NOT NULL default '',
PRIMARY KEY (`a`),
UNIQUE KEY `email` (`email`)
) ENGINE=HEAP ROW_FORMAT=DYNAMIC
) TYPE=HEAP ROW_FORMAT=DYNAMIC
set sql_mode="postgresql,oracle,mssql,db2,maxdb";
select @@sql_mode;
@@sql_mode
......
......@@ -1578,50 +1578,28 @@ select * from t1;
a b
1 0.123
drop table t1;
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
ts timestamp NOT NULL,
id_cns tinyint(3) unsigned NOT NULL default '0',
id_desc_nota int(11) NOT NULL default '1',
id_publ_uff int(11) NOT NULL default '0',
tipo enum('','UNO','DUE') NOT NULL default '',
f_aggiunte set('TRE','TRETRE','QUATTRO','CINQUE','SEI','SETTE') NOT NULL
default '',
anno_dep smallint(4) unsigned zerofill NOT NULL default '0000',
data_dep smallint(4) unsigned zerofill NOT NULL default '0000',
particolare mediumint(8) unsigned NOT NULL default '0',
generale mediumint(8) unsigned NOT NULL default '0',
bis tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY(id),
UNIQUE KEY idx_cns_gen_anno (anno_dep,id_cns,generale,particolare),
UNIQUE KEY idx_cns_par_anno (id_cns,anno_dep,tipo,particolare,bis)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=1;
INSERT INTO t1 (id, ts, id_cns, id_desc_nota, id_publ_uff, tipo, f_aggiunte,
anno_dep, data_dep, particolare, generale, bis) VALUES
(NULL, NULL, 16, 29, 622, 'UNO', '', 1987, 1218, 2048, 9681, 0),
(NULL, NULL, 50, 23, 1717, 'UNO', '', 1987, 1126, 1536, 13987, 0),
(NULL, NULL, 16, 123, 123, 'UNO', '', 1987, 1221, 2432, 14594, 0),
(NULL, NULL, 16, 124, 124, 'UNO', '', 1987, 1201, 1792, 13422, 0),
(NULL, NULL, 16, 125, 125, 'UNO', '', 1987, 0723, 1025, 10240, 0),
(NULL, NULL, 16, 126, 126, 'UNO', '', 1987, 1204, 1026, 7089, 0);
CREATE TABLE t2 (
id tinyint(3) unsigned NOT NULL auto_increment,
descr varchar(40) NOT NULL default '',
f_servizi set('UNO','DUE') NOT NULL default '',
data_uno_min int(8) unsigned NOT NULL default '0',
data_due_min int(8) unsigned NOT NULL default '0',
max_anno_dep smallint(6) unsigned NOT NULL default '0',
data_agg int(8) unsigned NOT NULL default '0',
PRIMARY KEY (id)
CREATE TABLE `t1` (
`id` int(11) NOT NULL auto_increment,
`id_cns` tinyint(3) unsigned NOT NULL default '0',
`tipo` enum('','UNO','DUE') NOT NULL default '',
`anno_dep` smallint(4) unsigned zerofill NOT NULL default '0000',
`particolare` mediumint(8) unsigned NOT NULL default '0',
`generale` mediumint(8) unsigned NOT NULL default '0',
`bis` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_cns_gen_anno` (`anno_dep`,`id_cns`,`generale`,`particolare`),
UNIQUE KEY `idx_cns_par_anno` (`id_cns`,`anno_dep`,`tipo`,`particolare`,`bis`)
);
INSERT INTO t2 (id, descr, f_servizi, data_uno_min, data_due_min,
max_anno_dep, data_agg) VALUES
(16, 'C_UNO', 'UNO,DUE', 19000000, 30000000, 1987, 0),
(50, 'C_TRE', 'UNO', 19000000, 30000000, 1990, 0);
SELECT cns.max_anno_dep = (SELECT s.anno_dep FROM t1 AS s WHERE
s.id_cns = cns.id ORDER BY s.anno_dep DESC LIMIT 1) AS PIPPO FROM
t2 AS cns;
PIPPO
1
NULL
INSERT INTO `t1` VALUES (1,16,'UNO',1987,2048,9681,0),(2,50,'UNO',1987,1536,13987,0),(3,16,'UNO',1987,2432,14594,0),(4,16,'UNO',1987,1792,13422,0),(5,16,'UNO',1987,1025,10240,0),(6,16,'UNO',1987,1026,7089,0);
CREATE TABLE `t2` (
`id` tinyint(3) unsigned NOT NULL auto_increment,
`max_anno_dep` smallint(6) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
);
INSERT INTO `t2` VALUES (16,1987),(50,1990),(51,1990);
SELECT cns.id, cns.max_anno_dep, cns.max_anno_dep = (SELECT s.anno_dep FROM t1 AS s WHERE s.id_cns = cns.id ORDER BY s.anno_dep DESC LIMIT 1) AS PIPPO FROM t2 AS cns;
id max_anno_dep PIPPO
16 1987 1
50 1990 0
51 1990 NULL
DROP TABLE t1, t2;
......@@ -10,10 +10,17 @@ select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
select ~5, cast(~5 as signed);
explain extended select ~5, cast(~5 as signed);
select cast(5 as unsigned) -6.0;
select cast(NULL as signed), cast(1/0 as signed);
select cast(NULL as unsigned), cast(1/0 as unsigned);
select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A";
select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
select cast("1:2:3" as TIME);
select CONVERT("2004-01-22 21:45:33",DATE);
select CONVERT(DATE "2004-01-22 21:45:33" USING latin1);
select CONVERT(DATE "2004-01-22 21:45:33",CHAR);
select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4));
select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4) BINARY);
select CAST(DATE "2004-01-22 21:45:33" AS CHAR(4) BINARY);
#
# Character set convertion
......@@ -21,6 +28,8 @@ select CONVERT("2004-01-22 21:45:33",DATE);
set names binary;
select cast(_latin1'test' as char character set latin2);
select cast(_koi8r'' as char character set cp1251);
select convert(_latin1'test', "latin1_german1_ci", "latin1_swedish_ci");
select convert(_koi8r'', "koi8r_general_ci", "cp1251_general_ci");
create table t1 select cast(_koi8r'' as char character set cp1251) as t;
show create table t1;
drop table t1;
......
......@@ -147,7 +147,7 @@ drop table t1;
CREATE TABLE `t1` (
`N` int(11) unsigned NOT NULL default '0',
`M` tinyint(1) default '0',
) TYPE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `t1` (N, M) VALUES (1, 0),(1, 0),(1, 0),(2, 0),(2, 0),(3, 0);
UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2;
select * from t1;
......@@ -167,7 +167,7 @@ CREATE TABLE t1 (
SORTORDER int(11) NOT NULL auto_increment,
KEY t1_SortIndex (SORTORDER),
KEY t1_IdIndex (OBJECTID)
) TYPE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE t2 (
ID int(11) default NULL,
PARID int(11) default NULL,
......
......@@ -466,8 +466,10 @@ select * from t1 where id=2;
create table t1 (word char(20) not null);
select * from t1;
show status like "Qcache_queries_in_cache";
load data infile '../../std_data/words.dat' into table t1;
--replace_result $MYSQL_TEST_DIR TEST_DIR
eval load data infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1;
show status like "Qcache_queries_in_cache";
select count(*) from t1;
drop table t1;
#
......@@ -476,7 +478,9 @@ drop table t1;
create table t1 (a int);
insert into t1 values (1),(2),(3);
show status like "Qcache_queries_in_cache";
select * from t1 into outfile "query_caceh.out.file";
select * from t1 into outfile "query_cache.out.file";
--error 1086
select * from t1 into outfile "query_cache.out.file";
select * from t1 limit 1 into dumpfile "query_cache.dump.file";
show status like "Qcache_queries_in_cache";
drop table t1;
......
......@@ -59,10 +59,11 @@ stop slave;
# this should stop immideately
start slave until master_log_file='master-bin.000001', master_log_pos=561;
--real-sleep 2;
# 2 is not enough when running with valgrind
--real-sleep 4;
# here the sql slave thread should be stopped
--replace_result $MASTER_MYPORT MASTER_MYPORT bin.000005 bin.000004 bin.000006 bin.000004 bin.000007 bin.000004
--replace_column 1 # 9 # 23 # 33 #
--replace_column 1 # 9 # 12 # 23 # 33 #
show slave status;
#testing various error conditions
......
......@@ -1026,52 +1026,26 @@ drop table t1;
# Bug 2479
#
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
ts timestamp NOT NULL,
id_cns tinyint(3) unsigned NOT NULL default '0',
id_desc_nota int(11) NOT NULL default '1',
id_publ_uff int(11) NOT NULL default '0',
tipo enum('','UNO','DUE') NOT NULL default '',
f_aggiunte set('TRE','TRETRE','QUATTRO','CINQUE','SEI','SETTE') NOT NULL
default '',
anno_dep smallint(4) unsigned zerofill NOT NULL default '0000',
data_dep smallint(4) unsigned zerofill NOT NULL default '0000',
particolare mediumint(8) unsigned NOT NULL default '0',
generale mediumint(8) unsigned NOT NULL default '0',
bis tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY(id),
UNIQUE KEY idx_cns_gen_anno (anno_dep,id_cns,generale,particolare),
UNIQUE KEY idx_cns_par_anno (id_cns,anno_dep,tipo,particolare,bis)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=1;
INSERT INTO t1 (id, ts, id_cns, id_desc_nota, id_publ_uff, tipo, f_aggiunte,
anno_dep, data_dep, particolare, generale, bis) VALUES
(NULL, NULL, 16, 29, 622, 'UNO', '', 1987, 1218, 2048, 9681, 0),
(NULL, NULL, 50, 23, 1717, 'UNO', '', 1987, 1126, 1536, 13987, 0),
(NULL, NULL, 16, 123, 123, 'UNO', '', 1987, 1221, 2432, 14594, 0),
(NULL, NULL, 16, 124, 124, 'UNO', '', 1987, 1201, 1792, 13422, 0),
(NULL, NULL, 16, 125, 125, 'UNO', '', 1987, 0723, 1025, 10240, 0),
(NULL, NULL, 16, 126, 126, 'UNO', '', 1987, 1204, 1026, 7089, 0);
CREATE TABLE t2 (
id tinyint(3) unsigned NOT NULL auto_increment,
descr varchar(40) NOT NULL default '',
f_servizi set('UNO','DUE') NOT NULL default '',
data_uno_min int(8) unsigned NOT NULL default '0',
data_due_min int(8) unsigned NOT NULL default '0',
max_anno_dep smallint(6) unsigned NOT NULL default '0',
data_agg int(8) unsigned NOT NULL default '0',
PRIMARY KEY (id)
CREATE TABLE `t1` (
`id` int(11) NOT NULL auto_increment,
`id_cns` tinyint(3) unsigned NOT NULL default '0',
`tipo` enum('','UNO','DUE') NOT NULL default '',
`anno_dep` smallint(4) unsigned zerofill NOT NULL default '0000',
`particolare` mediumint(8) unsigned NOT NULL default '0',
`generale` mediumint(8) unsigned NOT NULL default '0',
`bis` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_cns_gen_anno` (`anno_dep`,`id_cns`,`generale`,`particolare`),
UNIQUE KEY `idx_cns_par_anno` (`id_cns`,`anno_dep`,`tipo`,`particolare`,`bis`)
);
INSERT INTO `t1` VALUES (1,16,'UNO',1987,2048,9681,0),(2,50,'UNO',1987,1536,13987,0),(3,16,'UNO',1987,2432,14594,0),(4,16,'UNO',1987,1792,13422,0),(5,16,'UNO',1987,1025,10240,0),(6,16,'UNO',1987,1026,7089,0);
CREATE TABLE `t2` (
`id` tinyint(3) unsigned NOT NULL auto_increment,
`max_anno_dep` smallint(6) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
);
INSERT INTO `t2` VALUES (16,1987),(50,1990),(51,1990);
INSERT INTO t2 (id, descr, f_servizi, data_uno_min, data_due_min,
max_anno_dep, data_agg) VALUES
(16, 'C_UNO', 'UNO,DUE', 19000000, 30000000, 1987, 0),
(50, 'C_TRE', 'UNO', 19000000, 30000000, 1990, 0);
SELECT cns.max_anno_dep = (SELECT s.anno_dep FROM t1 AS s WHERE
s.id_cns = cns.id ORDER BY s.anno_dep DESC LIMIT 1) AS PIPPO FROM
t2 AS cns;
SELECT cns.id, cns.max_anno_dep, cns.max_anno_dep = (SELECT s.anno_dep FROM t1 AS s WHERE s.id_cns = cns.id ORDER BY s.anno_dep DESC LIMIT 1) AS PIPPO FROM t2 AS cns;
DROP TABLE t1, t2;
......@@ -4058,10 +4058,12 @@ void Field_datetime::sql_type(String &res) const
int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
{
int error= 0;
uint32 not_used;
char buff[80];
String tmpstr(buff,sizeof(buff), &my_charset_bin);
/* Convert character set if nesessary */
if (String::needs_conversion(from, length, cs, field_charset))
if (String::needs_conversion(length, cs, field_charset, &not_used))
{
tmpstr.copy(from, length, cs, field_charset);
from= tmpstr.ptr();
......@@ -4246,10 +4248,12 @@ uint Field_string::max_packed_col_length(uint max_length)
int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
{
int error= 0;
uint32 not_used;
char buff[80];
String tmpstr(buff,sizeof(buff), &my_charset_bin);
/* Convert character set if nesessary */
if (String::needs_conversion(from, length, cs, field_charset))
if (String::needs_conversion(length, cs, field_charset, &not_used))
{
tmpstr.copy(from, length, cs, field_charset);
from= tmpstr.ptr();
......@@ -4565,10 +4569,11 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
bool was_conversion;
char buff[80];
String tmpstr(buff,sizeof(buff), &my_charset_bin);
uint32 not_used;
/* Convert character set if nesessary */
if ((was_conversion= String::needs_conversion(from, length,
cs, field_charset)))
if ((was_conversion= String::needs_conversion(length, cs, field_charset,
&not_used)))
{
tmpstr.copy(from, length, cs, field_charset);
from= tmpstr.ptr();
......@@ -5079,10 +5084,12 @@ void Field_enum::store_type(ulonglong value)
int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs)
{
int err= 0;
uint32 not_used;
char buff[80];
String tmpstr(buff,sizeof(buff), &my_charset_bin);
/* Convert character set if nesessary */
if (String::needs_conversion(from, length, cs, field_charset))
if (String::needs_conversion(length, cs, field_charset, &not_used))
{
tmpstr.copy(from, length, cs, field_charset);
from= tmpstr.ptr();
......@@ -5259,11 +5266,12 @@ int Field_set::store(const char *from,uint length,CHARSET_INFO *cs)
int err= 0;
char *not_used;
uint not_used2;
uint32 not_used_offset;
char buff[80];
String tmpstr(buff,sizeof(buff), &my_charset_bin);
/* Convert character set if nesessary */
if (String::needs_conversion(from, length, cs, field_charset))
if (String::needs_conversion(length, cs, field_charset, &not_used_offset))
{
tmpstr.copy(from, length, cs, field_charset);
from= tmpstr.ptr();
......
......@@ -40,6 +40,7 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked)
if (!create(name, table, &create_info))
file= heap_open(name, mode);
}
ref_length= sizeof(HEAP_PTR);
return (file ? 0 : 1);
}
......@@ -335,7 +336,6 @@ int ha_heap::create(const char *name, TABLE *table_arg,
my_free((gptr) keydef, MYF(0));
if (file)
info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE);
ref_length= sizeof(HEAP_PTR);
return (error);
}
......
......@@ -1068,9 +1068,8 @@ String *Item_func_min_max::val_str(String *str)
}
}
}
if (!res) // If NULL
return 0;
res->set_charset(collation.collation);
if (res) // If !NULL
res->set_charset(collation.collation);
return res;
}
case ROW_RESULT:
......
......@@ -211,20 +211,28 @@ class Item_func_signed :public Item_int_func
{
public:
Item_func_signed(Item *a) :Item_int_func(a) {}
double val() { null_value=args[0]->null_value; return args[0]->val(); }
longlong val_int() { null_value=args[0]->null_value; return args[0]->val_int(); }
double val()
{
double tmp= args[0]->val();
null_value= args[0]->null_value;
return tmp;
}
longlong val_int()
{
longlong tmp= args[0]->val_int();
null_value= args[0]->null_value;
return tmp;
}
void fix_length_and_dec()
{ max_length=args[0]->max_length; unsigned_flag=0; }
void print(String *str);
};
class Item_func_unsigned :public Item_int_func
class Item_func_unsigned :public Item_func_signed
{
public:
Item_func_unsigned(Item *a) :Item_int_func(a) {}
double val() { null_value=args[0]->null_value; return args[0]->val(); }
longlong val_int() { null_value=args[0]->null_value; return args[0]->val_int(); }
Item_func_unsigned(Item *a) :Item_func_signed(a) {}
void fix_length_and_dec()
{ max_length=args[0]->max_length; unsigned_flag=1; }
void print(String *str);
......
......@@ -2126,14 +2126,12 @@ void Item_func_conv_charset::print(String *str)
String *Item_func_conv_charset3::val_str(String *str)
{
my_wc_t wc;
int cnvres;
const uchar *s, *se;
uchar *d, *d0, *de;
uint32 dmaxlen;
char cs1[30], cs2[30];
String to_cs_buff(cs1, sizeof(cs1), default_charset_info);
String from_cs_buff(cs2, sizeof(cs2), default_charset_info);
String *arg= args[0]->val_str(str);
String *to_cs= args[1]->val_str(str);
String *from_cs= args[2]->val_str(str);
String *to_cs= args[1]->val_str(&to_cs_buff);
String *from_cs= args[2]->val_str(&from_cs_buff);
CHARSET_INFO *from_charset;
CHARSET_INFO *to_charset;
......@@ -2143,51 +2141,17 @@ String *Item_func_conv_charset3::val_str(String *str)
!(from_charset=get_charset_by_name(from_cs->ptr(), MYF(MY_WME))) ||
!(to_charset=get_charset_by_name(to_cs->ptr(), MYF(MY_WME))))
{
null_value=1;
null_value= 1;
return 0;
}
s=(const uchar*)arg->ptr();
se=s+arg->length();
dmaxlen=arg->length()*to_charset->mbmaxlen+1;
str->alloc(dmaxlen);
d0=d=(unsigned char*)str->ptr();
de=d+dmaxlen;
while (1)
if (str_value.copy(arg->ptr(), arg->length(), from_charset, to_charset))
{
cnvres=from_charset->cset->mb_wc(from_charset,&wc,s,se);
if (cnvres>0)
{
s+=cnvres;
}
else if (cnvres==MY_CS_ILSEQ)
{
s++;
wc='?';
}
else
break;
outp:
cnvres=to_charset->cset->wc_mb(to_charset,wc,d,de);
if (cnvres>0)
{
d+=cnvres;
}
else if (cnvres==MY_CS_ILUNI && wc!='?')
{
wc='?';
goto outp;
}
else
break;
};
str->length((uint32) (d-d0));
str->set_charset(to_charset);
return str;
null_value= 1;
return 0;
}
null_value= 0;
return &str_value;
}
......
......@@ -1092,15 +1092,21 @@ void Item_sum_count_distinct::cleanup()
if (!original)
{
if (table)
{
free_tmp_table(current_thd, table);
table= 0;
}
delete tmp_table_param;
tmp_table_param= 0;
if (use_tree)
{
delete_tree(tree);
table= 0;
use_tree= 0;
use_tree= 0;
}
}
}
bool Item_sum_count_distinct::fix_fields(THD *thd, TABLE_LIST *tables,
Item **ref)
{
......@@ -1674,13 +1680,21 @@ void Item_func_group_concat::cleanup()
{
THD *thd= current_thd;
if (table)
{
free_tmp_table(thd, table);
table= 0;
}
delete tmp_table_param;
tmp_table_param= 0;
if (tree_mode)
{
tree_mode= 0;
delete_tree(tree);
}
}
}
Item_func_group_concat::~Item_func_group_concat()
{
/*
......
......@@ -397,12 +397,13 @@ class Item_sum_hybrid :public Item_sum
public:
Item_sum_hybrid(Item *item_par,int sign)
:Item_sum(item_par), hybrid_type(INT_RESULT), cmp_sign(sign),
used_table_cache(~(table_map) 0),
:Item_sum(item_par), sum(0.0), sum_int(0),
hybrid_type(INT_RESULT), hybrid_field_type(FIELD_TYPE_LONGLONG),
cmp_sign(sign), used_table_cache(~(table_map) 0),
cmp_charset(&my_charset_bin)
{}
Item_sum_hybrid(THD *thd, Item_sum_hybrid *item):
Item_sum(thd, item), value(item->value), tmp_value(item->tmp_value),
Item_sum(thd, item), value(item->value),
sum(item->sum), sum_int(item->sum_int), hybrid_type(item->hybrid_type),
hybrid_field_type(item->hybrid_field_type),cmp_sign(item->cmp_sign),
used_table_cache(item->used_table_cache), cmp_charset(item->cmp_charset) {}
......
......@@ -1005,7 +1005,7 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
}
/*
We can't use an index when comparing stings of
We can't use an index when comparing strings of
different collations
*/
if (field->result_type() == STRING_RESULT &&
......
......@@ -744,7 +744,7 @@ static File create_file(THD *thd, char *path, sql_exchange *exchange,
if (!access(path, F_OK))
{
my_error(ER_FILE_EXISTS_ERROR, MYF(0), exchange->file_name);
return 1;
return -1;
}
/* Create the file world readable */
if ((file= my_create(path, 0666, O_WRONLY, MYF(MY_WME))) < 0)
......
......@@ -993,10 +993,6 @@ class select_export :public select_to_file {
class select_dump :public select_to_file {
sql_exchange *exchange;
File file;
IO_CACHE cache;
ha_rows row_count;
public:
select_dump(sql_exchange *ex) :select_to_file(ex) {}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
......
......@@ -1005,8 +1005,10 @@ void mysql_stmt_execute(THD *thd, char *packet)
sl->where= sl->prep_where->copy_andor_structure(thd);
DBUG_ASSERT(sl->join == 0);
ORDER *order;
/* Fix GROUP list */
for (order=(ORDER *)sl->group_list.first ; order ; order=order->next)
order->item= (Item **)(order+1);
/* Fix ORDER list */
for (order=(ORDER *)sl->order_list.first ; order ; order=order->next)
order->item= (Item **)(order+1);
}
......
......@@ -519,8 +519,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
protocol->store_null();
// Send error to Comment field
protocol->store(thd->net.last_error, system_charset_info);
thd->net.last_error[0]=0;
thd->net.last_errno= 0;
thd->clear_error();
}
else
{
......
......@@ -230,68 +230,86 @@ bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs)
/*
Checks that the source string can be just copied
to the destination string without conversion.
If either character set conversion or adding leading
zeros (e.g. for UCS-2) must be done then return
value is TRUE else FALSE.
Checks that the source string can be just copied to the destination string
without conversion.
SYNPOSIS
needs_conversion()
arg_length Length of string to copy.
from_cs Character set to copy from
to_cs Character set to copy to
uint32 *offset Returns number of unaligned characters.
RETURN
0 No conversion needed
1 Either character set conversion or adding leading zeros
(e.g. for UCS-2) must be done
*/
bool String::needs_conversion(const char *str, uint32 arg_length,
CHARSET_INFO *from_cs,
CHARSET_INFO *to_cs)
bool String::needs_conversion(uint32 arg_length,
CHARSET_INFO *from_cs,
CHARSET_INFO *to_cs,
uint32 *offset)
{
*offset= 0;
if ((to_cs == &my_charset_bin) ||
(to_cs == from_cs) ||
my_charset_same(from_cs, to_cs) ||
((from_cs == &my_charset_bin) && (!(arg_length % to_cs->mbminlen))))
((from_cs == &my_charset_bin) &&
(!(*offset=(arg_length % to_cs->mbminlen)))))
return FALSE;
return TRUE;
}
/*
** For real multi-byte, ascii incompatible charactser sets,
** like UCS-2, add leading zeros if we have an incomplete character.
** Thus,
** SELECT _ucs2 0xAA
** will automatically be converted into
** SELECT _ucs2 0x00AA
Copy a multi-byte character sets with adding leading zeros.
SYNOPSIS
copy_aligned()
str String to copy
arg_length Length of string. This should NOT be dividable with
cs->mbminlen.
offset arg_length % cs->mb_minlength
cs Character set for 'str'
NOTES
For real multi-byte, ascii incompatible charactser sets,
like UCS-2, add leading zeros if we have an incomplete character.
Thus,
SELECT _ucs2 0xAA
will automatically be converted into
SELECT _ucs2 0x00AA
RETURN
0 ok
1 error
*/
bool String::copy_aligned(const char *str,uint32 arg_length,
bool String::copy_aligned(const char *str,uint32 arg_length, uint32 offset,
CHARSET_INFO *cs)
{
/* How many bytes are in incomplete character */
uint32 offs= (arg_length % cs->mbminlen);
offset= cs->mbmaxlen - offset; /* How many zeros we should prepend */
DBUG_ASSERT(offset && offset != cs->mbmaxlen);
if (!offs) /* All characters are complete, just copy */
{
copy(str, arg_length, cs);
return FALSE;
}
offs= cs->mbmaxlen - offs; /* How many zeros we should prepend */
uint32 aligned_length= arg_length + offs;
uint32 aligned_length= arg_length + offset;
if (alloc(aligned_length))
return TRUE;
/*
Probably this condition is not really necessary
because if aligned_length is 0 then offs is 0 too
and we'll return after calling set().
Note, this is only safe for little-endian UCS-2.
If we add big-endian UCS-2 sometimes, this code
will be more complicated. But it's OK for now.
*/
if ((str_length= aligned_length))
{
/*
Note, this is only safe for little-endian UCS-2.
If we add big-endian UCS-2 sometimes, this code
will be more complicated. But it's OK for now.
*/
bzero((char*)Ptr, offs);
memcpy(Ptr + offs, str, arg_length);
}
bzero((char*) Ptr, offset);
memcpy(Ptr + offset, str, arg_length);
Ptr[aligned_length]=0;
str_charset=cs;
/* str_length is always >= 0 as arg_length is != 0 */
str_length= aligned_length;
str_charset= cs;
return FALSE;
}
......@@ -300,14 +318,14 @@ bool String::set_or_copy_aligned(const char *str,uint32 arg_length,
CHARSET_INFO *cs)
{
/* How many bytes are in incomplete character */
uint32 offs= (arg_length % cs->mbminlen);
uint32 offset= (arg_length % cs->mbminlen);
if (!offs) /* All characters are complete, just copy */
if (!offset) /* All characters are complete, just copy */
{
set(str, arg_length, cs);
return FALSE;
}
return copy_aligned(str, arg_length, cs);
return copy_aligned(str, arg_length, offset, cs);
}
/* Copy with charset convertion */
......@@ -315,14 +333,11 @@ bool String::set_or_copy_aligned(const char *str,uint32 arg_length,
bool String::copy(const char *str, uint32 arg_length,
CHARSET_INFO *from_cs, CHARSET_INFO *to_cs)
{
if (!needs_conversion(str, arg_length, from_cs, to_cs))
{
uint32 offset;
if (!needs_conversion(arg_length, from_cs, to_cs, &offset))
return copy(str, arg_length, to_cs);
}
if ((from_cs == &my_charset_bin) && (arg_length % to_cs->mbminlen))
{
return copy_aligned(str, arg_length, to_cs);
}
if ((from_cs == &my_charset_bin) && offset)
return copy_aligned(str, arg_length, offset, to_cs);
uint32 new_length= to_cs->mbmaxlen*arg_length;
if (alloc(new_length))
......@@ -744,7 +759,8 @@ copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
while (1)
{
if ((cnvres=from_cs->cset->mb_wc(from_cs, &wc, (uchar*) from, from_end)) > 0)
if ((cnvres= from_cs->cset->mb_wc(from_cs, &wc, (uchar*) from,
from_end)) > 0)
from+= cnvres;
else if (cnvres == MY_CS_ILSEQ)
{
......
......@@ -183,9 +183,11 @@ class String
bool copy(); // Alloc string if not alloced
bool copy(const String &s); // Allocate new string
bool copy(const char *s,uint32 arg_length, CHARSET_INFO *cs); // Allocate new string
static bool needs_conversion(const char *s, uint32 arg_length,
CHARSET_INFO *cs_from, CHARSET_INFO *cs_to);
bool copy_aligned(const char *s, uint32 arg_length, CHARSET_INFO *cs);
static bool needs_conversion(uint32 arg_length,
CHARSET_INFO *cs_from, CHARSET_INFO *cs_to,
uint32 *offset);
bool copy_aligned(const char *s, uint32 arg_length, uint32 offset,
CHARSET_INFO *cs);
bool set_or_copy_aligned(const char *s, uint32 arg_length, CHARSET_INFO *cs);
bool copy(const char*s,uint32 arg_length, CHARSET_INFO *csfrom,
CHARSET_INFO *csto);
......
......@@ -482,8 +482,11 @@ int mysql_multi_update(THD *thd,
for (tl= select_lex->get_table_list() ; tl ; tl= tl->next)
{
if (tl->derived && (item_tables & tl->table->map))
{
my_printf_error(ER_NON_UPDATABLE_TABLE, ER(ER_NON_UPDATABLE_TABLE),
MYF(0), tl->alias, "UPDATE");
DBUG_RETURN(-1);
}
}
}
......
......@@ -918,7 +918,7 @@ create:
&tmp_table_alias :
(LEX_STRING*) 0),
TL_OPTION_UPDATING,
((using_update_log)?
(using_update_log ?
TL_READ_NO_INSERT:
TL_READ)))
YYABORT;
......@@ -2189,10 +2189,9 @@ select_init2:
select_part2:
{
LEX *lex=Lex;
SELECT_LEX * sel= lex->current_select;
if (lex->current_select == &lex->select_lex)
lex->lock_option= TL_READ; /* Only for global SELECT */
LEX *lex= Lex;
SELECT_LEX *sel= lex->current_select;
lex->lock_option= TL_READ;
if (sel->linkage != UNION_TYPE)
mysql_init_select(lex);
lex->current_select->parsing_place= SELECT_LEX_NODE::SELECT_LIST;
......@@ -3060,7 +3059,7 @@ opt_gorder_clause:
| order_clause
{
LEX *lex=Lex;
lex->gorder_list=
lex->gorder_list=
(SQL_LIST*) sql_memdup((char*) &lex->current_select->order_list,
sizeof(st_sql_list));
lex->current_select->order_list.empty();
......@@ -3084,16 +3083,16 @@ in_sum_expr:
};
cast_type:
BINARY { $$=ITEM_CAST_BINARY; }
BINARY { $$=ITEM_CAST_BINARY; Lex->charset= NULL; Lex->length= (char*)0; }
| CHAR_SYM opt_len opt_binary { $$=ITEM_CAST_CHAR; }
| NCHAR_SYM opt_len { $$=ITEM_CAST_CHAR; Lex->charset= national_charset_info; }
| SIGNED_SYM { $$=ITEM_CAST_SIGNED_INT; }
| SIGNED_SYM INT_SYM { $$=ITEM_CAST_SIGNED_INT; }
| UNSIGNED { $$=ITEM_CAST_UNSIGNED_INT; }
| UNSIGNED INT_SYM { $$=ITEM_CAST_UNSIGNED_INT; }
| DATE_SYM { $$=ITEM_CAST_DATE; }
| TIME_SYM { $$=ITEM_CAST_TIME; }
| DATETIME { $$=ITEM_CAST_DATETIME; }
| SIGNED_SYM { $$=ITEM_CAST_SIGNED_INT; Lex->charset= NULL; Lex->length= (char*)0; }
| SIGNED_SYM INT_SYM { $$=ITEM_CAST_SIGNED_INT; Lex->charset= NULL; Lex->length= (char*)0; }
| UNSIGNED { $$=ITEM_CAST_UNSIGNED_INT; Lex->charset= NULL; Lex->length= (char*)0; }
| UNSIGNED INT_SYM { $$=ITEM_CAST_UNSIGNED_INT; Lex->charset= NULL; Lex->length= (char*)0; }
| DATE_SYM { $$=ITEM_CAST_DATE; Lex->charset= NULL; Lex->length= (char*)0; }
| TIME_SYM { $$=ITEM_CAST_TIME; Lex->charset= NULL; Lex->length= (char*)0; }
| DATETIME { $$=ITEM_CAST_DATETIME; Lex->charset= NULL; Lex->length= (char*)0; }
;
expr_list:
......@@ -3895,6 +3894,7 @@ update:
LEX *lex= Lex;
mysql_init_select(lex);
lex->sql_command= SQLCOM_UPDATE;
lex->lock_option= TL_UNLOCK; /* Will be set later */
}
opt_low_priority opt_ignore join_table_list
SET update_list where_clause opt_order_clause delete_limit_clause
......
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