From 9c7528b89cc9a2eeeac1791e87fe7b539fa211ba Mon Sep 17 00:00:00 2001 From: "Ariznawl@163.com" Date: Tue, 4 Aug 2026 16:15:20 +0800 Subject: [PATCH] test: add Data Branch issue BVT coverage --- .../issue_26071_quoted_primary_keys.result | 90 ++++++++ .../edge/issue_26071_quoted_primary_keys.sql | 67 ++++++ .../issue_26073_backslash_metadata.result | 69 +++++++ .../edge/issue_26073_backslash_metadata.sql | 61 ++++++ .../edge/issue_26074_bool_bit_pick.result | 131 ++++++++++++ .../branch/edge/issue_26074_bool_bit_pick.sql | 109 ++++++++++ ...issue_26078_reversed_snapshot_range.result | 62 ++++++ .../issue_26078_reversed_snapshot_range.sql | 55 +++++ .../edge/issue_26081_hashmap_bulk.result | 64 ++++++ .../branch/edge/issue_26081_hashmap_bulk.sql | 62 ++++++ .../edge/issue_26114_target_quota.result | 194 ++++++++++++++++++ .../branch/edge/issue_26114_target_quota.sql | 119 +++++++++++ .../edge/issue_26118_hash_identifiers.result | 94 +++++++++ .../edge/issue_26118_hash_identifiers.sql | 86 ++++++++ .../edge/issue_26120_snapshot_identity.result | 145 +++++++++++++ .../edge/issue_26120_snapshot_identity.sql | 132 ++++++++++++ .../edge/issue_26121_internal_names.result | 121 +++++++++++ .../edge/issue_26121_internal_names.sql | 114 ++++++++++ .../issue_26127_embedded_backticks.result | 93 +++++++++ .../edge/issue_26127_embedded_backticks.sql | 85 ++++++++ .../branch/edge/issue_26128_output.result | 72 +++++++ .../branch/edge/issue_26128_output.sql | 50 +++++ .../branch/edge/issue_26136_vectors.result | 79 +++++++ .../branch/edge/issue_26136_vectors.sql | 69 +++++++ .../edge/issue_26205_deep_lineage.result | 183 +++++++++++++++++ .../branch/edge/issue_26205_deep_lineage.sql | 152 ++++++++++++++ 26 files changed, 2558 insertions(+) create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26071_quoted_primary_keys.result create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26071_quoted_primary_keys.sql create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26073_backslash_metadata.result create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26073_backslash_metadata.sql create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26074_bool_bit_pick.result create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26074_bool_bit_pick.sql create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26078_reversed_snapshot_range.result create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26078_reversed_snapshot_range.sql create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26081_hashmap_bulk.result create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26081_hashmap_bulk.sql create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26114_target_quota.result create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26114_target_quota.sql create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26118_hash_identifiers.result create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26118_hash_identifiers.sql create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26120_snapshot_identity.result create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26120_snapshot_identity.sql create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26121_internal_names.result create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26121_internal_names.sql create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26127_embedded_backticks.result create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26127_embedded_backticks.sql create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26128_output.result create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26128_output.sql create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26136_vectors.result create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26136_vectors.sql create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26205_deep_lineage.result create mode 100644 test/distributed/cases/git4data/branch/edge/issue_26205_deep_lineage.sql diff --git a/test/distributed/cases/git4data/branch/edge/issue_26071_quoted_primary_keys.result b/test/distributed/cases/git4data/branch/edge/issue_26071_quoted_primary_keys.result new file mode 100644 index 0000000000000..5e213bda30c94 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26071_quoted_primary_keys.result @@ -0,0 +1,90 @@ +drop database if exists bvt_issue_26071; +create database bvt_issue_26071; +use bvt_issue_26071; +create table control_base(id int primary key, value int); +insert into control_base values (1, 10), (2, 20); +data branch create table control_src from control_base; +data branch create table control_dst from control_base; +update control_src set value = 200 where id = 2; +data branch pick control_src into control_dst keys(2); +create table quoted_base(`order` int primary key, value int); +insert into quoted_base values (1, 10), (2, 20); +data branch create table quoted_src from quoted_base; +data branch create table quoted_left from quoted_base; +data branch create table quoted_pick from quoted_base; +data branch create table quoted_merge from quoted_base; +delete from quoted_src where `order` = 1; +update quoted_src set value = 200 where `order` = 2; +data branch diff quoted_src against quoted_left output summary; +➤ metric[12,0,0] ¦ quoted_src[-5,0,0] ¦ quoted_left[-5,0,0] 𝄀 +INSERTED ¦ 0 ¦ 0 𝄀 +DELETED ¦ 1 ¦ 0 𝄀 +UPDATED ¦ 1 ¦ 0 +data branch diff quoted_src against quoted_left output as quoted_diff; +➤ TABLE CREATED[12,0,0] 𝄀 +`bvt_issue_26071`.`quoted_diff` +select __mo_diff_source, __mo_diff_flag, `order`, value +from quoted_diff order by `order`; +➤ __mo_diff_source[12,-1,0] ¦ __mo_diff_flag[12,-1,0] ¦ order[4,32,0] ¦ value[4,32,0] 𝄀 +quoted_src ¦ DELETE ¦ 1 ¦ 10 𝄀 +quoted_src ¦ UPDATE ¦ 2 ¦ 200 +data branch pick quoted_src into quoted_pick keys(1, 2); +data branch merge quoted_src into quoted_merge; +create table composite_base( +`select` int, +`key-name` varchar(10), +value int, +primary key(`select`, `key-name`) +); +insert into composite_base values +(1, 'a', 10), +(2, 'b', 20), +(3, 'c', 30); +data branch create table composite_left from composite_base; +data branch create table composite_src from composite_base; +data branch create table composite_pick from composite_base; +data branch create table composite_merge from composite_base; +update composite_src set value = 200 +where `select` = 2 and `key-name` = 'b'; +delete from composite_src +where `select` = 3 and `key-name` = 'c'; +insert into composite_src values (4, 'd', 40); +data branch diff composite_src against composite_left output summary; +➤ metric[12,0,0] ¦ composite_src[-5,0,0] ¦ composite_left[-5,0,0] 𝄀 +INSERTED ¦ 1 ¦ 0 𝄀 +DELETED ¦ 1 ¦ 0 𝄀 +UPDATED ¦ 1 ¦ 0 +data branch diff composite_src against composite_left output as composite_diff; +➤ TABLE CREATED[12,0,0] 𝄀 +`bvt_issue_26071`.`composite_diff` +select __mo_diff_source, __mo_diff_flag, `select`, `key-name`, value +from composite_diff order by `select`, `key-name`; +➤ __mo_diff_source[12,-1,0] ¦ __mo_diff_flag[12,-1,0] ¦ select[4,32,0] ¦ key-name[12,-1,0] ¦ value[4,32,0] 𝄀 +composite_src ¦ UPDATE ¦ 2 ¦ b ¦ 200 𝄀 +composite_src ¦ DELETE ¦ 3 ¦ c ¦ 30 𝄀 +composite_src ¦ INSERT ¦ 4 ¦ d ¦ 40 +data branch pick composite_src into composite_pick +keys((2, 'b'), (3, 'c')); +data branch merge composite_src into composite_merge; +select id, value from control_dst order by id; +➤ id[4,32,0] ¦ value[4,32,0] 𝄀 +1 ¦ 10 𝄀 +2 ¦ 200 +select `order`, value from quoted_pick order by `order`; +➤ order[4,32,0] ¦ value[4,32,0] 𝄀 +2 ¦ 200 +select `order`, value from quoted_merge order by `order`; +➤ order[4,32,0] ¦ value[4,32,0] 𝄀 +2 ¦ 200 +select `select`, `key-name`, value +from composite_pick order by `select`, `key-name`; +➤ select[4,32,0] ¦ key-name[12,-1,0] ¦ value[4,32,0] 𝄀 +1 ¦ a ¦ 10 𝄀 +2 ¦ b ¦ 200 +select `select`, `key-name`, value +from composite_merge order by `select`, `key-name`; +➤ select[4,32,0] ¦ key-name[12,-1,0] ¦ value[4,32,0] 𝄀 +1 ¦ a ¦ 10 𝄀 +2 ¦ b ¦ 200 𝄀 +4 ¦ d ¦ 40 +drop database bvt_issue_26071; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26071_quoted_primary_keys.sql b/test/distributed/cases/git4data/branch/edge/issue_26071_quoted_primary_keys.sql new file mode 100644 index 0000000000000..840305464887e --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26071_quoted_primary_keys.sql @@ -0,0 +1,67 @@ +-- Regression for issue #26071. +-- DATA BRANCH must quote user-defined primary-key columns in LCA reconstruction. +drop database if exists bvt_issue_26071; +create database bvt_issue_26071; +use bvt_issue_26071; + +-- Ordinary identifier control. +create table control_base(id int primary key, value int); +insert into control_base values (1, 10), (2, 20); +data branch create table control_src from control_base; +data branch create table control_dst from control_base; +update control_src set value = 200 where id = 2; +data branch pick control_src into control_dst keys(2); + +-- Reserved-word single primary key. Exercise the LCA delete path in PICK/MERGE. +create table quoted_base(`order` int primary key, value int); +insert into quoted_base values (1, 10), (2, 20); +data branch create table quoted_src from quoted_base; +data branch create table quoted_left from quoted_base; +data branch create table quoted_pick from quoted_base; +data branch create table quoted_merge from quoted_base; +delete from quoted_src where `order` = 1; +update quoted_src set value = 200 where `order` = 2; +data branch diff quoted_src against quoted_left output summary; +data branch diff quoted_src against quoted_left output as quoted_diff; +select __mo_diff_source, __mo_diff_flag, `order`, value +from quoted_diff order by `order`; +data branch pick quoted_src into quoted_pick keys(1, 2); +data branch merge quoted_src into quoted_merge; + +-- Reserved-word and punctuation composite primary key. +create table composite_base( + `select` int, + `key-name` varchar(10), + value int, + primary key(`select`, `key-name`) +); +insert into composite_base values + (1, 'a', 10), + (2, 'b', 20), + (3, 'c', 30); +data branch create table composite_left from composite_base; +data branch create table composite_src from composite_base; +data branch create table composite_pick from composite_base; +data branch create table composite_merge from composite_base; +update composite_src set value = 200 +where `select` = 2 and `key-name` = 'b'; +delete from composite_src +where `select` = 3 and `key-name` = 'c'; +insert into composite_src values (4, 'd', 40); +data branch diff composite_src against composite_left output summary; +data branch diff composite_src against composite_left output as composite_diff; +select __mo_diff_source, __mo_diff_flag, `select`, `key-name`, value +from composite_diff order by `select`, `key-name`; +data branch pick composite_src into composite_pick +keys((2, 'b'), (3, 'c')); +data branch merge composite_src into composite_merge; + +select id, value from control_dst order by id; +select `order`, value from quoted_pick order by `order`; +select `order`, value from quoted_merge order by `order`; +select `select`, `key-name`, value +from composite_pick order by `select`, `key-name`; +select `select`, `key-name`, value +from composite_merge order by `select`, `key-name`; + +drop database bvt_issue_26071; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26073_backslash_metadata.result b/test/distributed/cases/git4data/branch/edge/issue_26073_backslash_metadata.result new file mode 100644 index 0000000000000..3db1969d9461f --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26073_backslash_metadata.result @@ -0,0 +1,69 @@ +drop database if exists `bvt\issue_26073`; +create database `bvt\issue_26073`; +create table `bvt\issue_26073`.normal_src( +id int primary key, +note varchar(30) +); +insert into `bvt\issue_26073`.normal_src values (1, 'normal'); +data branch create table `bvt\issue_26073`.normal_dst +from `bvt\issue_26073`.normal_src; +create table `bvt\issue_26073`.`src\t`( +id int primary key, +note varchar(30) +); +insert into `bvt\issue_26073`.`src\t` values (1, 'source'); +data branch create table `bvt\issue_26073`.`dst\t` +from `bvt\issue_26073`.`src\t`; +set @dst_id = ( +select rel_id +from mo_catalog.mo_tables +where account_id = 0 +and reldatabase = 'bvt\\issue_26073' +and relname = 'dst\\t' +); +set @branch_snapshot = concat('__mo_branch_', cast(@dst_id as varchar)); +insert into `bvt\issue_26073`.`dst\t` values (2, 'branch-only'); +select id, note from `bvt\issue_26073`.normal_dst order by id; +➤ id[4,32,0] ¦ note[12,-1,0] 𝄀 +1 ¦ normal +select id, note from `bvt\issue_26073`.`dst\t` order by id; +➤ id[4,32,0] ¦ note[12,-1,0] 𝄀 +1 ¦ source 𝄀 +2 ¦ branch-only +select hex(dst.reldatabase) as catalog_database_hex, +hex(s.database_name) as snapshot_database_hex, +hex(src.relname) as catalog_table_hex, +hex(s.table_name) as snapshot_table_hex, +s.obj_id = src.rel_id as source_object_matches +from mo_catalog.mo_snapshots s +join mo_catalog.mo_tables dst +on s.sname = concat('__mo_branch_', cast(dst.rel_id as varchar)) +join mo_catalog.mo_tables src +on src.account_id = dst.account_id +and src.reldatabase = dst.reldatabase +and src.relname = 'src\\t' +where s.kind = 'branch' +and dst.account_id = 0 +and dst.reldatabase = 'bvt\\issue_26073' +and dst.relname = 'dst\\t'; +➤ catalog_database_hex[12,-1,0] ¦ snapshot_database_hex[12,-1,0] ¦ catalog_table_hex[12,-1,0] ¦ snapshot_table_hex[12,-1,0] ¦ source_object_matches[-7,1,0] 𝄀 +6276745C69737375655F3236303733 ¦ 6276745C69737375655F3236303733 ¦ 7372635C74 ¦ 7372635C74 ¦ 1 +data branch diff `bvt\issue_26073`.`dst\t` +against `bvt\issue_26073`.`src\t` output summary; +➤ metric[12,0,0] ¦ bvt\issue_26073.dst\t[-5,0,0] ¦ bvt\issue_26073.src\t[-5,0,0] 𝄀 +INSERTED ¦ 1 ¦ 0 𝄀 +DELETED ¦ 0 ¦ 0 𝄀 +UPDATED ¦ 0 ¦ 0 +drop table `bvt\issue_26073`.`dst\t`; +select count(*) as protection_rows_after_drop +from mo_catalog.mo_snapshots where sname = @branch_snapshot; +➤ protection_rows_after_drop[-5,64,0] 𝄀 +0 +select count(*) as metadata_rows_after_drop +from mo_catalog.mo_branch_metadata where table_id = @dst_id; +➤ metadata_rows_after_drop[-5,64,0] 𝄀 +1 +select id, note from `bvt\issue_26073`.`src\t` order by id; +➤ id[4,32,0] ¦ note[12,-1,0] 𝄀 +1 ¦ source +drop database `bvt\issue_26073`; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26073_backslash_metadata.sql b/test/distributed/cases/git4data/branch/edge/issue_26073_backslash_metadata.sql new file mode 100644 index 0000000000000..866e73267c42f --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26073_backslash_metadata.sql @@ -0,0 +1,61 @@ +-- Regression for issue #26073. +-- Branch metadata must preserve every backslash byte in quoted identifiers. +drop database if exists `bvt\issue_26073`; +create database `bvt\issue_26073`; + +create table `bvt\issue_26073`.normal_src( + id int primary key, + note varchar(30) +); +insert into `bvt\issue_26073`.normal_src values (1, 'normal'); +data branch create table `bvt\issue_26073`.normal_dst +from `bvt\issue_26073`.normal_src; + +create table `bvt\issue_26073`.`src\t`( + id int primary key, + note varchar(30) +); +insert into `bvt\issue_26073`.`src\t` values (1, 'source'); +data branch create table `bvt\issue_26073`.`dst\t` +from `bvt\issue_26073`.`src\t`; +set @dst_id = ( + select rel_id + from mo_catalog.mo_tables + where account_id = 0 + and reldatabase = 'bvt\\issue_26073' + and relname = 'dst\\t' +); +set @branch_snapshot = concat('__mo_branch_', cast(@dst_id as varchar)); +insert into `bvt\issue_26073`.`dst\t` values (2, 'branch-only'); + +select id, note from `bvt\issue_26073`.normal_dst order by id; +select id, note from `bvt\issue_26073`.`dst\t` order by id; + +select hex(dst.reldatabase) as catalog_database_hex, + hex(s.database_name) as snapshot_database_hex, + hex(src.relname) as catalog_table_hex, + hex(s.table_name) as snapshot_table_hex, + s.obj_id = src.rel_id as source_object_matches +from mo_catalog.mo_snapshots s +join mo_catalog.mo_tables dst + on s.sname = concat('__mo_branch_', cast(dst.rel_id as varchar)) +join mo_catalog.mo_tables src + on src.account_id = dst.account_id + and src.reldatabase = dst.reldatabase + and src.relname = 'src\\t' +where s.kind = 'branch' + and dst.account_id = 0 + and dst.reldatabase = 'bvt\\issue_26073' + and dst.relname = 'dst\\t'; + +data branch diff `bvt\issue_26073`.`dst\t` +against `bvt\issue_26073`.`src\t` output summary; + +drop table `bvt\issue_26073`.`dst\t`; +select count(*) as protection_rows_after_drop +from mo_catalog.mo_snapshots where sname = @branch_snapshot; +select count(*) as metadata_rows_after_drop +from mo_catalog.mo_branch_metadata where table_id = @dst_id; +select id, note from `bvt\issue_26073`.`src\t` order by id; + +drop database `bvt\issue_26073`; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26074_bool_bit_pick.result b/test/distributed/cases/git4data/branch/edge/issue_26074_bool_bit_pick.result new file mode 100644 index 0000000000000..9b34bbe24cd82 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26074_bool_bit_pick.result @@ -0,0 +1,131 @@ +drop database if exists bvt_issue_26074; +create database bvt_issue_26074; +use bvt_issue_26074; +create table bool_base(k bool primary key, payload varchar(32), n int); +insert into bool_base values(false, 'base-false', 0), (true, 'base-true', 1); +data branch create table bool_src from bool_base; +data branch create table bool_dst from bool_base; +update bool_src set payload = concat(payload, '-src'), n = n + 10; +data branch pick bool_src into bool_dst keys(false); +select k, payload, n from bool_dst order by k; +k payload n +0 base-false-src 10 +1 base-true 1 +data branch pick bool_src into bool_dst keys(true); +select k, payload, n from bool_dst order by k; +k payload n +0 base-false-src 10 +1 base-true-src 11 +data branch create table bool_conf_src from bool_base; +data branch create table bool_conf_dst from bool_base; +delete from bool_conf_src where payload = 'base-false'; +update bool_conf_src set payload = 'src-true' where payload = 'base-true'; +data branch pick bool_conf_src into bool_conf_dst keys(0); +select k, payload from bool_conf_dst order by k; +k payload +1 base-true +update bool_conf_dst set payload = 'dst-true' where payload = 'base-true'; +data branch pick bool_conf_src into bool_conf_dst keys(1) when conflict fail; +internal error: conflict: bool_conf_src INSERT and bool_conf_dst INSERT on pk(true) with different values +select k, payload from bool_conf_dst order by k; +k payload +1 dst-true +data branch pick bool_conf_src into bool_conf_dst keys(1) when conflict accept; +select k, payload from bool_conf_dst order by k; +k payload +1 src-true +create table bool_comp_base( +k bool, +shard int, +payload varchar(32), +primary key(k, shard) +); +insert into bool_comp_base values +(false, 1, 'f1'), (false, 2, 'f2'), +(true, 1, 't1'), (true, 2, 't2'); +data branch create table bool_comp_src from bool_comp_base; +data branch create table bool_comp_dst from bool_comp_base; +update bool_comp_src set payload = concat(payload, '-src'); +delete from bool_comp_src where shard = 2 and payload = 'f2-src'; +data branch pick bool_comp_src into bool_comp_dst +keys((false, 1), (false, 2), (true, 2)); +select k, shard, payload from bool_comp_dst order by k, shard; +k shard payload +0 1 f1-src +1 1 t1 +1 2 t2-src +create table bit1_base(k bit(1) primary key, payload varchar(32)); +insert into bit1_base values(b'0', 'zero'), (b'1', 'one'); +data branch create table bit1_src from bit1_base; +data branch create table bit1_dst from bit1_base; +update bit1_src set payload = concat(payload, '-src'); +data branch pick bit1_src into bit1_dst keys(0, 1); +select hex(k), payload from bit1_dst order by k; +hex(k) payload +0 zero-src +1 one-src +create table bit8_base(k bit(8) primary key, payload varchar(32)); +insert into bit8_base values +(b'00000000', 'zero'), +(b'00000001', 'one'), +(b'01111111', 'one-two-seven'), +(b'11111111', 'two-five-five'); +data branch create table bit8_src from bit8_base; +data branch create table bit8_dst from bit8_base; +update bit8_src set payload = 'zero-src' where hex(k) = '0'; +update bit8_src set payload = 'one-two-seven-src' where hex(k) = '7F'; +update bit8_src set payload = 'two-five-five-src' where hex(k) = 'FF'; +delete from bit8_src where hex(k) = '1'; +data branch pick bit8_src into bit8_dst keys(0, 1, 3, 127, 255); +select hex(k), payload from bit8_dst order by k; +hex(k) payload +0 zero-src +7F one-two-seven-src +FF two-five-five-src +data branch create table bit8_sub_src from bit8_base; +data branch create table bit8_sub_dst from bit8_base; +update bit8_sub_src set payload = 'one-sub' where hex(k) = '1'; +update bit8_sub_src set payload = 'max-sub' where hex(k) = 'FF'; +data branch pick bit8_sub_src into bit8_sub_dst +keys(select k from bit8_sub_src where payload in ('one-sub', 'max-sub')); +select hex(k), payload from bit8_sub_dst order by k; +hex(k) payload +0 zero +1 one-sub +7F one-two-seven +FF max-sub +create table bit64_base(k bit(64) primary key, payload varchar(32)); +insert into bit64_base values +(0, 'zero'), +(9223372036854775808, 'high-bit'), +(18446744073709551615, 'max'); +data branch create table bit64_src from bit64_base; +data branch create table bit64_dst from bit64_base; +update bit64_src set payload = concat(payload, '-src'); +data branch pick bit64_src into bit64_dst +keys(0, 9223372036854775808, 18446744073709551615); +select hex(k), payload from bit64_dst order by k; +hex(k) payload +0 zero-src +8000000000000000 high-bit-src +FFFFFFFFFFFFFFFF max-src +data branch create table bit8_bad_src from bit8_base; +data branch create table bit8_bad_dst from bit8_base; +update bit8_bad_src set payload = 'changed' where hex(k) = 'FF'; +data branch pick bit8_bad_src into bit8_bad_dst keys(256); +Data truncation: data out of range: data type bit(8), value '256' +select hex(k), payload from bit8_bad_dst order by k; +hex(k) payload +0 zero +1 one +7F one-two-seven +FF two-five-five +data branch pick bit8_bad_src into bit8_bad_dst keys(-1); +Data truncation: data out of range: data type bit(8), value '-1' +select hex(k), payload from bit8_bad_dst order by k; +hex(k) payload +0 zero +1 one +7F one-two-seven +FF two-five-five +drop database bvt_issue_26074; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26074_bool_bit_pick.sql b/test/distributed/cases/git4data/branch/edge/issue_26074_bool_bit_pick.sql new file mode 100644 index 0000000000000..e772dc180c307 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26074_bool_bit_pick.sql @@ -0,0 +1,109 @@ +-- Regression for issue #26074. +-- DATA BRANCH PICK accepts BOOL and decimal BIT literal keys, including +-- boundary values, composite keys, conflicts, deletes, and typed subqueries. +drop database if exists bvt_issue_26074; +create database bvt_issue_26074; +use bvt_issue_26074; + +-- BOOL literals update only the selected rows. +create table bool_base(k bool primary key, payload varchar(32), n int); +insert into bool_base values(false, 'base-false', 0), (true, 'base-true', 1); +data branch create table bool_src from bool_base; +data branch create table bool_dst from bool_base; +update bool_src set payload = concat(payload, '-src'), n = n + 10; +data branch pick bool_src into bool_dst keys(false); +select k, payload, n from bool_dst order by k; +data branch pick bool_src into bool_dst keys(true); +select k, payload, n from bool_dst order by k; + +-- Numeric BOOL keys cover deletes and the conflict modes. +data branch create table bool_conf_src from bool_base; +data branch create table bool_conf_dst from bool_base; +delete from bool_conf_src where payload = 'base-false'; +update bool_conf_src set payload = 'src-true' where payload = 'base-true'; +data branch pick bool_conf_src into bool_conf_dst keys(0); +select k, payload from bool_conf_dst order by k; +update bool_conf_dst set payload = 'dst-true' where payload = 'base-true'; +-- @regex("conflict: bool_conf_src INSERT and bool_conf_dst INSERT on pk\(true\) with different values",true) +data branch pick bool_conf_src into bool_conf_dst keys(1) when conflict fail; +select k, payload from bool_conf_dst order by k; +data branch pick bool_conf_src into bool_conf_dst keys(1) when conflict accept; +select k, payload from bool_conf_dst order by k; + +-- BOOL works as one component of a composite primary key. +create table bool_comp_base( + k bool, + shard int, + payload varchar(32), + primary key(k, shard) +); +insert into bool_comp_base values + (false, 1, 'f1'), (false, 2, 'f2'), + (true, 1, 't1'), (true, 2, 't2'); +data branch create table bool_comp_src from bool_comp_base; +data branch create table bool_comp_dst from bool_comp_base; +update bool_comp_src set payload = concat(payload, '-src'); +delete from bool_comp_src where shard = 2 and payload = 'f2-src'; +data branch pick bool_comp_src into bool_comp_dst + keys((false, 1), (false, 2), (true, 2)); +select k, shard, payload from bool_comp_dst order by k, shard; + +-- BIT(1) accepts its complete decimal key range. +create table bit1_base(k bit(1) primary key, payload varchar(32)); +insert into bit1_base values(b'0', 'zero'), (b'1', 'one'); +data branch create table bit1_src from bit1_base; +data branch create table bit1_dst from bit1_base; +update bit1_src set payload = concat(payload, '-src'); +data branch pick bit1_src into bit1_dst keys(0, 1); +select hex(k), payload from bit1_dst order by k; + +-- BIT(8) covers lower/upper boundaries, update, delete, and an absent no-op key. +create table bit8_base(k bit(8) primary key, payload varchar(32)); +insert into bit8_base values + (b'00000000', 'zero'), + (b'00000001', 'one'), + (b'01111111', 'one-two-seven'), + (b'11111111', 'two-five-five'); +data branch create table bit8_src from bit8_base; +data branch create table bit8_dst from bit8_base; +update bit8_src set payload = 'zero-src' where hex(k) = '0'; +update bit8_src set payload = 'one-two-seven-src' where hex(k) = '7F'; +update bit8_src set payload = 'two-five-five-src' where hex(k) = 'FF'; +delete from bit8_src where hex(k) = '1'; +data branch pick bit8_src into bit8_dst keys(0, 1, 3, 127, 255); +select hex(k), payload from bit8_dst order by k; + +-- The typed-subquery path remains equivalent to compatible literals. +data branch create table bit8_sub_src from bit8_base; +data branch create table bit8_sub_dst from bit8_base; +update bit8_sub_src set payload = 'one-sub' where hex(k) = '1'; +update bit8_sub_src set payload = 'max-sub' where hex(k) = 'FF'; +data branch pick bit8_sub_src into bit8_sub_dst + keys(select k from bit8_sub_src where payload in ('one-sub', 'max-sub')); +select hex(k), payload from bit8_sub_dst order by k; + +-- BIT(64) accepts values on both sides of the signed boundary. +create table bit64_base(k bit(64) primary key, payload varchar(32)); +insert into bit64_base values + (0, 'zero'), + (9223372036854775808, 'high-bit'), + (18446744073709551615, 'max'); +data branch create table bit64_src from bit64_base; +data branch create table bit64_dst from bit64_base; +update bit64_src set payload = concat(payload, '-src'); +data branch pick bit64_src into bit64_dst + keys(0, 9223372036854775808, 18446744073709551615); +select hex(k), payload from bit64_dst order by k; + +-- Invalid BIT(8) literals fail without partially modifying the target. +data branch create table bit8_bad_src from bit8_base; +data branch create table bit8_bad_dst from bit8_base; +update bit8_bad_src set payload = 'changed' where hex(k) = 'FF'; +-- @regex("data type bit\(8\), value '256'",true) +data branch pick bit8_bad_src into bit8_bad_dst keys(256); +select hex(k), payload from bit8_bad_dst order by k; +-- @regex("data type bit\(8\), value '-1'",true) +data branch pick bit8_bad_src into bit8_bad_dst keys(-1); +select hex(k), payload from bit8_bad_dst order by k; + +drop database bvt_issue_26074; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26078_reversed_snapshot_range.result b/test/distributed/cases/git4data/branch/edge/issue_26078_reversed_snapshot_range.result new file mode 100644 index 0000000000000..e5d8f94cc5701 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26078_reversed_snapshot_range.result @@ -0,0 +1,62 @@ +drop snapshot if exists bvt_issue_26078_early; +drop snapshot if exists bvt_issue_26078_late; +drop database if exists bvt_issue_26078; +create database bvt_issue_26078; +use bvt_issue_26078; +create table base(id int primary key, val int); +insert into base values (1, 10), (2, 20), (3, 30), (4, 40); +data branch create table src from base; +data branch create table dst from base; +create snapshot bvt_issue_26078_early for table bvt_issue_26078 src; +update src set val = 200 where id = 2; +delete from src where id = 3; +insert into src values (5, 50); +create snapshot bvt_issue_26078_late for table bvt_issue_26078 src; +set @dst_id = ( +select rel_id from mo_catalog.mo_tables +where account_id = 0 +and reldatabase = 'bvt_issue_26078' +and relname = 'dst' +); +set @metadata_before = ( +select count(*) from mo_catalog.mo_branch_metadata +where table_id = @dst_id and table_deleted = false +); +set @protection_before = ( +select count(*) from mo_catalog.mo_snapshots +where sname = concat('__mo_branch_', cast(@dst_id as varchar)) +); +data branch pick src into dst +between snapshot bvt_issue_26078_late and bvt_issue_26078_early; +-- @regex("invalid BETWEEN SNAPSHOT range: start snapshot 'bvt_issue_26078_late' is later than end snapshot 'bvt_issue_26078_early'", true) +invalid input: invalid BETWEEN SNAPSHOT range: start snapshot 'bvt_issue_26078_late' is later than end snapshot 'bvt_issue_26078_early' +select id, val from dst order by id; +➤ id[4,32,0] ¦ val[4,32,0] 𝄀 +1 ¦ 10 𝄀 +2 ¦ 20 𝄀 +3 ¦ 30 𝄀 +4 ¦ 40 +select @metadata_before = ( +select count(*) from mo_catalog.mo_branch_metadata +where table_id = @dst_id and table_deleted = false +) as metadata_unchanged, +@protection_before = ( +select count(*) from mo_catalog.mo_snapshots +where sname = concat('__mo_branch_', cast(@dst_id as varchar)) +) as protection_unchanged; +➤ metadata_unchanged[-7,1,0] ¦ protection_unchanged[-7,1,0] 𝄀 +1 ¦ 1 +select 1 as session_alive_after_rejection; +➤ session_alive_after_rejection[-5,64,0] 𝄀 +1 +data branch pick src into dst +between snapshot bvt_issue_26078_early and bvt_issue_26078_late; +select id, val from dst order by id; +➤ id[4,32,0] ¦ val[4,32,0] 𝄀 +1 ¦ 10 𝄀 +2 ¦ 200 𝄀 +4 ¦ 40 𝄀 +5 ¦ 50 +drop snapshot bvt_issue_26078_early; +drop snapshot bvt_issue_26078_late; +drop database bvt_issue_26078; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26078_reversed_snapshot_range.sql b/test/distributed/cases/git4data/branch/edge/issue_26078_reversed_snapshot_range.sql new file mode 100644 index 0000000000000..3ee4904710610 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26078_reversed_snapshot_range.sql @@ -0,0 +1,55 @@ +-- Regression for issue #26078. +-- A reversed BETWEEN SNAPSHOT range must be rejected without partial changes. +drop snapshot if exists bvt_issue_26078_early; +drop snapshot if exists bvt_issue_26078_late; +drop database if exists bvt_issue_26078; +create database bvt_issue_26078; +use bvt_issue_26078; + +create table base(id int primary key, val int); +insert into base values (1, 10), (2, 20), (3, 30), (4, 40); +data branch create table src from base; +data branch create table dst from base; +create snapshot bvt_issue_26078_early for table bvt_issue_26078 src; +update src set val = 200 where id = 2; +delete from src where id = 3; +insert into src values (5, 50); +create snapshot bvt_issue_26078_late for table bvt_issue_26078 src; + +set @dst_id = ( + select rel_id from mo_catalog.mo_tables + where account_id = 0 + and reldatabase = 'bvt_issue_26078' + and relname = 'dst' +); +set @metadata_before = ( + select count(*) from mo_catalog.mo_branch_metadata + where table_id = @dst_id and table_deleted = false +); +set @protection_before = ( + select count(*) from mo_catalog.mo_snapshots + where sname = concat('__mo_branch_', cast(@dst_id as varchar)) +); + +-- @regex("invalid BETWEEN SNAPSHOT range: start snapshot 'bvt_issue_26078_late' is later than end snapshot 'bvt_issue_26078_early'",true) +data branch pick src into dst +between snapshot bvt_issue_26078_late and bvt_issue_26078_early; + +select id, val from dst order by id; +select @metadata_before = ( + select count(*) from mo_catalog.mo_branch_metadata + where table_id = @dst_id and table_deleted = false + ) as metadata_unchanged, + @protection_before = ( + select count(*) from mo_catalog.mo_snapshots + where sname = concat('__mo_branch_', cast(@dst_id as varchar)) + ) as protection_unchanged; +select 1 as session_alive_after_rejection; + +data branch pick src into dst +between snapshot bvt_issue_26078_early and bvt_issue_26078_late; +select id, val from dst order by id; + +drop snapshot bvt_issue_26078_early; +drop snapshot bvt_issue_26078_late; +drop database bvt_issue_26078; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26081_hashmap_bulk.result b/test/distributed/cases/git4data/branch/edge/issue_26081_hashmap_bulk.result new file mode 100644 index 0000000000000..0ab22e8d1d277 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26081_hashmap_bulk.result @@ -0,0 +1,64 @@ +drop database if exists bvt_issue_26081; +create database bvt_issue_26081; +use bvt_issue_26081; +create table base( +id int primary key, +val bigint, +payload varchar(32) +); +insert into base +select result, result, concat('row-', cast(result as varchar)) +from generate_series(1, 50000) g; +data branch create table branch_t from base; +data branch create table pick_dst from base; +data branch create table merge_dst from base; +update branch_t +set val = val + 100000, payload = 'updated' +where id between 1 and 10000; +delete from branch_t where id between 10001 and 20000; +insert into branch_t +select result, result, concat('row-', cast(result as varchar)) +from generate_series(50001, 60000) g; +data branch diff branch_t against base output summary; +➤ metric[12,0,0] ¦ branch_t[-5,0,0] ¦ base[-5,0,0] 𝄀 +INSERTED ¦ 10000 ¦ 0 𝄀 +DELETED ¦ 10000 ¦ 0 𝄀 +UPDATED ¦ 10000 ¦ 0 +create table pick_keys(id int primary key); +insert into pick_keys +select id from base +where id between 1 and 2500 +or id between 10001 and 12500; +insert into pick_keys +select id from branch_t where id between 50001 and 52500; +data branch pick branch_t into pick_dst keys(select id from pick_keys); +select count(*) as picked_rows, +sum(case when id between 1 and 2500 and val = id + 100000 then 1 else 0 end) as selected_updates, +sum(case when id between 10001 and 12500 then 1 else 0 end) as selected_deleted_rows, +sum(case when id between 50001 and 52500 then 1 else 0 end) as selected_inserts, +sum(case when id = 2501 and val = 2501 then 1 else 0 end) as unselected_update_control, +sum(case when id = 12501 and val = 12501 then 1 else 0 end) as unselected_delete_control, +sum(case when id = 52501 then 1 else 0 end) as unselected_insert_control +from pick_dst; +➤ picked_rows[-5,64,0] ¦ selected_updates[-5,64,0] ¦ selected_deleted_rows[-5,64,0] ¦ selected_inserts[-5,64,0] ¦ unselected_update_control[-5,64,0] ¦ unselected_delete_control[-5,64,0] ¦ unselected_insert_control[-5,64,0] 𝄀 +50000 ¦ 2500 ¦ 0 ¦ 2500 ¦ 1 ¦ 1 ¦ 0 +data branch merge branch_t into merge_dst; +select count(*) as rows_after_merge, +sum(id) as id_sum_after_merge, +sum(val) as val_sum_after_merge +from merge_dst; +➤ rows_after_merge[-5,64,0] ¦ id_sum_after_merge[-5,64,0] ¦ val_sum_after_merge[3,38,0] 𝄀 +50000 ¦ 1650025000 ¦ 2650025000 +select sum(case when id between 1 and 10000 and val = id + 100000 then 1 else 0 end) as updated_rows, +sum(case when id between 10001 and 20000 then 1 else 0 end) as deleted_rows, +sum(case when id between 50001 and 60000 then 1 else 0 end) as inserted_rows +from merge_dst; +➤ updated_rows[-5,64,0] ¦ deleted_rows[-5,64,0] ¦ inserted_rows[-5,64,0] 𝄀 +10000 ¦ 0 ¦ 10000 +select count(*) as base_rows, +sum(id) as base_id_sum, +sum(val) as base_val_sum +from base; +➤ base_rows[-5,64,0] ¦ base_id_sum[-5,64,0] ¦ base_val_sum[3,38,0] 𝄀 +50000 ¦ 1250025000 ¦ 1250025000 +drop database bvt_issue_26081; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26081_hashmap_bulk.sql b/test/distributed/cases/git4data/branch/edge/issue_26081_hashmap_bulk.sql new file mode 100644 index 0000000000000..06d3c4578cb39 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26081_hashmap_bulk.sql @@ -0,0 +1,62 @@ +-- Regression for issue #26081. +-- Public bulk control for the DATA BRANCH hashmap consumer. +-- The callback-error injection itself remains in BranchHashmap Go tests. +drop database if exists bvt_issue_26081; +create database bvt_issue_26081; +use bvt_issue_26081; + +create table base( + id int primary key, + val bigint, + payload varchar(32) +); +insert into base +select result, result, concat('row-', cast(result as varchar)) +from generate_series(1, 50000) g; +data branch create table branch_t from base; +data branch create table pick_dst from base; +data branch create table merge_dst from base; + +update branch_t +set val = val + 100000, payload = 'updated' +where id between 1 and 10000; +delete from branch_t where id between 10001 and 20000; +insert into branch_t +select result, result, concat('row-', cast(result as varchar)) +from generate_series(50001, 60000) g; + +data branch diff branch_t against base output summary; + +create table pick_keys(id int primary key); +insert into pick_keys +select id from base +where id between 1 and 2500 + or id between 10001 and 12500; +insert into pick_keys +select id from branch_t where id between 50001 and 52500; +data branch pick branch_t into pick_dst keys(select id from pick_keys); + +select count(*) as picked_rows, + sum(case when id between 1 and 2500 and val = id + 100000 then 1 else 0 end) as selected_updates, + sum(case when id between 10001 and 12500 then 1 else 0 end) as selected_deleted_rows, + sum(case when id between 50001 and 52500 then 1 else 0 end) as selected_inserts, + sum(case when id = 2501 and val = 2501 then 1 else 0 end) as unselected_update_control, + sum(case when id = 12501 and val = 12501 then 1 else 0 end) as unselected_delete_control, + sum(case when id = 52501 then 1 else 0 end) as unselected_insert_control +from pick_dst; + +data branch merge branch_t into merge_dst; +select count(*) as rows_after_merge, + sum(id) as id_sum_after_merge, + sum(val) as val_sum_after_merge +from merge_dst; +select sum(case when id between 1 and 10000 and val = id + 100000 then 1 else 0 end) as updated_rows, + sum(case when id between 10001 and 20000 then 1 else 0 end) as deleted_rows, + sum(case when id between 50001 and 60000 then 1 else 0 end) as inserted_rows +from merge_dst; +select count(*) as base_rows, + sum(id) as base_id_sum, + sum(val) as base_val_sum +from base; + +drop database bvt_issue_26081; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26114_target_quota.result b/test/distributed/cases/git4data/branch/edge/issue_26114_target_quota.result new file mode 100644 index 0000000000000..32900d08093f8 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26114_target_quota.result @@ -0,0 +1,194 @@ +drop account if exists bvt_issue_26114_acc; +create account bvt_issue_26114_acc admin_name = 'admin' identified by '111'; +select mo_feature_registry_upsert( +'branch', +'Branch feature', +'{"allowed_scope":[]}', +true +); +➤ mo_feature_registry_upsert(branch, Branch feature, {"allowed_scope":[]}, true)[12,-1,0] 𝄀 +{ + "now": { + "feature_code": "BRANCH", + "description": "Branch feature", + "scope_spec": { + "allowed_scope": [] + }, + "enabled": true + }, + "old": { + "feature_code": "BRANCH", + "description": "Branch feature", + "scope_spec": { + "allowed_scope": [] + }, + "enabled": true + } +} + +select mo_feature_registry_upsert( +'snapshot', +'Snapshot feature', +'{"allowed_scope":["account","database","table"]}', +true +); +➤ mo_feature_registry_upsert(snapshot, Snapshot feature, {"allowed_scope":["account","database","table"]}, true)[12,-1,0] 𝄀 +{ + "now": { + "feature_code": "SNAPSHOT", + "description": "Snapshot feature", + "scope_spec": { + "allowed_scope": ["account", "database", "table"] + }, + "enabled": true + }, + "old": { + "feature_code": "SNAPSHOT", + "description": "Snapshot feature", + "scope_spec": { + "allowed_scope": ["account", "database", "table"] + }, + "enabled": true + } +} + +set @target_id = ( +select account_id from mo_catalog.mo_account +where account_name = 'bvt_issue_26114_acc' +); +select mo_feature_limit_upsert(@target_id, 'snapshot', 'table', -1); +➤ mo_feature_limit_upsert(@target_id, snapshot, table, -1)[12,-1,0] 𝄀 +{ + "now": { + "account_id": 9, + "feature_code": "SNAPSHOT", + "scope": "table", + "quota": -1 + }, + "old": null +} + +select mo_feature_limit_upsert(@target_id, 'snapshot', 'database', -1); +➤ mo_feature_limit_upsert(@target_id, snapshot, database, -1)[12,-1,0] 𝄀 +{ + "now": { + "account_id": 9, + "feature_code": "SNAPSHOT", + "scope": "database", + "quota": -1 + }, + "old": null +} + +select mo_feature_limit_upsert(@target_id, 'branch', '', 0); +➤ mo_feature_limit_upsert(@target_id, branch, , 0)[12,-1,0] 𝄀 +{ + "now": { + "account_id": 9, + "feature_code": "BRANCH", + "scope": "", + "quota": 0 + }, + "old": null +} + +drop database if exists bvt_issue_26114_dst; +create database bvt_issue_26114_dst; +drop snapshot if exists bvt_issue_26114_table_sp; +drop snapshot if exists bvt_issue_26114_db_sp; +drop database if exists bvt_issue_26114_src; +create database bvt_issue_26114_src; +create table bvt_issue_26114_src.base( +id int primary key, +val varchar(20) +); +insert into bvt_issue_26114_src.base values (1, 'one'); +create snapshot bvt_issue_26114_table_sp +for table bvt_issue_26114_src base; +create snapshot bvt_issue_26114_db_sp +for database bvt_issue_26114_src; +data branch create table bvt_issue_26114_dst.blocked_table +from bvt_issue_26114_src.base{snapshot='bvt_issue_26114_table_sp'} +to account bvt_issue_26114_acc; +-- @regex("feature BRANCH with scope .* has disabled for account bvt_issue_26114_acc", true) +internal error: feature BRANCH with scope has disabled for account bvt_issue_26114_acc +data branch create database bvt_issue_26114_blocked_db +from bvt_issue_26114_src{snapshot='bvt_issue_26114_db_sp'} +to account bvt_issue_26114_acc; +-- @regex("feature BRANCH with scope .* has disabled for account bvt_issue_26114_acc", true) +internal error: feature BRANCH with scope has disabled for account bvt_issue_26114_acc +select count(*) as blocked_table_rows +from mo_catalog.mo_tables +where reldatabase = 'bvt_issue_26114_dst' +and relname = 'blocked_table'; +➤ blocked_table_rows[-5,64,0] 𝄀 +0 +select count(*) as blocked_database_rows +from mo_catalog.mo_database +where datname = 'bvt_issue_26114_blocked_db'; +➤ blocked_database_rows[-5,64,0] 𝄀 +0 +select count(*) as active_metadata_after_rejection +from mo_catalog.mo_branch_metadata b +join mo_catalog.mo_tables t on t.rel_id = b.table_id +where t.account_id = @target_id +and b.table_deleted = false; +➤ active_metadata_after_rejection[-5,64,0] 𝄀 +0 +select mo_feature_limit_upsert(@target_id, 'branch', '', 3); +➤ mo_feature_limit_upsert(@target_id, branch, , 3)[12,-1,0] 𝄀 +{ + "now": { + "account_id": 9, + "feature_code": "BRANCH", + "scope": "", + "quota": 3 + }, + "old": { + "account_id": 9, + "feature_code": "BRANCH", + "scope": "", + "quota": 0 + } +} + +data branch create table bvt_issue_26114_dst.allowed_table +from bvt_issue_26114_src.base{snapshot='bvt_issue_26114_table_sp'} +to account bvt_issue_26114_acc; +data branch create database bvt_issue_26114_allowed_db +from bvt_issue_26114_src{snapshot='bvt_issue_26114_db_sp'} +to account bvt_issue_26114_acc; +select id, val from bvt_issue_26114_dst.allowed_table order by id; +➤ id[4,32,0] ¦ val[12,-1,0] 𝄀 +1 ¦ one +select id, val from bvt_issue_26114_allowed_db.base order by id; +➤ id[4,32,0] ¦ val[12,-1,0] 𝄀 +1 ¦ one +select count(*) as target_owned_active_metadata +from mo_catalog.mo_branch_metadata b +join mo_catalog.mo_tables t on t.rel_id = b.table_id +where t.account_id = @target_id +and b.creator = @target_id +and b.table_deleted = false; +➤ target_owned_active_metadata[-5,64,0] 𝄀 +2 +data branch create table bvt_issue_26114_dst.allowed_table_2 +from bvt_issue_26114_src.base{snapshot='bvt_issue_26114_table_sp'} +to account bvt_issue_26114_acc; +data branch create table bvt_issue_26114_dst.rejected_after_limit +from bvt_issue_26114_src.base{snapshot='bvt_issue_26114_table_sp'} +to account bvt_issue_26114_acc; +-- @regex("exceeds.*limit of 3|limit of 3", true) +internal error: feature BRANCH with scope has reached the limit of 3 +select count(*) as rejected_table_rows +from mo_catalog.mo_tables +where reldatabase = 'bvt_issue_26114_dst' +and relname = 'rejected_after_limit'; +➤ rejected_table_rows[-5,64,0] 𝄀 +0 +drop database bvt_issue_26114_allowed_db; +drop database bvt_issue_26114_dst; +drop snapshot bvt_issue_26114_table_sp; +drop snapshot bvt_issue_26114_db_sp; +drop database bvt_issue_26114_src; +drop account bvt_issue_26114_acc; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26114_target_quota.sql b/test/distributed/cases/git4data/branch/edge/issue_26114_target_quota.sql new file mode 100644 index 0000000000000..1372bb8c5b720 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26114_target_quota.sql @@ -0,0 +1,119 @@ +-- Regression for issue #26114. +-- Cross-account DATA BRANCH quota and metadata ownership use the target account. +drop account if exists bvt_issue_26114_acc; +create account bvt_issue_26114_acc admin_name = 'admin' identified by '111'; + +-- @ignore:0 +select mo_feature_registry_upsert( + 'branch', + 'Branch feature', + '{"allowed_scope":[]}', + true +); +-- @ignore:0 +select mo_feature_registry_upsert( + 'snapshot', + 'Snapshot feature', + '{"allowed_scope":["account","database","table"]}', + true +); +set @target_id = ( + select account_id from mo_catalog.mo_account + where account_name = 'bvt_issue_26114_acc' +); +-- @ignore:0 +select mo_feature_limit_upsert(@target_id, 'snapshot', 'table', -1); +-- @ignore:0 +select mo_feature_limit_upsert(@target_id, 'snapshot', 'database', -1); +-- @ignore:0 +select mo_feature_limit_upsert(@target_id, 'branch', '', 0); + +-- @session:id=1&user=bvt_issue_26114_acc:admin&password=111{ +drop database if exists bvt_issue_26114_dst; +create database bvt_issue_26114_dst; +-- @session} + +drop snapshot if exists bvt_issue_26114_table_sp; +drop snapshot if exists bvt_issue_26114_db_sp; +drop database if exists bvt_issue_26114_src; +create database bvt_issue_26114_src; +create table bvt_issue_26114_src.base( + id int primary key, + val varchar(20) +); +insert into bvt_issue_26114_src.base values (1, 'one'); +create snapshot bvt_issue_26114_table_sp +for table bvt_issue_26114_src base; +create snapshot bvt_issue_26114_db_sp +for database bvt_issue_26114_src; + +-- @regex("feature BRANCH with scope .* has disabled for account bvt_issue_26114_acc",true) +data branch create table bvt_issue_26114_dst.blocked_table +from bvt_issue_26114_src.base{snapshot='bvt_issue_26114_table_sp'} +to account bvt_issue_26114_acc; + +-- @regex("feature BRANCH with scope .* has disabled for account bvt_issue_26114_acc",true) +data branch create database bvt_issue_26114_blocked_db +from bvt_issue_26114_src{snapshot='bvt_issue_26114_db_sp'} +to account bvt_issue_26114_acc; + +-- @session:id=1&user=bvt_issue_26114_acc:admin&password=111{ +select count(*) as blocked_table_rows +from mo_catalog.mo_tables +where reldatabase = 'bvt_issue_26114_dst' + and relname = 'blocked_table'; +select count(*) as blocked_database_rows +from mo_catalog.mo_database +where datname = 'bvt_issue_26114_blocked_db'; +-- @session} + +select count(*) as active_metadata_after_rejection +from mo_catalog.mo_branch_metadata b +join mo_catalog.mo_tables t on t.rel_id = b.table_id +where t.account_id = @target_id + and b.table_deleted = false; + +-- Raise quota and cover both table- and database-level success. +-- @ignore:0 +select mo_feature_limit_upsert(@target_id, 'branch', '', 3); +data branch create table bvt_issue_26114_dst.allowed_table +from bvt_issue_26114_src.base{snapshot='bvt_issue_26114_table_sp'} +to account bvt_issue_26114_acc; +data branch create database bvt_issue_26114_allowed_db +from bvt_issue_26114_src{snapshot='bvt_issue_26114_db_sp'} +to account bvt_issue_26114_acc; + +-- @session:id=1&user=bvt_issue_26114_acc:admin&password=111{ +select id, val from bvt_issue_26114_dst.allowed_table order by id; +select id, val from bvt_issue_26114_allowed_db.base order by id; +-- @session} + +select count(*) as target_owned_active_metadata +from mo_catalog.mo_branch_metadata b +join mo_catalog.mo_tables t on t.rel_id = b.table_id +where t.account_id = @target_id + and b.creator = @target_id + and b.table_deleted = false; + +-- Exhaust the remaining target quota with a second table, then reject the next. +data branch create table bvt_issue_26114_dst.allowed_table_2 +from bvt_issue_26114_src.base{snapshot='bvt_issue_26114_table_sp'} +to account bvt_issue_26114_acc; +-- @regex("exceeds.*limit of 3|limit of 3",true) +data branch create table bvt_issue_26114_dst.rejected_after_limit +from bvt_issue_26114_src.base{snapshot='bvt_issue_26114_table_sp'} +to account bvt_issue_26114_acc; + +-- @session:id=1&user=bvt_issue_26114_acc:admin&password=111{ +select count(*) as rejected_table_rows +from mo_catalog.mo_tables +where reldatabase = 'bvt_issue_26114_dst' + and relname = 'rejected_after_limit'; +drop database bvt_issue_26114_allowed_db; +drop database bvt_issue_26114_dst; +-- @session} + +drop snapshot bvt_issue_26114_table_sp; +drop snapshot bvt_issue_26114_db_sp; +drop database bvt_issue_26114_src; +drop account bvt_issue_26114_acc; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26118_hash_identifiers.result b/test/distributed/cases/git4data/branch/edge/issue_26118_hash_identifiers.result new file mode 100644 index 0000000000000..565e3d64946f8 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26118_hash_identifiers.result @@ -0,0 +1,94 @@ +drop database if exists bvt_issue_26118_branch; +drop database if exists bvt_issue_26118_clone; +drop database if exists `bvt#issue#26118`; +create database `bvt#issue#26118`; +create table `bvt#issue#26118`.`parent#p`( +id int primary key, +note varchar(32) +); +create table `bvt#issue#26118`.`child#c`( +id int primary key, +parent_id int, +constraint `fk#parent` foreign key(parent_id) +references `bvt#issue#26118`.`parent#p`(id) +); +insert into `bvt#issue#26118`.`parent#p` +values (1, 'one'), (2, 'two'); +insert into `bvt#issue#26118`.`child#c` +values (10, 1), (20, 2); +create view `bvt#issue#26118`.`view#1` as +select id, note from `bvt#issue#26118`.`parent#p`; +create view `bvt#issue#26118`.`view#2` as +select id, note from `bvt#issue#26118`.`view#1`; +data branch create database bvt_issue_26118_branch +from `bvt#issue#26118`; +create database bvt_issue_26118_clone clone `bvt#issue#26118`; +select 'branch' as copy_kind, count(*) as joined_rows +from bvt_issue_26118_branch.`child#c` c +join bvt_issue_26118_branch.`parent#p` p on c.parent_id = p.id +union all +select 'clone', count(*) +from bvt_issue_26118_clone.`child#c` c +join bvt_issue_26118_clone.`parent#p` p on c.parent_id = p.id +order by copy_kind; +➤ copy_kind[12,-1,0] ¦ joined_rows[-5,64,0] 𝄀 +branch ¦ 2 𝄀 +clone ¦ 2 +select 'branch' as copy_kind, count(*) as dependent_view_rows +from bvt_issue_26118_branch.`view#2` +union all +select 'clone', count(*) +from bvt_issue_26118_clone.`view#2` +order by copy_kind; +➤ copy_kind[12,-1,0] ¦ dependent_view_rows[-5,64,0] 𝄀 +branch ¦ 2 𝄀 +clone ¦ 2 +select db_name, constraint_name, table_name, refer_table_name, +count(*) as metadata_rows +from mo_catalog.mo_foreign_keys +where db_name in ('bvt_issue_26118_branch', 'bvt_issue_26118_clone') +and constraint_name = 'fk#parent' +and table_name = 'child#c' +and refer_table_name = 'parent#p' +group by db_name, constraint_name, table_name, refer_table_name +order by db_name; +➤ db_name[12,-1,0] ¦ constraint_name[12,-1,0] ¦ table_name[12,-1,0] ¦ refer_table_name[12,-1,0] ¦ metadata_rows[-5,64,0] 𝄀 +bvt_issue_26118_branch ¦ fk#parent ¦ child#c ¦ parent#p ¦ 1 𝄀 +bvt_issue_26118_clone ¦ fk#parent ¦ child#c ¦ parent#p ¦ 1 +insert into bvt_issue_26118_branch.`child#c` values (30, 999); +-- @regex("foreign key constraint fails", true) +internal error: Cannot add or update a child row: a foreign key constraint fails +insert into bvt_issue_26118_clone.`child#c` values (30, 999); +-- @regex("foreign key constraint fails", true) +internal error: Cannot add or update a child row: a foreign key constraint fails +insert into bvt_issue_26118_branch.`parent#p` values (3, 'branch-only'); +insert into bvt_issue_26118_branch.`child#c` values (30, 3); +select 'source' as location, count(*) as parent_rows, max(id) as max_parent_id +from `bvt#issue#26118`.`parent#p` +union all +select 'branch', count(*), max(id) +from bvt_issue_26118_branch.`parent#p` +union all +select 'clone', count(*), max(id) +from bvt_issue_26118_clone.`parent#p` +order by location; +➤ location[12,-1,0] ¦ parent_rows[-5,64,0] ¦ max_parent_id[4,32,0] 𝄀 +branch ¦ 3 ¦ 3 𝄀 +clone ¦ 2 ¦ 2 𝄀 +source ¦ 2 ¦ 2 +select id, note from bvt_issue_26118_branch.`view#2` order by id; +➤ id[4,32,0] ¦ note[12,-1,0] 𝄀 +1 ¦ one 𝄀 +2 ¦ two 𝄀 +3 ¦ branch-only +drop database bvt_issue_26118_branch; +data branch create database bvt_issue_26118_branch +from `bvt#issue#26118`; +select count(*) as recreated_joined_rows +from bvt_issue_26118_branch.`child#c` c +join bvt_issue_26118_branch.`parent#p` p on c.parent_id = p.id; +➤ recreated_joined_rows[-5,64,0] 𝄀 +2 +drop database bvt_issue_26118_branch; +drop database bvt_issue_26118_clone; +drop database `bvt#issue#26118`; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26118_hash_identifiers.sql b/test/distributed/cases/git4data/branch/edge/issue_26118_hash_identifiers.sql new file mode 100644 index 0000000000000..f92c746294736 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26118_hash_identifiers.sql @@ -0,0 +1,86 @@ +-- Regression for issue #26118. +-- Database CLONE and DATA BRANCH must preserve # identifiers and dependencies. +drop database if exists bvt_issue_26118_branch; +drop database if exists bvt_issue_26118_clone; +drop database if exists `bvt#issue#26118`; +create database `bvt#issue#26118`; + +create table `bvt#issue#26118`.`parent#p`( + id int primary key, + note varchar(32) +); +create table `bvt#issue#26118`.`child#c`( + id int primary key, + parent_id int, + constraint `fk#parent` foreign key(parent_id) + references `bvt#issue#26118`.`parent#p`(id) +); +insert into `bvt#issue#26118`.`parent#p` +values (1, 'one'), (2, 'two'); +insert into `bvt#issue#26118`.`child#c` +values (10, 1), (20, 2); +create view `bvt#issue#26118`.`view#1` as +select id, note from `bvt#issue#26118`.`parent#p`; +create view `bvt#issue#26118`.`view#2` as +select id, note from `bvt#issue#26118`.`view#1`; + +data branch create database bvt_issue_26118_branch +from `bvt#issue#26118`; +create database bvt_issue_26118_clone clone `bvt#issue#26118`; + +select 'branch' as copy_kind, count(*) as joined_rows +from bvt_issue_26118_branch.`child#c` c +join bvt_issue_26118_branch.`parent#p` p on c.parent_id = p.id +union all +select 'clone', count(*) +from bvt_issue_26118_clone.`child#c` c +join bvt_issue_26118_clone.`parent#p` p on c.parent_id = p.id +order by copy_kind; + +select 'branch' as copy_kind, count(*) as dependent_view_rows +from bvt_issue_26118_branch.`view#2` +union all +select 'clone', count(*) +from bvt_issue_26118_clone.`view#2` +order by copy_kind; + +select db_name, constraint_name, table_name, refer_table_name, + count(*) as metadata_rows +from mo_catalog.mo_foreign_keys +where db_name in ('bvt_issue_26118_branch', 'bvt_issue_26118_clone') + and constraint_name = 'fk#parent' + and table_name = 'child#c' + and refer_table_name = 'parent#p' +group by db_name, constraint_name, table_name, refer_table_name +order by db_name; + +-- Both destinations must enforce their own copied foreign key. +-- @regex("foreign key constraint fails",true) +insert into bvt_issue_26118_branch.`child#c` values (30, 999); +-- @regex("foreign key constraint fails",true) +insert into bvt_issue_26118_clone.`child#c` values (30, 999); + +insert into bvt_issue_26118_branch.`parent#p` values (3, 'branch-only'); +insert into bvt_issue_26118_branch.`child#c` values (30, 3); +select 'source' as location, count(*) as parent_rows, max(id) as max_parent_id +from `bvt#issue#26118`.`parent#p` +union all +select 'branch', count(*), max(id) +from bvt_issue_26118_branch.`parent#p` +union all +select 'clone', count(*), max(id) +from bvt_issue_26118_clone.`parent#p` +order by location; +select id, note from bvt_issue_26118_branch.`view#2` order by id; + +-- Cleanup and same-name recreation must not reuse stale dependency metadata. +drop database bvt_issue_26118_branch; +data branch create database bvt_issue_26118_branch +from `bvt#issue#26118`; +select count(*) as recreated_joined_rows +from bvt_issue_26118_branch.`child#c` c +join bvt_issue_26118_branch.`parent#p` p on c.parent_id = p.id; + +drop database bvt_issue_26118_branch; +drop database bvt_issue_26118_clone; +drop database `bvt#issue#26118`; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26120_snapshot_identity.result b/test/distributed/cases/git4data/branch/edge/issue_26120_snapshot_identity.result new file mode 100644 index 0000000000000..3211b017d17b4 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26120_snapshot_identity.result @@ -0,0 +1,145 @@ +drop snapshot if exists bvt_issue_26120_sp; +drop snapshot if exists bvt_issue_26120_control_sp; +drop snapshot if exists bvt_issue_26120_db_sp; +drop database if exists bvt_issue_26120_db_branch; +drop database if exists bvt_issue_26120_db_src; +drop database if exists bvt_issue_26120; +create database bvt_issue_26120; +use bvt_issue_26120; +create table control_parent(id int primary key, val varchar(20)); +insert into control_parent values (10, 'control-row'); +create snapshot bvt_issue_26120_control_sp +for table bvt_issue_26120 control_parent; +data branch create table control_child +from control_parent{snapshot='bvt_issue_26120_control_sp'}; +create table parent_t(id int primary key, val varchar(20)); +insert into parent_t values (1, 'snapshot-row'); +create snapshot bvt_issue_26120_sp for table bvt_issue_26120 parent_t; +drop table parent_t; +create table parent_t(id int primary key, val varchar(20)); +insert into parent_t values (2, 'current-row'); +data branch create table child_t +from parent_t{snapshot='bvt_issue_26120_sp'}; +create database bvt_issue_26120_db_src; +create table bvt_issue_26120_db_src.parent_t( +id int primary key, +val varchar(20) +); +insert into bvt_issue_26120_db_src.parent_t +values (1, 'db-snapshot-row'); +create snapshot bvt_issue_26120_db_sp +for database bvt_issue_26120_db_src; +drop table bvt_issue_26120_db_src.parent_t; +create table bvt_issue_26120_db_src.parent_t( +id int primary key, +val varchar(20) +); +insert into bvt_issue_26120_db_src.parent_t +values (2, 'db-current-row'); +data branch create database bvt_issue_26120_db_branch +from bvt_issue_26120_db_src{snapshot='bvt_issue_26120_db_sp'}; +select id, val from control_child; +➤ id[4,32,0] ¦ val[12,-1,0] 𝄀 +10 ¦ control-row +select id, val from child_t; +➤ id[4,32,0] ¦ val[12,-1,0] 𝄀 +1 ¦ snapshot-row +select count(*) as historical_parent_matches +from mo_catalog.mo_branch_metadata b +join mo_catalog.mo_tables child on child.rel_id = b.table_id +where child.account_id = 0 +and child.reldatabase = 'bvt_issue_26120' +and child.relname = 'child_t' +and b.p_table_id = ( +select old_parent.rel_id +from mo_catalog.mo_tables{snapshot='bvt_issue_26120_sp'} old_parent +where old_parent.account_id = 0 +and old_parent.reldatabase = 'bvt_issue_26120' +and old_parent.relname = 'parent_t' +) +and b.p_table_id <> ( +select new_parent.rel_id +from mo_catalog.mo_tables new_parent +where new_parent.account_id = 0 +and new_parent.reldatabase = 'bvt_issue_26120' +and new_parent.relname = 'parent_t' +); +➤ historical_parent_matches[-5,64,0] 𝄀 +1 +select count(*) as table_protection_snapshot_matches +from mo_catalog.mo_tables child +join mo_catalog.mo_snapshots protection +on protection.sname = concat('__mo_branch_', cast(child.rel_id as varchar)) +where child.account_id = 0 +and child.reldatabase = 'bvt_issue_26120' +and child.relname = 'child_t' +and protection.obj_id = ( +select old_parent.rel_id +from mo_catalog.mo_tables{snapshot='bvt_issue_26120_sp'} old_parent +where old_parent.account_id = 0 +and old_parent.reldatabase = 'bvt_issue_26120' +and old_parent.relname = 'parent_t' +); +➤ table_protection_snapshot_matches[-5,64,0] 𝄀 +1 +data branch diff child_t against parent_t output summary; +➤ metric[12,0,0] ¦ child_t[-5,0,0] ¦ parent_t[-5,0,0] 𝄀 +INSERTED ¦ 1 ¦ 1 𝄀 +DELETED ¦ 0 ¦ 0 𝄀 +UPDATED ¦ 0 ¦ 0 +select id, val from bvt_issue_26120_db_branch.parent_t; +➤ id[4,32,0] ¦ val[12,-1,0] 𝄀 +1 ¦ db-snapshot-row +select id, val from bvt_issue_26120_db_src.parent_t; +➤ id[4,32,0] ¦ val[12,-1,0] 𝄀 +2 ¦ db-current-row +select count(*) as database_historical_parent_matches +from mo_catalog.mo_branch_metadata b +join mo_catalog.mo_tables child on child.rel_id = b.table_id +where child.account_id = 0 +and child.reldatabase = 'bvt_issue_26120_db_branch' +and child.relname = 'parent_t' +and b.p_table_id = ( +select old_parent.rel_id +from mo_catalog.mo_tables{snapshot='bvt_issue_26120_db_sp'} old_parent +where old_parent.account_id = 0 +and old_parent.reldatabase = 'bvt_issue_26120_db_src' +and old_parent.relname = 'parent_t' +) +and b.p_table_id <> ( +select new_parent.rel_id +from mo_catalog.mo_tables new_parent +where new_parent.account_id = 0 +and new_parent.reldatabase = 'bvt_issue_26120_db_src' +and new_parent.relname = 'parent_t' +); +➤ database_historical_parent_matches[-5,64,0] 𝄀 +1 +select count(*) as database_protection_snapshot_matches +from mo_catalog.mo_tables child +join mo_catalog.mo_snapshots protection +on protection.sname = concat('__mo_branch_', cast(child.rel_id as varchar)) +where child.account_id = 0 +and child.reldatabase = 'bvt_issue_26120_db_branch' +and child.relname = 'parent_t' +and protection.obj_id = ( +select old_parent.rel_id +from mo_catalog.mo_tables{snapshot='bvt_issue_26120_db_sp'} old_parent +where old_parent.account_id = 0 +and old_parent.reldatabase = 'bvt_issue_26120_db_src' +and old_parent.relname = 'parent_t' +); +➤ database_protection_snapshot_matches[-5,64,0] 𝄀 +1 +data branch diff bvt_issue_26120_db_branch.parent_t +against bvt_issue_26120_db_src.parent_t output summary; +➤ metric[12,0,0] ¦ bvt_issue_26120_db_branch.parent_t[-5,0,0] ¦ bvt_issue_26120_db_src.parent_t[-5,0,0] 𝄀 +INSERTED ¦ 1 ¦ 1 𝄀 +DELETED ¦ 0 ¦ 0 𝄀 +UPDATED ¦ 0 ¦ 0 +drop database bvt_issue_26120_db_branch; +drop database bvt_issue_26120_db_src; +drop database bvt_issue_26120; +drop snapshot bvt_issue_26120_sp; +drop snapshot bvt_issue_26120_control_sp; +drop snapshot bvt_issue_26120_db_sp; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26120_snapshot_identity.sql b/test/distributed/cases/git4data/branch/edge/issue_26120_snapshot_identity.sql new file mode 100644 index 0000000000000..857e163fcc05e --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26120_snapshot_identity.sql @@ -0,0 +1,132 @@ +-- Regression for issue #26120. +-- Snapshot branches must bind ancestry to the historical relation generation. +drop snapshot if exists bvt_issue_26120_sp; +drop snapshot if exists bvt_issue_26120_control_sp; +drop snapshot if exists bvt_issue_26120_db_sp; +drop database if exists bvt_issue_26120_db_branch; +drop database if exists bvt_issue_26120_db_src; +drop database if exists bvt_issue_26120; +create database bvt_issue_26120; +use bvt_issue_26120; + +-- Ordinary snapshot control. +create table control_parent(id int primary key, val varchar(20)); +insert into control_parent values (10, 'control-row'); +create snapshot bvt_issue_26120_control_sp +for table bvt_issue_26120 control_parent; +data branch create table control_child +from control_parent{snapshot='bvt_issue_26120_control_sp'}; + +-- Table-level historical generation. +create table parent_t(id int primary key, val varchar(20)); +insert into parent_t values (1, 'snapshot-row'); +create snapshot bvt_issue_26120_sp for table bvt_issue_26120 parent_t; +drop table parent_t; +create table parent_t(id int primary key, val varchar(20)); +insert into parent_t values (2, 'current-row'); +data branch create table child_t +from parent_t{snapshot='bvt_issue_26120_sp'}; + +-- Database-level historical generation. +create database bvt_issue_26120_db_src; +create table bvt_issue_26120_db_src.parent_t( + id int primary key, + val varchar(20) +); +insert into bvt_issue_26120_db_src.parent_t +values (1, 'db-snapshot-row'); +create snapshot bvt_issue_26120_db_sp +for database bvt_issue_26120_db_src; +drop table bvt_issue_26120_db_src.parent_t; +create table bvt_issue_26120_db_src.parent_t( + id int primary key, + val varchar(20) +); +insert into bvt_issue_26120_db_src.parent_t +values (2, 'db-current-row'); +data branch create database bvt_issue_26120_db_branch +from bvt_issue_26120_db_src{snapshot='bvt_issue_26120_db_sp'}; + +select id, val from control_child; +select id, val from child_t; +select count(*) as historical_parent_matches +from mo_catalog.mo_branch_metadata b +join mo_catalog.mo_tables child on child.rel_id = b.table_id +where child.account_id = 0 + and child.reldatabase = 'bvt_issue_26120' + and child.relname = 'child_t' + and b.p_table_id = ( + select old_parent.rel_id + from mo_catalog.mo_tables{snapshot='bvt_issue_26120_sp'} old_parent + where old_parent.account_id = 0 + and old_parent.reldatabase = 'bvt_issue_26120' + and old_parent.relname = 'parent_t' + ) + and b.p_table_id <> ( + select new_parent.rel_id + from mo_catalog.mo_tables new_parent + where new_parent.account_id = 0 + and new_parent.reldatabase = 'bvt_issue_26120' + and new_parent.relname = 'parent_t' + ); +select count(*) as table_protection_snapshot_matches +from mo_catalog.mo_tables child +join mo_catalog.mo_snapshots protection + on protection.sname = concat('__mo_branch_', cast(child.rel_id as varchar)) +where child.account_id = 0 + and child.reldatabase = 'bvt_issue_26120' + and child.relname = 'child_t' + and protection.obj_id = ( + select old_parent.rel_id + from mo_catalog.mo_tables{snapshot='bvt_issue_26120_sp'} old_parent + where old_parent.account_id = 0 + and old_parent.reldatabase = 'bvt_issue_26120' + and old_parent.relname = 'parent_t' + ); +data branch diff child_t against parent_t output summary; + +select id, val from bvt_issue_26120_db_branch.parent_t; +select id, val from bvt_issue_26120_db_src.parent_t; +select count(*) as database_historical_parent_matches +from mo_catalog.mo_branch_metadata b +join mo_catalog.mo_tables child on child.rel_id = b.table_id +where child.account_id = 0 + and child.reldatabase = 'bvt_issue_26120_db_branch' + and child.relname = 'parent_t' + and b.p_table_id = ( + select old_parent.rel_id + from mo_catalog.mo_tables{snapshot='bvt_issue_26120_db_sp'} old_parent + where old_parent.account_id = 0 + and old_parent.reldatabase = 'bvt_issue_26120_db_src' + and old_parent.relname = 'parent_t' + ) + and b.p_table_id <> ( + select new_parent.rel_id + from mo_catalog.mo_tables new_parent + where new_parent.account_id = 0 + and new_parent.reldatabase = 'bvt_issue_26120_db_src' + and new_parent.relname = 'parent_t' + ); +select count(*) as database_protection_snapshot_matches +from mo_catalog.mo_tables child +join mo_catalog.mo_snapshots protection + on protection.sname = concat('__mo_branch_', cast(child.rel_id as varchar)) +where child.account_id = 0 + and child.reldatabase = 'bvt_issue_26120_db_branch' + and child.relname = 'parent_t' + and protection.obj_id = ( + select old_parent.rel_id + from mo_catalog.mo_tables{snapshot='bvt_issue_26120_db_sp'} old_parent + where old_parent.account_id = 0 + and old_parent.reldatabase = 'bvt_issue_26120_db_src' + and old_parent.relname = 'parent_t' + ); +data branch diff bvt_issue_26120_db_branch.parent_t +against bvt_issue_26120_db_src.parent_t output summary; + +drop database bvt_issue_26120_db_branch; +drop database bvt_issue_26120_db_src; +drop database bvt_issue_26120; +drop snapshot bvt_issue_26120_sp; +drop snapshot bvt_issue_26120_control_sp; +drop snapshot bvt_issue_26120_db_sp; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26121_internal_names.result b/test/distributed/cases/git4data/branch/edge/issue_26121_internal_names.result new file mode 100644 index 0000000000000..df4f553493b13 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26121_internal_names.result @@ -0,0 +1,121 @@ +drop database if exists bvt_issue_26121_branch; +drop database if exists bvt_issue_26121_clone; +drop database if exists bvt_issue_26121_delete; +drop database if exists bvt_issue_26121_src; +create database bvt_issue_26121_src; +create table bvt_issue_26121_src.`__mo_tmp_user_keep`( +id int primary key, +note varchar(20), +unique key uq_note(note) +); +create table bvt_issue_26121_src.`__mo_account_lock`( +id int primary key, +note varchar(20), +unique key uq_note(note) +); +create table bvt_issue_26121_src.`mo_increment_columns`( +id int primary key, +note varchar(20), +unique key uq_note(note) +); +insert into bvt_issue_26121_src.`__mo_tmp_user_keep` values (1, 'v1'); +insert into bvt_issue_26121_src.`__mo_account_lock` values (2, 'v2'); +insert into bvt_issue_26121_src.`mo_increment_columns` values (3, 'v3'); +create view bvt_issue_26121_src.user_visible_view as +select id, note from bvt_issue_26121_src.`__mo_tmp_user_keep`; +create table bvt_issue_26121_src.docs( +id int primary key, +body text +); +insert into bvt_issue_26121_src.docs +values (1, 'matrixone branch regression'), (2, 'ordinary document'); +create fulltext index ft_body on bvt_issue_26121_src.docs(body); +data branch create database bvt_issue_26121_branch +from bvt_issue_26121_src; +create database bvt_issue_26121_clone clone bvt_issue_26121_src; +data branch create database bvt_issue_26121_delete +from bvt_issue_26121_src; +create table bvt_issue_26121_delete.`__mo_tmp_user_keep_extra`( +id int primary key, +note varchar(20) +); +insert into bvt_issue_26121_delete.`__mo_tmp_user_keep_extra` +values (10, 'must-remain'); +select 'branch' as copy_kind, +(select count(*) from bvt_issue_26121_branch.`__mo_tmp_user_keep`) as tmp_rows, +(select count(*) from bvt_issue_26121_branch.`__mo_account_lock`) as lock_rows, +(select count(*) from bvt_issue_26121_branch.`mo_increment_columns`) as increment_rows +union all +select 'clone', +(select count(*) from bvt_issue_26121_clone.`__mo_tmp_user_keep`), +(select count(*) from bvt_issue_26121_clone.`__mo_account_lock`), +(select count(*) from bvt_issue_26121_clone.`mo_increment_columns`) +order by copy_kind; +➤ copy_kind[12,-1,0] ¦ tmp_rows[-5,64,0] ¦ lock_rows[-5,64,0] ¦ increment_rows[-5,64,0] 𝄀 +branch ¦ 1 ¦ 1 ¦ 1 𝄀 +clone ¦ 1 ¦ 1 ¦ 1 +select reldatabase, count(*) as indexed_user_tables +from mo_catalog.mo_tables t +where t.account_id = 0 +and t.reldatabase in ('bvt_issue_26121_branch', 'bvt_issue_26121_clone') +and t.relname in ('__mo_tmp_user_keep', '__mo_account_lock', 'mo_increment_columns') +and exists ( +select 1 from mo_catalog.mo_indexes i +where i.database_id = t.reldatabase_id +and i.table_id = t.rel_id +and i.name = 'uq_note' +) +group by reldatabase +order by reldatabase; +➤ reldatabase[12,-1,0] ¦ indexed_user_tables[-5,64,0] 𝄀 +bvt_issue_26121_branch ¦ 3 𝄀 +bvt_issue_26121_clone ¦ 3 +select 'branch' as copy_kind, id, note +from bvt_issue_26121_branch.user_visible_view +union all +select 'clone', id, note +from bvt_issue_26121_clone.user_visible_view +order by copy_kind; +➤ copy_kind[12,-1,0] ¦ id[4,32,0] ¦ note[12,-1,0] 𝄀 +branch ¦ 1 ¦ v1 𝄀 +clone ¦ 1 ¦ v1 +select 'branch' as copy_kind, count(*) as fulltext_matches +from bvt_issue_26121_branch.docs +where match(body) against('matrixone branch') +union all +select 'clone', count(*) +from bvt_issue_26121_clone.docs +where match(body) against('matrixone branch') +order by copy_kind; +➤ copy_kind[12,-1,0] ¦ fulltext_matches[-5,64,0] 𝄀 +branch ¦ 1 𝄀 +clone ¦ 1 +select t.reldatabase, count(*) as copied_fulltext_indexes +from mo_catalog.mo_tables t +join mo_catalog.mo_indexes i +on i.database_id = t.reldatabase_id and i.table_id = t.rel_id +where t.account_id = 0 +and t.reldatabase in ('bvt_issue_26121_branch', 'bvt_issue_26121_clone') +and t.relname = 'docs' +and i.name = 'ft_body' +group by t.reldatabase +order by t.reldatabase; +➤ reldatabase[12,-1,0] ¦ copied_fulltext_indexes[-5,64,0] 𝄀 +bvt_issue_26121_branch ¦ 1 𝄀 +bvt_issue_26121_clone ¦ 1 +data branch delete database bvt_issue_26121_delete; +-- @regex("is not an active branch table", true) +internal error: DATA BRANCH DELETE target bvt_issue_26121_delete.__mo_tmp_user_keep_extra is not an active branch table +select count(*) as retained_database +from mo_catalog.mo_database +where datname = 'bvt_issue_26121_delete'; +➤ retained_database[-5,64,0] 𝄀 +1 +select id, note +from bvt_issue_26121_delete.`__mo_tmp_user_keep_extra`; +➤ id[4,32,0] ¦ note[12,-1,0] 𝄀 +10 ¦ must-remain +drop database bvt_issue_26121_delete; +drop database bvt_issue_26121_branch; +drop database bvt_issue_26121_clone; +drop database bvt_issue_26121_src; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26121_internal_names.sql b/test/distributed/cases/git4data/branch/edge/issue_26121_internal_names.sql new file mode 100644 index 0000000000000..2426046bfca42 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26121_internal_names.sql @@ -0,0 +1,114 @@ +-- Regression for issue #26121. +-- User tables must not be filtered only because their names look internal. +drop database if exists bvt_issue_26121_branch; +drop database if exists bvt_issue_26121_clone; +drop database if exists bvt_issue_26121_delete; +drop database if exists bvt_issue_26121_src; +create database bvt_issue_26121_src; + +create table bvt_issue_26121_src.`__mo_tmp_user_keep`( + id int primary key, + note varchar(20), + unique key uq_note(note) +); +create table bvt_issue_26121_src.`__mo_account_lock`( + id int primary key, + note varchar(20), + unique key uq_note(note) +); +create table bvt_issue_26121_src.`mo_increment_columns`( + id int primary key, + note varchar(20), + unique key uq_note(note) +); +insert into bvt_issue_26121_src.`__mo_tmp_user_keep` values (1, 'v1'); +insert into bvt_issue_26121_src.`__mo_account_lock` values (2, 'v2'); +insert into bvt_issue_26121_src.`mo_increment_columns` values (3, 'v3'); +create view bvt_issue_26121_src.user_visible_view as +select id, note from bvt_issue_26121_src.`__mo_tmp_user_keep`; + +-- A fulltext index supplies a genuine system-managed hidden relation control. +create table bvt_issue_26121_src.docs( + id int primary key, + body text +); +insert into bvt_issue_26121_src.docs +values (1, 'matrixone branch regression'), (2, 'ordinary document'); +create fulltext index ft_body on bvt_issue_26121_src.docs(body); + +data branch create database bvt_issue_26121_branch +from bvt_issue_26121_src; +create database bvt_issue_26121_clone clone bvt_issue_26121_src; +data branch create database bvt_issue_26121_delete +from bvt_issue_26121_src; +create table bvt_issue_26121_delete.`__mo_tmp_user_keep_extra`( + id int primary key, + note varchar(20) +); +insert into bvt_issue_26121_delete.`__mo_tmp_user_keep_extra` +values (10, 'must-remain'); + +select 'branch' as copy_kind, + (select count(*) from bvt_issue_26121_branch.`__mo_tmp_user_keep`) as tmp_rows, + (select count(*) from bvt_issue_26121_branch.`__mo_account_lock`) as lock_rows, + (select count(*) from bvt_issue_26121_branch.`mo_increment_columns`) as increment_rows +union all +select 'clone', + (select count(*) from bvt_issue_26121_clone.`__mo_tmp_user_keep`), + (select count(*) from bvt_issue_26121_clone.`__mo_account_lock`), + (select count(*) from bvt_issue_26121_clone.`mo_increment_columns`) +order by copy_kind; + +select reldatabase, count(*) as indexed_user_tables +from mo_catalog.mo_tables t +where t.account_id = 0 + and t.reldatabase in ('bvt_issue_26121_branch', 'bvt_issue_26121_clone') + and t.relname in ('__mo_tmp_user_keep', '__mo_account_lock', 'mo_increment_columns') + and exists ( + select 1 from mo_catalog.mo_indexes i + where i.database_id = t.reldatabase_id + and i.table_id = t.rel_id + and i.name = 'uq_note' + ) +group by reldatabase +order by reldatabase; + +select 'branch' as copy_kind, id, note +from bvt_issue_26121_branch.user_visible_view +union all +select 'clone', id, note +from bvt_issue_26121_clone.user_visible_view +order by copy_kind; + +select 'branch' as copy_kind, count(*) as fulltext_matches +from bvt_issue_26121_branch.docs +where match(body) against('matrixone branch') +union all +select 'clone', count(*) +from bvt_issue_26121_clone.docs +where match(body) against('matrixone branch') +order by copy_kind; + +select t.reldatabase, count(*) as copied_fulltext_indexes +from mo_catalog.mo_tables t +join mo_catalog.mo_indexes i + on i.database_id = t.reldatabase_id and i.table_id = t.rel_id +where t.account_id = 0 + and t.reldatabase in ('bvt_issue_26121_branch', 'bvt_issue_26121_clone') + and t.relname = 'docs' + and i.name = 'ft_body' +group by t.reldatabase +order by t.reldatabase; + +-- @regex("is not an active branch table",true) +data branch delete database bvt_issue_26121_delete; +select count(*) as retained_database +from mo_catalog.mo_database +where datname = 'bvt_issue_26121_delete'; +select id, note +from bvt_issue_26121_delete.`__mo_tmp_user_keep_extra`; + +drop database bvt_issue_26121_delete; +drop database bvt_issue_26121_branch; +drop database bvt_issue_26121_clone; +drop database bvt_issue_26121_src; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26127_embedded_backticks.result b/test/distributed/cases/git4data/branch/edge/issue_26127_embedded_backticks.result new file mode 100644 index 0000000000000..62124d7f3870a --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26127_embedded_backticks.result @@ -0,0 +1,93 @@ +drop database if exists bvt_issue_26127_branch; +drop database if exists bvt_issue_26127_clone; +drop database if exists bvt_issue_26127_src; +create database bvt_issue_26127_src; +create table bvt_issue_26127_src.`src``table`( +id int primary key, +note varchar(32) +); +insert into bvt_issue_26127_src.`src``table` values (1, 'source-row'); +create table bvt_issue_26127_src.`ordinary``clone` +clone bvt_issue_26127_src.`src``table`; +data branch create table bvt_issue_26127_src.`branch``clone` +from bvt_issue_26127_src.`src``table`; +create table bvt_issue_26127_src.parent_p( +id int primary key, +note varchar(32) +); +create table bvt_issue_26127_src.child_c( +id int primary key, +parent_id int, +constraint fk_parent foreign key(parent_id) +references bvt_issue_26127_src.parent_p(id) +); +insert into bvt_issue_26127_src.parent_p +values (1, 'parent-one'), (2, 'parent-two'); +insert into bvt_issue_26127_src.child_c values (10, 1), (20, 2); +create view bvt_issue_26127_src.view_v as +select id, note from bvt_issue_26127_src.parent_p; +data branch create database bvt_issue_26127_branch +from bvt_issue_26127_src; +create database bvt_issue_26127_clone clone bvt_issue_26127_src; +select 'ordinary_table_clone' as clone_kind, id, note +from bvt_issue_26127_src.`ordinary``clone` +union all +select 'data_branch_table', id, note +from bvt_issue_26127_src.`branch``clone` +union all +select 'data_branch_database', id, note +from bvt_issue_26127_branch.`src``table` +union all +select 'ordinary_database_clone', id, note +from bvt_issue_26127_clone.`src``table` +order by clone_kind; +➤ clone_kind[12,-1,0] ¦ id[4,32,0] ¦ note[12,-1,0] 𝄀 +data_branch_database ¦ 1 ¦ source-row 𝄀 +data_branch_table ¦ 1 ¦ source-row 𝄀 +ordinary_database_clone ¦ 1 ¦ source-row 𝄀 +ordinary_table_clone ¦ 1 ¦ source-row +select 'branch' as copy_kind, c.id, p.note +from bvt_issue_26127_branch.child_c c +join bvt_issue_26127_branch.parent_p p on c.parent_id = p.id +union all +select 'clone', c.id, p.note +from bvt_issue_26127_clone.child_c c +join bvt_issue_26127_clone.parent_p p on c.parent_id = p.id +order by copy_kind, id; +➤ copy_kind[12,-1,0] ¦ id[4,32,0] ¦ note[12,-1,0] 𝄀 +branch ¦ 10 ¦ parent-one 𝄀 +branch ¦ 20 ¦ parent-two 𝄀 +clone ¦ 10 ¦ parent-one 𝄀 +clone ¦ 20 ¦ parent-two +select 'branch' as copy_kind, id, note +from bvt_issue_26127_branch.view_v +union all +select 'clone', id, note +from bvt_issue_26127_clone.view_v +order by copy_kind, id; +➤ copy_kind[12,-1,0] ¦ id[4,32,0] ¦ note[12,-1,0] 𝄀 +branch ¦ 1 ¦ parent-one 𝄀 +branch ¦ 2 ¦ parent-two 𝄀 +clone ¦ 1 ¦ parent-one 𝄀 +clone ¦ 2 ¦ parent-two +insert into bvt_issue_26127_branch.child_c values (30, 999); +-- @regex("foreign key constraint fails", true) +internal error: Cannot add or update a child row: a foreign key constraint fails +insert into bvt_issue_26127_clone.child_c values (30, 999); +-- @regex("foreign key constraint fails", true) +internal error: Cannot add or update a child row: a foreign key constraint fails +insert into bvt_issue_26127_branch.parent_p values (3, 'branch-only'); +select 'source' as location, count(*) as parent_rows +from bvt_issue_26127_src.parent_p +union all +select 'branch', count(*) from bvt_issue_26127_branch.parent_p +union all +select 'clone', count(*) from bvt_issue_26127_clone.parent_p +order by location; +➤ location[12,-1,0] ¦ parent_rows[-5,64,0] 𝄀 +branch ¦ 3 𝄀 +clone ¦ 2 𝄀 +source ¦ 2 +drop database bvt_issue_26127_branch; +drop database bvt_issue_26127_clone; +drop database bvt_issue_26127_src; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26127_embedded_backticks.sql b/test/distributed/cases/git4data/branch/edge/issue_26127_embedded_backticks.sql new file mode 100644 index 0000000000000..561b46e307703 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26127_embedded_backticks.sql @@ -0,0 +1,85 @@ +-- Regression for issue #26127. +-- Repaired scope: embedded backticks in table names across CLONE/DATA BRANCH. +-- The still-open embedded-backtick dependent-view path is intentionally absent. +drop database if exists bvt_issue_26127_branch; +drop database if exists bvt_issue_26127_clone; +drop database if exists bvt_issue_26127_src; +create database bvt_issue_26127_src; + +create table bvt_issue_26127_src.`src``table`( + id int primary key, + note varchar(32) +); +insert into bvt_issue_26127_src.`src``table` values (1, 'source-row'); +create table bvt_issue_26127_src.`ordinary``clone` +clone bvt_issue_26127_src.`src``table`; +data branch create table bvt_issue_26127_src.`branch``clone` +from bvt_issue_26127_src.`src``table`; + +-- Ordinary dependency names remain a control for database-level copying. +create table bvt_issue_26127_src.parent_p( + id int primary key, + note varchar(32) +); +create table bvt_issue_26127_src.child_c( + id int primary key, + parent_id int, + constraint fk_parent foreign key(parent_id) + references bvt_issue_26127_src.parent_p(id) +); +insert into bvt_issue_26127_src.parent_p +values (1, 'parent-one'), (2, 'parent-two'); +insert into bvt_issue_26127_src.child_c values (10, 1), (20, 2); +create view bvt_issue_26127_src.view_v as +select id, note from bvt_issue_26127_src.parent_p; + +data branch create database bvt_issue_26127_branch +from bvt_issue_26127_src; +create database bvt_issue_26127_clone clone bvt_issue_26127_src; + +select 'ordinary_table_clone' as clone_kind, id, note +from bvt_issue_26127_src.`ordinary``clone` +union all +select 'data_branch_table', id, note +from bvt_issue_26127_src.`branch``clone` +union all +select 'data_branch_database', id, note +from bvt_issue_26127_branch.`src``table` +union all +select 'ordinary_database_clone', id, note +from bvt_issue_26127_clone.`src``table` +order by clone_kind; + +select 'branch' as copy_kind, c.id, p.note +from bvt_issue_26127_branch.child_c c +join bvt_issue_26127_branch.parent_p p on c.parent_id = p.id +union all +select 'clone', c.id, p.note +from bvt_issue_26127_clone.child_c c +join bvt_issue_26127_clone.parent_p p on c.parent_id = p.id +order by copy_kind, id; + +select 'branch' as copy_kind, id, note +from bvt_issue_26127_branch.view_v +union all +select 'clone', id, note +from bvt_issue_26127_clone.view_v +order by copy_kind, id; + +-- @regex("foreign key constraint fails",true) +insert into bvt_issue_26127_branch.child_c values (30, 999); +-- @regex("foreign key constraint fails",true) +insert into bvt_issue_26127_clone.child_c values (30, 999); +insert into bvt_issue_26127_branch.parent_p values (3, 'branch-only'); + +select 'source' as location, count(*) as parent_rows +from bvt_issue_26127_src.parent_p +union all +select 'branch', count(*) from bvt_issue_26127_branch.parent_p +union all +select 'clone', count(*) from bvt_issue_26127_clone.parent_p +order by location; + +drop database bvt_issue_26127_branch; +drop database bvt_issue_26127_clone; +drop database bvt_issue_26127_src; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26128_output.result b/test/distributed/cases/git4data/branch/edge/issue_26128_output.result new file mode 100644 index 0000000000000..b54de5eb1bfac --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26128_output.result @@ -0,0 +1,72 @@ +drop database if exists bvt_issue_26128; +create database bvt_issue_26128; +use bvt_issue_26128; +create table base( +id int primary key, +payload varchar(200) +); +insert into base values +(1, 'comma,value'), +(2, 'quote"value'), +(3, 'back\\slash'), +(4, '中文原值'), +(5, 'line1\nline2'); +data branch create table branch_t from base; +update branch_t set payload = 'comma,updated' where id = 1; +delete from branch_t where id = 2; +update branch_t set payload = '中文"更新"' where id = 4; +insert into branch_t values (6, 'new\nline'); +select id, hex(payload) as payload_hex from base order by id; +➤ id[4,32,0] ¦ payload_hex[12,-1,0] 𝄀 +1 ¦ 636F6D6D612C76616C7565 𝄀 +2 ¦ 71756F74652276616C7565 𝄀 +3 ¦ 6261636B5C736C617368 𝄀 +4 ¦ E4B8ADE69687E58E9FE580BC 𝄀 +5 ¦ 6C696E65310A6C696E6532 +select id, hex(payload) as payload_hex from branch_t order by id; +➤ id[4,32,0] ¦ payload_hex[12,-1,0] 𝄀 +1 ¦ 636F6D6D612C75706461746564 𝄀 +3 ¦ 6261636B5C736C617368 𝄀 +4 ¦ E4B8ADE6968722E69BB4E696B022 𝄀 +5 ¦ 6C696E65310A6C696E6532 𝄀 +6 ¦ 6E65770A6C696E65 +data branch diff branch_t against base output file '/tmp/'; +➤ FILE SAVED TO[12,0,0] ¦ HINT[12,0,0] 𝄀 +/tmp/diff_branch_t_base_20260730_035035.sql ¦ DELETE FROM `bvt_issue_26128`.`base`, INSERT INTO `bvt_issue_26128`.`base` +data branch diff branch_t against base output as diff_rows; +➤ TABLE CREATED[12,0,0] 𝄀 +`bvt_issue_26128`.`diff_rows` +select __mo_diff_source, +__mo_diff_flag, +id, +hex(payload) as payload_hex +from diff_rows +order by id; +➤ __mo_diff_source[12,-1,0] ¦ __mo_diff_flag[12,-1,0] ¦ id[4,32,0] ¦ payload_hex[12,-1,0] 𝄀 +branch_t ¦ UPDATE ¦ 1 ¦ 636F6D6D612C75706461746564 𝄀 +branch_t ¦ DELETE ¦ 2 ¦ 71756F74652276616C7565 𝄀 +branch_t ¦ UPDATE ¦ 4 ¦ E4B8ADE6968722E69BB4E696B022 𝄀 +branch_t ¦ INSERT ¦ 6 ¦ 6E65770A6C696E65 +select count(*) as output_as_branch_metadata +from mo_catalog.mo_branch_metadata b +join mo_catalog.mo_tables t on t.rel_id = b.table_id +where t.account_id = 0 +and t.reldatabase = 'bvt_issue_26128' +and t.relname = 'diff_rows'; +➤ output_as_branch_metadata[-5,64,0] 𝄀 +0 +select id, hex(payload) as payload_hex from base order by id; +➤ id[4,32,0] ¦ payload_hex[12,-1,0] 𝄀 +1 ¦ 636F6D6D612C76616C7565 𝄀 +2 ¦ 71756F74652276616C7565 𝄀 +3 ¦ 6261636B5C736C617368 𝄀 +4 ¦ E4B8ADE69687E58E9FE580BC 𝄀 +5 ¦ 6C696E65310A6C696E6532 +select id, hex(payload) as payload_hex from branch_t order by id; +➤ id[4,32,0] ¦ payload_hex[12,-1,0] 𝄀 +1 ¦ 636F6D6D612C75706461746564 𝄀 +3 ¦ 6261636B5C736C617368 𝄀 +4 ¦ E4B8ADE6968722E69BB4E696B022 𝄀 +5 ¦ 6C696E65310A6C696E6532 𝄀 +6 ¦ 6E65770A6C696E65 +drop database bvt_issue_26128; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26128_output.sql b/test/distributed/cases/git4data/branch/edge/issue_26128_output.sql new file mode 100644 index 0000000000000..aae0fee633e53 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26128_output.sql @@ -0,0 +1,50 @@ +-- Regression for issue #26128. +-- Public DATA BRANCH output paths preserve difficult strings and input tables. +-- The batch.Dup failure injection itself remains in frontend Go tests. +drop database if exists bvt_issue_26128; +create database bvt_issue_26128; +use bvt_issue_26128; + +create table base( + id int primary key, + payload varchar(200) +); +insert into base values + (1, 'comma,value'), + (2, 'quote"value'), + (3, 'back\\slash'), + (4, '中文原值'), + (5, 'line1\nline2'); +data branch create table branch_t from base; +update branch_t set payload = 'comma,updated' where id = 1; +delete from branch_t where id = 2; +update branch_t set payload = '中文"更新"' where id = 4; +insert into branch_t values (6, 'new\nline'); + +select id, hex(payload) as payload_hex from base order by id; +select id, hex(payload) as payload_hex from branch_t order by id; + +-- The path and hint are generated dynamically; success and both columns are +-- still required, while their text is excluded from baseline comparison. +-- @ignore:0,1 +data branch diff branch_t against base output file '/tmp/'; + +data branch diff branch_t against base output as diff_rows; +select __mo_diff_source, + __mo_diff_flag, + id, + hex(payload) as payload_hex +from diff_rows +order by id; +select count(*) as output_as_branch_metadata +from mo_catalog.mo_branch_metadata b +join mo_catalog.mo_tables t on t.rel_id = b.table_id +where t.account_id = 0 + and t.reldatabase = 'bvt_issue_26128' + and t.relname = 'diff_rows'; + +-- Output generation must not mutate either input. +select id, hex(payload) as payload_hex from base order by id; +select id, hex(payload) as payload_hex from branch_t order by id; + +drop database bvt_issue_26128; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26136_vectors.result b/test/distributed/cases/git4data/branch/edge/issue_26136_vectors.result new file mode 100644 index 0000000000000..b402ded092e9f --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26136_vectors.result @@ -0,0 +1,79 @@ +drop database if exists bvt_issue_26136; +create database bvt_issue_26136; +use bvt_issue_26136; +create table base( +id int primary key, +bf vecbf16(3), +h vecf16(3), +i8 vecint8(3), +u8 vecuint8(3), +f32 vecf32(3), +f64 vecf64(3) +); +insert into base values +(1, null, null, null, null, null, null), +(2, '[1,2,3]', '[4,5,6]', '[-128,0,127]', '[0,1,255]', +'[1.25,2.5,3.75]', '[4.5,5.5,6.5]'), +(3, '[2,2,2]', '[3,3,3]', '[-3,0,3]', '[3,4,5]', +'[2.25,2.5,2.75]', '[3.25,3.5,3.75]'), +(4, '[4,4,4]', '[5,5,5]', '[-4,0,4]', '[4,5,6]', +'[4.25,4.5,4.75]', '[5.25,5.5,5.75]'); +data branch create table left_b from base; +data branch create table right_b from base; +data branch create table merge_dst from base; +update right_b set +bf = '[7,8,9]', +h = '[10,11,12]', +i8 = '[-1,-2,-3]', +u8 = '[253,254,255]', +f32 = '[9,8,7]', +f64 = '[6,5,4]' +where id = 1; +update right_b set +bf = '[9,8,7]', +h = '[6,5,4]', +i8 = '[-127,1,126]', +u8 = '[255,128,0]', +f32 = '[7.75,8.5,9.25]', +f64 = '[6.75,5.5,4.25]' +where id = 2; +update right_b set +bf = null, +h = null, +i8 = null, +u8 = null, +f32 = null, +f64 = null +where id = 3; +delete from right_b where id = 4; +insert into right_b values +(5, '[5,5,5]', '[6,6,6]', '[-5,0,5]', '[0,127,255]', +'[5.25,5.5,5.75]', '[6.25,6.5,6.75]'); +select id, bf, h, i8, u8, f32, f64 from left_b order by id; +➤ id[4,32,0] ¦ bf[12,3,0] ¦ h[12,3,0] ¦ i8[12,3,0] ¦ u8[12,3,0] ¦ f32[12,3,0] ¦ f64[12,3,0] 𝄀 +1 ¦ null ¦ null ¦ null ¦ null ¦ null ¦ null 𝄀 +2 ¦ [1, 2, 3] ¦ [4, 5, 6] ¦ [-128, 0, 127] ¦ [0, 1, 255] ¦ [1.25, 2.5, 3.75] ¦ [4.5, 5.5, 6.5] 𝄀 +3 ¦ [2, 2, 2] ¦ [3, 3, 3] ¦ [-3, 0, 3] ¦ [3, 4, 5] ¦ [2.25, 2.5, 2.75] ¦ [3.25, 3.5, 3.75] 𝄀 +4 ¦ [4, 4, 4] ¦ [5, 5, 5] ¦ [-4, 0, 4] ¦ [4, 5, 6] ¦ [4.25, 4.5, 4.75] ¦ [5.25, 5.5, 5.75] +data branch diff right_b against left_b output summary; +➤ metric[12,0,0] ¦ right_b[-5,0,0] ¦ left_b[-5,0,0] 𝄀 +INSERTED ¦ 1 ¦ 0 𝄀 +DELETED ¦ 1 ¦ 0 𝄀 +UPDATED ¦ 3 ¦ 0 +data branch pick right_b into left_b keys(1, 2, 3, 4); +data branch merge right_b into merge_dst; +select id, bf, h, i8, u8, f32, f64 from left_b order by id; +➤ id[4,32,0] ¦ bf[12,3,0] ¦ h[12,3,0] ¦ i8[12,3,0] ¦ u8[12,3,0] ¦ f32[12,3,0] ¦ f64[12,3,0] 𝄀 +1 ¦ [7, 8, 9] ¦ [10, 11, 12] ¦ [-1, -2, -3] ¦ [253, 254, 255] ¦ [9, 8, 7] ¦ [6, 5, 4] 𝄀 +2 ¦ [9, 8, 7] ¦ [6, 5, 4] ¦ [-127, 1, 126] ¦ [255, 128, 0] ¦ [7.75, 8.5, 9.25] ¦ [6.75, 5.5, 4.25] 𝄀 +3 ¦ null ¦ null ¦ null ¦ null ¦ null ¦ null +select count(*) as unselected_insert_rows from left_b where id = 5; +➤ unselected_insert_rows[-5,64,0] 𝄀 +0 +select id, bf, h, i8, u8, f32, f64 from merge_dst order by id; +➤ id[4,32,0] ¦ bf[12,3,0] ¦ h[12,3,0] ¦ i8[12,3,0] ¦ u8[12,3,0] ¦ f32[12,3,0] ¦ f64[12,3,0] 𝄀 +1 ¦ [7, 8, 9] ¦ [10, 11, 12] ¦ [-1, -2, -3] ¦ [253, 254, 255] ¦ [9, 8, 7] ¦ [6, 5, 4] 𝄀 +2 ¦ [9, 8, 7] ¦ [6, 5, 4] ¦ [-127, 1, 126] ¦ [255, 128, 0] ¦ [7.75, 8.5, 9.25] ¦ [6.75, 5.5, 4.25] 𝄀 +3 ¦ null ¦ null ¦ null ¦ null ¦ null ¦ null 𝄀 +5 ¦ [5, 5, 5] ¦ [6, 6, 6] ¦ [-5, 0, 5] ¦ [0, 127, 255] ¦ [5.25, 5.5, 5.75] ¦ [6.25, 6.5, 6.75] +drop database bvt_issue_26136; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26136_vectors.sql b/test/distributed/cases/git4data/branch/edge/issue_26136_vectors.sql new file mode 100644 index 0000000000000..063b5b662e495 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26136_vectors.sql @@ -0,0 +1,69 @@ +-- Regression for issue #26136. +-- DATA BRANCH supports all vector families, NULL transitions, and boundaries. +drop database if exists bvt_issue_26136; +create database bvt_issue_26136; +use bvt_issue_26136; + +create table base( + id int primary key, + bf vecbf16(3), + h vecf16(3), + i8 vecint8(3), + u8 vecuint8(3), + f32 vecf32(3), + f64 vecf64(3) +); +insert into base values + (1, null, null, null, null, null, null), + (2, '[1,2,3]', '[4,5,6]', '[-128,0,127]', '[0,1,255]', + '[1.25,2.5,3.75]', '[4.5,5.5,6.5]'), + (3, '[2,2,2]', '[3,3,3]', '[-3,0,3]', '[3,4,5]', + '[2.25,2.5,2.75]', '[3.25,3.5,3.75]'), + (4, '[4,4,4]', '[5,5,5]', '[-4,0,4]', '[4,5,6]', + '[4.25,4.5,4.75]', '[5.25,5.5,5.75]'); +data branch create table left_b from base; +data branch create table right_b from base; +data branch create table merge_dst from base; + +update right_b set + bf = '[7,8,9]', + h = '[10,11,12]', + i8 = '[-1,-2,-3]', + u8 = '[253,254,255]', + f32 = '[9,8,7]', + f64 = '[6,5,4]' +where id = 1; +update right_b set + bf = '[9,8,7]', + h = '[6,5,4]', + i8 = '[-127,1,126]', + u8 = '[255,128,0]', + f32 = '[7.75,8.5,9.25]', + f64 = '[6.75,5.5,4.25]' +where id = 2; +update right_b set + bf = null, + h = null, + i8 = null, + u8 = null, + f32 = null, + f64 = null +where id = 3; +delete from right_b where id = 4; +insert into right_b values + (5, '[5,5,5]', '[6,6,6]', '[-5,0,5]', '[0,127,255]', + '[5.25,5.5,5.75]', '[6.25,6.5,6.75]'); + +select id, bf, h, i8, u8, f32, f64 from left_b order by id; +data branch diff right_b against left_b output summary; +data branch pick right_b into left_b keys(1, 2, 3, 4); +data branch merge right_b into merge_dst; + +-- PICK covers NULL->value, value->value, value->NULL, and DELETE. +select id, bf, h, i8, u8, f32, f64 from left_b order by id; +-- The unselected INSERT remains absent from PICK. +select count(*) as unselected_insert_rows from left_b where id = 5; +-- MERGE covers the same transitions plus INSERT. +select id, bf, h, i8, u8, f32, f64 from merge_dst order by id; + +drop database bvt_issue_26136; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26205_deep_lineage.result b/test/distributed/cases/git4data/branch/edge/issue_26205_deep_lineage.result new file mode 100644 index 0000000000000..eb93f6e4668be --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26205_deep_lineage.result @@ -0,0 +1,183 @@ +drop database if exists bvt_issue_26205; +create database bvt_issue_26205; +use bvt_issue_26205; +create table b0(id int primary key, val int); +insert into b0 values (1, 10), (2, 20); +data branch create table b1 from b0; +update b1 set val = 11 where id = 1; +data branch create table b2 from b1; +insert into b2 values (3, 30); +data branch create table b3 from b2; +delete from b3 where id = 2; +data branch create table b4 from b3; +data branch create table b5 from b4; +data branch create table b6 from b5; +data branch create table b7 from b6; +data branch create table b8 from b7; +data branch create table b9 from b8; +data branch create table b10 from b9; +data branch create table b11 from b10; +data branch create table b12 from b11; +data branch create table b13 from b12; +data branch create table b14 from b13; +data branch create table b15 from b14; +data branch create table b16 from b15; +data branch create table sibling from b8; +update sibling set val = 88 where id = 1; +insert into sibling values (5, 50); +update b16 set val = 33 where id = 3; +insert into b16 values (4, 40); +data branch create table merge_dst from b0; +data branch create table pick_dst from b0; +data branch diff b16 against b0 output summary; +➤ metric[12,0,0] ¦ b16[-5,0,0] ¦ b0[-5,0,0] 𝄀 +INSERTED ¦ 2 ¦ 0 𝄀 +DELETED ¦ 1 ¦ 0 𝄀 +UPDATED ¦ 1 ¦ 0 +data branch diff b16 against sibling output summary; +➤ metric[12,0,0] ¦ b16[-5,0,0] ¦ sibling[-5,0,0] 𝄀 +INSERTED ¦ 1 ¦ 1 𝄀 +DELETED ¦ 0 ¦ 0 𝄀 +UPDATED ¦ 1 ¦ 1 +data branch pick b16 into pick_dst keys(1, 2, 3, 4); +data branch merge b16 into merge_dst; +select id, val from b16 order by id; +➤ id[4,32,0] ¦ val[4,32,0] 𝄀 +1 ¦ 11 𝄀 +3 ¦ 33 𝄀 +4 ¦ 40 +select id, val from sibling order by id; +➤ id[4,32,0] ¦ val[4,32,0] 𝄀 +1 ¦ 88 𝄀 +3 ¦ 30 𝄀 +5 ¦ 50 +select id, val from pick_dst order by id; +➤ id[4,32,0] ¦ val[4,32,0] 𝄀 +1 ¦ 11 𝄀 +3 ¦ 33 𝄀 +4 ¦ 40 +select id, val from merge_dst order by id; +➤ id[4,32,0] ¦ val[4,32,0] 𝄀 +1 ¦ 11 𝄀 +3 ¦ 33 𝄀 +4 ¦ 40 +select count(*) as active_lineage_nodes +from mo_catalog.mo_branch_metadata b +join mo_catalog.mo_tables t on t.rel_id = b.table_id +where t.account_id = 0 +and t.reldatabase = 'bvt_issue_26205' +and t.relname in ( +'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', +'b9', 'b10', 'b11', 'b12', 'b13', 'b14', 'b15', 'b16' +) +and b.table_deleted = false; +➤ active_lineage_nodes[-5,64,0] 𝄀 +16 +create table lineage_ids(name varchar(32) primary key, table_id bigint unsigned); +insert into lineage_ids +select relname, rel_id +from mo_catalog.mo_tables +where account_id = 0 +and reldatabase = 'bvt_issue_26205' +and relname in ( +'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', +'b9', 'b10', 'b11', 'b12', 'b13', 'b14', 'b15', 'b16', +'sibling' +); +data branch delete table b8; +select b.table_deleted as deleted_intermediate +from lineage_ids i +join mo_catalog.mo_branch_metadata b on b.table_id = i.table_id +where i.name = 'b8'; +➤ deleted_intermediate[-7,1,0] 𝄀 +1 +select count(*) as protected_intermediate_snapshots +from lineage_ids i +join mo_catalog.mo_snapshots s +on s.sname = concat('__mo_branch_', cast(i.table_id as char)) +and s.kind = 'branch' +where i.name = 'b8'; +➤ protected_intermediate_snapshots[-5,64,0] 𝄀 +1 +data branch diff b16 against sibling output summary; +➤ metric[12,0,0] ¦ b16[-5,0,0] ¦ sibling[-5,0,0] 𝄀 +INSERTED ¦ 1 ¦ 1 𝄀 +DELETED ¦ 0 ¦ 0 𝄀 +UPDATED ¦ 1 ¦ 1 +data branch create table post_delete_dst from b0; +data branch pick sibling into post_delete_dst keys(1, 2, 3, 5); +select id, val from post_delete_dst order by id; +➤ id[4,32,0] ¦ val[4,32,0] 𝄀 +1 ¦ 88 𝄀 +3 ¦ 30 𝄀 +5 ¦ 50 +data branch delete table b9; +data branch delete table b10; +data branch delete table b11; +data branch delete table b12; +data branch delete table b13; +data branch delete table b14; +data branch delete table b15; +data branch delete table b16; +select count(*) as live_split_owner_snapshots +from lineage_ids i +join mo_catalog.mo_snapshots s +on s.sname = concat('__mo_branch_', cast(i.table_id as char)) +and s.kind = 'branch' +where i.name in ('b8', 'sibling'); +➤ live_split_owner_snapshots[-5,64,0] 𝄀 +2 +select count(*) as drained_descendant_snapshots +from lineage_ids i +join mo_catalog.mo_snapshots s +on s.sname = concat('__mo_branch_', cast(i.table_id as char)) +and s.kind = 'branch' +where i.name in ('b9', 'b10', 'b11', 'b12', 'b13', 'b14', 'b15', 'b16'); +➤ drained_descendant_snapshots[-5,64,0] 𝄀 +0 +data branch diff sibling against b0 output summary; +➤ metric[12,0,0] ¦ sibling[-5,0,0] ¦ b0[-5,0,0] 𝄀 +INSERTED ¦ 2 ¦ 0 𝄀 +DELETED ¦ 1 ¦ 0 𝄀 +UPDATED ¦ 1 ¦ 0 +data branch delete table sibling; +select count(*) as intermediate_snapshots_after_last_child +from lineage_ids i +join mo_catalog.mo_snapshots s +on s.sname = concat('__mo_branch_', cast(i.table_id as char)) +and s.kind = 'branch' +where i.name = 'b8'; +➤ intermediate_snapshots_after_last_child[-5,64,0] 𝄀 +0 +data branch delete table b1; +select count(*) as root_snapshots_with_live_descendant +from lineage_ids i +join mo_catalog.mo_snapshots s +on s.sname = concat('__mo_branch_', cast(i.table_id as char)) +and s.kind = 'branch' +where i.name = 'b1'; +➤ root_snapshots_with_live_descendant[-5,64,0] 𝄀 +1 +data branch delete table b2; +data branch delete table b3; +data branch delete table b4; +data branch delete table b5; +data branch delete table b6; +data branch delete table b7; +select count(*) as remaining_lineage_snapshots +from lineage_ids i +join mo_catalog.mo_snapshots s +on s.sname = concat('__mo_branch_', cast(i.table_id as char)) +and s.kind = 'branch'; +➤ remaining_lineage_snapshots[-5,64,0] 𝄀 +0 +select count(*) as deleted_lineage_rows +from lineage_ids i +join mo_catalog.mo_branch_metadata b on b.table_id = i.table_id +where b.table_deleted = true; +➤ deleted_lineage_rows[-5,64,0] 𝄀 +17 +data branch delete table post_delete_dst; +data branch delete table merge_dst; +data branch delete table pick_dst; +drop database bvt_issue_26205; diff --git a/test/distributed/cases/git4data/branch/edge/issue_26205_deep_lineage.sql b/test/distributed/cases/git4data/branch/edge/issue_26205_deep_lineage.sql new file mode 100644 index 0000000000000..40a8a38ef1de1 --- /dev/null +++ b/test/distributed/cases/git4data/branch/edge/issue_26205_deep_lineage.sql @@ -0,0 +1,152 @@ +-- Regression for issue #26205. +-- Public control: a valid deep DATA BRANCH lineage remains traversable. +-- Cyclic in-memory metadata is constructed directly by the NewDAG Go test. +drop database if exists bvt_issue_26205; +create database bvt_issue_26205; +use bvt_issue_26205; + +create table b0(id int primary key, val int); +insert into b0 values (1, 10), (2, 20); +data branch create table b1 from b0; +update b1 set val = 11 where id = 1; +data branch create table b2 from b1; +insert into b2 values (3, 30); +data branch create table b3 from b2; +delete from b3 where id = 2; +data branch create table b4 from b3; +data branch create table b5 from b4; +data branch create table b6 from b5; +data branch create table b7 from b6; +data branch create table b8 from b7; +data branch create table b9 from b8; +data branch create table b10 from b9; +data branch create table b11 from b10; +data branch create table b12 from b11; +data branch create table b13 from b12; +data branch create table b14 from b13; +data branch create table b15 from b14; +data branch create table b16 from b15; + +data branch create table sibling from b8; +update sibling set val = 88 where id = 1; +insert into sibling values (5, 50); +update b16 set val = 33 where id = 3; +insert into b16 values (4, 40); +data branch create table merge_dst from b0; +data branch create table pick_dst from b0; + +data branch diff b16 against b0 output summary; +data branch diff b16 against sibling output summary; +data branch pick b16 into pick_dst keys(1, 2, 3, 4); +data branch merge b16 into merge_dst; + +select id, val from b16 order by id; +select id, val from sibling order by id; +select id, val from pick_dst order by id; +select id, val from merge_dst order by id; +select count(*) as active_lineage_nodes +from mo_catalog.mo_branch_metadata b +join mo_catalog.mo_tables t on t.rel_id = b.table_id +where t.account_id = 0 + and t.reldatabase = 'bvt_issue_26205' + and t.relname in ( + 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', + 'b9', 'b10', 'b11', 'b12', 'b13', 'b14', 'b15', 'b16' + ) + and b.table_deleted = false; + +-- Keep stable table ids after their physical tables are deleted. Deleting an +-- intermediate owner must retain its protect snapshot while a descendant is +-- alive, and the surviving branches must remain usable through that history. +create table lineage_ids(name varchar(32) primary key, table_id bigint unsigned); +insert into lineage_ids +select relname, rel_id +from mo_catalog.mo_tables +where account_id = 0 + and reldatabase = 'bvt_issue_26205' + and relname in ( + 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', + 'b9', 'b10', 'b11', 'b12', 'b13', 'b14', 'b15', 'b16', + 'sibling' + ); + +data branch delete table b8; +select b.table_deleted as deleted_intermediate +from lineage_ids i +join mo_catalog.mo_branch_metadata b on b.table_id = i.table_id +where i.name = 'b8'; +select count(*) as protected_intermediate_snapshots +from lineage_ids i +join mo_catalog.mo_snapshots s + on s.sname = concat('__mo_branch_', cast(i.table_id as char)) + and s.kind = 'branch' +where i.name = 'b8'; + +data branch diff b16 against sibling output summary; +data branch create table post_delete_dst from b0; +data branch pick sibling into post_delete_dst keys(1, 2, 3, 5); +select id, val from post_delete_dst order by id; + +-- Delete the long descendant path parent-first. b8 stays protected by its +-- live sibling, while the drained b9..b16 path is reclaimed synchronously. +data branch delete table b9; +data branch delete table b10; +data branch delete table b11; +data branch delete table b12; +data branch delete table b13; +data branch delete table b14; +data branch delete table b15; +data branch delete table b16; +select count(*) as live_split_owner_snapshots +from lineage_ids i +join mo_catalog.mo_snapshots s + on s.sname = concat('__mo_branch_', cast(i.table_id as char)) + and s.kind = 'branch' +where i.name in ('b8', 'sibling'); +select count(*) as drained_descendant_snapshots +from lineage_ids i +join mo_catalog.mo_snapshots s + on s.sname = concat('__mo_branch_', cast(i.table_id as char)) + and s.kind = 'branch' +where i.name in ('b9', 'b10', 'b11', 'b12', 'b13', 'b14', 'b15', 'b16'); +data branch diff sibling against b0 output summary; + +-- Once the sibling and the final live descendant are gone, no protect +-- snapshot from the original lineage may remain. +data branch delete table sibling; +select count(*) as intermediate_snapshots_after_last_child +from lineage_ids i +join mo_catalog.mo_snapshots s + on s.sname = concat('__mo_branch_', cast(i.table_id as char)) + and s.kind = 'branch' +where i.name = 'b8'; + +data branch delete table b1; +select count(*) as root_snapshots_with_live_descendant +from lineage_ids i +join mo_catalog.mo_snapshots s + on s.sname = concat('__mo_branch_', cast(i.table_id as char)) + and s.kind = 'branch' +where i.name = 'b1'; +data branch delete table b2; +data branch delete table b3; +data branch delete table b4; +data branch delete table b5; +data branch delete table b6; +data branch delete table b7; + +select count(*) as remaining_lineage_snapshots +from lineage_ids i +join mo_catalog.mo_snapshots s + on s.sname = concat('__mo_branch_', cast(i.table_id as char)) + and s.kind = 'branch'; +select count(*) as deleted_lineage_rows +from lineage_ids i +join mo_catalog.mo_branch_metadata b on b.table_id = i.table_id +where b.table_deleted = true; + +data branch delete table post_delete_dst; +data branch delete table merge_dst; +data branch delete table pick_dst; + +drop database bvt_issue_26205;