Merge succeeds with invalid generated-column expression after source column rename
- Dominant language
- Go
- Stars
- 24.4k
- Forks
- 873
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 121
Description
### Description
A three-way schema merge can report success with zero conflicts while producing a table whose generated-column expression references a column name that no longer exists.
One branch adds a generated column based on `a`; the other branch renames `a` to `base`. The merge keeps the renamed column but does not rewrite or reject the generated expression, so even `SHOW CREATE TABLE` fails afterward.
### Reproduction
Start in a new directory:
```sh
dolt init --name oracle --email oracle@test
dolt sql <<'SQL'
CREATE TABLE t(id INTEGER PRIMARY KEY, a INT);
INSERT INTO t VALUES (1, 5);
CALL dolt_commit('-Am', 'ancestor');
CALL dolt_branch('feat');
CALL dolt_checkout('feat');
ALTER TABLE t ADD COLUMN doubled INT GENERATED ALWAYS AS (a * 2) VIRTUAL;
CALL dolt_commit('-Am', 'add generated');
CALL dolt_checkout('main');
ALTER TABLE t RENAME COLUMN a TO base;
CALL dolt_commit('-Am', 'rename source');
CALL dolt_merge('feat');
SHOW CREATE TABLE t;
SELECT id, base, doubled FROM t;
SQL
```
### Actual behavior
`dolt_merge` reports a successful merge with no conflicts:
```text
| fast_forward | conflicts | message |
| 0 | 0 | merge successful |
```
The next statement fails:
```text
error on line 1 for query SHOW CREATE TABLE t: column "a" could not be found in any table in scope
```
The merged schema retained the generated expression's reference to `a`, even though the merged source column is named `base`.
### Expected behavior
The merge must not report success and install an invalid schema. It should either:
- produce a valid merged schema, rewriting the generated expression to reference `base`; or
- return a handled schema conflict and leave the working state valid.
### Environment
- Dolt 2.2.2
- macOS arm64
Contributor guide
No contributing guide indexed for this repository
Research direction
Run the supplied dolt_merge SQL reproduction first, including SHOW CREATE TABLE and the SELECT after the merge. Trace the three-way schema merge and generated-column handling for the rename and added-column branches. Done means the merge either rewrites the expression to base or reports a handled schema conflict without installing an invalid schema.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100