mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 11:01:52 +01:00
ea1b25046c
When updating a table with virtual BLOB columns, the following might happen: - an old record is read from the table, it has no virtual blob values - update_virtual_fields() is run, vcol blob gets its value into the record. But only a pointer to the value is in the table->record[0], the value is in Field_blob::value String (but it doesn't have to be! it can be in the record, if the column is just a copy of another columns: ... b VARCHAR, c BLOB AS (b) ...) - store_record(table,record[1]), old record now is in record[1] - fill_record() prepares new values in record[0], vcol blob is updated, new value replaces the old one in the Field_blob::value - now both record[1] and record[0] have a pointer that points to the *new* vcol blob value. Or record[1] has a pointer to nowhere if Field_blob::value had to realloc. To fix this I have introduced a new String object 'read_value' in Field_blob. When updating virtual columns when a row has been read, the allocated value is stored in 'read_value' instead of 'value'. The allocated blobs for the new row is stored in 'value' as before. I also made, as a safety precaution, the insert delayed handling of blobs more general by using value to store strings instead of the record. This ensures that virtual functions on delayed insert should work in as in the case of normal insert. Triggers are now properly updating the read, write and vcol maps for used fields. This means that we don't need VCOL_UPDATE_FOR_READ_WRITE anymore and there is no need for any other special handling of triggers in update_virtual_fields(). To be able to test how many times virtual fields are invoked, I also relaxed rules that one can use local (@) variables in DEFAULT and non persistent virtual field expressions.
41 lines
1.3 KiB
Text
41 lines
1.3 KiB
Text
#
|
|
# MDEV-7113 difference between check_vcol_func_processor and check_partition_func_processor
|
|
#
|
|
|
|
# the following functions must not be supported in persistent columns.
|
|
# but for compatibility reasons it won't be done in a GA version,
|
|
# we'll only fix most critical issues (inconsistent results, crashes)
|
|
|
|
connect (con1, localhost, root);
|
|
|
|
set lc_time_names = 'es_MX';
|
|
set time_zone='+10:00';
|
|
set div_precision_increment=20;
|
|
|
|
create table t1 (a int, b int, v decimal(20,19) as (a/3));
|
|
create table t2 (a int, b int, v int as (a+@a)); drop table t2;
|
|
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
|
create table t2 (a int, b int, v int as (a+@a) PERSISTENT);
|
|
create table t3_ok (a int, b int, v int as (a+@@error_count));
|
|
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
|
create table t3 (a int, b int, v int as (a+@@error_count) PERSISTENT);
|
|
create table t4 (a int, b int, v int as (@a:=a)); drop table t4;
|
|
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
|
|
create table t4 (a int, b int, v int as (@a:=a) PERSISTENT);
|
|
create table t8 (a int, b int, v varchar(100) as (from_unixtime(a)));
|
|
|
|
insert t1 (a,b) values (1,2);
|
|
insert t8 (a,b) values (1234567890,2);
|
|
|
|
select * from t1;
|
|
select * from t8;
|
|
|
|
disconnect con1;
|
|
connection default;
|
|
set time_zone='+1:00';
|
|
flush tables;
|
|
|
|
select * from t1;
|
|
select * from t8;
|
|
|
|
drop table t1, t3_ok, t8;
|