~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/unireg.cc

  • Committer: Brian Aker
  • Date: 2008-10-20 04:28:21 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-20081020042821-rqqdrccuu8195k3y
Second pass of thd cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
                            Create_field *last_field);
41
41
static bool pack_fields(File file, List<Create_field> &create_fields,
42
42
                        ulong data_offset);
43
 
static bool make_empty_rec(Session *thd, int file, enum legacy_db_type table_type,
 
43
static bool make_empty_rec(Session *session, int file, enum legacy_db_type table_type,
44
44
                           uint32_t table_options,
45
45
                           List<Create_field> &create_fields,
46
46
                           uint32_t reclength, ulong data_offset,
58
58
  virtual bool handle_error(uint32_t sql_errno,
59
59
                            const char *message,
60
60
                            DRIZZLE_ERROR::enum_warning_level level,
61
 
                            Session *thd);
 
61
                            Session *session);
62
62
  bool is_handled;
63
63
  Pack_header_error_handler() :is_handled(false) {}
64
64
};
69
69
handle_error(uint32_t sql_errno,
70
70
             const char * /* message */,
71
71
             DRIZZLE_ERROR::enum_warning_level /* level */,
72
 
             Session * /* thd */)
 
72
             Session * /* session */)
73
73
{
74
74
  is_handled= (sql_errno == ER_TOO_MANY_FIELDS);
75
75
  return is_handled;
80
80
 
81
81
  SYNOPSIS
82
82
    mysql_create_frm()
83
 
    thd                 Thread handler
 
83
    session                     Thread handler
84
84
    file_name           Path for file (including database and .frm)
85
85
    db                  Name of database
86
86
    table               Name of table
95
95
    1  error
96
96
*/
97
97
 
98
 
bool mysql_create_frm(Session *thd, const char *file_name,
 
98
bool mysql_create_frm(Session *session, const char *file_name,
99
99
                      const char *db, const char *table,
100
100
                      HA_CREATE_INFO *create_info,
101
101
                      List<Create_field> &create_fields,
127
127
    create_info->null_bits++;
128
128
  data_offset= (create_info->null_bits + 7) / 8;
129
129
 
130
 
  thd->push_internal_handler(&pack_header_error_handler);
 
130
  session->push_internal_handler(&pack_header_error_handler);
131
131
 
132
132
  error= pack_header(forminfo,
133
133
                     create_fields,info_length,
134
134
                     screens, create_info->table_options,
135
135
                     data_offset, db_file);
136
136
 
137
 
  thd->pop_internal_handler();
 
137
  session->pop_internal_handler();
138
138
 
139
139
  if (error)
140
140
  {
210
210
#endif
211
211
  }
212
212
 
213
 
  if ((file=create_frm(thd, file_name, db, table, reclength, fileinfo,
 
213
  if ((file=create_frm(session, file_name, db, table, reclength, fileinfo,
214
214
                       create_info, keys, key_info)) < 0)
215
215
  {
216
216
    free(screen_buff);
239
239
  my_seek(file,
240
240
               (ulong) uint2korr(fileinfo+6)+ (ulong) key_buff_length,
241
241
               MY_SEEK_SET,MYF(0));
242
 
  if (make_empty_rec(thd,file,ha_legacy_type(create_info->db_type),
 
242
  if (make_empty_rec(session,file,ha_legacy_type(create_info->db_type),
243
243
                     create_info->table_options,
244
244
                     create_fields,reclength, data_offset, db_file))
245
245
    goto err;
356
356
 
357
357
  SYNOPSIS
358
358
    rea_create_table()
359
 
    thd                 Thread handler
 
359
    session                     Thread handler
360
360
    path                Name of file (including database, without .frm)
361
361
    db                  Data base name
362
362
    table_name          Table name
371
371
    1  error
372
372
*/
373
373
 
374
 
int rea_create_table(Session *thd, const char *path,
 
374
int rea_create_table(Session *session, const char *path,
375
375
                     const char *db, const char *table_name,
376
376
                     HA_CREATE_INFO *create_info,
377
377
                     List<Create_field> &create_fields,
381
381
 
382
382
  char frm_name[FN_REFLEN];
383
383
  strxmov(frm_name, path, reg_ext, NULL);
384
 
  if (mysql_create_frm(thd, frm_name, db, table_name, create_info,
 
384
  if (mysql_create_frm(session, frm_name, db, table_name, create_info,
385
385
                       create_fields, keys, key_info, file))
386
386
 
387
387
    return(1);
388
388
 
389
389
  // Make sure mysql_create_frm din't remove extension
390
390
  assert(*fn_rext(frm_name));
391
 
  if (thd->variables.keep_files_on_create)
 
391
  if (session->variables.keep_files_on_create)
392
392
    create_info->options|= HA_CREATE_KEEP_FILES;
393
393
  if (file->ha_create_handler_files(path, NULL, CHF_CREATE_FLAG, create_info))
394
394
    goto err_handler;
395
 
  if (!create_info->frm_only && ha_create_table(thd, path, db, table_name,
 
395
  if (!create_info->frm_only && ha_create_table(session, path, db, table_name,
396
396
                                                create_info,0))
397
397
    goto err_handler;
398
398
  return(0);
940
940
 
941
941
/* save an empty record on start of formfile */
942
942
 
943
 
static bool make_empty_rec(Session *thd, File file,
 
943
static bool make_empty_rec(Session *session, File file,
944
944
                           enum legacy_db_type table_type __attribute__((unused)),
945
945
                           uint32_t table_options,
946
946
                           List<Create_field> &create_fields,
955
955
  Table table;
956
956
  TABLE_SHARE share;
957
957
  Create_field *field;
958
 
  enum_check_fields old_count_cuted_fields= thd->count_cuted_fields;
 
958
  enum_check_fields old_count_cuted_fields= session->count_cuted_fields;
959
959
  
960
960
 
961
961
  /* We need a table to generate columns for default values */
968
968
    return(1);
969
969
  }
970
970
 
971
 
  table.in_use= thd;
 
971
  table.in_use= session;
972
972
  table.s->db_low_byte_first= handler->low_byte_first();
973
973
  table.s->blob_ptr_size= portable_sizeof_char_ptr;
974
974
 
981
981
  null_pos= buff;
982
982
 
983
983
  List_iterator<Create_field> it(create_fields);
984
 
  thd->count_cuted_fields= CHECK_FIELD_WARN;    // To find wrong default values
 
984
  session->count_cuted_fields= CHECK_FIELD_WARN;    // To find wrong default values
985
985
  while ((field=it++))
986
986
  {
987
987
    /*
1054
1054
 
1055
1055
err:
1056
1056
  free(buff);
1057
 
  thd->count_cuted_fields= old_count_cuted_fields;
 
1057
  session->count_cuted_fields= old_count_cuted_fields;
1058
1058
  return(error);
1059
1059
} /* make_empty_rec */