• Alexander Barkov's avatar
    MDEV-12668 SRID is not preserved in UNION, VIEW, MIN, MAX · 001f93df
    Alexander Barkov authored
    Fixing the problem that an operation involving a mix of
    two or more GEOMETRY operands did not preserve their SRIDs.
    Now SRIDs are preserved by hybrid functions, subqueries, TVCs, UNIONs, VIEWs.
    
    Incompatible change:
      An attempt to mix two different SRIDs now raises an error.
    
    Details:
    
    - Adding a new class Type_extra_attributes. It's a generic
      container which can store very specific data type attributes.
      For now it can store one uint32 and one const pointer attribute
      (for GEOMETRY's SRID and for ENUM/SET TYPELIB respectively).
      In the future it can grow as needed.
    
      Type_extra_attributes will also be reused soon to store "const Type_zone*"
      pointers for the TIMESTAMP's "WITH TIME ZONE 'tz'" attribute
      (a timestamp data type with a fixed time zone independent from @@time_zone).
      The time zone attribute will be stored in exactly the same way like
      a TYPELIB pointer is stored by ENUM/SET.
    
    - Removing Column_definition_attributes members "interval" and "srid".
      Deriving Column_definition_attributes from the generic attribute container
      Type_extra_attributes instead.
    
    - Adding a new class Type_typelib_attributes, to store
      the TYPELIB of the ENUM and SET data types. Deriving Field_enum from it.
      Removing the member Field_enum::typelib.
    
    - Adding a new class Type_geom_attributes, to store
      the GEOMETRY related attributes. Deriving Field_geom from it.
      Removing the member Field_geom::srid.
    
    - Removing virtual methods:
        Field::get_typelib()
        Type_all_attributes::get_typelib() and
        Type_all_attributes::set_typelib()
      They were very specific to TYPELIB.
      Adding more generic virtual methods instead:
      * Field::type_extra_attributes() - to get extra attributes
      * Type_all_attributes::type_extra_attributes() - to get extra attributes
      * Type_all_attributes::type_extra_attributes_addr() - to set extra attributes
    
    - Removing Item_type_holder::enum_set_typelib. Deriving Item_type_holder
      from the generic attribute container Type_extra_attributes instead.
      This makes it possible for UNION to preserve SRID
      (in addition to preserving TYPELIB).
    
    - Deriving Item_hybrid_func from Type_extra_attributes.
      This makes it possible for hybrid functions (e.g. CASE, COALESCE,
      LEAST, GREATEST etc) to preserve SRID.
    
    - Deriving Item_singlerow_subselect from Type_extra_attributes and
      overriding methods:
      * Item_cache::type_extra_attributes()
      * subselect_single_select_engine::fix_length_and_dec()
      * Item_singlerow_subselect::type_extra_attributes()
      * Item_singlerow_subselect::type_extra_attributes_addr()
      This is needed to preserve SRID in subqueries and TVCs
    
    - Cleanup: fixing the data type of members
      * Binlog_type_info::m_enum_typelib
      * Binlog_type_info::m_set_typelib
      from "TYPELIB *" to "const TYPELIB *"
    001f93df
sql_yacc.yy 597 KB