1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV 13679 Enabled sequences to be used in DEFAULT

Other changes done to get this to work:
- Added 'internal_tables' to TABLE object to list which sequence tables
  is needed to use the table.
- Mark any expression using DEFAULT() with LEX->default_used.
  This is needed when deciding if we should open internal sequence
  tables when a table is opened (we don't need to open sequence tables
  if the main table is only used with SELECT).
- Create_and_open_temporary_table() can now also open all internal
  sequence tables.
- Added option MYSQL_LOCK_USE_MALLOC to mysql_lock_tables()
  to force memory allocation to be used with malloc instead of
  memroot.
- Added flag to MYSQL_LOCK to remember if allocation was done with
  malloc or memroot (makes code simpler and safer).
- init_one_table_for_prelocking() now takes argument for what lock to
  use instead of it's a routine or something else.
- Renamed prelocking placeholders to make them more understandable as
  they are now used in more code.
- Changed test in check_lock_and_start_stmt() if found table has correct
  locks. The old test didn't work for tables that has lock
  TL_WRITE_ALLOW_WRITE, which is what sequence tables are using.
- Added VCOL_NOT_VIRTUAL option to ensure that sequence functions can't
  be used with virtual columns
- More sequence tests
This commit is contained in:
Monty
2017-12-22 14:56:09 +02:00
parent 5b4c8469d5
commit 9cc7789e90
22 changed files with 591 additions and 51 deletions

View File

@ -4894,7 +4894,8 @@ int create_table_impl(THD *thd,
if (!frm_only && create_info->tmp_table())
{
TABLE *table= thd->create_and_open_tmp_table(create_info->db_type, frm,
path, db, table_name, true);
path, db, table_name, true,
false);
if (!table)
{
@ -9296,7 +9297,7 @@ bool mysql_alter_table(THD *thd, const char *new_db, const char *new_name,
thd->create_and_open_tmp_table(new_db_type, &frm,
alter_ctx.get_tmp_path(),
alter_ctx.new_db, alter_ctx.tmp_name,
false)))
false, true)))
goto err_new_table_cleanup;
/* Set markers for fields in TABLE object for altered table. */
@ -9441,7 +9442,8 @@ bool mysql_alter_table(THD *thd, const char *new_db, const char *new_name,
}
// It's now safe to take the table level lock.
if (lock_tables(thd, table_list, alter_ctx.tables_opened, 0))
if (lock_tables(thd, table_list, alter_ctx.tables_opened,
MYSQL_LOCK_USE_MALLOC))
goto err_new_table_cleanup;
if (ha_create_table(thd, alter_ctx.get_tmp_path(),
@ -9458,7 +9460,7 @@ bool mysql_alter_table(THD *thd, const char *new_db, const char *new_name,
thd->create_and_open_tmp_table(new_db_type, &frm,
alter_ctx.get_tmp_path(),
alter_ctx.new_db, alter_ctx.tmp_name,
true);
true, true);
if (!tmp_table)
{
goto err_new_table_cleanup;
@ -9492,7 +9494,7 @@ bool mysql_alter_table(THD *thd, const char *new_db, const char *new_name,
thd->create_and_open_tmp_table(new_db_type, &frm,
alter_ctx.get_tmp_path(),
alter_ctx.new_db, alter_ctx.tmp_name,
true);
true, true);
}
if (!new_table)
goto err_new_table_cleanup;