• Igor Babaev's avatar
    Fixed the bug mdev-12558. · a287bfa0
    Igor Babaev authored
    In the current code temporary tables we identified and opened before
    other tables. CTE tables are identified in the same procedure as
    regular tables. When a temporary table and a CTE table have the same
    name T any reference to T that is in the scope of the CTE declaration
    must be associated with this CTE. Yet it was not done properly.
    When a reference to T was found in the scope of the declaration
    of CTE T a pointer to this CTE was set in the reference. No check
    that the reference had been already associated with a temporary table
    was done. As a result, if the temporary table T  had been created then
    the reference to T was considered simultaneously as reference to the CTE
    named T and as a reference to the temporary table named T. This
    confused the code that were executed later and caused a crash of
    the server.
    Now when a table reference is associated with a CTE any previous
    association with a temporary table is dropped.
    
    This problem could be easily avoided if the temporary tables were
    not identified prematurely.
    as reference to CTE named T and
    a287bfa0
cte_nonrecursive.result 33.8 KB