~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_db.cc

  • Committer: Monty Taylor
  • Date: 2008-08-02 01:03:15 UTC
  • mto: (236.1.42 codestyle)
  • mto: This revision was merged to the branch mainline in revision 261.
  • Revision ID: monty@inaugust.com-20080802010315-65h5938pymg9d99z
Moved m4 macros to top-level m4 dir, per GNU standards (and where gettext wanted it :)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
 
17
17
/* create and drop of databases */
18
 
#include <drizzled/server_includes.h>
 
18
 
 
19
#include "mysql_priv.h"
19
20
#include <mysys/mysys_err.h>
20
21
#include <mysys/my_dir.h>
21
22
#include "log.h"
34
35
static bool rm_dir_w_symlink(const char *org_path, bool send_error);
35
36
static void mysql_change_db_impl(THD *thd,
36
37
                                 LEX_STRING *new_db_name,
37
 
                                 const CHARSET_INFO * const new_db_charset);
 
38
                                 CHARSET_INFO *new_db_charset);
38
39
 
39
40
 
40
41
/* Database lock hash */
101
102
{
102
103
  char *name;                   /* Database name                  */
103
104
  uint name_length;             /* Database length name           */
104
 
  const CHARSET_INFO *charset;  /* Database default character set */
 
105
  CHARSET_INFO *charset;        /* Database default character set */
105
106
} my_dbopt_t;
106
107
 
107
108
 
280
281
    }
281
282
    
282
283
    opt->name= tmp_name;
283
 
    stpcpy(opt->name, dbname);
 
284
    strmov(opt->name, dbname);
284
285
    opt->name_length= length;
285
286
    
286
287
    if ((error= my_hash_insert(&dboptions, (uchar*) opt)))
377
378
  bool error=1;
378
379
  uint nbytes;
379
380
 
380
 
  memset(create, 0, sizeof(*create));
 
381
  memset((char*) create, 0, sizeof(*create));
381
382
  create->default_table_charset= thd->variables.collation_server;
382
383
 
383
384
  /* Check if options for this database are already in the hash */
505
506
    set, even if the database does not exist.
506
507
*/
507
508
 
508
 
const CHARSET_INFO *get_default_db_collation(THD *thd, const char *db_name)
 
509
CHARSET_INFO *get_default_db_collation(THD *thd, const char *db_name)
509
510
{
510
511
  HA_CREATE_INFO db_info;
511
512
 
599
600
      error= -1;
600
601
      goto exit;
601
602
    }
602
 
    push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
 
603
    push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
603
604
                        ER_DB_CREATE_EXISTS, ER(ER_DB_CREATE_EXISTS), db);
604
605
    if (!silent)
605
606
      my_ok(thd);
837
838
  thd->clear_current_stmt_binlog_row_based();
838
839
 
839
840
  length= build_table_filename(path, sizeof(path), db, "", "", 0);
840
 
  stpcpy(path+length, MY_DB_OPT_FILE);          // Append db option file name
 
841
  strmov(path+length, MY_DB_OPT_FILE);          // Append db option file name
841
842
  del_dbopt(path);                              // Remove dboption hash entry
842
843
  path[length]= '\0';                           // Remove file name
843
844
 
851
852
      goto exit;
852
853
    }
853
854
    else
854
 
      push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
 
855
      push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
855
856
                          ER_DB_DROP_EXISTS, ER(ER_DB_DROP_EXISTS), db);
856
857
  }
857
858
  else
914
915
 
915
916
    if (!(query= (char*) thd->alloc(MAX_DROP_TABLE_Q_LEN)))
916
917
      goto exit; /* not much else we can do */
917
 
    query_pos= query_data_start= stpcpy(query,"drop table ");
 
918
    query_pos= query_data_start= strmov(query,"drop table ");
918
919
    query_end= query + MAX_DROP_TABLE_Q_LEN;
919
920
    db_len= strlen(db);
920
921
 
932
933
      }
933
934
 
934
935
      *query_pos++ = '`';
935
 
      query_pos= stpcpy(query_pos,tbl->table_name);
 
936
      query_pos= strmov(query_pos,tbl->table_name);
936
937
      *query_pos++ = '`';
937
938
      *query_pos++ = ',';
938
939
    }
1010
1011
      if (!table_list)
1011
1012
        goto err;
1012
1013
      table_list->db= (char*) (table_list+1);
1013
 
      table_list->table_name= stpcpy(table_list->db, db) + 1;
 
1014
      table_list->table_name= strmov(table_list->db, db) + 1;
1014
1015
      VOID(filename_to_tablename(file->name, table_list->table_name,
1015
1016
                                 MYSQL50_TABLE_NAME_PREFIX_LENGTH +
1016
1017
                                 strlen(file->name) + 1));
1128
1129
 
1129
1130
static void mysql_change_db_impl(THD *thd,
1130
1131
                                 LEX_STRING *new_db_name,
1131
 
                                 const CHARSET_INFO * const new_db_charset)
 
1132
                                 CHARSET_INFO *new_db_charset)
1132
1133
{
1133
1134
  /* 1. Change current database in THD. */
1134
1135
 
1293
1294
bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
1294
1295
{
1295
1296
  LEX_STRING new_db_file_name;
1296
 
  const CHARSET_INFO *db_default_cl;
 
1297
  CHARSET_INFO *db_default_cl;
1297
1298
 
1298
1299
  if (new_db_name == NULL ||
1299
1300
      new_db_name->length == 0)
1372
1373
    {
1373
1374
      /* Throw a warning and free new_db_file_name. */
1374
1375
 
1375
 
      push_warning_printf(thd, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
 
1376
      push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
1376
1377
                          ER_BAD_DB_ERROR, ER(ER_BAD_DB_ERROR),
1377
1378
                          new_db_file_name.str);
1378
1379