Skip to content
8.8 Constraints, Errors, and Troubleshooting

8.8 Constraints, Errors, and Troubleshooting

When migrating SQL from another RDBMS, similar names can suggest equivalent features incorrectly. First check Edition and public syntax, then examine data constraints separately from concurrency issues.

Feature Support

TRANSACTION is Standard Edition only. Cluster rejects CREATE TABLE, CREATE TRANSACTION TABLE, and CREATE TXN TABLE. Specify CREATE LOG TABLE explicitly for LOG.

RequirementSupport or alternative
General SELECT/INSERT/UPDATE/DELETESupported; changes without WHERE target all rows
Single-column PRIMARY KEYSupported; one per table
Single/composite UNIQUE INDEXSupported; create separately after the table
Column UNIQUE or table-level PRIMARY KEYThese creation forms are unsupported
FOREIGN KEY, Trigger, Stored ProcedureUnsupported
BEGIN/COMMIT/ROLLBACKSupported; nested BEGIN and SAVEPOINT unsupported
ADD/DROP/RENAME COLUMN, RENAME TOCheck supported conditions
MODIFY COLUMNUnsupported
AppendCheck SDK public paths and batch boundaries
TAG METADATA/BASETIME/BASEDISTANCENot applicable to TRANSACTION

LOOKUP can support small reference-data changes in Cluster, but is not a complete replacement for explicit relational transactions. Separate requirements appropriately, such as LOG/TAG for source events and another RDBMS for relational transactions.

Diagnosis by Error

SymptomWhat to checkNext action
ERR-01418 uniqueness violationPrimary/unique keys and existing dataCorrect input or review UPSERT rules
NOT NULL violationOmitted values, NULL, empty strings, and DEFAULTCheck input and constraints
UPDATE affects 0 rowsKey and current-state predicatesDistinguish missing/already-processed targets
Resource busyOther writers, stale read snapshots, and open cursorsWait, restart the transaction, or close cursors as appropriate
COMMIT/ROLLBACK is busyOpen result sets on the same connectionClose result sets and retry termination
Subsequent SQL is rejected after an errorRollback-only stateROLLBACK and start a new operation
DDL failsReferencing indexes/views and active transactionsAdjust dependencies and timing
Mounted values differ from expectationsMount, owner, and table namesDistinguish production from backup data

Resource busy errors require different retry strategies. See the two-connection exercises in Locks and Busy Timeout. Do not retry solely because the error text contains TRANSACTION.

Constraint Errors and Data Preservation

CREATE TRANSACTION TABLE ch8_error (
    id    LONG PRIMARY KEY,
    code  VARCHAR(32) NOT NULL,
    value INTEGER
);
CREATE UNIQUE INDEX ch8_error_code ON ch8_error(code);
INSERT INTO ch8_error VALUES (1, 'A', 10);

Each optional example below intentionally fails. Run only the statement being checked, separately from normal SQL.

-- Duplicate PRIMARY KEY
INSERT INTO ch8_error VALUES (1, 'B', 20);
-- Duplicate UNIQUE key
INSERT INTO ch8_error VALUES (2, 'A', 20);
-- Required-value violation
INSERT INTO ch8_error VALUES (3, NULL, 30);
-- Unsupported schema change
ALTER TABLE ch8_error MODIFY COLUMN (code VARCHAR(64));
SELECT id, code, value FROM ch8_error ORDER BY id;
DROP TABLE ch8_error;

The final query contains only (1, A, 10). Distinguish a failed statement preserving state from automatic cancellation of earlier successful statements inside BEGIN; the latter does not follow. See the comparison in Transactions.

Collecting Diagnostic Information

Collect server version/Edition, DDL and indexes, executed SQL, error code and full message, and actual affected row counts. For connection failures, also record COMMIT request/response times and business keys. Redact passwords, personal information, and sensitive business values; share only a minimal reproducer.

Do not repair by editing internal storage files or recreating production tables. Establish the cause and whether changes were applied first to reduce data loss.

Last updated on