Skip to content

Commit

Permalink
ALTER TABLE test cases (#2069)
Browse files Browse the repository at this point in the history
  • Loading branch information
makalaaneesh authored Dec 13, 2024
1 parent e563b23 commit 75ab89e
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions yb-voyager/src/query/queryissue/issues_ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,84 @@ func testAlterTableAddPKOnPartitionIssue(t *testing.T) {
assertErrorCorrectlyThrownForIssueForYBVersion(t, err, "changing primary key of a partitioned table is not yet implemented", alterTableAddPKOnPartitionIssue)
}

func testSetAttributeIssue(t *testing.T) {
ctx := context.Background()
conn, err := getConn()
assert.NoError(t, err)

defer conn.Close(context.Background())
_, err = conn.Exec(ctx, `
CREATE TABLE public.event_search (
event_id text,
room_id text,
sender text,
key text,
vector tsvector,
origin_server_ts bigint,
stream_ordering bigint
);
ALTER TABLE ONLY public.event_search ALTER COLUMN room_id SET (n_distinct=-0.01)`)

assertErrorCorrectlyThrownForIssueForYBVersion(t, err, "ALTER TABLE ALTER column not supported yet", setAttributeIssue)
}

func testClusterOnIssue(t *testing.T) {
ctx := context.Background()
conn, err := getConn()
assert.NoError(t, err)

defer conn.Close(context.Background())
_, err = conn.Exec(ctx, `
CREATE TABLE test(ID INT PRIMARY KEY NOT NULL,
Name TEXT NOT NULL,
Age INT NOT NULL,
Address CHAR(50),
Salary REAL);
CREATE UNIQUE INDEX test_age_salary ON public.test USING btree (age ASC NULLS LAST, salary ASC NULLS LAST);
ALTER TABLE public.test CLUSTER ON test_age_salary`)

assertErrorCorrectlyThrownForIssueForYBVersion(t, err, "ALTER TABLE CLUSTER not supported yet", clusterOnIssue)
}

func testDisableRuleIssue(t *testing.T) {
ctx := context.Background()
conn, err := getConn()
assert.NoError(t, err)

defer conn.Close(context.Background())
_, err = conn.Exec(ctx, `
create table trule (a int);
create rule trule_rule as on update to trule do instead nothing;
ALTER TABLE trule DISABLE RULE trule_rule`)

assertErrorCorrectlyThrownForIssueForYBVersion(t, err, "ALTER TABLE DISABLE RULE not supported yet", disableRuleIssue)
}

func testStorageParameterIssue(t *testing.T) {
ctx := context.Background()
conn, err := getConn()
assert.NoError(t, err)

defer conn.Close(context.Background())
_, err = conn.Exec(ctx, `
CREATE TABLE public.example (
name text,
email text,
new_id integer NOT NULL,
id2 integer NOT NULL,
CONSTRAINT example_name_check CHECK ((char_length(name) > 3))
);
ALTER TABLE ONLY public.example
ADD CONSTRAINT example_email_key UNIQUE (email) WITH (fillfactor = 70);`)

assertErrorCorrectlyThrownForIssueForYBVersion(t, err, "unrecognized parameter", storageParameterIssue)
}

func TestDDLIssuesInYBVersion(t *testing.T) {
var err error
ybVersion := os.Getenv("YB_VERSION")
Expand Down Expand Up @@ -202,4 +280,16 @@ func TestDDLIssuesInYBVersion(t *testing.T) {
success = t.Run(fmt.Sprintf("%s-%s", "alter table add PK on partition", ybVersion), testAlterTableAddPKOnPartitionIssue)
assert.True(t, success)

success = t.Run(fmt.Sprintf("%s-%s", "set attribute", ybVersion), testSetAttributeIssue)
assert.True(t, success)

success = t.Run(fmt.Sprintf("%s-%s", "cluster on", ybVersion), testClusterOnIssue)
assert.True(t, success)

success = t.Run(fmt.Sprintf("%s-%s", "disable rule", ybVersion), testDisableRuleIssue)
assert.True(t, success)

success = t.Run(fmt.Sprintf("%s-%s", "storage parameter", ybVersion), testStorageParameterIssue)
assert.True(t, success)

}

0 comments on commit 75ab89e

Please sign in to comment.