Merge fails with "syntax error" when a table's CHECK uses a jsonb operator and either side changed the schema

未关闭
#3,979 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go, postgresql
领域
databases

调研方向

Reproduce with the setup SQL in the issue against doltgresql: create the table with the jsonb CHECK, branch to src and dst, change the schema on src, change data on dst, then run dolt_merge. Find where the syntax error is raised during the merge, since the same history without a CHECK succeeds. Done when the merge completes for the ->>, -> and ? cases and the @> refusal is addressed or split out.

由索引模型根据 Issue 内容生成。

描述

customer issue

Doltgres version: 1.5.1

Setup:

CREATE TABLE objects (
  id text PRIMARY KEY,
  project_id text NOT NULL,
  body jsonb NOT NULL,
  CHECK (body->>'left' <> 'forbidden')
);
INSERT INTO objects VALUES ('r1', 'p1', '{"left": "a"}');
SELECT dolt_commit('-Am', 'base');
SELECT dolt_branch('dst');
SELECT dolt_branch('src');

On src, change the schema:

-- connected to src
ALTER TABLE objects ADD COLUMN extra text;
UPDATE objects SET extra = 'x' WHERE id = 'r1';
SELECT dolt_commit('-Am', 'add column');

On dst, change any data:

-- connected to dst
UPDATE objects SET project_id = 'p2' WHERE id = 'r1';
SELECT dolt_commit('-Am', 'edit');
SELECT dolt_merge('src');

Expected: the merge succeeds, because the two changes do not conflict.

Actual: ERROR: syntax error at position 18 near 'body' (SQLSTATE XX000). Nothing is merged.

Observations:

  • The -> operator fails the same way. With ? (CHECK (body ? 'left')), the message is syntax error at position 16 near ':v1'.
  • It also fails when the source drops a column, when the source adds the CHECK itself, and when only the destination added a column while the source changed data.
  • These succeed: the same history with no CHECK, a function-form CHECK (CHECK (jsonb_typeof(body) = 'object')), data-only changes on both sides, and a merge into a destination with no change since the merge base.
  • Separately, a CHECK using @> cannot hold a row: the first INSERT fails with JSON contains is not yet supported.
  • The same refusal occurs inside an explicit transaction (BEGIN before dolt_merge), so it does not depend on autocommit.
主要语言
Go
星标
2.2k
派生
93
平均合并
19 小时 38 分钟
30 天内合并 PR
132

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

dolthub/doltgresql 的其他 Issue

查看 dolthub/doltgresql 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。