Commit 1d86145d authored by unknown's avatar unknown

Merge paul@bk-internal.mysql.com:/home/bk/mysql-4.1

into teton.kitebird.com:/home/paul/mysql-4.1

parents aa3b45f6 9a7ea958
......@@ -44,7 +44,7 @@
#include <locale.h>
#endif
const char *VER= "14.3";
const char *VER= "14.4";
/* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH 1024
......@@ -134,7 +134,8 @@ static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0,
vertical=0, line_numbers=1, column_names=1,opt_html=0,
opt_xml=0,opt_nopager=1, opt_outfile=0, named_cmds= 0,
tty_password= 0, opt_nobeep=0, opt_reconnect=1,
default_charset_used= 0, opt_secure_auth= 0;
default_charset_used= 0, opt_secure_auth= 0,
default_pager_set= 0;
static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0;
static my_string opt_mysql_unix_port=0;
static int connect_flag=CLIENT_INTERACTIVE;
......@@ -173,9 +174,7 @@ static CHARSET_INFO *charset_info= &my_charset_latin1;
#include "sslopt-vars.h"
#ifndef DBUG_OFF
const char *default_dbug_option="d:t:o,/tmp/mysql.trace";
#endif
void tee_fprintf(FILE *file, const char *fmt, ...);
void tee_fputs(const char *s, FILE *file);
......@@ -331,8 +330,11 @@ int main(int argc,char *argv[])
strmov(pager, "stdout"); // the default, if --pager wasn't given
{
char *tmp=getenv("PAGER");
if (tmp)
strmov(default_pager,tmp);
if (tmp && strlen(tmp))
{
default_pager_set= 1;
strmov(default_pager, tmp);
}
}
if (!isatty(0) || !isatty(1))
{
......@@ -467,6 +469,8 @@ static struct my_option my_long_options[] =
{
{"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
0, 0, 0, 0, 0},
{"help", 'I', "Synonym for -?", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
0, 0, 0, 0, 0},
{"auto-rehash", OPT_AUTO_REHASH,
"Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash.",
(gptr*) &rehash, (gptr*) &rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
......@@ -484,8 +488,11 @@ static struct my_option my_long_options[] =
{"compress", 'C', "Use compression in server/client protocol.",
(gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0},
#ifndef DBUG_OFF
{"debug", '#', "Output debug log.", (gptr*) &default_dbug_option,
#ifdef DBUG_OFF
{"debug", '#', "This is a non-debug version. Catch this and exit",
0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
#else
{"debug", '#', "Output debug log", (gptr*) &default_dbug_option,
(gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"database", 'D', "Database to use.", (gptr*) &current_db,
......@@ -608,19 +615,27 @@ static struct my_option my_long_options[] =
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"wait", 'w', "Wait and retry if connection is down.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"connect_timeout", OPT_CONNECT_TIMEOUT, "", (gptr*) &opt_connect_timeout,
{"connect_timeout", OPT_CONNECT_TIMEOUT,
"Number of seconds before connection timeout.",
(gptr*) &opt_connect_timeout,
(gptr*) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 3600*12, 0,
0, 1},
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "",
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
"Max packet length to send to, or receive from server",
(gptr*) &max_allowed_packet, (gptr*) &max_allowed_packet, 0, GET_ULONG,
REQUIRED_ARG, 16 *1024L*1024L, 4096, (longlong) 2*1024L*1024L*1024L,
MALLOC_OVERHEAD, 1024, 0},
{"net_buffer_length", OPT_NET_BUFFER_LENGTH, "",
{"net_buffer_length", OPT_NET_BUFFER_LENGTH,
"Buffer for TCP/IP and socket communication",
(gptr*) &net_buffer_length, (gptr*) &net_buffer_length, 0, GET_ULONG,
REQUIRED_ARG, 16384, 1024, 512*1024*1024L, MALLOC_OVERHEAD, 1024, 0},
{"select_limit", OPT_SELECT_LIMIT, "", (gptr*) &select_limit,
{"select_limit", OPT_SELECT_LIMIT,
"Automatic limit for SELECT when using --safe-updates",
(gptr*) &select_limit,
(gptr*) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ~0L, 0, 1, 0},
{"max_join_size", OPT_MAX_JOIN_SIZE, "", (gptr*) &max_join_size,
{"max_join_size", OPT_MAX_JOIN_SIZE,
"Automatic limit for rows in a join when using --safe-updates",
(gptr*) &max_join_size,
(gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ~0L, 0, 1,
0},
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
......@@ -689,11 +704,16 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
else
{
opt_nopager= 0;
if (argument)
if (argument && strlen(argument))
{
default_pager_set= 1;
strmov(pager, argument);
else
strmov(default_pager, pager);
}
else if (default_pager_set)
strmov(pager, default_pager);
strmov(default_pager, pager);
else
opt_nopager= 1;
}
break;
case OPT_NOPAGER:
......@@ -814,6 +834,7 @@ static int get_options(int argc, char **argv)
strmov(default_pager, "stdout");
strmov(pager, "stdout");
opt_nopager= 1;
default_pager_set= 0;
opt_outfile= 0;
opt_reconnect= 0;
connect_flag= 0; /* Not in interactive mode */
......@@ -1535,7 +1556,7 @@ static int com_server_help(String *buffer __attribute__((unused)),
init_pager();
char last_char;
int num_name, num_cat;
int num_name= 0, num_cat= 0;
LINT_INIT(num_name);
LINT_INIT(num_cat);
......@@ -2163,12 +2184,17 @@ com_pager(String *buffer, char *line __attribute__((unused)))
if (status.batch)
return 0;
/* Skip space from file name */
while (my_isspace(charset_info,*line))
/* Skip spaces in front of the pager command */
while (my_isspace(charset_info, *line))
line++;
if (!(param= strchr(line, ' '))) // if pager was not given, use the default
/* Skip the pager command */
param= strchr(line, ' ');
/* Skip the spaces between the command and the argument */
while (param && my_isspace(charset_info, *param))
param++;
if (!param || !strlen(param)) // if pager was not given, use the default
{
if (!default_pager[0])
if (!default_pager_set)
{
tee_fprintf(stdout, "Default pager wasn't set, using stdout.\n");
opt_nopager=1;
......@@ -2180,9 +2206,7 @@ com_pager(String *buffer, char *line __attribute__((unused)))
}
else
{
while (my_isspace(charset_info,*param))
param++;
end=strmake(pager_name, param, sizeof(pager_name)-1);
end= strmake(pager_name, param, sizeof(pager_name)-1);
while (end > pager_name && (my_isspace(charset_info,end[-1]) ||
my_iscntrl(charset_info,end[-1])))
end--;
......@@ -2191,7 +2215,7 @@ com_pager(String *buffer, char *line __attribute__((unused)))
strmov(default_pager, pager_name);
}
opt_nopager=0;
tee_fprintf(stdout, "PAGER set to %s\n", pager);
tee_fprintf(stdout, "PAGER set to '%s'\n", pager);
return 0;
}
......@@ -2202,6 +2226,7 @@ com_nopager(String *buffer __attribute__((unused)),
{
strmov(pager, "stdout");
opt_nopager=1;
PAGER= stdout;
tee_fprintf(stdout, "PAGER set to stdout\n");
return 0;
}
......
......@@ -37,7 +37,7 @@
** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov
*/
#define DUMP_VERSION "10.4"
#define DUMP_VERSION "10.5"
#include <my_global.h>
#include <my_sys.h>
......@@ -107,7 +107,8 @@ static CHARSET_INFO *charset_info= &my_charset_latin1;
const char *compatible_mode_names[]=
{
"MYSQL323", "MYSQL40", "POSTGRESQL", "ORACLE", "MSSQL", "DB2",
"SAPDB", "NO_KEY_OPTIONS", "NO_TABLE_OPTIONS", "NO_FIELD_OPTIONS",
"MAXDB", "NO_KEY_OPTIONS", "NO_TABLE_OPTIONS", "NO_FIELD_OPTIONS",
"ANSI",
NullS
};
TYPELIB compatible_mode_typelib= {array_elements(compatible_mode_names) - 1,
......@@ -136,7 +137,7 @@ static struct my_option my_long_options[] =
"Directory where character sets are.", (gptr*) &charsets_dir,
(gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"compatible", OPT_COMPATIBLE,
"Change the dump to be compatible with a given mode. By default tables are dumped without any restrictions. Legal modes are: mysql323, mysql40, postgresql, oracle, mssql, db2, sapdb, 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.",
"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},
{"complete-insert", 'c', "Use complete insert statements.", (gptr*) &cFlag,
......@@ -239,7 +240,7 @@ static struct my_option my_long_options[] =
{"quick", 'q', "Don't buffer query, dump directly to stdout.",
(gptr*) &quick, (gptr*) &quick, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"quote-names",'Q', "Quote table and column names with backticks (`).",
(gptr*) &opt_quoted, (gptr*) &opt_quoted, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
(gptr*) &opt_quoted, (gptr*) &opt_quoted, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0,
0, 0},
{"result-file", 'r',
"Direct output to a given file. This option should be used in MSDOS, because it prevents new line '\\n' from being converted to '\\r\\n' (carriage return + line feed).",
......@@ -830,7 +831,7 @@ static uint getTableStructure(char *table, char* db)
char *end;
uint i;
sprintf(buff, "/*!41000 SET @@sql_mode=\"");
sprintf(buff, "/*!40100 SET @@sql_mode=\"");
end= strend(buff);
for (i= 0; opt_compatible_mode; opt_compatible_mode>>= 1, i++)
{
......
......@@ -17,11 +17,12 @@
C_MODE_START
enum get_opt_var_type { GET_NO_ARG, GET_BOOL, GET_INT, GET_UINT, GET_LONG,
GET_ULONG, GET_LL, GET_ULL, GET_STR, GET_STR_ALLOC
GET_ULONG, GET_LL, GET_ULL, GET_STR, GET_STR_ALLOC,
GET_DISABLED
};
#define GET_ASK_ADDR 128
#define GET_TYPE_MASK 127
#define GET_ASK_ADDR 128
#define GET_TYPE_MASK 127
enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG };
......
......@@ -68,6 +68,7 @@ extern const char * NEAR globerrs[]; /* my_error_messages is here */
#define EXIT_UNKNOWN_SUFFIX 9
#define EXIT_NO_PTR_TO_VARIABLE 10
#define EXIT_CANNOT_CONNECT_TO_SERVICE 11
#define EXIT_OPTION_DISABLED 12
#ifdef __cplusplus
......
......@@ -412,3 +412,12 @@ t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
DROP TABLE t1;
CREATE TABLE t1 (a int UNIQUE);
ALTER TABLE t1 DROP PRIMARY KEY;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) default NULL,
UNIQUE KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
......@@ -19,6 +19,12 @@ SELECT HEX(a) FROM t2;
HEX(a)
D0BFD180D0BED0B1D0B0
DROP TABLE t1, t2;
CREATE TABLE t1 (description text character set cp1250 NOT NULL);
INSERT INTO t1 (description) VALUES (_latin2'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddde');
SELECT description FROM t1;
description
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddde
DROP TABLE t1;
CREATE TABLE t1 (a TEXT CHARACTER SET cp1251) SELECT _koi8r'' AS a;
CREATE TABLE t2 (a TEXT CHARACTER SET utf8);
SHOW CREATE TABLE t1;
......
......@@ -173,6 +173,12 @@ SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630061005F';
word
cat
DROP TABLE t1;
select insert(_ucs2 0x006100620063,10,2,_ucs2 0x006400650066);
insert(_ucs2 0x006100620063,10,2,_ucs2 0x006400650066)
abc
select insert(_ucs2 0x006100620063,1,2,_ucs2 0x006400650066);
insert(_ucs2 0x006100620063,1,2,_ucs2 0x006400650066)
defc
SET NAMES latin1;
CREATE TABLE t1 (
word VARCHAR(64),
......
......@@ -62,3 +62,9 @@ select 'A' like 'a' collate utf8_bin;
select _utf8 0xD0B0D0B1D0B2 like concat(_utf8'%',_utf8 0xD0B1,_utf8 '%');
_utf8 0xD0B0D0B1D0B2 like concat(_utf8'%',_utf8 0xD0B1,_utf8 '%')
1
select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
insert('txs',2,1,'hi') insert('is ',4,0,'a') insert('txxxxt',2,4,'es')
this is a test
select insert("aa",100,1,"b"),insert("aa",1,3,"b");
insert("aa",100,1,"b") insert("aa",1,3,"b")
aa b
......@@ -88,20 +88,37 @@ drop table t2;
create table t1 (
test_set set( 'val1', 'val2', 'val3' ) not null default '',
name char(20) default 'O''Brien' comment 'O''Brien as default',
c int not null comment 'int column'
) comment = 'it\'s a table' ;
show create table t1 ;
c int not null comment 'int column',
`c-b` int comment 'name with a space',
`space ` int comment 'name with a space',
) comment = 'it\'s a table' ;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`test_set` set('val1','val2','val3') NOT NULL default '',
`name` char(20) default 'O''Brien' COMMENT 'O''Brien as default',
`c` int(11) NOT NULL default '0' COMMENT 'int column'
`c` int(11) NOT NULL default '0' COMMENT 'int column',
`c-b` int(11) default NULL COMMENT 'name with a space',
`space ` int(11) default NULL COMMENT 'name with a space'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='it''s a table'
set sql_quote_show_create=0;
show create table t1;
Table Create Table
t1 CREATE TABLE t1 (
test_set set('val1','val2','val3') NOT NULL default '',
name char(20) default 'O''Brien' COMMENT 'O''Brien as default',
c int(11) NOT NULL default '0' COMMENT 'int column',
`c-b` int(11) default NULL COMMENT 'name with a space',
`space ` int(11) default NULL COMMENT 'name with a space'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='it''s a table'
set sql_quote_show_create=1;
show full columns from t1;
Field Type Collation Null Key Default Extra Privileges Comment
test_set set('val1','val2','val3') latin1_swedish_ci select,insert,update,references
name char(20) latin1_swedish_ci YES O'Brien select,insert,update,references O'Brien as default
c int(11) NULL 0 select,insert,update,references int column
c-b int(11) NULL YES NULL select,insert,update,references name with a space
space int(11) NULL YES NULL select,insert,update,references name with a space
drop table t1;
create table t1 (a int not null, unique aa (a));
show create table t1;
......
......@@ -244,3 +244,12 @@ LOCK TABLES t1 WRITE;
ALTER TABLE t1 DISABLE KEYS;
SHOW INDEX FROM t1;
DROP TABLE t1;
#
# Bug 2361
#
CREATE TABLE t1 (a int UNIQUE);
ALTER TABLE t1 DROP PRIMARY KEY;
SHOW CREATE TABLE t1;
DROP TABLE t1;
......@@ -14,6 +14,15 @@ INSERT t2 SELECT * FROM t1;
SELECT HEX(a) FROM t2;
DROP TABLE t1, t2;
#
# Check that long strings conversion does not fail (bug#2218)
#
CREATE TABLE t1 (description text character set cp1250 NOT NULL);
INSERT INTO t1 (description) VALUES (_latin2'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasssssssssssaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddde');
SELECT description FROM t1;
DROP TABLE t1;
# same with TEXT
CREATE TABLE t1 (a TEXT CHARACTER SET cp1251) SELECT _koi8r'' AS a;
CREATE TABLE t2 (a TEXT CHARACTER SET utf8);
......@@ -62,3 +71,4 @@ SET NAMES koi8r;
SELECT hex('');
SET character_set_connection=cp1251;
SELECT hex('');
......@@ -93,6 +93,12 @@ SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630025';
SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630061005F';
DROP TABLE t1;
#
# Check that INSERT works fine.
# This invokes charpos() function.
select insert(_ucs2 0x006100620063,10,2,_ucs2 0x006400650066);
select insert(_ucs2 0x006100620063,1,2,_ucs2 0x006400650066);
######################################################
#
......@@ -191,4 +197,3 @@ DROP TABLE t1;
# END OF Bug 1264 test
#
########################################################
......@@ -35,3 +35,9 @@ select _utf8 0xD0B0D0B1D0B2 like concat(_utf8'%',_utf8 0xD0B1,_utf8 '%');
#
#select _utf8 0xD0B0D0B1D0B2 like concat(_utf8'%',_utf8 0xD091,_utf8 '%');
#
#
# Bug 2367: INSERT() behaviour is different for different charsets.
#
select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
select insert("aa",100,1,"b"),insert("aa",1,3,"b");
......@@ -53,9 +53,14 @@ drop table t2;
create table t1 (
test_set set( 'val1', 'val2', 'val3' ) not null default '',
name char(20) default 'O''Brien' comment 'O''Brien as default',
c int not null comment 'int column'
c int not null comment 'int column',
`c-b` int comment 'name with a space',
`space ` int comment 'name with a space',
) comment = 'it\'s a table' ;
show create table t1 ;
show create table t1;
set sql_quote_show_create=0;
show create table t1;
set sql_quote_show_create=1;
show full columns from t1;
drop table t1;
......
......@@ -357,7 +357,7 @@ static int add_collation(CHARSET_INFO *cs)
}
#define MAX_BUF 1024*16
#define MY_MAX_ALLOWED_BUF 1024*1024
#define MY_CHARSET_INDEX "Index.xml"
const char *charsets_dir= NULL;
......@@ -369,16 +369,19 @@ static my_bool my_read_charset_file(const char *filename, myf myflags)
char *buf;
int fd;
uint len;
MY_STAT stat_info;
if (!(buf= (char *)my_malloc(MAX_BUF,myflags)))
return FALSE;
if (!my_stat(filename, &stat_info, MYF(MY_WME)) ||
((len= (uint)stat_info.st_size) > MY_MAX_ALLOWED_BUF) ||
!(buf= (char *)my_malloc(len,myflags)))
return TRUE;
if ((fd=my_open(filename,O_RDONLY,myflags)) < 0)
{
my_free(buf,myflags);
return TRUE;
}
len=read(fd,buf,MAX_BUF);
len=read(fd,buf,len);
my_close(fd,myflags);
if (my_parse_charset_xml(buf,len,add_collation))
......
......@@ -461,7 +461,8 @@ static char *remove_end_comment(char *ptr)
else if (quote == *ptr)
quote= 0;
}
if (!quote && *ptr == '#') /* We are not inside a comment */
/* We are not inside a comment */
if (!quote && (*ptr == '#' || *ptr == ';'))
{
*ptr= 0;
return ptr;
......
......@@ -1175,8 +1175,8 @@ int _flush_io_cache(IO_CACHE *info, int need_append_buffer_lock)
info IO_CACHE Handle to free
NOTES
It's currently safe to call this if one has called io_cache_init()
on the 'info' object, even if io_cache_init() failed.
It's currently safe to call this if one has called init_io_cache()
on the 'info' object, even if init_io_cache() failed.
This function is also safe to call twice with the same handle.
RETURN
......
......@@ -285,6 +285,19 @@ int handle_options(int *argc, char ***argv,
return EXIT_AMBIGUOUS_OPTION;
}
}
if ((optp->var_type & GET_TYPE_MASK) == GET_DISABLED)
{
if (my_getopt_print_errors)
fprintf(stderr,
"%s: %s: Option '%s' used, but is disabled\n", my_progname,
option_is_loose ? "WARNING" : "ERROR", opt_str);
if (option_is_loose)
{
(*argc)--;
continue;
}
return EXIT_OPTION_DISABLED;
}
if (must_be_var && (optp->var_type & GET_TYPE_MASK) == GET_NO_ARG)
{
if (my_getopt_print_errors)
......@@ -358,6 +371,14 @@ int handle_options(int *argc, char ***argv,
{
/* Option recognized. Find next what to do with it */
opt_found= 1;
if ((optp->var_type & GET_TYPE_MASK) == GET_DISABLED)
{
if (my_getopt_print_errors)
fprintf(stderr,
"%s: ERROR: Option '-%c' used, but is disabled\n",
my_progname, optp->id);
return EXIT_OPTION_DISABLED;
}
if ((optp->var_type & GET_TYPE_MASK) == GET_BOOL &&
optp->arg_type == NO_ARG)
{
......@@ -550,7 +571,7 @@ static int findopt(char *optpat, uint length,
const struct my_option **opt_res,
char **ffname)
{
int count;
uint count;
struct my_option *opt= (struct my_option *) *opt_res;
for (count= 0; opt->name; opt++)
......@@ -562,7 +583,8 @@ static int findopt(char *optpat, uint length,
*ffname= (char *) opt->name; /* We only need to know one prev */
if (!opt->name[length]) /* Exact match */
return 1;
count++;
if (!count || strcmp(*ffname, opt->name)) /* Don't count synonyms */
count++;
}
}
return count;
......@@ -882,7 +904,8 @@ void my_print_variables(const struct my_option *options)
longlong2str(*((ulonglong*) value), buff, 10);
printf("%s\n", buff);
break;
default: /* dummy default to avoid compiler warnings */
default:
printf("(Disabled)\n");
break;
}
}
......
......@@ -4567,17 +4567,19 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
}
else
{
bool was_conversion;
char buff[80];
String tmpstr(buff,sizeof(buff), &my_charset_bin);
/* Convert character set if nesessary */
if (use_conversion(cs, field_charset))
if ((was_conversion= use_conversion(cs, field_charset)))
{
tmpstr.copy(from, length, cs, field_charset);
from= tmpstr.ptr();
length= tmpstr.length();
}
Field_blob::store_length(length);
if (table->copy_blobs || length <= MAX_FIELD_WIDTH)
if (was_conversion || table->copy_blobs || length <= MAX_FIELD_WIDTH)
{ // Must make a copy
if (from != value.ptr()) // For valgrind
{
......
......@@ -975,14 +975,10 @@ String *Item_func_right::val_str(String *str)
if (res->length() <= (uint) length)
return res; /* purecov: inspected */
/*
As far "res" contains at least "length" bytes
(according to the above condition and return),
the below statement is safe. res->numchars() can
never return a value less than "length".
*/
uint start=res->numchars()-(uint) length;
start=res->charpos(start);
uint start=res->numchars();
if (start <= (uint) length)
return res;
start=res->charpos(start - (uint) length);
tmp_value.set(*res,start,res->length()-start);
return &tmp_value;
}
......
......@@ -38,6 +38,7 @@ typedef ulong key_part_map; /* Used for finding key parts */
/* useful constants */
extern const key_map key_map_empty;
extern const key_map key_map_full;
extern const char *primary_key_name;
#include "mysql_com.h"
#include <violite.h>
......
......@@ -695,39 +695,53 @@ select_export::~select_export()
thd->sent_row_count=row_count;
}
int
select_export::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
static int create_file(THD *thd, char *path, sql_exchange *exchange,
File *file, IO_CACHE *cache)
{
char path[FN_REFLEN];
uint option=4;
bool blob_flag=0;
unit= u;
uint option= 4;
#ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS
option|=1; // Force use of db directory
option|= 1; // Force use of db directory
#endif
if ((uint) strlen(exchange->file_name) + NAME_LEN >= FN_REFLEN)
strmake(path,exchange->file_name,FN_REFLEN-1);
(void) fn_format(path,exchange->file_name, thd->db ? thd->db : "", "",
(void) fn_format(path, exchange->file_name, thd->db ? thd->db : "", "",
option);
if (!access(path,F_OK))
if (!access(path, F_OK))
{
my_error(ER_FILE_EXISTS_ERROR, MYF(0), exchange->file_name);
return 1;
}
/* Create the file world readable */
if ((file=my_create(path, 0666, O_WRONLY, MYF(MY_WME))) < 0)
if ((*file= my_create(path, 0666, O_WRONLY, MYF(MY_WME))) < 0)
return 1;
#ifdef HAVE_FCHMOD
(void) fchmod(file,0666); // Because of umask()
(void) fchmod(*file, 0666); // Because of umask()
#else
(void) chmod(path,0666);
(void) chmod(path, 0666);
#endif
if (init_io_cache(&cache,file,0L,WRITE_CACHE,0L,1,MYF(MY_WME)))
if (init_io_cache(cache, *file, 0L, WRITE_CACHE, 0L, 1, MYF(MY_WME)))
{
my_close(file,MYF(0));
file= -1;
my_close(*file, MYF(0));
my_delete(path, MYF(0)); // Delete file on error, it was just created
*file= -1;
end_io_cache(cache);
return 1;
}
return 0;
}
int
select_export::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
{
char path[FN_REFLEN];
bool blob_flag=0;
unit= u;
if ((uint) strlen(exchange->file_name) + NAME_LEN >= FN_REFLEN)
strmake(path,exchange->file_name,FN_REFLEN-1);
if (create_file(thd, path, exchange, &file, &cache))
return 1;
/* Check if there is any blobs in data */
{
List_iterator_fast<Item> li(list);
......@@ -901,7 +915,6 @@ bool select_export::send_data(List<Item> &items)
void select_export::send_error(uint errcode, const char *err)
{
::send_error(thd,errcode,err);
(void) end_io_cache(&cache);
(void) my_close(file,MYF(0));
file= -1;
}
......@@ -938,33 +951,9 @@ int
select_dump::prepare(List<Item> &list __attribute__((unused)),
SELECT_LEX_UNIT *u)
{
uint option=4;
unit= u;
#ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS
option|=1; // Force use of db directory
#endif
(void) fn_format(path,exchange->file_name, thd->db ? thd->db : "", "",
option);
if (!access(path,F_OK))
{
my_error(ER_FILE_EXISTS_ERROR,MYF(0),exchange->file_name);
if (create_file(thd, path, exchange, &file, &cache))
return 1;
}
/* Create the file world readable */
if ((file=my_create(path, 0666, O_WRONLY, MYF(MY_WME))) < 0)
return 1;
#ifdef HAVE_FCHMOD
(void) fchmod(file,0666); // Because of umask()
#else
(void) chmod(path,0666);
#endif
if (init_io_cache(&cache,file,0L,WRITE_CACHE,0L,1,MYF(MY_WME)))
{
my_close(file,MYF(0));
my_delete(path,MYF(0));
file= -1;
return 1;
}
return 0;
}
......@@ -1011,9 +1000,7 @@ bool select_dump::send_data(List<Item> &items)
void select_dump::send_error(uint errcode,const char *err)
{
::send_error(thd,errcode,err);
(void) end_io_cache(&cache);
(void) my_close(file,MYF(0));
(void) my_delete(path,MYF(0)); // Delete file on error
file= -1;
}
......
......@@ -274,9 +274,9 @@ int get_topics_for_keyword(THD *thd, TABLE *topics, TABLE *relations,
DBUG_ENTER("get_topics_for_keyword");
if ((iindex_topic= find_type((char*) "PRIMARY",
if ((iindex_topic= find_type((char*) primary_key_name,
&topics->keynames, 1+2)-1)<0 ||
(iindex_relations= find_type((char*) "PRIMARY",
(iindex_relations= find_type((char*) primary_key_name,
&relations->keynames, 1+2)-1)<0)
{
send_error(thd,ER_CORRUPT_HELP_DB);
......
......@@ -9130,16 +9130,16 @@ int mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result)
{
res= mysql_explain_select(thd, sl,
(((&thd->lex->select_lex)==sl)?
((thd->lex->all_selects_list != sl)?"PRIMARY":
"SIMPLE"):
((thd->lex->all_selects_list != sl) ?
primary_key_name : "SIMPLE"):
((sl == first)?
((sl->linkage == DERIVED_TABLE_TYPE) ?
"DERIVED":
((sl->uncacheable & UNCACHEABLE_DEPENDENT)?
((sl->uncacheable & UNCACHEABLE_DEPENDENT) ?
"DEPENDENT SUBQUERY":
(sl->uncacheable?"UNCACHEABLE SUBQUERY":
"SUBQUERY"))):
((sl->uncacheable & UNCACHEABLE_DEPENDENT)?
((sl->uncacheable & UNCACHEABLE_DEPENDENT) ?
"DEPENDENT UNION":
sl->uncacheable?"UNCACHEABLE UNION":
"UNION"))),
......
......@@ -997,6 +997,19 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd)
DBUG_RETURN(0);
}
/* possible TODO: call find_keyword() from sql_lex.cc here */
static bool require_quotes(const char *name, uint length)
{
uint i, d, c;
for (i=0; i<length; i+=d)
{
c=((uchar *)name)[i];
d=my_mbcharlen(system_charset_info, c);
if (d==1 && !system_charset_info->ident_map[c])
return 1;
}
return 0;
}
void
append_identifier(THD *thd, String *packet, const char *name, uint length)
......@@ -1007,7 +1020,8 @@ append_identifier(THD *thd, String *packet, const char *name, uint length)
else
qtype= '`';
if (thd->options & OPTION_QUOTE_SHOW_CREATE)
if ((thd->options & OPTION_QUOTE_SHOW_CREATE) ||
require_quotes(name, length))
{
packet->append(&qtype, 1);
packet->append(name, length, system_charset_info);
......@@ -1167,7 +1181,7 @@ store_create_info(THD *thd, TABLE *table, String *packet)
bool found_primary=0;
packet->append(",\n ", 4);
if (i == primary_key && !strcmp(key_info->name,"PRIMARY"))
if (i == primary_key && !strcmp(key_info->name, primary_key_name))
{
found_primary=1;
packet->append("PRIMARY ", 8);
......
......@@ -29,7 +29,7 @@
#include <io.h>
#endif
static const char *primary_key_name="PRIMARY";
const char *primary_key_name= "PRIMARY";
static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end);
static char *make_unique_key_name(const char *field_name,KEY *start,KEY *end);
......@@ -2242,13 +2242,15 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
KEY *key_info=table->key_info;
for (uint i=0 ; i < table->keys ; i++,key_info++)
{
if (drop_primary && (key_info->flags & HA_NOSAME))
char *key_name= key_info->name;
if (drop_primary && (key_info-> flags & HA_NOSAME) &&
!my_strcasecmp(system_charset_info, key_name, primary_key_name))
{
drop_primary=0;
drop_primary= 0;
continue;
}
char *key_name=key_info->name;
Alter_drop *drop;
drop_it.rewind();
while ((drop=drop_it++))
......@@ -2303,7 +2305,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
key_list.push_back(new Key(key_info->flags & HA_SPATIAL ? Key::SPATIAL :
(key_info->flags & HA_NOSAME ?
(!my_strcasecmp(system_charset_info,
key_name, "PRIMARY") ?
key_name, primary_key_name) ?
Key::PRIMARY : Key::UNIQUE) :
(key_info->flags & HA_FULLTEXT ?
Key::FULLTEXT : Key::MULTIPLE)),
......
......@@ -481,8 +481,8 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
/* Fix key->name and key_part->field */
if (key_parts)
{
uint primary_key=(uint) (find_type((char*) "PRIMARY",&outparam->keynames,
3)-1);
uint primary_key=(uint) (find_type((char*) primary_key_name,
&outparam->keynames, 3) - 1);
uint ha_option=outparam->file->table_flags();
keyinfo=outparam->key_info;
key_part=keyinfo->key_part;
......
......@@ -271,7 +271,7 @@ uint my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)),
b+= (mblen= my_ismbchar(cs,b,e)) ? mblen : 1;
pos--;
}
return b-b0;
return pos ? e+2-b0 : b-b0;
}
uint my_instr_mb(CHARSET_INFO *cs,
......
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