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

Đang mở
#3,979 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go, postgresql
Lĩnh vực
databases

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Go
Star
2.2k
Fork
93
Merge trung bình
19 giờ 38 phút
Pull request đã merge (30 ngày)
132

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dolthub/doltgresql

Tất cả issue của dolthub/doltgresql

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.