Merge
This commit is contained in:
commit
f02cab2853
@ -37,7 +37,7 @@
|
|||||||
** Tõnu Samuel <tonu@please.do.not.remove.this.spam.ee>
|
** Tõnu 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>
|
||||||
@ -600,15 +600,54 @@ 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 (cFlag)
|
||||||
|
sprintf(insert_pat, "INSERT %sINTO %s (", delayed, table_name);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf(insert_pat, "INSERT %sINTO %s VALUES ", delayed, table_name);
|
||||||
|
if (!extended_insert)
|
||||||
|
strcat(insert_pat,"(");
|
||||||
|
}
|
||||||
|
|
||||||
|
strpos=strend(insert_pat);
|
||||||
|
while ((row=mysql_fetch_row(tableRes)))
|
||||||
|
{
|
||||||
|
ulong *lengths=mysql_fetch_lengths(tableRes);
|
||||||
|
if (init)
|
||||||
|
{
|
||||||
|
if (cFlag)
|
||||||
|
strpos=strmov(strpos,", ");
|
||||||
|
}
|
||||||
|
init=1;
|
||||||
|
if (cFlag)
|
||||||
|
strpos=strmov(strpos,quote_name(row[SHOW_FIELDNAME],name_buff));
|
||||||
|
}
|
||||||
|
if (cFlag)
|
||||||
|
{
|
||||||
|
strpos=strmov(strpos,") VALUES ");
|
||||||
|
if (!extended_insert)
|
||||||
|
strpos=strmov(strpos,"(");
|
||||||
|
}
|
||||||
|
numFields = (uint) mysql_num_rows(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];
|
||||||
|
|
||||||
|
sprintf(buff,"show create table %s",table_name);
|
||||||
|
if (mysql_query(sock, buff))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: Can't get CREATE TABLE for table '%s' (%s)\n",
|
||||||
|
my_progname, table, mysql_error(sock));
|
||||||
|
safe_exit(EX_MYSQLERR);
|
||||||
|
DBUG_RETURN(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (path)
|
if (path)
|
||||||
{
|
{
|
||||||
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
|
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
|
||||||
@ -626,151 +665,10 @@ static uint getTableStructure(char *table, char* db)
|
|||||||
fprintf(sql_file, "\n#\n# Table structure for table '%s'\n#\n\n", table);
|
fprintf(sql_file, "\n#\n# Table structure for table '%s'\n#\n\n", table);
|
||||||
if (opt_drop)
|
if (opt_drop)
|
||||||
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name);
|
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",table_name);
|
||||||
fprintf(sql_file, "CREATE TABLE %s (\n", table_name);
|
|
||||||
}
|
|
||||||
if (cFlag)
|
|
||||||
sprintf(insert_pat, "INSERT %sINTO %s (", delayed, table_name);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprintf(insert_pat, "INSERT %sINTO %s VALUES ", delayed, table_name);
|
|
||||||
if (!extended_insert)
|
|
||||||
strcat(insert_pat,"(");
|
|
||||||
}
|
|
||||||
|
|
||||||
strpos=strend(insert_pat);
|
|
||||||
while ((row=mysql_fetch_row(tableRes)))
|
|
||||||
{
|
|
||||||
ulong *lengths=mysql_fetch_lengths(tableRes);
|
|
||||||
if (init)
|
|
||||||
{
|
|
||||||
if (!tFlag)
|
|
||||||
fputs(",\n",sql_file);
|
|
||||||
if (cFlag)
|
|
||||||
strpos=strmov(strpos,", ");
|
|
||||||
}
|
|
||||||
init=1;
|
|
||||||
if (cFlag)
|
|
||||||
strpos=strmov(strpos,quote_name(row[SHOW_FIELDNAME],name_buff));
|
|
||||||
if (!tFlag)
|
|
||||||
{
|
|
||||||
if (opt_keywords)
|
|
||||||
fprintf(sql_file, " %s.%s %s", table_name,
|
|
||||||
quote_name(row[SHOW_FIELDNAME],name_buff), row[SHOW_TYPE]);
|
|
||||||
else
|
|
||||||
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);
|
|
||||||
mysql_free_result(tableRes);
|
|
||||||
if (!tFlag)
|
|
||||||
{
|
|
||||||
char buff[20+FN_REFLEN];
|
|
||||||
uint keynr,primary_key;
|
|
||||||
sprintf(buff,"show keys from %s",table_name);
|
|
||||||
if (mysql_query(sock, buff))
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s: Can't get keys for table '%s' (%s)\n",
|
|
||||||
my_progname, table, mysql_error(sock));
|
|
||||||
if (sql_file != stdout)
|
|
||||||
my_fclose(sql_file, MYF(MY_WME));
|
|
||||||
safe_exit(EX_MYSQLERR);
|
|
||||||
DBUG_RETURN(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
tableRes=mysql_store_result(sock);
|
tableRes=mysql_store_result(sock);
|
||||||
/* Find first which key is primary key */
|
row=mysql_fetch_row(tableRes);
|
||||||
keynr=0;
|
fprintf(sql_file, "%s;\n", row[1]);
|
||||||
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)
|
|
||||||
{
|
|
||||||
if (keynr++)
|
|
||||||
putc(')', sql_file);
|
|
||||||
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
|
|
||||||
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)
|
|
||||||
putc(')', sql_file);
|
|
||||||
fputs("\n)",sql_file);
|
|
||||||
|
|
||||||
/* Get MySQL specific create options */
|
|
||||||
if (create_options)
|
|
||||||
{
|
|
||||||
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 */
|
||||||
|
@ -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
|
||||||
|
@ -472,7 +472,7 @@ int main(int argc,char **argv)
|
|||||||
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);
|
||||||
|
|
||||||
|
@ -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},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user