4022
MariaDBERRORNotableSystem VersioningHIGH confidence

System versioned table: row start/end column has wrong type

What this means

ER_VERS_FIELD_WRONG_TYPE (4022) is returned when the row_start or row_end column of a system-versioned table is defined with an incompatible data type. These columns must be TIMESTAMP(6) or BIGINT UNSIGNED.

How to reproduce
trigger — this will error
trigger — this will error
CREATE TABLE orders (
  id INT PRIMARY KEY,
  row_start INT,  -- wrong: must be TIMESTAMP(6) or BIGINT UNSIGNED
  row_end   INT,
  PERIOD FOR SYSTEM_TIME(row_start, row_end)
) WITH SYSTEM VERSIONING;

expected output

ERROR 4022 (HY000): Sys-ver field 'row_start' has wrong type

Fix

Use TIMESTAMP(6) for the versioning period columns

WHEN When creating or altering a system-versioned table.

Use TIMESTAMP(6) for the versioning period columns
CREATE TABLE orders (
  id INT PRIMARY KEY,
  row_start TIMESTAMP(6) GENERATED ALWAYS AS ROW START,
  row_end   TIMESTAMP(6) GENERATED ALWAYS AS ROW END,
  PERIOD FOR SYSTEM_TIME(row_start, row_end)
) WITH SYSTEM VERSIONING;

Why this works

TIMESTAMP(6) with GENERATED ALWAYS AS ROW START/END is the canonical definition for system-versioned tables in MariaDB.

What not to do

Use INT or DATETIME for versioning columns

Only TIMESTAMP(6) and BIGINT UNSIGNED are valid for system-time period columns — any other type causes error 4022.

Version notes
MariaDB 10.3

System versioning (temporal tables) was introduced in MariaDB 10.3. The 4022–4030 range covers system-versioning errors.

Sources
Official documentation ↗

MariaDB — System-Versioned Tables

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors