mirror of
https://github.com/MariaDB/server.git
synced 2025-02-13 17:05:35 +01:00
![Monty](/assets/img/avatar_default.png)
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.
36 lines
1.3 KiB
Text
36 lines
1.3 KiB
Text
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;
|
|
create table t2 (a int, b int, v int as (a+@a) PERSISTENT);
|
|
ERROR HY000: Function or expression '@a' cannot be used in the GENERATED ALWAYS AS clause of `v`
|
|
create table t3_ok (a int, b int, v int as (a+@@error_count));
|
|
create table t3 (a int, b int, v int as (a+@@error_count) PERSISTENT);
|
|
ERROR HY000: Function or expression '@@error_count' cannot be used in the GENERATED ALWAYS AS clause of `v`
|
|
create table t4 (a int, b int, v int as (@a:=a));
|
|
drop table t4;
|
|
create table t4 (a int, b int, v int as (@a:=a) PERSISTENT);
|
|
ERROR HY000: Function or expression '@a' cannot be used in the GENERATED ALWAYS AS clause of `v`
|
|
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;
|
|
a b v
|
|
1 2 0.3333333333333333333
|
|
select * from t8;
|
|
a b v
|
|
1234567890 2 2009-02-14 09:31:30
|
|
disconnect con1;
|
|
connection default;
|
|
set time_zone='+1:00';
|
|
flush tables;
|
|
select * from t1;
|
|
a b v
|
|
1 2 0.3333333330000000000
|
|
select * from t8;
|
|
a b v
|
|
1234567890 2 2009-02-14 00:31:30
|
|
drop table t1, t3_ok, t8;
|