diff options
author | serg@serg.mylan <> | 2004-01-30 07:32:35 +0100 |
---|---|---|
committer | serg@serg.mylan <> | 2004-01-30 07:32:35 +0100 |
commit | f0f9e0d7d70f74588cfb11512ee76d7be402f2bf (patch) | |
tree | 242bce729ff2d2dfb92c773ed35af8a6c92cf648 /sql/sql_db.cc | |
parent | 776f4dc0c3dd5bc9470e397d0efb4da3820dadcb (diff) | |
download | mariadb-git-f0f9e0d7d70f74588cfb11512ee76d7be402f2bf.tar.gz |
SHOW CREATE DATABASE moved to sql_show.cc where it belongs
db name is printed with append_identifier for a proper quoting
Diffstat (limited to 'sql/sql_db.cc')
-rw-r--r-- | sql/sql_db.cc | 91 |
1 files changed, 1 insertions, 90 deletions
diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 697859eb264..b9da6ffd3f4 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -25,8 +25,6 @@ #include <direct.h> #endif -#define MY_DB_OPT_FILE "db.opt" - const char *del_exts[]= {".frm", ".BAK", ".TMD",".opt", NullS}; static TYPELIB deletable_extentions= {array_elements(del_exts)-1,"del_exts", del_exts}; @@ -92,7 +90,7 @@ static bool write_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) */ -static bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) +bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) { File file; char buf[256]; @@ -668,90 +666,3 @@ bool mysql_change_db(THD *thd, const char *name) DBUG_RETURN(0); } - -int mysqld_show_create_db(THD *thd, char *dbname, - HA_CREATE_INFO *create_info) -{ - int length; - char path[FN_REFLEN], *to; - uint db_access; - bool found_libchar; - HA_CREATE_INFO create; - uint create_options = create_info ? create_info->options : 0; - Protocol *protocol=thd->protocol; - DBUG_ENTER("mysql_show_create_db"); - - if (check_db_name(dbname)) - { - net_printf(thd,ER_WRONG_DB_NAME, dbname); - DBUG_RETURN(1); - } - -#ifndef NO_EMBEDDED_ACCESS_CHECKS - if (test_all_bits(thd->master_access,DB_ACLS)) - db_access=DB_ACLS; - else - db_access= (acl_get(thd->host,thd->ip, thd->priv_user,dbname,0) | - thd->master_access); - if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname))) - { - net_printf(thd,ER_DBACCESS_DENIED_ERROR, - thd->priv_user, - thd->host_or_ip, - dbname); - mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR), - thd->priv_user, - thd->host_or_ip, - dbname); - DBUG_RETURN(1); - } -#endif - - (void) sprintf(path,"%s/%s",mysql_data_home, dbname); - length=unpack_dirname(path,path); // Convert if not unix - found_libchar= 0; - if (length && path[length-1] == FN_LIBCHAR) - { - found_libchar= 1; - path[length-1]=0; // remove ending '\' - } - if (access(path,F_OK)) - { - net_printf(thd,ER_BAD_DB_ERROR,dbname); - DBUG_RETURN(1); - } - if (found_libchar) - path[length-1]= FN_LIBCHAR; - strmov(path+length, MY_DB_OPT_FILE); - load_db_opt(thd, path, &create); - - List<Item> field_list; - field_list.push_back(new Item_empty_string("Database",NAME_LEN)); - field_list.push_back(new Item_empty_string("Create Database",1024)); - - if (protocol->send_fields(&field_list,1)) - DBUG_RETURN(1); - - protocol->prepare_for_resend(); - protocol->store(dbname, strlen(dbname), system_charset_info); - 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.default_table_charset) - { - int cl= (create.default_table_charset->state & MY_CS_PRIMARY) ? 0 : 1; - to= strxmov(to," /*!40100" - " DEFAULT CHARACTER SET ",create.default_table_charset->csname, - cl ? " COLLATE " : "", - cl ? create.default_table_charset->name : "", - " */",NullS); - } - protocol->store(path, (uint) (to-path), system_charset_info); - - if (protocol->write()) - DBUG_RETURN(1); - send_eof(thd); - DBUG_RETURN(0); -} |