~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/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:
32
32
 
33
33
void open_table_error(TABLE_SHARE *share, int error, int db_errno,
34
34
                      myf errortype, int errarg);
35
 
static int open_binary_frm(THD *thd, TABLE_SHARE *share,
 
35
static int open_binary_frm(Session *thd, TABLE_SHARE *share,
36
36
                           unsigned char *head, File file);
37
37
static void fix_type_pointers(const char ***array, TYPELIB *point_to_type,
38
38
                              uint32_t types, char **names);
189
189
    use key_length= 0 as neither table_cache_key or key_length will be used).
190
190
*/
191
191
 
192
 
void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key,
 
192
void init_tmp_table_share(Session *thd, TABLE_SHARE *share, const char *key,
193
193
                          uint32_t key_length, const char *table_name,
194
194
                          const char *path)
195
195
{
294
294
   6    Unknown .frm version
295
295
*/
296
296
 
297
 
int open_table_def(THD *thd, TABLE_SHARE *share, uint32_t db_flags  __attribute__((unused)))
 
297
int open_table_def(Session *thd, TABLE_SHARE *share, uint32_t db_flags  __attribute__((unused)))
298
298
{
299
299
  int error, table_type;
300
300
  bool error_given;
410
410
  Read data from a binary .frm file from MySQL 3.23 - 5.0 into TABLE_SHARE
411
411
*/
412
412
 
413
 
static int open_binary_frm(THD *thd, TABLE_SHARE *share, unsigned char *head,
 
413
static int open_binary_frm(Session *thd, TABLE_SHARE *share, unsigned char *head,
414
414
                           File file)
415
415
{
416
416
  int error, errarg= 0;
1282
1282
    false                Ok, a partition field array was created
1283
1283
*/
1284
1284
 
1285
 
bool fix_fields_vcol_func(THD *thd,
 
1285
bool fix_fields_vcol_func(Session *thd,
1286
1286
                          Item* func_expr,
1287
1287
                          Table *table,
1288
1288
                          const char *field_name)
1413
1413
    true            Failure
1414
1414
    false           Success
1415
1415
*/
1416
 
bool unpack_vcol_info_from_frm(THD *thd,
 
1416
bool unpack_vcol_info_from_frm(Session *thd,
1417
1417
                               Table *table,
1418
1418
                               Field *field,
1419
1419
                               LEX_STRING *vcol_expr,
1541
1541
   7    Table definition has changed in engine
1542
1542
*/
1543
1543
 
1544
 
int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
 
1544
int open_table_from_share(Session *thd, TABLE_SHARE *share, const char *alias,
1545
1545
                          uint32_t db_stat, uint32_t prgflag, uint32_t ha_open_flags,
1546
1546
                          Table *outparam, open_table_mode open_mode)
1547
1547
{
2271
2271
 
2272
2272
        /* Create a .frm file */
2273
2273
 
2274
 
File create_frm(THD *thd, const char *name, const char *db,
 
2274
File create_frm(Session *thd, const char *name, const char *db,
2275
2275
                const char *table, uint32_t reclength, unsigned char *fileinfo,
2276
2276
                HA_CREATE_INFO *create_info, uint32_t keys, KEY *key_info)
2277
2277
{
2760
2760
  DESCRIPTION
2761
2761
    Create Item_field object for each column in the table and
2762
2762
    initialize it with the corresponding Field. New items are
2763
 
    created in the current THD memory root.
 
2763
    created in the current Session memory root.
2764
2764
 
2765
2765
  RETURN VALUE
2766
2766
    0                    success
3308
3308
    TableList::reinit_before_use()
3309
3309
*/
3310
3310
 
3311
 
void TableList::reinit_before_use(THD *thd)
 
3311
void TableList::reinit_before_use(Session *thd)
3312
3312
{
3313
3313
  /*
3314
3314
    Reset old pointers to TABLEs: they are not valid since the tables
3547
3547
  true       table
3548
3548
*/
3549
3549
 
3550
 
bool mysql_frm_type(THD *thd __attribute__((unused)),
 
3550
bool mysql_frm_type(Session *thd __attribute__((unused)),
3551
3551
                    char *path, enum legacy_db_type *dbt)
3552
3552
{
3553
3553
  File file;
3584
3584
 
3585
3585
 
3586
3586
/* Prototypes */
3587
 
void free_tmp_table(THD *thd, Table *entry);
 
3587
void free_tmp_table(Session *thd, Table *entry);
3588
3588
 
3589
3589
/**
3590
3590
  Create field for temporary table from given field.
3608
3608
    new_created field
3609
3609
*/
3610
3610
 
3611
 
Field *create_tmp_field_from_field(THD *thd, Field *org_field,
 
3611
Field *create_tmp_field_from_field(Session *thd, Field *org_field,
3612
3612
                                   const char *name, Table *table,
3613
3613
                                   Item_field *item, uint32_t convert_blob_length)
3614
3614
{
3670
3670
    new_created field
3671
3671
*/
3672
3672
 
3673
 
static Field *create_tmp_field_from_item(THD *thd __attribute__((unused)),
 
3673
static Field *create_tmp_field_from_item(Session *thd __attribute__((unused)),
3674
3674
                                         Item *item, Table *table,
3675
3675
                                         Item ***copy_func, bool modify_item,
3676
3676
                                         uint32_t convert_blob_length)
3794
3794
    new_created field
3795
3795
*/
3796
3796
 
3797
 
Field *create_tmp_field_for_schema(THD *thd __attribute__((unused)),
 
3797
Field *create_tmp_field_for_schema(Session *thd __attribute__((unused)),
3798
3798
                                   Item *item, Table *table)
3799
3799
{
3800
3800
  if (item->field_type() == DRIZZLE_TYPE_VARCHAR)
3844
3844
    new_created field
3845
3845
*/
3846
3846
 
3847
 
Field *create_tmp_field(THD *thd, Table *table,Item *item, Item::Type type,
 
3847
Field *create_tmp_field(Session *thd, Table *table,Item *item, Item::Type type,
3848
3848
                        Item ***copy_func, Field **from_field,
3849
3849
                        Field **default_field,
3850
3850
                        bool group, bool modify_item,
3950
3950
  corresponding Item_field items, pointing at the fields in the
3951
3951
  temporary table, unless this was prohibited by true
3952
3952
  value of argument save_sum_fields. The Item_field objects
3953
 
  are created in THD memory root.
 
3953
  are created in Session memory root.
3954
3954
 
3955
3955
  @param thd                  thread handle
3956
3956
  @param param                a description used as input to create the table
3970
3970
#define RATIO_TO_PACK_ROWS             2
3971
3971
 
3972
3972
Table *
3973
 
create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
 
3973
create_tmp_table(Session *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
3974
3974
                 order_st *group, bool distinct, bool save_sum_fields,
3975
3975
                 uint64_t select_options, ha_rows rows_limit,
3976
3976
                 char *table_alias)
4083
4083
      bitmap_lock_clear_bit(&temp_pool, temp_pool_slot);
4084
4084
    return(NULL);                               /* purecov: inspected */
4085
4085
  }
4086
 
  /* Copy_field belongs to TMP_TABLE_PARAM, allocate it in THD mem_root */
 
4086
  /* Copy_field belongs to TMP_TABLE_PARAM, allocate it in Session mem_root */
4087
4087
  if (!(param->copy_field= copy= new (thd->mem_root) Copy_field[field_count]))
4088
4088
  {
4089
4089
    if (temp_pool_slot != MY_BIT_NONE)
4654
4654
    The sole purpose of this Table object is to use the power of Field
4655
4655
    class to read/write data to/from table->record[0]. Then one can store
4656
4656
    the record in any container (RB tree, hash, etc).
4657
 
    The table is created in THD mem_root, so are the table's fields.
 
4657
    The table is created in Session mem_root, so are the table's fields.
4658
4658
    Consequently, if you don't BLOB fields, you don't need to free it.
4659
4659
 
4660
4660
  @param thd         connection handle
4664
4664
    0 if out of memory, Table object in case of success
4665
4665
*/
4666
4666
 
4667
 
Table *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list)
 
4667
Table *create_virtual_tmp_table(Session *thd, List<Create_field> &field_list)
4668
4668
{
4669
4669
  uint32_t field_count= field_list.elements;
4670
4670
  uint32_t blob_count= 0;
4922
4922
}
4923
4923
 
4924
4924
 
4925
 
void Table::free_tmp_table(THD *thd)
 
4925
void Table::free_tmp_table(Session *thd)
4926
4926
{
4927
4927
  MEM_ROOT own_root= mem_root;
4928
4928
  const char *save_proc_info;
4960
4960
  to this.
4961
4961
*/
4962
4962
 
4963
 
bool create_myisam_from_heap(THD *thd, Table *table,
 
4963
bool create_myisam_from_heap(Session *thd, Table *table,
4964
4964
                             MI_COLUMNDEF *start_recinfo,
4965
4965
                             MI_COLUMNDEF **recinfo, 
4966
4966
                             int error, bool ignore_last_dupp_key_error)