Commit ebc0c7a
authored
Support for weak binding views to allow dropping of underlying objects 5_3_STABLE (#3957)
Cherry picked commit from: #3806
Description
Currently, Babelfish only supports strong binding for views, which prevents dropping or altering referenced objects when views depend on them. This behavior differs from SQL Server, which by default allows dropping underlying tables or views unless WITH SCHEMABINDING is explicitly specified.
With this change, Babelfish now supports configurable view binding modes:
1. Strong binding (default): Prevents dropping referenced objects if views depend on them
2. Weak binding: Allows dropping of referenced objects
This feature aligns Babelfish more closely with SQL Server's behavior, providing greater flexibility
Key aspects include:
1. A new GUC parameter babelfishpg_tsql.weak_view_binding to control the default binding behavior (default is false)
2. Support for explicit WITH SCHEMABINDING to create strongly bound views regardless of the GUC setting
3. Ability to create weakly bound views by default when the GUC is enabled
4. Proper handling of ALTER VIEW operations in both binding modes
In SQL Server, views are weakly bound by default, allowing underlying objects to be dropped or altered. With our implementation, users can now choose between SQL Server's default behavior (weak binding) or the previously enforced behavior (strong binding).
Important Limitation :
This implementation currently only addresses DROP operations on tables, views, functions, procedures as well as ALTER operations on views when these objects are bound by dependent views. ALTER TABLE/ ALTER FUNCTION operations (such as dropping columns or changing data types) are still restricted when dependent views exist, regardless of binding mode. This differs from SQL Server's behavior, where weak binding also allows ALTER operations on referenced objects.
When the same underlying object is recreated, its broken child view will get repaired only if it follows postgresql restrictions for CREATE OR REPLACE VIEW. [The new query must generate the same columns that were generated by the existing view query (that is, the same column names in the same order and with the same data types), but it may add additional columns to the end of the list]
https://www.postgresql.org/docs/current/sql-createview.html#:~:text=The%20new%20query,be%20completely%20different.
Issues Resolved: BABEL-1660
Signed-off-by: Rahul Parande rparande@amazon.com1 parent ad38ed3 commit ebc0c7a
File tree
41 files changed
+5082
-36
lines changed- contrib/babelfishpg_tsql
- runtime
- src
- test/JDBC
- expected
- input/views
- upgrade
- 15_10
- 15_12
- 15_13
- 15_14
- 15_1
- 15_2
- 15_3
- 15_4
- 15_5
- 15_6
- 15_7
- 15_8
- 16_10
- 16_1
- 16_2
- 16_3
- 16_4
- 16_6
- 16_8
- 16_9
- 17_4
- 17_5
- latest
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
41 files changed
+5082
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4481 | 4481 | | |
4482 | 4482 | | |
4483 | 4483 | | |
| 4484 | + | |
| 4485 | + | |
| 4486 | + | |
| 4487 | + | |
| 4488 | + | |
| 4489 | + | |
4484 | 4490 | | |
4485 | | - | |
| 4491 | + | |
4486 | 4492 | | |
4487 | 4493 | | |
4488 | 4494 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1199 | 1199 | | |
1200 | 1200 | | |
1201 | 1201 | | |
1202 | | - | |
| 1202 | + | |
1203 | 1203 | | |
1204 | 1204 | | |
1205 | 1205 | | |
1206 | 1206 | | |
1207 | 1207 | | |
1208 | 1208 | | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
1209 | 1214 | | |
1210 | | - | |
| 1215 | + | |
1211 | 1216 | | |
1212 | 1217 | | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
1213 | 1236 | | |
1214 | 1237 | | |
1215 | 1238 | | |
| |||
1239 | 1262 | | |
1240 | 1263 | | |
1241 | 1264 | | |
1242 | | - | |
| 1265 | + | |
1243 | 1266 | | |
1244 | 1267 | | |
1245 | 1268 | | |
| |||
1249 | 1272 | | |
1250 | 1273 | | |
1251 | 1274 | | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
1252 | 1278 | | |
1253 | 1279 | | |
1254 | 1280 | | |
1255 | 1281 | | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
1256 | 1286 | | |
1257 | 1287 | | |
1258 | 1288 | | |
| |||
1273 | 1303 | | |
1274 | 1304 | | |
1275 | 1305 | | |
1276 | | - | |
1277 | | - | |
| 1306 | + | |
1278 | 1307 | | |
1279 | 1308 | | |
1280 | 1309 | | |
1281 | 1310 | | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
1282 | 1327 | | |
1283 | 1328 | | |
1284 | 1329 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| 205 | + | |
| 206 | + | |
205 | 207 | | |
206 | 208 | | |
207 | 209 | | |
208 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
209 | 214 | | |
210 | 215 | | |
211 | 216 | | |
212 | 217 | | |
213 | 218 | | |
214 | | - | |
215 | | - | |
216 | | - | |
| 219 | + | |
| 220 | + | |
217 | 221 | | |
218 | 222 | | |
219 | 223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
630 | 631 | | |
631 | 632 | | |
632 | 633 | | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
633 | 644 | | |
634 | 645 | | |
635 | 646 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
0 commit comments