Commit 21066bde authored by peter@mysql.com's avatar peter@mysql.com

Merge mysql.com:/home/pz/mysql/mysql-4.1-root

into mysql.com:/home/pz/mysql/mysql-4.1
parents 8bcace70 8229d282
...@@ -1252,7 +1252,7 @@ static int init_dumping(char *database) ...@@ -1252,7 +1252,7 @@ static int init_dumping(char *database)
MYSQL_ROW row; MYSQL_ROW row;
MYSQL_RES *dbinfo; MYSQL_RES *dbinfo;
sprintf(qbuf,"SHOW CREATE DATABASE %s",database); sprintf(qbuf,"SHOW CREATE DATABASE IF NOT EXISTS %s",database);
if (mysql_query(sock, qbuf) || !(dbinfo = mysql_store_result(sock))) if (mysql_query(sock, qbuf) || !(dbinfo = mysql_store_result(sock)))
{ {
......
...@@ -497,7 +497,7 @@ int mysqld_show_logs(THD *thd); ...@@ -497,7 +497,7 @@ int mysqld_show_logs(THD *thd);
void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild); void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild);
int mysqld_dump_create_info(THD *thd, TABLE *table, int fd = -1); int mysqld_dump_create_info(THD *thd, TABLE *table, int fd = -1);
int mysqld_show_create(THD *thd, TABLE_LIST *table_list); int mysqld_show_create(THD *thd, TABLE_LIST *table_list);
int mysqld_show_create_db(THD *thd, const char *dbname); int mysqld_show_create_db(THD *thd, const char *dbname, HA_CREATE_INFO *create);
void mysqld_list_processes(THD *thd,const char *user,bool verbose); void mysqld_list_processes(THD *thd,const char *user,bool verbose);
int mysqld_show_status(THD *thd); int mysqld_show_status(THD *thd);
......
...@@ -597,7 +597,7 @@ bool mysql_change_db(THD *thd, const char *name) ...@@ -597,7 +597,7 @@ bool mysql_change_db(THD *thd, const char *name)
} }
int mysqld_show_create_db(THD *thd, const char *dbname) int mysqld_show_create_db(THD *thd, const char *dbname, HA_CREATE_INFO *create_info)
{ {
int length; int length;
char path[FN_REFLEN], *to; char path[FN_REFLEN], *to;
...@@ -605,6 +605,8 @@ int mysqld_show_create_db(THD *thd, const char *dbname) ...@@ -605,6 +605,8 @@ int mysqld_show_create_db(THD *thd, const char *dbname)
bool found_libchar; bool found_libchar;
HA_CREATE_INFO create; HA_CREATE_INFO create;
CONVERT *convert=thd->variables.convert_set; CONVERT *convert=thd->variables.convert_set;
uint create_options = create_info ? create_info->options : 0;
DBUG_ENTER("mysql_show_create_db"); DBUG_ENTER("mysql_show_create_db");
if (check_db_name(dbname)) if (check_db_name(dbname))
...@@ -660,12 +662,17 @@ int mysqld_show_create_db(THD *thd, const char *dbname) ...@@ -660,12 +662,17 @@ int mysqld_show_create_db(THD *thd, const char *dbname)
String *packet = &thd->packet; String *packet = &thd->packet;
packet->length(0); packet->length(0);
net_store_data(packet, convert, dbname); net_store_data(packet, convert, dbname);
to= strxmov(path, "CREATE DATABASE `", dbname, "`", NullS); to= strxmov(path, "CREATE DATABASE ", NullS);
if (create_options & HA_LEX_CREATE_IF_NOT_EXISTS)
to= strxmov(to,"/*!32312 IF NOT EXISTS*/ ", NullS);
to=strxmov(to,"`",dbname,"`", NullS);
if (create.table_charset) if (create.table_charset)
to= strxmov(to," DEFAULT CHARACTER SET ", create.table_charset->name, to= strxmov(to," /*!40100 DEFAULT CHARACTER SET ",
NullS); create.table_charset->name,"*/",NullS);
net_store_data(packet, convert, path, (uint) (to-path)); net_store_data(packet, convert, path, (uint) (to-path));
if (my_net_write(&thd->net,(char*) packet->ptr(), packet->length())) if (my_net_write(&thd->net,(char*) packet->ptr(), packet->length()))
DBUG_RETURN(1); DBUG_RETURN(1);
......
...@@ -2465,7 +2465,7 @@ mysql_execute_command(THD *thd) ...@@ -2465,7 +2465,7 @@ mysql_execute_command(THD *thd)
send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION); send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION);
goto error; goto error;
} }
res=mysqld_show_create_db(thd,lex->name); res=mysqld_show_create_db(thd,lex->name,&lex->create_info);
break; break;
} }
case SQLCOM_CREATE_FUNCTION: case SQLCOM_CREATE_FUNCTION:
......
...@@ -2987,7 +2987,13 @@ opt_table_sym: ...@@ -2987,7 +2987,13 @@ opt_table_sym:
/* Show things */ /* Show things */
show: SHOW { Lex->wild=0;} show_param; show: SHOW
{
LEX *lex=Lex;
lex->wild=0;
bzero((char*) &lex->create_info,sizeof(lex->create_info));
}
show_param;
show_param: show_param:
DATABASES wild DATABASES wild
...@@ -3100,10 +3106,11 @@ show_param: ...@@ -3100,10 +3106,11 @@ show_param:
lex->grant_user=$3; lex->grant_user=$3;
lex->grant_user->password.str=NullS; lex->grant_user->password.str=NullS;
} }
| CREATE DATABASE ident | CREATE DATABASE opt_if_not_exists ident
{ {
Lex->sql_command=SQLCOM_SHOW_CREATE_DB; Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
Lex->name=$3.str; Lex->create_info.options=$3;
Lex->name=$4.str;
} }
| CREATE TABLE_SYM table_ident | CREATE TABLE_SYM table_ident
{ {
......
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