mirror of
https://github.com/MariaDB/server.git
synced 2025-10-30 18:36:12 +01:00
normalize_cond() translated `WHERE col` into `WHERE col<>0`
But the opetator "not equal to 0" does not necessarily exists
for all data types.
For example, the query:
SELECT * FROM t1 WHERE inet6col;
was translated to:
SELECT * FROM t1 WHERE inet6col<>0;
which further failed with this error:
ERROR : Illegal parameter data types inet6 and bigint for operation '<>'
This patch changes the translation from `col<>0` to `col IS TRUE`.
So now
SELECT * FROM t1 WHERE inet6col;
gets translated to:
SELECT * FROM t1 WHERE inet6col IS TRUE;
Details:
1. Implementing methods:
- Field_longstr::val_bool()
- Field_string::val_bool()
- Item::val_int_from_val_str()
If the input contains bad data,
these methods raise a better error message:
Truncated incorrect BOOLEAN value
Before the change, the error was:
Truncated incorrect DOUBLE value
2. Fixing normalize_cond() to generate Item_func_istrue/Item_func_isfalse
instances instead of Item_func_ne/Item_func_eq
3. Making Item_func_truth sargable, so it uses the range optimizer.
Implementing the following methods:
- get_mm_tree(), get_mm_leaf(), add_key_fields() in Item_func_truth.
- get_func_mm_tree(), for all Item_func_truth descendants.
4. Implementing the method negated_item() for all Item_func_truth
descendants, so the negated item has a chance to be sargable:
For example,
WHERE NOT col IS NOT FALSE -- this notation is not sargable
is now translated to:
WHERE col IS FALSE -- this notation is sargable
|
||
|---|---|---|
| .. | ||
| audit_null | ||
| auth_dialog | ||
| auth_ed25519 | ||
| auth_examples | ||
| auth_gssapi | ||
| auth_pam | ||
| auth_parsec | ||
| auth_pipe | ||
| auth_socket | ||
| aws_key_management | ||
| cracklib_password_check | ||
| daemon_example | ||
| debug_key_management | ||
| disks | ||
| example_key_management | ||
| feedback | ||
| file_key_management | ||
| fulltext | ||
| func_test | ||
| handler_socket | ||
| hashicorp_key_management | ||
| locale_info | ||
| metadata_lock_info | ||
| password_reuse_check | ||
| provider_bzip2 | ||
| provider_lz4 | ||
| provider_lzma | ||
| provider_lzo | ||
| provider_snappy | ||
| qc_info | ||
| query_response_time | ||
| server_audit | ||
| simple_password_check | ||
| sql_errlog | ||
| test_sql_service | ||
| type_geom | ||
| type_inet | ||
| type_mysql_json | ||
| type_mysql_timestamp | ||
| type_test | ||
| type_uuid | ||
| user_variables | ||
| userstat | ||
| versioning | ||
| win_auth_client | ||
| wsrep_info | ||