MCPcopy Create free account
hub / github.com/MariaDB/server / mysql_prepare_create_table_finalize

Function mysql_prepare_create_table_finalize

sql/sql_table.cc:3257–4115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3255*/
3256
3257static int
3258mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info,
3259 Alter_info *alter_info, uint *db_options,
3260 handler *file, KEY **key_info_buffer,
3261 uint *key_count, int create_table_mode)
3262{
3263 Lex_ident_column key_name;
3264 Create_field *sql_field,*dup_field;
3265 uint field,null_fields;
3266 ulong record_offset= 0;
3267 KEY_PART_INFO *key_part_info;
3268 int field_no,dup_no;
3269 int select_field_pos,auto_increment=0;
3270 List_iterator_fast<Create_field> it(alter_info->create_list);
3271 List_iterator<Create_field> it2(alter_info->create_list);
3272 uint total_uneven_bit_length= 0;
3273 bool tmp_table= create_table_mode == C_ALTER_TABLE;
3274 const bool create_simple= thd->lex->create_simple();
3275 const CHARSET_INFO *scs= system_charset_info;
3276 DBUG_ENTER("mysql_prepare_create_table");
3277
3278 select_field_pos= get_select_field_pos(alter_info, create_info->versioned());
3279 null_fields= 0;
3280 create_info->varchar= 0;
3281
3282 /* Handle creation of sequences */
3283 if (create_info->sequence)
3284 {
3285 if (!(file->ha_table_flags() & HA_CAN_TABLES_WITHOUT_ROLLBACK))
3286 {
3287 my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0), file->table_type(),
3288 SEQUENCE_clex_str.str);
3289 DBUG_RETURN(TRUE);
3290 }
3291
3292 /* The user specified fields: check that structure is ok */
3293 if (check_sequence_fields(thd->lex, &alter_info->create_list,
3294 alter_info->db, alter_info->table_name))
3295 DBUG_RETURN(TRUE);
3296 }
3297
3298
3299 for (field_no=0; (sql_field=it++) ; field_no++)
3300 {
3301 if (!(sql_field->flags & NOT_NULL_FLAG))
3302 null_fields++;
3303
3304 if (sql_field->real_field_type() == MYSQL_TYPE_BIT &&
3305 file->ha_table_flags() & HA_CAN_BIT_FIELD)
3306 total_uneven_bit_length+= sql_field->length & 7;
3307
3308 /* Check if we have used the same field name before */
3309 for (dup_no=0; (dup_field=it2++) != sql_field; dup_no++)
3310 {
3311 if (sql_field->field_name.streq(dup_field->field_name))
3312 {
3313 /*
3314 If this was a CREATE ... SELECT statement, accept a field

Callers 2

mysql_create_frm_imageFunction · 0.85

Calls 15

get_select_field_posFunction · 0.85
my_errorFunction · 0.85
check_sequence_fieldsFunction · 0.85
parse_option_listFunction · 0.85
my_messageFunction · 0.85
init_key_infoFunction · 0.85
check_ident_lengthFunction · 0.85
is_foreign_key_prefixFunction · 0.85
push_warning_printfFunction · 0.85
make_unique_key_nameFunction · 0.85
check_if_keyname_existsFunction · 0.85

Tested by

no test coverage detected