1164
1164
unlock_global_read_lock(session);
1165
1165
session->my_ok();
1167
case SQLCOM_LOCK_TABLES:
1169
We try to take transactional locks if
1170
- only transactional locks are requested (lex->lock_transactional) and
1171
- no non-transactional locks exist (!session->locked_tables).
1173
if (lex->lock_transactional && !session->locked_tables)
1177
All requested locks are transactional and no non-transactional
1180
if ((rc= try_transactional_lock(session, all_tables)) == -1)
1188
Non-transactional locking has been requested or
1189
non-transactional locks exist already or transactional locks are
1190
not supported by all storage engines. Take non-transactional
1195
One or more requested locks are non-transactional and/or
1196
non-transactional locks exist or a storage engine does not support
1197
transactional locks. Check if at least one transactional lock is
1198
requested. If yes, warn about the conversion to non-transactional
1199
locks or abort in strict mode.
1201
if (check_transactional_lock(session, all_tables))
1203
unlock_locked_tables(session);
1204
/* we must end the trasaction first, regardless of anything */
1205
if (! session->endActiveTransaction())
1207
session->in_lock_tables= true;
1208
session->options|= OPTION_TABLE_LOCK;
1210
if (!(res= simple_open_n_lock_tables(session, all_tables)))
1212
session->locked_tables=session->lock;
1214
(void) set_handler_table_locks(session, all_tables, false);
1220
Need to end the current transaction, so the storage engine (InnoDB)
1221
can free its locks if LOCK TABLES locked some tables before finding
1222
that it can't lock a table in its list
1224
ha_autocommit_or_rollback(session, 1);
1225
(void) session->endActiveTransaction();
1226
session->options&= ~(OPTION_TABLE_LOCK);
1228
session->in_lock_tables= false;
1230
1167
case SQLCOM_CREATE_DB:
1934
1871
LEX *lex= session->lex;
1937
return(0); // End of memory
1874
return NULL; // End of memory
1938
1875
alias_str= alias ? alias->str : table->table.str;
1939
1876
if (!test(table_options & TL_OPTION_ALIAS) &&
1940
1877
check_table_name(table->table.str, table->table.length))
1942
1879
my_error(ER_WRONG_TABLE_NAME, MYF(0), table->table.str);
1946
1883
if (table->is_derived_table() == false && table->db.str &&
1947
1884
check_db_name(&table->db))
1949
1886
my_error(ER_WRONG_DB_NAME, MYF(0), table->db.str);
1953
1890
if (!alias) /* Alias is case sensitive */
1957
1894
my_message(ER_DERIVED_MUST_HAVE_ALIAS,
1958
1895
ER(ER_DERIVED_MUST_HAVE_ALIAS), MYF(0));
1961
1898
if (!(alias_str= (char*) session->memdup(alias_str,table->table.length+1)))
1964
1901
if (!(ptr = (TableList *) session->calloc(sizeof(TableList))))
1965
return(0); /* purecov: inspected */
1902
return NULL; /* purecov: inspected */
1966
1903
if (table->db.str)
1968
1905
ptr->is_fqtn= true;
1981
1918
ptr->table_name=table->table.str;
1982
1919
ptr->table_name_length=table->table.length;
1983
1920
ptr->lock_type= lock_type;
1984
ptr->lock_timeout= -1; /* default timeout */
1985
ptr->lock_transactional= 1; /* allow transactional locks */
1986
1921
ptr->updating= test(table_options & TL_OPTION_UPDATING);
1987
1922
ptr->force_index= test(table_options & TL_OPTION_FORCE_INDEX);
1988
1923
ptr->ignore_leaves= test(table_options & TL_OPTION_IGNORE_LEAVES);
2003
1938
my_error(ER_UNKNOWN_TABLE, MYF(0),
2004
1939
ptr->table_name, INFORMATION_SCHEMA_NAME.c_str());
2007
1942
ptr->schema_table_name= ptr->table_name;
2008
1943
ptr->schema_table= schema_table;
2022
1957
!strcmp(ptr->db, tables->db))
2024
1959
my_error(ER_NONUNIQ_TABLE, MYF(0), alias_str); /* purecov: tested */
2025
return(0); /* purecov: tested */
1960
return NULL; /* purecov: tested */
2088
2023
if (!(ptr= (TableList*) session->calloc(ALIGN_SIZE(sizeof(TableList))+
2089
2024
sizeof(nested_join_st))))
2091
2026
nested_join= ptr->nested_join=
2092
2027
((nested_join_st*) ((unsigned char*) ptr + ALIGN_SIZE(sizeof(TableList))));
2166
2101
if (!(ptr= (TableList*) session->calloc(ALIGN_SIZE(sizeof(TableList))+
2167
2102
sizeof(nested_join_st))))
2169
2104
nested_join= ptr->nested_join=
2170
2105
((nested_join_st*) ((unsigned char*) ptr + ALIGN_SIZE(sizeof(TableList))));