diff options
author | Igor Babaev <igor@askmonty.org> | 2012-02-24 16:50:22 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2012-02-24 16:50:22 -0800 |
commit | 841a74a4d6ebdaa2760ce615e7fc18f57100ee19 (patch) | |
tree | f3a656b6c3262d7a6b0847b0820848ad685480b0 /sql/table.h | |
parent | 567d871ff0c9cbdcaa4f9daa6810760edc901e14 (diff) | |
download | mariadb-git-841a74a4d6ebdaa2760ce615e7fc18f57100ee19.tar.gz |
Fixed LP bug #939009.
The result of materialization of the right part of an IN subquery predicate
is placed into a temporary table. Each row of the materialized table is
distinct. A unique key over all fields of the temporary table is defined and
created. It allows to perform key look-ups into the table.
The table created for a materialized subquery can be accessed by key as
any other table. The function best_access-path search for the best access
to join a table to a given partial join. With some where conditions this
function considers a possibility of a ref_or_null access. If such access
employs the unique key on the temporary table then when estimating
the cost this access the function tries to use the array rec_per_key. Yet,
such array is not built for this unique key. This causes a crash of the server.
Rows returned by the subquery that contain nulls don't have to be placed
into temporary table, as they cannot be match any row produced by the
left part of the subquery predicate. So all fields of the temporary table
can be defined as non-nullable. In this case any ref_or_null access
to the temporary table does not make any sense and it does not make sense
to estimate such an access.
The fix makes sure that the temporary table for a materialized IN subquery
is defined with columns that are all non-nullable. The also ensures that
any row with nulls returned by the subquery is not placed into the
temporary table.
Diffstat (limited to 'sql/table.h')
-rw-r--r-- | sql/table.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sql/table.h b/sql/table.h index 8de71658493..5be5f4b481c 100644 --- a/sql/table.h +++ b/sql/table.h @@ -665,6 +665,9 @@ enum index_hint_type INDEX_HINT_FORCE }; +#define CHECK_ROW_FOR_NULLS_TO_REJECT (1 << 0) +#define REJECT_ROW_DUE_TO_NULL_FIELDS (1 << 1) + struct st_table { st_table() {} /* Remove gcc warning */ @@ -807,6 +810,26 @@ struct st_table { NULL, including columns declared as "not null" (see maybe_null). */ bool null_row; + /* + No rows that contain null values can be placed into this table. + Currently this flag can be set to true only for a temporary table + that used to store the result of materialization of a subquery. + */ + bool no_rows_with_nulls; + /* + This field can contain two bit flags: + CHECK_ROW_FOR_NULLS_TO_REJECT + REJECT_ROW_DUE_TO_NULL_FIELDS + The first flag is set for the dynamic contexts where it is prohibited + to write any null into the table. + The second flag is set only if the first flag is set on. + The informs the outer scope that there was an attept to write null + into a field of the table in the context where it is prohibited. + This flag should be set off as soon as the first flag is set on. + Currently these flags are used only the tables tno_rows_with_nulls set + to true. + */ + uint8 null_catch_flags; /* TODO: Each of the following flags take up 8 bits. They can just as easily |