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