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

Abierto
#3,979 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go, postgresql
Área
databases

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
Go
Estrellas
2.2k
Forks
93
Merge medio
19 h 38 min
PR fusionados (30 d)
132

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de dolthub/doltgresql

Todos los issues de dolthub/doltgresql

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.