Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ce25828

Browse files
author
Rahul Parande
committedMar 18, 2025·
Added test case for dependent check
Signed-off-by: Rahul Parande <rparande@amazon.com>
1 parent 7ed2e40 commit ce25828

7 files changed

+93
-3
lines changed
 

‎contrib/babelfishpg_tsql/src/pl_handler.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -4951,8 +4951,8 @@ get_old_view_acl(Oid oldViewOid)
49514951
errmsg("cache lookup failed for relation %u", oldViewOid)));
49524952

49534953
aclDatum = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_relacl, &isNull);
4954-
if (!isNull)
4955-
oldViewAcl = DatumGetAclPCopy(aclDatum);
4954+
Assert(!isNull);
4955+
oldViewAcl = DatumGetAclPCopy(aclDatum);
49564956

49574957
ReleaseSysCache(tuple);
49584958

‎test/JDBC/expected/alter-view-vu-cleanup.out

+9
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ GO
7474
DROP VIEW IF EXISTS guest.alter_v1;
7575
GO
7676

77+
DROP VIEW IF EXISTS alter_v25;
78+
GO
79+
80+
DROP VIEW IF EXISTS alter_v24;
81+
GO
82+
83+
DROP VIEW IF EXISTS alter_v26;
84+
GO
85+
7786
-- Drop the tables
7887
DROP TABLE IF EXISTS alter_t;
7988
GO

‎test/JDBC/expected/alter-view-vu-prepare.out

+9
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,12 @@ GO
5555

5656
CREATE VIEW alter_v8 AS SELECT a, b, c, d, e FROM alter_t4;
5757
GO
58+
59+
CREATE VIEW alter_v24 AS SELECT a, b, c, d FROM alter_t;
60+
GO
61+
62+
CREATE VIEW alter_v25 AS SELECT a, b FROM alter_v24;
63+
GO
64+
65+
CREATE VIEW alter_v26 AS SELECT a, b, c, d FROM alter_t;
66+
GO

‎test/JDBC/expected/alter-view-vu-verify.out

+43
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,49 @@ int#!#varchar
373373
~~END~~
374374

375375

376+
-- Alter View having dependent view [Error]
377+
ALTER VIEW alter_v24 AS SELECT a,b FROM alter_t;
378+
GO
379+
~~ERROR (Code: 33557097)~~
380+
381+
~~ERROR (Message: cannot drop view alter_v24 because other objects depend on it)~~
382+
383+
384+
SELECT * FROM alter_v24;
385+
GO
386+
~~START~~
387+
int#!#varchar#!#varchar#!#int
388+
1#!#a#!#a#!#1
389+
2#!#b#!#b#!#2
390+
3#!#c#!#c#!#3
391+
4#!#d#!#d#!#4
392+
5#!#e#!#e#!#5
393+
6#!#f#!#f#!#6
394+
7#!#g#!#g#!#7
395+
8#!#h#!#h#!#8
396+
9#!#i#!#i#!#9
397+
10#!#j#!#j#!#10
398+
~~END~~
399+
400+
401+
-- Verify dependent view after Alter on underlying view fails
402+
SELECT * FROM alter_v25;
403+
GO
404+
~~START~~
405+
int#!#varchar
406+
1#!#a
407+
2#!#b
408+
3#!#c
409+
4#!#d
410+
5#!#e
411+
6#!#f
412+
7#!#g
413+
8#!#h
414+
9#!#i
415+
10#!#j
416+
~~END~~
417+
418+
376419
-- Change int to bigint
377420
ALTER VIEW alter_v7 AS SELECT CAST(a AS bigint) AS a, b, c, d, e FROM alter_t4;
378421
GO

‎test/JDBC/input/alter/alter-view-vu-cleanup.sql

+9
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ GO
7474
DROP VIEW IF EXISTS guest.alter_v1;
7575
GO
7676

77+
DROP VIEW IF EXISTS alter_v25;
78+
GO
79+
80+
DROP VIEW IF EXISTS alter_v24;
81+
GO
82+
83+
DROP VIEW IF EXISTS alter_v26;
84+
GO
85+
7786
-- Drop the tables
7887
DROP TABLE IF EXISTS alter_t;
7988
GO

‎test/JDBC/input/alter/alter-view-vu-prepare.sql

+10-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,13 @@ CREATE VIEW alter_v7 AS SELECT a, b, c, d, e FROM alter_t4;
4444
GO
4545

4646
CREATE VIEW alter_v8 AS SELECT a, b, c, d, e FROM alter_t4;
47-
GO
47+
GO
48+
49+
CREATE VIEW alter_v24 AS SELECT a, b, c, d FROM alter_t;
50+
GO
51+
52+
CREATE VIEW alter_v25 AS SELECT a, b FROM alter_v24;
53+
GO
54+
55+
CREATE VIEW alter_v26 AS SELECT a, b, c, d FROM alter_t;
56+
GO

‎test/JDBC/input/alter/alter-view-vu-verify.sql

+11
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ GO
127127
SELECT * FROM dbo.alter_v1;
128128
GO
129129

130+
-- Alter View having dependent view [Error]
131+
ALTER VIEW alter_v24 AS SELECT a,b FROM alter_t;
132+
GO
133+
134+
SELECT * FROM alter_v24;
135+
GO
136+
137+
-- Verify dependent view after Alter on underlying view fails
138+
SELECT * FROM alter_v25;
139+
GO
140+
130141
-- Change int to bigint
131142
ALTER VIEW alter_v7 AS SELECT CAST(a AS bigint) AS a, b, c, d, e FROM alter_t4;
132143
GO

0 commit comments

Comments
 (0)
Please sign in to comment.