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

Function create_internal_tmp_table

sql/sql_select.cc:23431–23612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23429
23430
23431bool create_internal_tmp_table(TABLE *table, KEY *org_keyinfo,
23432 TMP_ENGINE_COLUMNDEF *start_recinfo,
23433 TMP_ENGINE_COLUMNDEF **recinfo,
23434 ulonglong options)
23435{
23436 int error;
23437 MARIA_KEYDEF *keydefs= 0, *keydef;
23438 MARIA_UNIQUEDEF uniquedef;
23439 TABLE_SHARE *share= table->s;
23440 MARIA_CREATE_INFO create_info;
23441 bool use_unique= false;
23442 DBUG_ENTER("create_internal_tmp_table");
23443
23444 if (share->keys)
23445 { // Get keys for ni_create
23446 HA_KEYSEG *seg;
23447 DBUG_ASSERT(share->key_parts);
23448
23449 if (!(multi_alloc_root(&table->mem_root,
23450 &seg, sizeof(*seg) * share->key_parts,
23451 &keydefs, sizeof(*keydefs) * share->keys,
23452 NullS)))
23453 goto err;
23454 keydef= keydefs;
23455
23456 bzero(seg, sizeof(*seg) * share->key_parts);
23457
23458 /* Note that share->keys may change in the loop ! */
23459 for (KEY *keyinfo= org_keyinfo, *end_keyinfo= keyinfo + share->keys;
23460 keyinfo < end_keyinfo ;
23461 keyinfo++)
23462 {
23463 /*
23464 Note that a similar check is performed during
23465 subquery_types_allow_materialization. See MDEV-7122 for more details as
23466 to why. Whenever this changes, it must be updated there as well, for
23467 all tmp_table engines.
23468 */
23469 if (keyinfo->key_length > table->file->max_key_length() ||
23470 keyinfo->user_defined_key_parts > table->file->max_key_parts() ||
23471 (keyinfo->flags & HA_UNIQUE_HASH))
23472 {
23473 if (!(keyinfo->flags & (HA_NOSAME | HA_UNIQUE_HASH)))
23474 {
23475 my_error(ER_INTERNAL_ERROR, MYF(0),
23476 "Using too big key for internal temp tables");
23477 DBUG_RETURN(1);
23478 }
23479 /* Can't create a key; Make a unique constraint instead of a key */
23480 share->total_keys= --share->keys;
23481 share->key_parts-= keyinfo->user_defined_key_parts;
23482 share->ext_key_parts-= keyinfo->ext_key_parts;
23483 use_unique= true;
23484 bzero((char*) &uniquedef,sizeof(uniquedef));
23485 uniquedef.keysegs= keyinfo->user_defined_key_parts;
23486 uniquedef.seg=seg;
23487 uniquedef.null_are_equal=1;
23488 keyinfo->flags|= HA_UNIQUE_HASH;

Callers 4

mysql_derived_createFunction · 0.85
instantiate_tmp_tableFunction · 0.85

Calls 15

multi_alloc_rootFunction · 0.85
my_errorFunction · 0.85
maria_createFunction · 0.85
alloc_rootFunction · 0.85
mi_createFunction · 0.85
set_createdMethod · 0.80
max_key_lengthMethod · 0.45
max_key_partsMethod · 0.45
charsetMethod · 0.45
pack_lengthMethod · 0.45

Tested by

no test coverage detected