Commit 69e962c4 authored by unknown's avatar unknown

Merge


client/mysqldump.c:
  merged
include/Makefile.am:
  merged
sql/gen_lex_hash.cc:
  merged
sql/lex.h:
  merged
parents 357167f2 c231b598
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
** Tnu Samuel <tonu@please.do.not.remove.this.spam.ee> ** Tnu Samuel <tonu@please.do.not.remove.this.spam.ee>
**/ **/
#define DUMP_VERSION "8.8" #define DUMP_VERSION "8.9"
#include <global.h> #include <global.h>
#include <my_sys.h> #include <my_sys.h>
...@@ -470,7 +470,7 @@ static int get_options(int *argc,char ***argv) ...@@ -470,7 +470,7 @@ static int get_options(int *argc,char ***argv)
static void DBerror(MYSQL *mysql, const char *when) static void DBerror(MYSQL *mysql, const char *when)
{ {
DBUG_ENTER("DBerror"); DBUG_ENTER("DBerror");
my_printf_error(0,"Got error: %d: %s %s", MYF(0), my_printf_error(0,"Got error: %d: %s %s", MYF(0),
mysql_errno(mysql), mysql_error(mysql), when); mysql_errno(mysql), mysql_error(mysql), when);
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
...@@ -600,34 +600,10 @@ static uint getTableStructure(char *table, char* db) ...@@ -600,34 +600,10 @@ static uint getTableStructure(char *table, char* db)
{ {
fprintf(stderr, "%s: Can't get info about table: '%s'\nerror: %s\n", fprintf(stderr, "%s: Can't get info about table: '%s'\nerror: %s\n",
my_progname, table, mysql_error(sock)); my_progname, table, mysql_error(sock));
if (sql_file != stdout)
my_fclose(sql_file, MYF(MY_WME));
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
/* Make an sql-file, if path was given iow. option -T was given */
if (!tFlag)
{
if (path)
{
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
strmov(tmp_path,path);
convert_dirname(tmp_path);
sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4),
O_WRONLY, MYF(MY_WME));
if (!sql_file) /* If file couldn't be opened */
{
safe_exit(EX_MYSQLERR);
DBUG_RETURN(0);
}
write_heder(sql_file, db);
}
fprintf(sql_file, "\n#\n# Table structure for table '%s'\n#\n\n", table);
if (opt_drop)
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name);
fprintf(sql_file, "CREATE TABLE %s (\n", table_name);
}
if (cFlag) if (cFlag)
sprintf(insert_pat, "INSERT %sINTO %s (", delayed, table_name); sprintf(insert_pat, "INSERT %sINTO %s (", delayed, table_name);
else else
...@@ -643,134 +619,56 @@ static uint getTableStructure(char *table, char* db) ...@@ -643,134 +619,56 @@ static uint getTableStructure(char *table, char* db)
ulong *lengths=mysql_fetch_lengths(tableRes); ulong *lengths=mysql_fetch_lengths(tableRes);
if (init) if (init)
{ {
if (!tFlag)
fputs(",\n",sql_file);
if (cFlag) if (cFlag)
strpos=strmov(strpos,", "); strpos=strmov(strpos,", ");
} }
init=1; init=1;
if (cFlag) if (cFlag)
strpos=strmov(strpos,quote_name(row[SHOW_FIELDNAME],name_buff)); strpos=strmov(strpos,quote_name(row[SHOW_FIELDNAME],name_buff));
if (!tFlag) }
{ if (cFlag)
if (opt_keywords) {
fprintf(sql_file, " %s.%s %s", table_name, strpos=strmov(strpos,") VALUES ");
quote_name(row[SHOW_FIELDNAME],name_buff), row[SHOW_TYPE]); if (!extended_insert)
else strpos=strmov(strpos,"(");
fprintf(sql_file, " %s %s", quote_name(row[SHOW_FIELDNAME],name_buff),
row[SHOW_TYPE]);
if (row[SHOW_DEFAULT])
{
fputs(" DEFAULT ", sql_file);
unescape(sql_file,row[SHOW_DEFAULT],lengths[SHOW_DEFAULT]);
}
if (!row[SHOW_NULL][0])
fputs(" NOT NULL", sql_file);
if (row[SHOW_EXTRA][0])
fprintf(sql_file, " %s",row[SHOW_EXTRA]);
}
} }
numFields = (uint) mysql_num_rows(tableRes); numFields = (uint) mysql_num_rows(tableRes);
mysql_free_result(tableRes); mysql_free_result(tableRes);
if (!tFlag) if (!tFlag)
{ {
/* Make an sql-file, if path was given iow. option -T was given */
char buff[20+FN_REFLEN]; char buff[20+FN_REFLEN];
uint keynr,primary_key;
sprintf(buff,"show keys from %s",table_name); sprintf(buff,"show create table %s",table_name);
if (mysql_query(sock, buff)) if (mysql_query(sock, buff))
{ {
fprintf(stderr, "%s: Can't get keys for table '%s' (%s)\n", fprintf(stderr, "%s: Can't get CREATE TABLE for table '%s' (%s)\n",
my_progname, table, mysql_error(sock)); my_progname, table, mysql_error(sock));
if (sql_file != stdout)
my_fclose(sql_file, MYF(MY_WME));
safe_exit(EX_MYSQLERR); safe_exit(EX_MYSQLERR);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
tableRes=mysql_store_result(sock); if (path)
/* Find first which key is primary key */
keynr=0;
primary_key=INT_MAX;
while ((row=mysql_fetch_row(tableRes)))
{
if (atoi(row[3]) == 1)
{
keynr++;
#ifdef FORCE_PRIMARY_KEY
if (atoi(row[1]) == 0 && primary_key == INT_MAX)
primary_key=keynr;
#endif
if (!strcmp(row[2],"PRIMARY"))
{
primary_key=keynr;
break;
}
}
}
mysql_data_seek(tableRes,0);
keynr=0;
while ((row=mysql_fetch_row(tableRes)))
{ {
if (atoi(row[3]) == 1) char filename[FN_REFLEN], tmp_path[FN_REFLEN];
strmov(tmp_path,path);
convert_dirname(tmp_path);
sql_file= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4),
O_WRONLY, MYF(MY_WME));
if (!sql_file) /* If file couldn't be opened */
{ {
if (keynr++) safe_exit(EX_MYSQLERR);
putc(')', sql_file); DBUG_RETURN(0);
if (atoi(row[1])) /* Test if duplicate key */
/* Duplicate allowed */
fprintf(sql_file, ",\n KEY %s (",quote_name(row[2],name_buff));
else if (keynr == primary_key)
fputs(",\n PRIMARY KEY (",sql_file); /* First UNIQUE is primary */
else
fprintf(sql_file, ",\n UNIQUE %s (",quote_name(row[2],name_buff));
} }
else write_heder(sql_file, db);
putc(',', sql_file);
fputs(quote_name(row[4],name_buff), sql_file);
if (row[7])
fprintf(sql_file, "(%s)",row[7]); /* Sub key */
} }
if (keynr) fprintf(sql_file, "\n#\n# Table structure for table '%s'\n#\n\n", table);
putc(')', sql_file); if (opt_drop)
fputs("\n)",sql_file); fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name);
/* Get MySQL specific create options */ tableRes=mysql_store_result(sock);
if (create_options) row=mysql_fetch_row(tableRes);
{ fprintf(sql_file, "%s;\n", row[1]);
sprintf(buff,"show table status like '%s'",table);
if (mysql_query(sock, buff))
{
if (mysql_errno(sock) != ER_PARSE_ERROR)
{ /* If old MySQL version */
if (verbose)
fprintf(stderr,
"# Warning: Couldn't get status information for table '%s' (%s)\n",
table,mysql_error(sock));
}
}
else if (!(tableRes=mysql_store_result(sock)) ||
!(row=mysql_fetch_row(tableRes)))
{
fprintf(stderr,
"Error: Couldn't read status information for table '%s' (%s)\n",
table,mysql_error(sock));
}
else
{
fputs("/*!",sql_file);
print_value(sql_file,tableRes,row,"type=","Type",0);
print_value(sql_file,tableRes,row,"","Create_options",0);
print_value(sql_file,tableRes,row,"comment=","Comment",1);
fputs(" */",sql_file);
}
mysql_free_result(tableRes); /* Is always safe to free */
}
fputs(";\n", sql_file);
}
if (cFlag)
{
strpos=strmov(strpos,") VALUES ");
if (!extended_insert)
strpos=strmov(strpos,"(");
} }
DBUG_RETURN(numFields); DBUG_RETURN(numFields);
} /* getTableStructure */ } /* getTableStructure */
...@@ -951,7 +849,7 @@ static void dumpTable(uint numFields, char *table) ...@@ -951,7 +849,7 @@ static void dumpTable(uint numFields, char *table)
safe_exit(EX_EOM); safe_exit(EX_EOM);
} }
dynstr_append(&extended_row,"\'"); dynstr_append(&extended_row,"\'");
extended_row.length += extended_row.length +=
mysql_real_escape_string(&mysql_connection, mysql_real_escape_string(&mysql_connection,
&extended_row.str[extended_row.length],row[i],length); &extended_row.str[extended_row.length],row[i],length);
extended_row.str[extended_row.length]='\0'; extended_row.str[extended_row.length]='\0';
...@@ -1047,7 +945,7 @@ static char *getTableName(int reset) ...@@ -1047,7 +945,7 @@ static char *getTableName(int reset)
} }
if ((row = mysql_fetch_row(res))) if ((row = mysql_fetch_row(res)))
return((char*) row[0]); return((char*) row[0]);
if (reset) if (reset)
mysql_data_seek(res,0); /* We want to read again */ mysql_data_seek(res,0); /* We want to read again */
else else
...@@ -1135,14 +1033,14 @@ static int dump_all_tables_in_db(char *database) ...@@ -1135,14 +1033,14 @@ static int dump_all_tables_in_db(char *database)
dynstr_append(&query, " READ /*!32311 LOCAL */,"); dynstr_append(&query, " READ /*!32311 LOCAL */,");
} }
if (numrows && mysql_real_query(sock, query.str, query.length-1)) if (numrows && mysql_real_query(sock, query.str, query.length-1))
DBerror(sock, "when using LOCK TABLES"); DBerror(sock, "when using LOCK TABLES");
/* We shall continue here, if --force was given */ /* We shall continue here, if --force was given */
dynstr_free(&query); dynstr_free(&query);
} }
if (flush_logs) if (flush_logs)
{ {
if (mysql_refresh(sock, REFRESH_LOG)) if (mysql_refresh(sock, REFRESH_LOG))
DBerror(sock, "when doing refresh"); DBerror(sock, "when doing refresh");
/* We shall continue here, if --force was given */ /* We shall continue here, if --force was given */
} }
while ((table = getTableName(0))) while ((table = getTableName(0)))
...@@ -1176,14 +1074,14 @@ static int dump_selected_tables(char *db, char **table_names, int tables) ...@@ -1176,14 +1074,14 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
dynstr_append(&query, " READ /*!32311 LOCAL */,"); dynstr_append(&query, " READ /*!32311 LOCAL */,");
} }
if (mysql_real_query(sock, query.str, query.length-1)) if (mysql_real_query(sock, query.str, query.length-1))
DBerror(sock, "when doing LOCK TABLES"); DBerror(sock, "when doing LOCK TABLES");
/* We shall countinue here, if --force was given */ /* We shall countinue here, if --force was given */
dynstr_free(&query); dynstr_free(&query);
} }
if (flush_logs) if (flush_logs)
{ {
if (mysql_refresh(sock, REFRESH_LOG)) if (mysql_refresh(sock, REFRESH_LOG))
DBerror(sock, "when doing refresh"); DBerror(sock, "when doing refresh");
/* We shall countinue here, if --force was given */ /* We shall countinue here, if --force was given */
} }
for (; tables > 0 ; tables-- , table_names++) for (; tables > 0 ; tables-- , table_names++)
...@@ -1259,7 +1157,7 @@ int main(int argc, char **argv) ...@@ -1259,7 +1157,7 @@ int main(int argc, char **argv)
else if (argc > 1 && !opt_databases) else if (argc > 1 && !opt_databases)
dump_selected_tables(*argv, (argv + 1), (argc - 1)); dump_selected_tables(*argv, (argv + 1), (argc - 1));
/* One or more databases, all tables */ /* One or more databases, all tables */
else else
dump_databases(argv); dump_databases(argv);
if (opt_first_slave) if (opt_first_slave)
......
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
# #
# This library is free software; you can redistribute it and/or # This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public # modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either # License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version. # version 2 of the License, or (at your option) any later version.
# #
# This library is distributed in the hope that it will be useful, # This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details. # Library General Public License for more details.
# #
# You should have received a copy of the GNU Library General Public # You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the Free # License along with this library; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
...@@ -45,7 +45,7 @@ my_config.h: ../config.h ...@@ -45,7 +45,7 @@ my_config.h: ../config.h
# This should be changed in the source and removed. # This should be changed in the source and removed.
my_global.h: global.h my_global.h: global.h
-$(RM) my_global.h -$(CHMOD) u+w my_global.h
$(CP) global.h my_global.h $(CP) global.h my_global.h
# These files should not be included in distributions since they are # These files should not be included in distributions since they are
......
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
...@@ -116,7 +116,7 @@ static void make_prime_array(uint start) ...@@ -116,7 +116,7 @@ static void make_prime_array(uint start)
uint max_index=(uint) sqrt((double) max_allowed_array); uint max_index=(uint) sqrt((double) max_allowed_array);
bzero((char*) primes,sizeof(primes[0])*max_allowed_array); bzero((char*) primes,sizeof(primes[0])*max_allowed_array);
i=2; i=2;
while (i < max_index) while (i < max_index)
{ {
...@@ -124,7 +124,7 @@ static void make_prime_array(uint start) ...@@ -124,7 +124,7 @@ static void make_prime_array(uint start)
primes[j]=1; primes[j]=1;
while (primes[++i]) ; while (primes[++i]) ;
} }
to=primes; to=primes;
for (i=start ; i <= max_allowed_array ; i++) for (i=start ; i <= max_allowed_array ; i++)
if (!primes[i]) if (!primes[i])
...@@ -451,7 +451,7 @@ static void make_max_length_table(void) ...@@ -451,7 +451,7 @@ static void make_max_length_table(void)
{ {
unique_length[(uchar) symbols[i].name[0]]=length; unique_length[(uchar) symbols[i].name[0]]=length;
unique_length[(uchar) tolower(symbols[i].name[0])]=length; unique_length[(uchar) tolower(symbols[i].name[0])]=length;
} }
} }
for (i=0 ; i < sizeof(sql_functions)/sizeof(SYMBOL) ; i++) for (i=0 ; i < sizeof(sql_functions)/sizeof(SYMBOL) ; i++)
{ {
...@@ -470,9 +470,9 @@ int main(int argc,char **argv) ...@@ -470,9 +470,9 @@ int main(int argc,char **argv)
struct rand_struct rand_st; struct rand_struct rand_st;
static uint best_mod,best_add,best_functype; static uint best_mod,best_add,best_functype;
int error; int error;
MY_INIT(argv[0]); MY_INIT(argv[0]);
start_value=6059524L; best_t1=2194873L; best_t2=4441039L; best_type=4; /* mode=4159 add=8 func_type: 0 */ start_value=7223692L; best_t1=2365832L; best_t2=1560117L; best_type=0; /* mode=4519 add=5 func_type: 0 */
if (get_options(argc,(char **) argv)) if (get_options(argc,(char **) argv))
exit(1); exit(1);
...@@ -540,7 +540,7 @@ printf("/* This code is generated by gen_lex_hash.cc that seeks for a perfect\nh ...@@ -540,7 +540,7 @@ printf("/* This code is generated by gen_lex_hash.cc that seeks for a perfect\nh
printf("/* start_value=%ldL; best_t1=%ldL; best_t2=%ldL; best_type=%d; */ /* mode=%d add=%d type: %d */\n\n", printf("/* start_value=%ldL; best_t1=%ldL; best_t2=%ldL; best_type=%d; */ /* mode=%d add=%d type: %d */\n\n",
start_value, best_t1, best_t2,best_type, start_value, best_t1, best_t2,best_type,
best_mod, best_add, best_functype); best_mod, best_add, best_functype);
printf("inline SYMBOL *get_hash_symbol(const char *s,unsigned int length,bool function)\n\ printf("inline SYMBOL *get_hash_symbol(const char *s,unsigned int length,bool function)\n\
{\n\ {\n\
ulong idx = %lu+char_table[(uchar) *s];\n\ ulong idx = %lu+char_table[(uchar) *s];\n\
......
...@@ -211,6 +211,7 @@ static SYMBOL symbols[] = { ...@@ -211,6 +211,7 @@ static SYMBOL symbols[] = {
{ "MINUTE_SECOND", SYM(MINUTE_SECOND_SYM),0,0}, { "MINUTE_SECOND", SYM(MINUTE_SECOND_SYM),0,0},
{ "MODIFY", SYM(MODIFY_SYM),0,0}, { "MODIFY", SYM(MODIFY_SYM),0,0},
{ "MONTH", SYM(MONTH_SYM),0,0}, { "MONTH", SYM(MONTH_SYM),0,0},
{ "MRG_MYISAM", SYM(MERGE_SYM),0,0},
{ "MYISAM", SYM(MYISAM_SYM),0,0}, { "MYISAM", SYM(MYISAM_SYM),0,0},
{ "NATURAL", SYM(NATURAL),0,0}, { "NATURAL", SYM(NATURAL),0,0},
{ "NATIONAL", SYM(NATIONAL_SYM),0,0}, { "NATIONAL", SYM(NATIONAL_SYM),0,0},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment