~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_parse.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:
18
18
#include "sql_repl.h"
19
19
#include "rpl_filter.h"
20
20
#include "repl_failsafe.h"
21
 
#include <m_ctype.h>
22
 
#include <myisam.h>
23
 
#include <my_dir.h>
 
21
#include <drizzled/drizzled_error_messages.h>
24
22
 
25
23
/**
26
24
  @defgroup Runtime_Environment Runtime Environment
27
25
  @{
28
26
*/
29
27
 
30
 
static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables);
31
28
 
32
29
const char *any_db="*any*";     // Special symbol for check_access
33
30
 
34
 
const LEX_STRING command_name[]={
 
31
const LEX_STRING command_name[COM_END+1]={
35
32
  { C_STRING_WITH_LEN("Sleep") },
36
33
  { C_STRING_WITH_LEN("Quit") },
37
34
  { C_STRING_WITH_LEN("Init DB") },
45
42
  { C_STRING_WITH_LEN("Processlist") },
46
43
  { C_STRING_WITH_LEN("Connect") },
47
44
  { C_STRING_WITH_LEN("Kill") },
48
 
  { C_STRING_WITH_LEN("Debug") },
49
45
  { C_STRING_WITH_LEN("Ping") },
50
46
  { C_STRING_WITH_LEN("Time") },
51
 
  { C_STRING_WITH_LEN("Delayed insert") },
52
47
  { C_STRING_WITH_LEN("Change user") },
53
48
  { C_STRING_WITH_LEN("Binlog Dump") },
54
 
  { C_STRING_WITH_LEN("Table Dump") },
55
49
  { C_STRING_WITH_LEN("Connect Out") },
56
50
  { C_STRING_WITH_LEN("Register Slave") },
57
 
  { C_STRING_WITH_LEN("Prepare") },
58
 
  { C_STRING_WITH_LEN("Execute") },
59
 
  { C_STRING_WITH_LEN("Long Data") },
60
 
  { C_STRING_WITH_LEN("Close stmt") },
61
 
  { C_STRING_WITH_LEN("Reset stmt") },
62
51
  { C_STRING_WITH_LEN("Set option") },
63
 
  { C_STRING_WITH_LEN("Fetch") },
64
52
  { C_STRING_WITH_LEN("Daemon") },
65
53
  { C_STRING_WITH_LEN("Error") }  // Last command number
66
54
};
177
165
 
178
166
void init_update_queries(void)
179
167
{
180
 
  bzero((uchar*) &sql_command_flags, sizeof(sql_command_flags));
 
168
  memset((uchar*) &sql_command_flags, 0, sizeof(sql_command_flags));
181
169
 
182
170
  sql_command_flags[SQLCOM_CREATE_TABLE]=   CF_CHANGES_DATA;
183
171
  sql_command_flags[SQLCOM_CREATE_INDEX]=   CF_CHANGES_DATA;
253
241
  */
254
242
  rw_rdlock(var_mutex);
255
243
  save_client_capabilities= thd->client_capabilities;
256
 
  thd->client_capabilities|= CLIENT_MULTI_QUERIES;
 
244
  thd->client_capabilities|= CLIENT_MULTI_STATEMENTS;
257
245
  /*
258
246
    We don't need return result of execution to client side.
259
247
    To forbid this we should set thd->net.vio to 0.
737
725
    lex_start(thd);
738
726
 
739
727
    status_var_increment(thd->status_var.com_stat[SQLCOM_SHOW_FIELDS]);
740
 
    bzero((char*) &table_list,sizeof(table_list));
 
728
    memset((char*) &table_list, 0, sizeof(table_list));
741
729
    if (thd->copy_db_to(&table_list.db, &table_list.db_length))
742
730
      break;
743
731
    /*
822
810
      SHUTDOWN_DEFAULT is 0. If client is >= 4.1.3, the shutdown level is in
823
811
      packet[0].
824
812
    */
825
 
    enum mysql_enum_shutdown_level level=
826
 
      (enum mysql_enum_shutdown_level) (uchar) packet[0];
 
813
    enum drizzle_enum_shutdown_level level=
 
814
      (enum drizzle_enum_shutdown_level) (uchar) packet[0];
827
815
    if (level == SHUTDOWN_DEFAULT)
828
816
      level= SHUTDOWN_WAIT_ALL_BUFFERS; // soon default will be configurable
829
817
    else if (level != SHUTDOWN_WAIT_ALL_BUFFERS)
1648
1636
    */
1649
1637
    thd->enable_slow_log= opt_log_slow_admin_statements;
1650
1638
 
1651
 
    bzero((char*) &create_info, sizeof(create_info));
 
1639
    memset((char*) &create_info, 0, sizeof(create_info));
1652
1640
    create_info.db_type= 0;
1653
1641
    create_info.row_type= ROW_TYPE_NOT_USED;
1654
1642
    create_info.default_table_charset= thd->variables.collation_database;
1714
1702
 
1715
1703
      { // Rename of table
1716
1704
          TABLE_LIST tmp_table;
1717
 
          bzero((char*) &tmp_table,sizeof(tmp_table));
 
1705
          memset((char*) &tmp_table, 0, sizeof(tmp_table));
1718
1706
          tmp_table.table_name= lex->name.str;
1719
1707
          tmp_table.db=select_lex->db;
1720
1708
      }
2350
2338
    res= mysql_rm_db(thd, lex->name.str, lex->drop_if_exists, 0);
2351
2339
    break;
2352
2340
  }
2353
 
  case SQLCOM_ALTER_DB_UPGRADE:
2354
 
  {
2355
 
    LEX_STRING *db= & lex->name;
2356
 
    if (end_active_trans(thd))
2357
 
    {
2358
 
      res= 1;
2359
 
      break;
2360
 
    }
2361
 
    if (thd->slave_thread && 
2362
 
       (!rpl_filter->db_ok(db->str) ||
2363
 
        !rpl_filter->db_ok_with_wild_table(db->str)))
2364
 
    {
2365
 
      res= 1;
2366
 
      my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0));
2367
 
      break;
2368
 
    }
2369
 
    if (check_db_name(db))
2370
 
    {
2371
 
      my_error(ER_WRONG_DB_NAME, MYF(0), db->str);
2372
 
      break;
2373
 
    }
2374
 
    if (thd->locked_tables || thd->active_transaction())
2375
 
    {
2376
 
      res= 1;
2377
 
      my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
2378
 
                 ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
2379
 
      goto error;
2380
 
    }
2381
 
 
2382
 
    res= mysql_upgrade_db(thd, db);
2383
 
    if (!res)
2384
 
      my_ok(thd);
2385
 
    break;
2386
 
  }
2387
2341
  case SQLCOM_ALTER_DB:
2388
2342
  {
2389
2343
    LEX_STRING *db= &lex->name;
2651
2605
  return(res || thd->is_error());
2652
2606
}
2653
2607
 
2654
 
 
2655
 
static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
 
2608
bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
2656
2609
{
2657
2610
  LEX   *lex= thd->lex;
2658
2611
  select_result *result=lex->result;
2940
2893
  lex->sql_command= SQLCOM_SELECT;
2941
2894
  tmp.str= (char*) var_name;
2942
2895
  tmp.length=strlen(var_name);
2943
 
  bzero((char*) &null_lex_string.str, sizeof(null_lex_string));
 
2896
  memset((char*) &null_lex_string.str, 0, sizeof(null_lex_string));
2944
2897
  /*
2945
2898
    We set the name of Item to @@session.var_name because that then is used
2946
2899
    as the column name in the output.
3134
3087
    */
3135
3088
    if (default_value->type() == Item::FUNC_ITEM && 
3136
3089
        !(((Item_func*)default_value)->functype() == Item_func::NOW_FUNC &&
3137
 
         type == MYSQL_TYPE_TIMESTAMP))
 
3090
         type == DRIZZLE_TYPE_TIMESTAMP))
3138
3091
    {
3139
3092
      my_error(ER_INVALID_DEFAULT, MYF(0), field_name->str);
3140
3093
      return(1);
3156
3109
    }
3157
3110
  }
3158
3111
 
3159
 
  if (on_update_value && type != MYSQL_TYPE_TIMESTAMP)
 
3112
  if (on_update_value && type != DRIZZLE_TYPE_TIMESTAMP)
3160
3113
  {
3161
3114
    my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name->str);
3162
3115
    return(1);
3434
3387
    - 0, otherwise
3435
3388
*/
3436
3389
 
3437
 
TABLE_LIST *st_select_lex::end_nested_join(THD *thd __attribute__((__unused__)))
 
3390
TABLE_LIST *st_select_lex::end_nested_join(THD *thd __attribute__((unused)))
3438
3391
{
3439
3392
  TABLE_LIST *ptr;
3440
3393
  NESTED_JOIN *nested_join;
3925
3878
    This is written such that we have a short lock on LOCK_thread_count
3926
3879
*/
3927
3880
 
3928
 
uint kill_one_thread(THD *thd __attribute__((__unused__)),
3929
 
                     ulong id, bool only_kill_query)
 
3881
static unsigned int
 
3882
kill_one_thread(THD *thd __attribute__((unused)),
 
3883
                ulong id, bool only_kill_query)
3930
3884
{
3931
3885
  THD *tmp;
3932
3886
  uint error=ER_NO_SUCH_THREAD;
4106
4060
*/
4107
4061
 
4108
4062
bool multi_update_precheck(THD *thd,
4109
 
                           TABLE_LIST *tables __attribute__((__unused__)))
 
4063
                           TABLE_LIST *tables __attribute__((unused)))
4110
4064
{
4111
4065
  const char *msg= 0;
4112
4066
  LEX *lex= thd->lex;
4143
4097
*/
4144
4098
 
4145
4099
bool multi_delete_precheck(THD *thd,
4146
 
                           TABLE_LIST *tables __attribute__((__unused__)))
 
4100
                           TABLE_LIST *tables __attribute__((unused)))
4147
4101
{
4148
4102
  SELECT_LEX *select_lex= &thd->lex->select_lex;
4149
4103
  TABLE_LIST **save_query_tables_own_last= thd->lex->query_tables_own_last;
4178
4132
  @return Matching table, NULL otherwise.
4179
4133
*/
4180
4134
 
4181
 
static TABLE_LIST *multi_delete_table_match(LEX *lex __attribute__((__unused__)),
 
4135
static TABLE_LIST *multi_delete_table_match(LEX *lex __attribute__((unused)),
4182
4136
                                            TABLE_LIST *tbl,
4183
4137
                                            TABLE_LIST *tables)
4184
4138
{
4270
4224
    true  Error
4271
4225
*/
4272
4226
 
4273
 
bool update_precheck(THD *thd, TABLE_LIST *tables __attribute__((__unused__)))
 
4227
bool update_precheck(THD *thd, TABLE_LIST *tables __attribute__((unused)))
4274
4228
{
4275
4229
  if (thd->lex->select_lex.item_list.elements != thd->lex->value_list.elements)
4276
4230
  {
4293
4247
    true   error
4294
4248
*/
4295
4249
 
4296
 
bool insert_precheck(THD *thd, TABLE_LIST *tables __attribute__((__unused__)))
 
4250
bool insert_precheck(THD *thd, TABLE_LIST *tables __attribute__((unused)))
4297
4251
{
4298
4252
  LEX *lex= thd->lex;
4299
4253
 
4324
4278
*/
4325
4279
 
4326
4280
bool create_table_precheck(THD *thd,
4327
 
                           TABLE_LIST *tables __attribute__((__unused__)),
 
4281
                           TABLE_LIST *tables __attribute__((unused)),
4328
4282
                           TABLE_LIST *create_table)
4329
4283
{
4330
4284
  LEX *lex= thd->lex;
4535
4489
 
4536
4490
  if (home_dir_len < dir_len)
4537
4491
  {
4538
 
    if (lower_case_file_system)
4539
 
    {
4540
 
      if (!my_strnncoll(character_set_filesystem,
4541
 
                        (const uchar*) conv_path, home_dir_len,
4542
 
                        (const uchar*) mysql_unpacked_real_data_home,
4543
 
                        home_dir_len))
4544
 
        return(1);
4545
 
    }
4546
 
    else if (!memcmp(conv_path, mysql_unpacked_real_data_home, home_dir_len))
 
4492
    if (!my_strnncoll(character_set_filesystem,
 
4493
                      (const uchar*) conv_path, home_dir_len,
 
4494
                      (const uchar*) mysql_unpacked_real_data_home,
 
4495
                      home_dir_len))
4547
4496
      return(1);
4548
4497
  }
4549
4498
  return(0);