~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Brian Aker
  • Date: 2008-10-20 03:40:03 UTC
  • mto: (492.3.21 drizzle-clean-code)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: brian@tangent.org-20081020034003-t2dcnl0ayr2ymm8k
THD -> Session rename

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
                                    enum enum_enable_or_disable keys_onoff,
35
35
                                    bool error_if_not_empty);
36
36
 
37
 
static bool prepare_blob_field(THD *thd, Create_field *sql_field);
38
 
static bool check_engine(THD *, const char *, HA_CREATE_INFO *);
 
37
static bool prepare_blob_field(Session *thd, Create_field *sql_field);
 
38
static bool check_engine(Session *, const char *, HA_CREATE_INFO *);
39
39
static int
40
 
mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
 
40
mysql_prepare_create_table(Session *thd, HA_CREATE_INFO *create_info,
41
41
                           Alter_info *alter_info,
42
42
                           bool tmp_table,
43
43
                               uint32_t *db_options,
44
44
                               handler *file, KEY **key_info_buffer,
45
45
                               uint32_t *key_count, int select_field_count);
46
46
static bool
47
 
mysql_prepare_alter_table(THD *thd, Table *table,
 
47
mysql_prepare_alter_table(Session *thd, Table *table,
48
48
                          HA_CREATE_INFO *create_info,
49
49
                          Alter_info *alter_info);
50
50
 
202
202
    path length
203
203
*/
204
204
 
205
 
uint32_t build_tmptable_filename(THD* thd, char *buff, size_t bufflen)
 
205
uint32_t build_tmptable_filename(Session* thd, char *buff, size_t bufflen)
206
206
{
207
207
 
208
208
  char *p= my_stpncpy(buff, mysql_tmpdir, bufflen);
236
236
    file
237
237
*/
238
238
 
239
 
void write_bin_log(THD *thd, bool clear_error,
 
239
void write_bin_log(Session *thd, bool clear_error,
240
240
                   char const *query, ulong query_length)
241
241
{
242
242
  if (mysql_bin_log.is_open())
243
243
  {
244
244
    if (clear_error)
245
245
      thd->clear_error();
246
 
    thd->binlog_query(THD::STMT_QUERY_TYPE,
 
246
    thd->binlog_query(Session::STMT_QUERY_TYPE,
247
247
                      query, query_length, false, false);
248
248
  }
249
249
}
273
273
 
274
274
*/
275
275
 
276
 
bool mysql_rm_table(THD *thd,TableList *tables, bool if_exists, bool drop_temporary)
 
276
bool mysql_rm_table(Session *thd,TableList *tables, bool if_exists, bool drop_temporary)
277
277
{
278
278
  bool error, need_start_waiting= false;
279
279
 
338
338
   -1   Thread was killed
339
339
*/
340
340
 
341
 
int mysql_rm_table_part2(THD *thd, TableList *tables, bool if_exists,
 
341
int mysql_rm_table_part2(Session *thd, TableList *tables, bool if_exists,
342
342
                         bool drop_temporary, bool drop_view,
343
343
                         bool dont_log_query)
344
344
{
874
874
*/
875
875
 
876
876
static int
877
 
mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
 
877
mysql_prepare_create_table(Session *thd, HA_CREATE_INFO *create_info,
878
878
                           Alter_info *alter_info,
879
879
                           bool tmp_table,
880
880
                               uint32_t *db_options,
1611
1611
    apply it to the table.
1612
1612
*/
1613
1613
 
1614
 
static void set_table_default_charset(THD *thd,
 
1614
static void set_table_default_charset(Session *thd,
1615
1615
                                      HA_CREATE_INFO *create_info, char *db)
1616
1616
{
1617
1617
  /*
1643
1643
        In this case the error is given
1644
1644
*/
1645
1645
 
1646
 
static bool prepare_blob_field(THD *thd __attribute__((unused)),
 
1646
static bool prepare_blob_field(Session *thd __attribute__((unused)),
1647
1647
                               Create_field *sql_field)
1648
1648
{
1649
1649
 
1702
1702
    true  error
1703
1703
*/
1704
1704
 
1705
 
bool mysql_create_table_no_lock(THD *thd,
 
1705
bool mysql_create_table_no_lock(Session *thd,
1706
1706
                                const char *db, const char *table_name,
1707
1707
                                HA_CREATE_INFO *create_info,
1708
1708
                                Alter_info *alter_info,
1922
1922
  Database locking aware wrapper for mysql_create_table_no_lock(),
1923
1923
*/
1924
1924
 
1925
 
bool mysql_create_table(THD *thd, const char *db, const char *table_name,
 
1925
bool mysql_create_table(Session *thd, const char *db, const char *table_name,
1926
1926
                        HA_CREATE_INFO *create_info,
1927
1927
                        Alter_info *alter_info,
1928
1928
                        bool internal_tmp_table,
2064
2064
                   const char *old_name, const char *new_db,
2065
2065
                   const char *new_name, uint32_t flags)
2066
2066
{
2067
 
  THD *thd= current_thd;
 
2067
  Session *thd= current_thd;
2068
2068
  char from[FN_REFLEN], to[FN_REFLEN], lc_from[FN_REFLEN], lc_to[FN_REFLEN];
2069
2069
  char *from_base= from, *to_base= to;
2070
2070
  char tmp_name[NAME_LEN+1];
2137
2137
    Win32 clients must also have a WRITE LOCK on the table !
2138
2138
*/
2139
2139
 
2140
 
void wait_while_table_is_used(THD *thd, Table *table,
 
2140
void wait_while_table_is_used(Session *thd, Table *table,
2141
2141
                              enum ha_extra_function function)
2142
2142
{
2143
2143
 
2171
2171
    Win32 clients must also have a WRITE LOCK on the table !
2172
2172
*/
2173
2173
 
2174
 
void close_cached_table(THD *thd, Table *table)
 
2174
void close_cached_table(Session *thd, Table *table)
2175
2175
{
2176
2176
 
2177
2177
  wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
2189
2189
  return;
2190
2190
}
2191
2191
 
2192
 
static int send_check_errmsg(THD *thd, TableList* table,
 
2192
static int send_check_errmsg(Session *thd, TableList* table,
2193
2193
                             const char* operator_name, const char* errmsg)
2194
2194
 
2195
2195
{
2206
2206
}
2207
2207
 
2208
2208
 
2209
 
static int prepare_for_repair(THD *thd, TableList *table_list,
 
2209
static int prepare_for_repair(Session *thd, TableList *table_list,
2210
2210
                              HA_CHECK_OPT *check_opt)
2211
2211
{
2212
2212
  int error= 0;
2354
2354
    true  Message should be sent by caller 
2355
2355
          (admin operation or network communication failed)
2356
2356
*/
2357
 
static bool mysql_admin_table(THD* thd, TableList* tables,
 
2357
static bool mysql_admin_table(Session* thd, TableList* tables,
2358
2358
                              HA_CHECK_OPT* check_opt,
2359
2359
                              const char *operator_name,
2360
2360
                              thr_lock_type lock_type,
2361
2361
                              bool open_for_modify,
2362
2362
                              bool no_warnings_for_error,
2363
2363
                              uint32_t extra_open_options,
2364
 
                              int (*prepare_func)(THD *, TableList *,
 
2364
                              int (*prepare_func)(Session *, TableList *,
2365
2365
                                                  HA_CHECK_OPT *),
2366
 
                              int (handler::*operator_func)(THD *,
 
2366
                              int (handler::*operator_func)(Session *,
2367
2367
                                                            HA_CHECK_OPT *))
2368
2368
{
2369
2369
  TableList *table;
2756
2756
}
2757
2757
 
2758
2758
 
2759
 
bool mysql_repair_table(THD* thd, TableList* tables, HA_CHECK_OPT* check_opt)
 
2759
bool mysql_repair_table(Session* thd, TableList* tables, HA_CHECK_OPT* check_opt)
2760
2760
{
2761
2761
  return(mysql_admin_table(thd, tables, check_opt,
2762
2762
                                "repair", TL_WRITE, 1,
2767
2767
}
2768
2768
 
2769
2769
 
2770
 
bool mysql_optimize_table(THD* thd, TableList* tables, HA_CHECK_OPT* check_opt)
 
2770
bool mysql_optimize_table(Session* thd, TableList* tables, HA_CHECK_OPT* check_opt)
2771
2771
{
2772
2772
  return(mysql_admin_table(thd, tables, check_opt,
2773
2773
                                "optimize", TL_WRITE, 1,0,0,0,
2788
2788
   true  error
2789
2789
*/
2790
2790
 
2791
 
bool mysql_assign_to_keycache(THD* thd, TableList* tables,
 
2791
bool mysql_assign_to_keycache(Session* thd, TableList* tables,
2792
2792
                             LEX_STRING *key_cache_name)
2793
2793
{
2794
2794
  HA_CHECK_OPT check_opt;
2835
2835
    0     ok
2836
2836
*/
2837
2837
 
2838
 
int reassign_keycache_tables(THD *thd __attribute__((unused)),
 
2838
int reassign_keycache_tables(Session *thd __attribute__((unused)),
2839
2839
                             KEY_CACHE *src_cache,
2840
2840
                             KEY_CACHE *dst_cache)
2841
2841
{
2859
2859
    @retval       0                        success
2860
2860
    @retval       1                        error
2861
2861
*/
2862
 
bool mysql_create_like_schema_frm(THD* thd, TableList* schema_table,
 
2862
bool mysql_create_like_schema_frm(Session* thd, TableList* schema_table,
2863
2863
                                  char *dst_path, HA_CREATE_INFO *create_info)
2864
2864
{
2865
2865
  HA_CREATE_INFO local_create_info;
2907
2907
    true  error
2908
2908
*/
2909
2909
 
2910
 
bool mysql_create_like_table(THD* thd, TableList* table, TableList* src_table,
 
2910
bool mysql_create_like_table(Session* thd, TableList* table, TableList* src_table,
2911
2911
                             HA_CREATE_INFO *create_info)
2912
2912
{
2913
2913
  Table *name_lock= 0;
3103
3103
}
3104
3104
 
3105
3105
 
3106
 
bool mysql_analyze_table(THD* thd, TableList* tables, HA_CHECK_OPT* check_opt)
 
3106
bool mysql_analyze_table(Session* thd, TableList* tables, HA_CHECK_OPT* check_opt)
3107
3107
{
3108
3108
  thr_lock_type lock_type = TL_READ_NO_INSERT;
3109
3109
 
3113
3113
}
3114
3114
 
3115
3115
 
3116
 
bool mysql_check_table(THD* thd, TableList* tables,HA_CHECK_OPT* check_opt)
 
3116
bool mysql_check_table(Session* thd, TableList* tables,HA_CHECK_OPT* check_opt)
3117
3117
{
3118
3118
  thr_lock_type lock_type = TL_READ_NO_INSERT;
3119
3119
 
3126
3126
 
3127
3127
/* table_list should contain just one table */
3128
3128
static int
3129
 
mysql_discard_or_import_tablespace(THD *thd,
 
3129
mysql_discard_or_import_tablespace(Session *thd,
3130
3130
                                   TableList *table_list,
3131
3131
                                   enum tablespace_op_type tablespace_op)
3132
3132
{
3252
3252
 
3253
3253
static
3254
3254
bool
3255
 
compare_tables(THD *thd,
 
3255
compare_tables(Session *thd,
3256
3256
               Table *table,
3257
3257
               Alter_info *alter_info,
3258
3258
                           HA_CREATE_INFO *create_info,
3290
3290
      destroy the copy.
3291
3291
    */
3292
3292
    Alter_info tmp_alter_info(*alter_info, thd->mem_root);
3293
 
    THD *thd= table->in_use;
 
3293
    Session *thd= table->in_use;
3294
3294
    uint32_t db_options= 0; /* not used */
3295
3295
    /* Create the prepared information. */
3296
3296
    if (mysql_prepare_create_table(thd, create_info,
3651
3651
  return(error);
3652
3652
}
3653
3653
 
3654
 
int create_temporary_table(THD *thd,
 
3654
int create_temporary_table(Session *thd,
3655
3655
                           Table *table,
3656
3656
                           char *new_db,
3657
3657
                           char *tmp_name,
3743
3743
    The temporary table is created without storing it in any storage engine
3744
3744
    and is opened only to get the table struct and frm file reference.
3745
3745
*/
3746
 
Table *create_altered_table(THD *thd,
 
3746
Table *create_altered_table(Session *thd,
3747
3747
                            Table *table,
3748
3748
                            char *new_db,
3749
3749
                            HA_CREATE_INFO *create_info,
3805
3805
    operation directly, on-line without mysql having to copy
3806
3806
    the table.
3807
3807
*/
3808
 
int mysql_fast_or_online_alter_table(THD *thd,
 
3808
int mysql_fast_or_online_alter_table(Session *thd,
3809
3809
                                     Table *table,
3810
3810
                                     Table *altered_table,
3811
3811
                                     HA_CREATE_INFO *create_info,
3963
3963
*/
3964
3964
 
3965
3965
static bool
3966
 
mysql_prepare_alter_table(THD *thd, Table *table,
 
3966
mysql_prepare_alter_table(Session *thd, Table *table,
3967
3967
                          HA_CREATE_INFO *create_info,
3968
3968
                          Alter_info *alter_info)
3969
3969
{
4373
4373
    true   Error
4374
4374
*/
4375
4375
 
4376
 
bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
 
4376
bool mysql_alter_table(Session *thd,char *new_db, char *new_name,
4377
4377
                       HA_CREATE_INFO *create_info,
4378
4378
                       TableList *table_list,
4379
4379
                       Alter_info *alter_info,
5102
5102
  int error;
5103
5103
  Copy_field *copy,*copy_end;
5104
5104
  ulong found_count,delete_count;
5105
 
  THD *thd= current_thd;
 
5105
  Session *thd= current_thd;
5106
5106
  uint32_t length= 0;
5107
5107
  SORT_FIELD *sortorder;
5108
5108
  READ_RECORD info;
5310
5310
 RETURN
5311
5311
    Like mysql_alter_table().
5312
5312
*/
5313
 
bool mysql_recreate_table(THD *thd, TableList *table_list)
 
5313
bool mysql_recreate_table(Session *thd, TableList *table_list)
5314
5314
{
5315
5315
  HA_CREATE_INFO create_info;
5316
5316
  Alter_info alter_info;
5333
5333
}
5334
5334
 
5335
5335
 
5336
 
bool mysql_checksum_table(THD *thd, TableList *tables,
 
5336
bool mysql_checksum_table(Session *thd, TableList *tables,
5337
5337
                          HA_CHECK_OPT *check_opt)
5338
5338
{
5339
5339
  TableList *table;
5449
5449
  return(true);
5450
5450
}
5451
5451
 
5452
 
static bool check_engine(THD *thd, const char *table_name,
 
5452
static bool check_engine(Session *thd, const char *table_name,
5453
5453
                         HA_CREATE_INFO *create_info)
5454
5454
{
5455
5455
  handlerton **new_engine= &create_info->db_type;