Commit d8d675d
Support for weak binding views to allow dropping of underlying objects BABEL_4_X_DEV (babelfish-for-postgresql#3965)
* Support for weak binding views to allow dropping of underlying objects.This commit introduces support for both strong and weak view binding in Babelfish, aligning more closely with SQL Server's default behavior while maintaining flexibility. (babelfish-for-postgresql#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:
Strong binding (default): Prevents dropping referenced objects if views depend on them
Weak binding: Allows dropping of referenced objects
This feature aligns Babelfish more closely with SQL Server's behavior, providing greater flexibility
Key aspects include:
A new GUC parameter babelfishpg_tsql.weak_view_binding to control the default binding behavior (default is false)
Support for explicit WITH SCHEMABINDING to create strongly bound views regardless of the GUC setting
Ability to create weakly bound views by default when the GUC is enabled
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
* Fix crash during tuple update for broken view by registering an active transaction snapshot
---------
Signed-off-by: Rahul Parande <rparande@amazon.com>
Co-authored-by: Rahul Parande <rparande@amazon.com>1 parent 277cc0b commit d8d675d
File tree
39 files changed
+5085
-33
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
- latest
39 files changed
+5085
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4482 | 4482 | | |
4483 | 4483 | | |
4484 | 4484 | | |
| 4485 | + | |
| 4486 | + | |
| 4487 | + | |
| 4488 | + | |
| 4489 | + | |
| 4490 | + | |
4485 | 4491 | | |
4486 | | - | |
| 4492 | + | |
4487 | 4493 | | |
4488 | 4494 | | |
4489 | 4495 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1198 | 1198 | | |
1199 | 1199 | | |
1200 | 1200 | | |
1201 | | - | |
| 1201 | + | |
1202 | 1202 | | |
1203 | 1203 | | |
1204 | 1204 | | |
1205 | 1205 | | |
1206 | 1206 | | |
1207 | 1207 | | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
1208 | 1213 | | |
1209 | | - | |
| 1214 | + | |
1210 | 1215 | | |
1211 | 1216 | | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
1212 | 1235 | | |
1213 | 1236 | | |
1214 | 1237 | | |
| |||
1238 | 1261 | | |
1239 | 1262 | | |
1240 | 1263 | | |
1241 | | - | |
| 1264 | + | |
1242 | 1265 | | |
1243 | 1266 | | |
1244 | 1267 | | |
| |||
1248 | 1271 | | |
1249 | 1272 | | |
1250 | 1273 | | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
1251 | 1277 | | |
1252 | 1278 | | |
1253 | 1279 | | |
1254 | 1280 | | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
1255 | 1285 | | |
1256 | 1286 | | |
1257 | 1287 | | |
| |||
1272 | 1302 | | |
1273 | 1303 | | |
1274 | 1304 | | |
1275 | | - | |
1276 | | - | |
| 1305 | + | |
1277 | 1306 | | |
1278 | 1307 | | |
1279 | 1308 | | |
1280 | 1309 | | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
1281 | 1326 | | |
1282 | 1327 | | |
1283 | 1328 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
| 205 | + | |
204 | 206 | | |
205 | 207 | | |
206 | 208 | | |
207 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
208 | 213 | | |
209 | 214 | | |
210 | 215 | | |
211 | 216 | | |
212 | 217 | | |
213 | | - | |
214 | | - | |
215 | | - | |
| 218 | + | |
| 219 | + | |
216 | 220 | | |
217 | 221 | | |
218 | 222 | | |
| |||
| 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