mirror of
https://github.com/MariaDB/server.git
synced 2026-02-12 05:38:42 +01:00
This patch implements basic IDENTITY feature, with the following
syntax:
<col> GENERATED {ALWAYS AS | BY DEFAULT [ON NULL]} identity_props
The following identity_props are recognized and saved in
the table metadata, but ignored
- START WITH num
- INCREMENT BY num
- MAXVALUE num
- MINVALUE num
- ORDER, NOORDER
- CYCLE, NOCYCLE
- NOMINVALUE, NO MINVALUE
- NOMAXVALUE, NO MAXVALUE
The following identity_props are newly added keywords, however they are
not reserved, i.e. can be used as identifiers, column names, etc. just
as before:
- KEEP
- SCALE
- SHARD
- EXTEND
- NOKEEP
- NOSCALE
- NOSHARD
- NOEXTEND
The patch is designed in minimalistic manner, re-using existing
AUTO_INCREMENT implementation, yet utilizing the default values
evaluation mechanism. As a result, it grants usage of CHECK constraints
and other table expressions: vcols, default values with identity column.
Some notes:
* IDENTITY is evaluated as Field's default_value. Even GENERATED ALWAYS
is considered "default", since the IDENTITY expression is not
determistic.
* However, the GENERATED ALWAYS kind cannot be assigned in DMLs in
STRICT SQL_MODE. That is, the behavior for users is like for other
GENERATED ALWAYS columns.
* It honors INSERT_ID and uses it, which is important for
statement-based replication to work.
* START WITH and INCREMENT BY are ignored. auto_increment_increment and
auto_increment_offset are being followed instead, exactly as for
AUTO_INCREMENT.
* Since IDENTITY behaves as DEFAULT, it cannot follow
NO_AUTO_VALUE_ON_ZERO and should accept user-set keyword with zeroes,
even when it is off, otherwise, `default` will not work.
See test "Zeroes and defaults handling".
* IDENTITY column is always replicated and saved in mariadb-dump, which
is guaranteed by using default_value instead of vcol_expr (vcols, even
stored, are usually not replicated).
* In frm, it is loaded and saved as a default expression. For that,
parse_vcol_expr definition was extended to support things like GENERATED
BY DEFAULT, and even GENERATED ALWAYS. That is, no EXTRA2 header had to
be added.
* AUTO_INCREMENT is not transformed into default_value and works
completely as before.
* IDENTITY should work without the key, and moreover should generate new
values without repetition. If no suitable key is created by user, one is
created implicitly.
* New IDENTITY keyword is added as not-reserved.
handler::update_auto_increment: extract a part checking for explicit
value and zeroes. Invoke only for AUTO_INCREMENT. The rest is contained
in handler::update_auto_increment_impl, which will be invoked by
IDENTITY. Add field argument to use instead of next_number_field.
Note that for IDENTITY, field is not always next_number_field
(Item_default_value can create its own field).
* show_create.cc: changes make it possible to output Field's
default_value as GENERATED BY DEFAULT, instead of DEFAULT (expr).
* Item_field::check_vcol_func_processor: allow default on IDENTITY
fields (they still have AUTO_INCREMENT properties, like unireg_check)
* Item_default_value::tie_field: forbid default(x) exprs.
Item_default_value distinguishes `default` and `default(x)` by the
vcol_assignment_ok flag.
* mysql_prepare_create_table_finalize: make sure there is at least
one key where IDENTITY field goes as a first key_part. If there's none -
create one.
Known issues:
* LAST_INSERT_ID() is not working for now.
Limitations:
* default(identity_column), is disabled, because persistent write is
not properly done in that case.
|
||
|---|---|---|
| .. | ||
| federated_gcol.result | ||
| gcol_archive.result | ||
| gcol_blackhole.result | ||
| gcol_blocked_sql_funcs_innodb.result | ||
| gcol_blocked_sql_funcs_myisam.result | ||
| gcol_bug20746926.result | ||
| gcol_bugfixes.result | ||
| gcol_column_def_options_innodb.result | ||
| gcol_column_def_options_myisam.result | ||
| gcol_csv.result | ||
| gcol_falcon.result | ||
| gcol_handler_innodb.result | ||
| gcol_handler_myisam.result | ||
| gcol_ins_upd_innodb.result | ||
| gcol_ins_upd_myisam.result | ||
| gcol_keys_innodb.result | ||
| gcol_keys_myisam.result | ||
| gcol_memory.result | ||
| gcol_merge.result | ||
| gcol_ndb.result | ||
| gcol_non_stored_columns_innodb.result | ||
| gcol_non_stored_columns_myisam.result | ||
| gcol_partition_innodb.result | ||
| gcol_partition_myisam.result | ||
| gcol_purge.result | ||
| gcol_rejected_innodb.result | ||
| gcol_rollback.result | ||
| gcol_select_innodb.result | ||
| gcol_select_myisam.result | ||
| gcol_supported_sql_funcs_innodb.result | ||
| gcol_supported_sql_funcs_myisam.result | ||
| gcol_trigger_sp_innodb.result | ||
| gcol_trigger_sp_myisam.result | ||
| gcol_update.result | ||
| gcol_view_innodb.result | ||
| gcol_view_myisam.result | ||
| innodb_partition.result | ||
| innodb_prefix_index_check.result | ||
| innodb_virtual_basic.result | ||
| innodb_virtual_blob.result | ||
| innodb_virtual_debug.result | ||
| innodb_virtual_debug_purge.result | ||
| innodb_virtual_fk.result | ||
| innodb_virtual_fk_restart.result | ||
| innodb_virtual_index.result | ||
| innodb_virtual_purge.result | ||
| innodb_virtual_rebuild.result | ||
| innodb_virtual_stats.result | ||
| innodb_wl8114.result | ||
| main_alter_table.result | ||
| main_mysqldump.result | ||
| rpl_gcol.result | ||
| virtual_index_drop.result | ||