[Bug]: COPY ADD NOT NULL without DEFAULT synthesizes invalid VARBINARY/YEAR/UUID/TIMESTAMP backfills
I maintainer di solito rispondono entro 1 giorno
@matrix-meow ci sta già lavorando.
Dal 27/11/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Description
Tested on MatrixOne main c0cef5c9cce2164fedd201c188bfffe4d2d09a96 (version() = 8.0.30-MatrixOne-v1.3.0, git_version() = c0cef5c), single CN.
On a nonempty table, COPY ADD of a NOT NULL column without an explicit DEFAULT synthesizes invalid backfill expressions for VARBINARY, YEAR, UUID, and TIMESTAMP:
- VARBINARY, YEAR, and UUID fall through to literal SQL
NULLand fail with 3819. - TIMESTAMP uses the out-of-range literal
0001-01-01 00:00:00and fails with 1366.
These statements should backfill existing rows with a valid implicit zero value for the type, as the INT omitted-default control and the corresponding explicit-default controls do. They must not manufacture an internal NULL or a timestamp below the supported lower bound.
Minimal reproductions
VARBINARY
CREATE TABLE t_vb(a INT);
INSERT INTO t_vb VALUES(1),(2);
ALTER TABLE t_vb ALGORITHM=COPY,ADD COLUMN v VARBINARY(8) NOT NULL;
Actual result:
Error 3819: Column 'v' cannot be null
Expected result: success, with both existing rows backfilled to the empty byte string (HEX(v)='').
YEAR
CREATE TABLE t_year(a INT);
INSERT INTO t_year VALUES(1),(2);
ALTER TABLE t_year ALGORITHM=COPY,ADD COLUMN v YEAR NOT NULL;
Actual result: Error 3819, Column 'v' cannot be null.
Expected result: success, with existing rows backfilled to 0000.
UUID
CREATE TABLE t_uuid(a INT);
INSERT INTO t_uuid VALUES(1),(2);
ALTER TABLE t_uuid ALGORITHM=COPY,ADD COLUMN v UUID NOT NULL;
Actual result: Error 3819, Column 'v' cannot be null.
Expected result: success, with existing rows backfilled to 00000000-0000-0000-0000-000000000000.
TIMESTAMP
CREATE TABLE t_ts(a INT);
INSERT INTO t_ts VALUES(1),(2);
ALTER TABLE t_ts ALGORITHM=COPY,ADD COLUMN v TIMESTAMP NOT NULL;
Actual result: Error 1366 while converting the synthesized year-1 datetime value.
Expected result: success using the engine's valid implicit zero-timestamp representation, rather than generating 0001-01-01 00:00:00, which is outside the TIMESTAMP value domain.
Positive controls and failure atomicity
For VARBINARY/YEAR/UUID:
- The same ALTER succeeds on an empty table and creates a NOT NULL column.
- Explicit
DEFAULT '',DEFAULT 0, and the zero UUID string respectively succeed and backfill the expected values. ADD COLUMN v INT NOT NULLwithout DEFAULT succeeds and backfills0.
For TIMESTAMP:
- Empty-table ADD and an explicit valid default succeed.
- The legal lower-bound values succeed in UTC and
+08:00controls. - A genuinely out-of-range value after timezone conversion is still rejected.
For every failing nonempty-table statement, the original schema and both original rows remain intact in the same session and a fresh connection. The connection remains usable. Thus this is an erroneous rejection before publication, not partial schema or row corruption.
Root cause
pkg/sql/plan/build_alter_add_column.go invokes buildNotNullColumnVal for COPY ADD NOT NULL when no explicit DEFAULT is present.
In pkg/sql/plan/build_alter_table.go:buildNotNullColumnVal:
T_varbinary,T_year, andT_uuidhave no branch and reach the fallbackdefaultValue = "null";T_timestampreturnsdefaultValue = "'0001-01-01 00:00:00'".
The generated INSERT ... SELECT then enforces NOT NULL against literal NULL for the first three types. For TIMESTAMP, year 1 is below types.TimestampMinValue and is not the engine's special ZeroTimestamp representation. Explicit DEFAULT statements bypass this helper, which explains the positive controls.
Validation
VARBINARY/YEAR/UUID and their empty-table, explicit-default, INT-control, fresh-connection, and atomicity checks passed as 33/33 probe assertions in each of two independent fresh-database runs.
The final TIMESTAMP probe independently passed 27/27 assertions in each of two runs, covering UTC and +08:00, omitted and explicit defaults, legal boundaries, invalid boundaries, and failure atomicity. Earlier TIMESTAMP probe outputs with client-side datetime formatting oracle errors are not used as evidence.
Duplicate check
Open and closed searches covered COPY ADD NOT NULL without DEFAULT, errors 3819/1366, all four types, buildNotNullColumnVal, and the year-1 literal. No matching issue was found.
Closed #15002 was an older vector backfill problem fixed by #15016. Open #20567 concerns other low-precision scalar types. Open #32604 concerns INSERT/default-policy behavior and diagnostics, not this ALTER helper or its year-1 TIMESTAMP expression. #30256, #33280, and #33316-#33318 cover different COPY paths.
- Lingua principale
- Go
- Stelle
- 1.9k
- Fork
- 312
- Merge medio
- 21h 57m
- PR unite (30g)
- 730
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di matrixorigin/matrixone
-
kind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
matrixorigin/matrixone#33363 ·
I maintainer di solito rispondono entro 1 giorno
-
kind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
matrixorigin/matrixone#33362 ·
I maintainer di solito rispondono entro 1 giorno
-
SLEEP rejects NULL and negative durations that MySQL acceptsForse già presa @XuPeng-SH l’ha presa 8 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
matrixorigin/matrixone#32653 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Shared CI loses Coverage results during GitHub throttling and runs 4.2-dev with the wrong GoForse già presa @XuPeng-SH l’ha presa oggi. Aperta
matrixorigin/matrixone#33416 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: RENAME COLUMN leaves stale partition expression and unreplayable SHOW CREATEForse già presa @matrix-meow l’ha presa oggi. Apertakind/bug needs-triage
matrixorigin/matrixone#33397 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di matrixorigin/matrixone
Issue simili
-
enhancement good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno
-
Windows系统上,希望复制路径增加 Unix 格式Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
-
go good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Azure/prometheus-collector#1828 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni