Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALTER TABLE support for ADD COLUMN, DROP COLUMN, and RENAME COLUMN #785

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

fulghum
Copy link
Contributor

@fulghum fulghum commented Oct 1, 2024

No description provided.

Copy link
Contributor

github-actions bot commented Oct 1, 2024

Main PR
Total 42090 42090
Successful 12164 12342
Failures 29926 29748
Partial Successes1 4914 4915
Main PR
Successful 28.9000% 29.3229%
Failures 71.1000% 70.6771%

Progressions

alter_table

QUERY: ALTER TABLE attmp ADD COLUMN a int4 default 3;
QUERY: ALTER TABLE attmp ADD COLUMN b name;
QUERY: ALTER TABLE attmp ADD COLUMN c text;
QUERY: ALTER TABLE attmp ADD COLUMN d float8;
QUERY: ALTER TABLE attmp ADD COLUMN e float4;
QUERY: ALTER TABLE attmp ADD COLUMN f int2;
QUERY: ALTER TABLE attmp ADD COLUMN i char;
QUERY: ALTER TABLE attmp ADD COLUMN k int4;
QUERY: ALTER TABLE attmp ADD COLUMN m xid;
QUERY: ALTER TABLE attmp ADD COLUMN n oidvector;
QUERY: ALTER TABLE attmp ADD COLUMN p boolean;
QUERY: ALTER TABLE attmp ADD COLUMN v timestamp;
QUERY: ALTER TABLE attmp ADD COLUMN w interval;
QUERY: ALTER TABLE attmp ADD COLUMN x float8[];
QUERY: ALTER TABLE attmp ADD COLUMN y float4[];
QUERY: ALTER TABLE attmp ADD COLUMN z int2[];
QUERY: ALTER TABLE attmp ADD COLUMN a int4;
QUERY: ALTER TABLE attmp ADD COLUMN b name;
QUERY: ALTER TABLE attmp ADD COLUMN c text;
QUERY: ALTER TABLE attmp ADD COLUMN d float8;
QUERY: ALTER TABLE attmp ADD COLUMN e float4;
QUERY: ALTER TABLE attmp ADD COLUMN f int2;
QUERY: ALTER TABLE attmp ADD COLUMN i char;
QUERY: ALTER TABLE attmp ADD COLUMN k int4;
QUERY: ALTER TABLE attmp ADD COLUMN m xid;
QUERY: ALTER TABLE attmp ADD COLUMN n oidvector;
QUERY: ALTER TABLE attmp ADD COLUMN p boolean;
QUERY: ALTER TABLE attmp ADD COLUMN v timestamp;
QUERY: ALTER TABLE attmp ADD COLUMN w interval;
QUERY: ALTER TABLE attmp ADD COLUMN x float8[];
QUERY: ALTER TABLE attmp ADD COLUMN y float4[];
QUERY: ALTER TABLE attmp ADD COLUMN z int2[];
QUERY: alter table atacc3 add test2 bool;
QUERY: alter table atacc3 drop test2;
QUERY: alter table atacc3 add test2 int;
QUERY: update atacc3 set test2 = 4 where test2 is null;
QUERY: select * from atacc1;
QUERY: select * from atacc1 order by a;
QUERY: select atacc1.* from atacc1;
QUERY: select a from atacc1;
QUERY: select atacc1.a from atacc1;
QUERY: select a,b,c,d from atacc1;
QUERY: select * from atacc1 where a = 1;
QUERY: update atacc1 set a = 3;
QUERY: update atacc1 set b = 2 where a = 3;
QUERY: insert into atacc1 values (10, 11, 12, 13);
QUERY: insert into atacc1 values (11, 12, 13);
QUERY: insert into atacc1 (a,b,c,d) values (10,11,12,13);
QUERY: insert into atacc1 (b,c,d) values (11,12,13);
QUERY: delete from atacc1 where a = 3;
QUERY: select * from myview;
QUERY: alter table atacc1 add primary key(a);
QUERY: alter table atacc1 add foreign key (a) references atacc2(id);
QUERY: alter table atacc2 add foreign key (id) references atacc1(a);
QUERY: create index "testing_idx" on atacc1(a);
QUERY: insert into atacc1 values (21, 22, 23);
QUERY: alter table atacc1 drop c;
QUERY: alter table atacc1 drop d;
QUERY: alter table atacc1 drop b;
QUERY: select * from atacc1;
QUERY: alter table parent drop a;
QUERY: alter table parent drop c;
QUERY: alter table attest drop a;
QUERY: copy attest from stdin;
QUERY: select * from attest;
QUERY: copy attest from stdin;
QUERY: select * from attest;
QUERY: copy attest(b,c) from stdin;
QUERY: select * from attest;
QUERY: alter table only dropColumn drop column e;
QUERY: alter table dropColumnChild drop column c;
QUERY: alter table dropColumn drop column a;
QUERY: alter table renameColumnChild rename column b to a;
QUERY: alter table renameColumn add column w int;
QUERY: alter table p1 drop column f1;
QUERY: alter table p1 add column f2 text;
QUERY: alter table test_storage add b int default random()::int;
QUERY: ALTER TABLE test_type_diff ADD COLUMN f2 int;
QUERY: ALTER TABLE tt7 DROP q;
QUERY: ALTER TABLE IF EXISTS tt8 ADD COLUMN f int;
QUERY: ALTER TABLE IF EXISTS tt8 ADD CONSTRAINT xxx PRIMARY KEY(f);
QUERY: ALTER TABLE IF EXISTS tt8 RENAME COLUMN f TO f1;
QUERY: alter table p11 add a int;
QUERY: alter table p11 drop a;
QUERY: alter table p11 add a int not null;
QUERY: alter table defpart_attach_test_d drop b;
QUERY: insert into defpart_attach_test_d values (1), (2);
QUERY: alter table bar2 add column b integer not null default 1;

copy

QUERY: alter table header_copytest drop column c;
QUERY: alter table header_copytest add column c text;
QUERY: alter table header_copytest drop column b;

create_index

QUERY: ALTER TABLE concur_reindex_tab ADD COLUMN c2 text;
QUERY: INSERT INTO concur_reindex_tab VALUES  (1, 'a');
QUERY: INSERT INTO concur_reindex_tab VALUES  (2, 'a');

create_misc

QUERY: ALTER TABLE e_star* RENAME COLUMN e TO ee;
QUERY: ALTER TABLE d_star* RENAME COLUMN d TO dd;
QUERY: ALTER TABLE c_star* RENAME COLUMN c TO cc;
QUERY: ALTER TABLE b_star* RENAME COLUMN b TO bb;
QUERY: ALTER TABLE a_star* RENAME COLUMN a TO aa;
QUERY: ALTER TABLE a_star RENAME COLUMN aa TO foo;
QUERY: ALTER TABLE a_star RENAME COLUMN foo TO aa;
QUERY: ALTER TABLE e_star* ADD COLUMN e int4;
QUERY: ALTER TABLE a_star* ADD COLUMN a text;

create_table

QUERY: alter table defcheck_def drop c;
QUERY: insert into defcheck_def values (0, 0);

create_view

QUERY: alter table tt2 add column d int;
QUERY: alter table tt2 add column e int;
QUERY: alter table tt3 rename c to d;
QUERY: alter table tt3 add column c int;
QUERY: alter table tt3 add column e int;
QUERY: alter table tt2 drop column d;
QUERY: alter table tt5 add column c int;
QUERY: alter table tt5 add column cc int;
QUERY: alter table tt5 drop column c;
QUERY: alter table tt7 drop column xx;
QUERY: alter table tt7 add column zz int;
QUERY: alter table tt7 add column z int;
QUERY: alter table tt7 drop column zz;
QUERY: alter table tt8 add column z2 int;
QUERY: alter table tt7a drop column xx;
QUERY: alter table tt9 drop column xx;
QUERY: alter table tt11 add column z int;
QUERY: alter table tt14t drop column f2;

event_trigger

QUERY: ALTER TABLE schema_one.table_one DROP COLUMN a;
QUERY: alter table rewriteme add column baz int default 0;

Regressions

fast_default

QUERY:          INSERT INTO vtype2 VALUES (2);
RECEIVED ERROR: number of values does not match number of columns provided (errno 1105) (sqlstate HY000)

fast_default

QUERY: ALTER TABLE T ADD COLUMN c1 TIMESTAMP DEFAULT now();
QUERY: ALTER TABLE T ADD COLUMN c_bigint BIGINT NOT NULL DEFAULT -1;
QUERY: ALTER TABLE T ADD COLUMN c_text TEXT DEFAULT 'hello';
QUERY: UPDATE T SET c_text = '"' || c_text || '"'  WHERE pk < 10;
QUERY: ALTER TABLE T ADD COLUMN c_int INT NOT NULL DEFAULT -1;
QUERY: ALTER TABLE T ADD COLUMN c_text TEXT DEFAULT 'Hello';
QUERY: ALTER TABLE t ADD COLUMN x int NOT NULL DEFAULT 4;
QUERY: ALTER TABLE t ADD COLUMN y int NOT NULL DEFAULT 5;
QUERY: SELECT * FROM t;
QUERY: UPDATE t SET y = 2;
QUERY: SELECT * FROM t;
QUERY: ALTER TABLE leader ADD c int;
QUERY: ALTER TABLE leader DROP c;
QUERY: ALTER TABLE vtype ADD COLUMN b DOUBLE PRECISION DEFAULT 0.2;
QUERY: ALTER TABLE vtype ADD COLUMN c BOOLEAN DEFAULT true;
QUERY: SELECT * FROM vtype;
QUERY: ALTER TABLE vtype2 ADD COLUMN b varchar(10) DEFAULT 'xxx';
QUERY: alter table has_fast_default add column f2 int default 42;
QUERY: table has_fast_default;

foreign_key

QUERY: ALTER TABLE pk2 DROP COLUMN b;
QUERY: ALTER TABLE fk2 DROP COLUMN b;
QUERY: ALTER TABLE pk32 DROP COLUMN b;
QUERY: ALTER TABLE fk3 DROP COLUMN b;

generated

QUERY: ALTER TABLE gtest10a DROP COLUMN b;
QUERY: ALTER TABLE gtest25 ADD COLUMN b int GENERATED ALWAYS AS (a * 3) STORED;
QUERY: SELECT * FROM gtest25 ORDER BY a;
QUERY: ALTER TABLE gtest25 ADD COLUMN d int DEFAULT 101;
QUERY: ALTER TABLE gtest29 DROP COLUMN a;
QUERY: ALTER TABLE gtest28a DROP COLUMN a;

identity

QUERY:          INSERT INTO itest13 VALUES (1), (2), (3);
RECEIVED ERROR: number of values does not match number of columns provided (errno 1105) (sqlstate HY000)
QUERY:          INSERT INTO itest8 VALUES(0), (1);
RECEIVED ERROR: number of values does not match number of columns provided (errno 1105) (sqlstate HY000)

identity

QUERY: ALTER TABLE itest13 ADD COLUMN b int GENERATED BY DEFAULT AS IDENTITY;
QUERY: ALTER TABLE itest13 ADD COLUMN c int GENERATED BY DEFAULT AS IDENTITY;
QUERY: ALTER TABLE itest8
  ADD COLUMN f4 int;
QUERY: ALTER TABLE itest8
  ADD COLUMN f5 int GENERATED ALWAYS AS IDENTITY;

index_including

QUERY: ALTER TABLE tbl DROP COLUMN c3;

indexing

QUERY: alter table idxpart2 drop column c;
QUERY: alter table pk2 drop column b;
QUERY: alter table covidxpart3 drop c;

inherit

QUERY: ALTER TABLE inht1 RENAME a TO aa;
QUERY: ALTER TABLE inhts RENAME d TO dd;
QUERY: ALTER TABLE inht1 RENAME aa TO aaa;
QUERY: ALTER TABLE inht1 RENAME aaa TO aaaa;
QUERY: ALTER TABLE errtst_child_fastdef ADD COLUMN data int NOT NULL DEFAULT 0;

insert

QUERY: alter table donothingbrtrig_test2 drop column c;
QUERY: alter table returningwrtest2 drop c;

insert_conflict

QUERY: alter table parted_conflict_1 drop column drp;

matview

QUERY: ALTER TABLE mvtest_v RENAME COLUMN i TO x;
QUERY: UPDATE mvtest_v SET j = 3 WHERE x = 1;
QUERY: SELECT * FROM mvtest_v;

partition_prune

QUERY: ALTER TABLE part_rev DROP COLUMN c;

plpgsql

QUERY: alter table test_01 drop column a;
QUERY: insert into test_01 values(10,20);
QUERY: alter table tabwithcols drop column b;
QUERY: alter table tabwithcols drop column d;
QUERY: alter table tabwithcols add column d int;
QUERY: ALTER TABLE alter_table_under_transition_tables
  DROP column name;

rowsecurity

QUERY: ALTER TABLE t1 DROP COLUMN junk1;
QUERY: ALTER TABLE document ADD COLUMN dnotes text DEFAULT '';
QUERY: SELECT * FROM document WHERE did = 4;

stats_ext

QUERY: ALTER TABLE ab1 DROP COLUMN a;

triggers

QUERY:          CREATE VIEW main_view AS SELECT a, b FROM main_table;
RECEIVED ERROR: column "b" could not be found in any table in scope (errno 1105) (sqlstate HY000)
QUERY:          DROP VIEW main_view;
RECEIVED ERROR: the view regression.main_view does not exist (errno 1105) (sqlstate HY000)

triggers

QUERY: alter table parted1_irreg drop column fd;
QUERY: insert into parted1_irreg values ('aardwolf', 2);
QUERY: alter table parted_trigger_2 drop column drp;
QUERY: alter table child2 drop column x;
QUERY: insert into child2 values ('BBB', 42);

updatable_views

QUERY: ALTER TABLE tx1 DROP COLUMN b;
QUERY: ALTER TABLE tx2 DROP COLUMN c;
QUERY: ALTER TABLE tx3 DROP COLUMN d;
QUERY: alter table wcowrtest2 drop c;

vacuum

QUERY: ALTER TABLE vactst ADD COLUMN t TEXT;

Footnotes

  1. These are tests that we're marking as Successful, however they do not match the expected output in some way. This is due to small differences, such as different wording on the error messages, or the column names being incorrect while the data itself is correct.

Copy link
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for this!

@fulghum fulghum merged commit 057c8c7 into main Oct 1, 2024
16 checks passed
@fulghum fulghum deleted the fulghum/alter-table branch October 1, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants