You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This known limitation states that arranging DML statements so they come after DDL statements should work, but it contradicts a few of these examples. And @joshimhoff confirmed that you can't, for example, add a column and then update its value within a single transaction.
The text was updated successfully, but these errors were encountered:
create table t (a int primary key);
begin;
savepoint cockroach_restart;
alter table t add column e int;
select a,e from t;
ERROR: column "e" does not exist
SQLSTATE: 42703
create table t (a int primary key);
begin;
savepoint cockroach_restart;
alter table t add column e int;
update t set e = 1;
ERROR: column "e" does not exist
SQLSTATE: 42703
Note that the example in this section of the docs DOES work. (I.e., if the table is created inside the transaction, it works.)
BEGIN;
SAVEPOINT cockroach_restart;
CREATE TABLE fruits (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name STRING,
color STRING
);
INSERT INTO fruits (name, color) VALUES ('apple', 'red');
ALTER TABLE fruits ADD COLUMN inventory_count INTEGER DEFAULT 5;
ALTER TABLE fruits ADD CONSTRAINT name CHECK (name IN ('apple', 'banana', 'orange'));
SELECT name, color, inventory_count FROM fruits;
RELEASE SAVEPOINT cockroach_restart;
COMMIT;
This known limitation states that arranging DML statements so they come after DDL statements should work, but it contradicts a few of these examples. And @joshimhoff confirmed that you can't, for example, add a column and then update its value within a single transaction.
The text was updated successfully, but these errors were encountered: