Skip to content

Commit f9a9a03

Browse files
author
Rahul Parande
committed
Added test files to schedule
Signed-off-by: Rahul Parande <rparande@amazon.com>
1 parent 5aa6754 commit f9a9a03

File tree

28 files changed

+351
-78
lines changed

28 files changed

+351
-78
lines changed

test/JDBC/expected/weak-binding-vu-cleanup.out

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ GO
138138
DROP VIEW IF EXISTS self_ref_v1;
139139
GO
140140

141+
DROP VIEW IF EXISTS dependent_view;
142+
GO
143+
144+
DROP VIEW IF EXISTS test_view;
145+
GO
146+
147+
DROP VIEW IF EXISTS vw_fnc_check;
148+
GO
149+
141150
USE master;
142151
GO
143152

@@ -163,7 +172,12 @@ GO
163172
DROP TABLE IF EXISTS self_ref_t1;
164173
GO
165174

166-
-- Drop tables in master database
175+
DROP TABLE IF EXISTS orders;
176+
GO
177+
178+
DROP TABLE IF EXISTS customer;
179+
GO
180+
167181
DROP TABLE IF EXISTS test_table;
168182
GO
169183

@@ -177,6 +191,9 @@ GO
177191
DROP FUNCTION IF EXISTS view_test.sample_function1;
178192
GO
179193

194+
DROP FUNCTION IF EXISTS fnc_dependancy_check;
195+
GO
196+
180197
DROP SCHEMA IF EXISTS view_test;
181198
GO
182199

test/JDBC/expected/weak-binding-vu-prepare.out

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,6 @@ CREATE VIEW view_test.strong_view2 AS
4444
SELECT id, name FROM view_test.strong_view1;
4545
GO
4646

47-
select set_config('babelfishpg_tsql.weak_view_binding', 'true', false)
48-
GO
49-
~~START~~
50-
text
51-
on
52-
~~END~~
53-
54-
55-
-- Test weak binding views
5647
CREATE VIEW view_test.weak_view1 AS
5748
SELECT * FROM view_test.base_table2;
5849
GO
@@ -61,14 +52,6 @@ CREATE VIEW view_test.weak_view2 AS
6152
SELECT * FROM view_test.weak_view1;
6253
GO
6354

64-
select set_config('babelfishpg_tsql.weak_view_binding', 'false', false)
65-
GO
66-
~~START~~
67-
text
68-
off
69-
~~END~~
70-
71-
7255
CREATE FUNCTION view_test.sample_function1()
7356
RETURNS TABLE AS
7457
RETURN (
@@ -80,27 +63,63 @@ CREATE VIEW view_test.weak_view_function1 AS
8063
SELECT * FROM view_test.sample_function1();
8164
GO
8265

66+
CREATE TABLE test_table_for_strong_view (
67+
id INT,
68+
name VARCHAR(50)
69+
);
70+
GO
71+
72+
73+
/* Script from customer */
74+
CREATE TABLE customer (
75+
customer_id INT IDENTITY(1,1) PRIMARY KEY,
76+
customer_name TEXT NOT NULL
77+
);
78+
GO
79+
80+
CREATE FUNCTION fnc_dependancy_check (@param1 NVARCHAR(100),
81+
@param2 NVARCHAR(100),
82+
@param3 NVARCHAR(100))
83+
RETURNS NVARCHAR(300)
84+
AS
85+
BEGIN
86+
RETURN @param1 + ' - ' + @param2 + ' - ' + @param3;
87+
END;
88+
GO
8389

90+
CREATE VIEW vw_fnc_check AS
91+
SELECT customer_id,
92+
fnc_dependancy_check(customer_name, 'Code', 'Desc') AS code_desc
93+
FROM customer;
94+
GO
8495

85-
---------------------------------------------------------------------
86-
---------------------------------------------------------------------
87-
-- Create STRONG VIEW in weak binding mode
88-
select set_config('babelfishpg_tsql.weak_view_binding', 'true', false)
96+
DROP FUNCTION fnc_dependancy_check;
8997
GO
90-
~~START~~
91-
text
92-
on
93-
~~END~~
98+
~~ERROR (Code: 33557097)~~
9499

100+
~~ERROR (Message: cannot drop function fnc_dependancy_check(nvarchar,nvarchar,nvarchar) because schema-bound view depends on it)~~
95101

96-
CREATE TABLE test_table_for_strong_view (
97-
id INT,
98-
name VARCHAR(50)
102+
103+
CREATE TABLE orders (
104+
order_id INT PRIMARY KEY,
105+
customer_id INT REFERENCES customer(customer_id),
106+
order_date DATE NOT NULL
99107
);
100108
GO
101109

102-
CREATE VIEW v1_strong WITH SCHEMABINDING AS SELECT * FROM test_table_for_strong_view;
110+
CREATE VIEW test_view AS
111+
SELECT c.customer_id, c.customer_name, o.order_id, o.order_date
112+
FROM customer c
113+
JOIN orders o ON c.customer_id = o.customer_id
114+
GO
115+
116+
CREATE VIEW dependent_view AS
117+
SELECT customer_id, customer_name FROM test_view;
103118
GO
104119

105-
CREATE VIEW v2_strong WITH SCHEMABINDING AS SELECT * FROM v1_strong;
120+
DROP VIEW test_view;
106121
GO
122+
~~ERROR (Code: 33557097)~~
123+
124+
~~ERROR (Message: cannot drop view test_view because schema-bound view depends on it)~~
125+

test/JDBC/expected/weak-binding-vu-verify.out

Lines changed: 112 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,70 @@ GO
2727
~~ERROR (Message: cannot drop table master_view_test.base_table1 because schema-bound view depends on it)~~
2828

2929

30+
SELECT set_config('babelfishpg_tsql.weak_view_binding', 'true', false)
31+
GO
32+
~~START~~
33+
text
34+
on
35+
~~END~~
36+
37+
38+
ALTER VIEW view_test.strong_view1 AS
39+
SELECT * FROM view_test.base_table1;
40+
GO
41+
42+
DROP TABLE view_test.base_table1;
43+
GO
44+
45+
SELECT * FROM view_test.strong_view1;
46+
GO
47+
~~ERROR (Code: 33557097)~~
48+
49+
~~ERROR (Message: relation "view_test.base_table1" does not exist)~~
50+
51+
52+
SELECT * FROM view_test.strong_view2;
53+
GO
54+
~~ERROR (Code: 33557097)~~
55+
56+
~~ERROR (Message: relation "view_test.base_table1" does not exist)~~
57+
58+
59+
60+
-- Recreate the base table
61+
CREATE TABLE view_test.base_table1 (
62+
id INT,
63+
name VARCHAR(50)
64+
);
65+
SELECT * FROM view_test.strong_view2;
66+
GO
67+
~~START~~
68+
int#!#varchar
69+
~~END~~
70+
71+
72+
SELECT * FROM view_test.strong_view1;
73+
GO
74+
~~START~~
75+
int#!#varchar
76+
~~END~~
77+
3078

3179
------------------------------------------------------------
3280
-- Dropping a view having dependent weak view
3381
------------------------------------------------------------
82+
select set_config('babelfishpg_tsql.weak_view_binding', 'true', false)
83+
GO
84+
~~START~~
85+
text
86+
on
87+
~~END~~
88+
89+
90+
ALTER VIEW view_test.weak_view1 AS
91+
SELECT * FROM view_test.base_table2;
92+
GO
93+
3494
-- [view_test.weak_view1] has dependent weak view [view_test.weak_view2]
3595
DROP VIEW view_test.weak_view1;
3696
GO
@@ -77,7 +137,6 @@ int#!#varchar
77137
~~END~~
78138

79139

80-
81140
------------------------------------------------------------
82141
-- Test to check the behavior of weak binding views
83142
-- when the base table is dropped
@@ -1122,6 +1181,20 @@ int#!#int#!#int
11221181
-- Set of user operations performed to change strong view
11231182
-- to weak view
11241183
------------------------------------------------------------
1184+
select set_config('babelfishpg_tsql.weak_view_binding', 'true', false)
1185+
GO
1186+
~~START~~
1187+
text
1188+
on
1189+
~~END~~
1190+
1191+
1192+
CREATE VIEW v1_strong WITH SCHEMABINDING AS SELECT * FROM test_table_for_strong_view;
1193+
GO
1194+
1195+
CREATE VIEW v2_strong WITH SCHEMABINDING AS SELECT * FROM v1_strong;
1196+
GO
1197+
11251198
DROP TABLE IF EXISTS test_table_for_strong_view;
11261199
GO
11271200
~~ERROR (Code: 33557097)~~
@@ -1136,14 +1209,6 @@ GO
11361209
~~ERROR (Message: cannot drop view v1_strong because schema-bound view depends on it)~~
11371210

11381211

1139-
select set_config('babelfishpg_tsql.weak_view_binding', 'true', false)
1140-
GO
1141-
~~START~~
1142-
text
1143-
on
1144-
~~END~~
1145-
1146-
11471212
ALTER VIEW v1_strong AS SELECT * FROM test_table_for_strong_view;
11481213
GO
11491214

@@ -1377,3 +1442,41 @@ GO
13771442

13781443
~~ERROR (Message: view definition cannot contain a self-reference)~~
13791444

1445+
1446+
ALTER VIEW vw_fnc_check AS
1447+
SELECT customer_id,
1448+
fnc_dependancy_check(customer_name, 'Code', 'Desc') AS code_desc
1449+
FROM customer;
1450+
GO
1451+
1452+
DROP FUNCTION fnc_dependancy_check;
1453+
GO
1454+
1455+
ALTER VIEW test_view AS
1456+
SELECT c.customer_id, c.customer_name, o.order_id, o.order_date
1457+
FROM customer c
1458+
JOIN orders o ON c.customer_id = o.customer_id;
1459+
GO
1460+
1461+
DROP VIEW test_view;
1462+
GO
1463+
1464+
SELECT * FROM dependent_view;
1465+
GO
1466+
~~ERROR (Code: 33557097)~~
1467+
1468+
~~ERROR (Message: relation "test_view" does not exist)~~
1469+
1470+
1471+
CREATE VIEW test_view AS
1472+
SELECT c.customer_id, c.customer_name, o.order_id, o.order_date
1473+
FROM customer c
1474+
JOIN orders o ON c.customer_id = o.customer_id;
1475+
GO
1476+
1477+
SELECT * FROM dependent_view;
1478+
GO
1479+
~~START~~
1480+
int#!#text
1481+
~~END~~
1482+

test/JDBC/input/views/weak-binding-vu-cleanup.sql

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ GO
138138
DROP VIEW IF EXISTS self_ref_v1;
139139
GO
140140

141+
DROP VIEW IF EXISTS dependent_view;
142+
GO
143+
144+
DROP VIEW IF EXISTS test_view;
145+
GO
146+
147+
DROP VIEW IF EXISTS vw_fnc_check;
148+
GO
149+
141150
USE master;
142151
GO
143152

@@ -163,7 +172,12 @@ GO
163172
DROP TABLE IF EXISTS self_ref_t1;
164173
GO
165174

166-
-- Drop tables in master database
175+
DROP TABLE IF EXISTS orders;
176+
GO
177+
178+
DROP TABLE IF EXISTS customer;
179+
GO
180+
167181
DROP TABLE IF EXISTS test_table;
168182
GO
169183

@@ -177,6 +191,9 @@ GO
177191
DROP FUNCTION IF EXISTS view_test.sample_function1;
178192
GO
179193

194+
DROP FUNCTION IF EXISTS fnc_dependancy_check;
195+
GO
196+
180197
DROP SCHEMA IF EXISTS view_test;
181198
GO
182199

0 commit comments

Comments
 (0)