Repository navigation
Handle dropped FK parent tables in constraint verification and merge - #5838
Conversation
When a foreign-key parent table is absent from the current catalog (and not a nonlocal table), skip parent PK backfill and omit the NOT EXISTS subquery against the missing parent table so empty child tables and rows with NULL FK columns yield 0 violations without error, while non-NULL orphaned child rows are recorded as foreign key violations (tolerating NULL ReferencedColumns entries when the FK omitted explicit parent column names). In dolt_verify_constraints(), also pass tables dropped since HEAD to appendFkChildren() so unchanged child tables referencing a dropped parent are included in the default scan. Fixes #5808
|
Gate: success · CI run Engine counters: success Performance hotspotsPR-base gates: 1.25× per workload and 1.15× per section/suite, with a 10 ms minimum regression and confirmation across three attempts. Stock ratios expose standing gaps and are reported separately. Retained workloads report fixed batches; xN in a workload name is the number of repetitions. A workload marked ×N times N repetitions as one batch, each after the same untimed warm-up, so small workloads clear the 10 ms floor; its ms are the batch total. Add Column With Default#3233: deferred to the storage-format upgrade.
Wide Row Trade-offsWide values are read from disk whenever they are fetched until they move out of band: #3325. 8,192 rows per table, 4 MiB cache (768 KiB for
Uncached Reads65,536 rows with 1024 B payloads, about 68 MB, under a 4 MiB cache: every chunk read is verified against its BLAKE3 content address, while SQLite reads the same pages from the OS cache (#3408). Stock is SQLite.
Primary Key Index RewritesSecondary index entries carry the primary key, so changing a non-integer key rewrites every index entry of the row, while SQLite's indexes point at an unchanged rowid; the no-index and integer-key cases are the controls (#3419). Fixed workloads use 65,536 rows with 256 B payloads; retained workloads use the parameters in their linked issues. Each timed statement runs in a transaction that rolls back. Stock is SQLite.
Text Key Index FetchesRows are clustered by their primary key and there is no rowid, so a non-covering index fetch searches the table by the key the index entry carries; a text key costs a byte-wise search where SQLite seeks an integer rowid. The integer-key case is the control (#3492). Fixed workloads use 65,536 rows with 256 B payloads; retained workloads use the parameters in their linked issues. Each timed statement runs in a transaction that rolls back. Stock is SQLite.
Pending Edit MapUncommitted edits live in a sorted pending map: writes pay to fill it, and reads in the transaction merge it with the tree and skip its deletes. The file-backed update and live-row probes are the controls (#3418). Fixed workloads use 65,536 rows with 256 B payloads; retained workloads use the parameters in their linked issues. Each timed statement runs in a transaction that rolls back. Stock is SQLite.
In Transaction with MutationsEach timed statement follows an untimed mutation in the same transaction; rollback is untimed.
|
DoltLite performance vs PR base
blobpk details
compositepk details
int details
textpk details
vc details
File remotes: 100 MB, 5 paired runs; 25% + 5ms individual / 15% aggregate gates, three-attempt confirmation. All relative performance gates passed. |
DoltLite source coverage
Merged 152 pooled raw profiles from the distributed Linux correctness jobs. Per-file coverage (108 files)
|
Fixes #5808
Summary
src/doltlite_merge_constraints_fk.c:aCur(and not nonlocal) with no schema conflict on the child table, skipbackfillParentPk, omit theAND NOT EXISTS (SELECT 1 FROM main."%w" AS p ...)clause (and parent catalog lookup), and tolerate NULLazToslots inbuildFkViolationInfowhen the FK omitted explicit parent column names.no such table; non-NULL child rows are recorded asforeign keyviolations.src/doltlite_verify_constraints.c:HEAD(present inaAncbut absent fromaCur) and pass them toappendFkChildrenso unchanged child tables referencing a dropped parent are scanned by defaultdolt_verify_constraints().test/doltlite_fk_metadata.test:REFERENCES p) and explicit (REFERENCES p(id)) foreign keys with dropped parent tables for empty child tables, NULL FK rows, and non-NULL orphaned rows underdolt_verify_constraints(),dolt_verify_constraints('--all'), anddolt_merge().Testing
build/doltliteandbuild/testfixture.doltlite_fk_metadata,doltlite_fk_lookup,doltlite_fk_parent_affinity,doltlite_merge_dropped_fk,doltlite_constraint_violation_json,doltlite_constraint_rowid,doltlite_constraint_temp_shadow,doltlite_merge_constraint_prune,doltlite_nonlocal_tables,doltlite_workspace_fk,doltlite_workspace_shadowed_fk.lint_layers.sh,lint_no_raw_os_fileio.sh,lint_ref_writers.sh,lint_prolly_guards.sh,lint_suite_finish_exit.sh,lint_new_table_am.sh,lint_native_test_helpers.sh.