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

SQL: derived, hiding, error messages

Many related changes.

Note that AS OF condition must always be pushed down to physical tables,
it cannot be applied to a derived or a view. Thus:

* no versioning for internal temporary tables, they can never store
  historical data.
* remove special versioning code from mysql_derived_prepare and
  remove ER_VERS_DERIVED_PROHIBITED - derived can have no historical
  data and cannot be prohibited for system versioning related reasons.
* do not expand select list for derived/views with sys vers fields,
  derived/views can never have historical data.
* remove special invisiblity rules for sys vers fields, they are no
  longer needed after the previous change
* remove system_versioning_hide, it lost the meaning after the
  previous change.
* remove ER_VERS_SYSTEM_TIME_CLASH, it's no "clash", the inner
  AS OF clause always wins.
* non-versioned fields in a historical query

reword the warning text, downgrade to note, don't
replace values with NULLs
This commit is contained in:
Sergei Golubchik
2017-12-30 13:40:36 +01:00
committed by Aleksey Midenkov
parent b06b5c3eab
commit e6a7457653
35 changed files with 98 additions and 451 deletions

View File

@ -7492,31 +7492,6 @@ bool get_key_map_from_key_list(key_map *map, TABLE *table,
}
inline
bool Field::vers_sys_invisible(THD *thd) const
{
DBUG_ASSERT(vers_sys_field());
enum_sql_command sql_command= thd->lex->sql_command;
SELECT_LEX *slex= thd->lex->current_select;
ulong vers_hide= thd->variables.vers_hide;
DBUG_ASSERT(table);
DBUG_ASSERT(table->versioned());
DBUG_ASSERT(table->pos_in_table_list);
TABLE_LIST *tl= table->pos_in_table_list;
vers_system_time_t vers_type= tl->vers_conditions.type;
return (sql_command == SQLCOM_CREATE_VIEW ||
slex->nest_level > 0 ||
vers_hide == VERS_HIDE_FULL ||
(invisible && (
thd->lex->sql_command != SQLCOM_SELECT ||
vers_hide == VERS_HIDE_IMPLICIT ||
(vers_hide == VERS_HIDE_AUTO && (
vers_type == SYSTEM_TIME_UNSPECIFIED ||
vers_type == SYSTEM_TIME_AS_OF)))));
}
/*
Drops in all fields instead of current '*' field
@ -7646,33 +7621,13 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
Field_iterator_natural_join).
But view fields can never be invisible.
*/
if ((field= field_iterator.field()) &&
(field->vers_sys_field() ?
field->vers_sys_invisible(thd) :
field->invisible != VISIBLE))
{
if ((field= field_iterator.field()) && field->invisible != VISIBLE)
continue;
}
Item *item;
if (!(item= field_iterator.create_item(thd)))
DBUG_RETURN(TRUE);
if (item->type() == Item::REF_ITEM)
{
Item *i= item;
while (i->type() == Item::REF_ITEM)
i= *((Item_ref *)i)->ref;
if (i->type() == Item::FIELD_ITEM)
{
Item_field *f= (Item_field *)i;
DBUG_ASSERT(f->field);
if (f->field->vers_sys_field() && f->field->vers_sys_invisible(thd))
continue;
}
}
/* cache the table for the Item_fields inserted by expanding stars */
if (item->type() == Item::FIELD_ITEM && tables->cacheable_table)
((Item_field *)item)->cached_table= tables;