Skip to content

Support for weak binding views to allow dropping of underlying objects#585

Merged
forestkeeper merged 20 commits into
babelfish-for-postgresql:BABEL_5_X_DEV__PG_17_Xfrom
amazon-aurora:weak-view
Jul 11, 2025
Merged

Support for weak binding views to allow dropping of underlying objects#585
forestkeeper merged 20 commits into
babelfish-for-postgresql:BABEL_5_X_DEV__PG_17_Xfrom
amazon-aurora:weak-view

Conversation

@R4hul04

@R4hul04 R4hul04 commented Jun 5, 2025

Copy link
Copy Markdown
Contributor

Description

This PR introduces improvements to Babelfish's view handling, focusing on weak binding views. The changes enable more SQL Server-compatible behavior for view dependencies.

This PR introduces the following changes:

  1. Added hook in DROP codepath to allow dropping underlying objects (tables, functions, views) referenced by weak binding views without errors, while maintaining the view structure
  2. Implemented a view repair mechanism hook that automatically fixes broken views when their referenced objects are recreated, eliminating the need for manual view recreation

Implementation Details

  1. Added a new flags BBF_VIEW_DEF_FLAG_IS_BROKEN to track views with missing dependencies and BBF_VIEW_DEF_FLAG_IS_WEAK_VIEW to identify view's schemabinding property in babelfish_view_def catalog
  2. Implemented hooks in object drop operations to detect and mark dependent views as broken
  3. Added preQueryRewrtie hook for view repair mechanism that activates when a broken view is accessed during the rewriting
  4. Wrapper function for DefineVirtualRelation

Issues Resolved

BABEL-1660

Signed-off-by: Rahul Parande rparande@amazon.com

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the PostgreSQL license, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Rahul Parande added 5 commits June 5, 2025 17:18
Signed-off-by: Rahul Parande <rparande@amazon.com>
Signed-off-by: Rahul Parande <rparande@amazon.com>
Signed-off-by: Rahul Parande <rparande@amazon.com>
Signed-off-by: Rahul Parande <rparande@amazon.com>
Signed-off-by: Rahul Parande <rparande@amazon.com>
Comment thread src/backend/commands/dropcmds.c Outdated
Rahul Parande added 4 commits June 9, 2025 19:12
views

Signed-off-by: Rahul Parande <rparande@amazon.com>
Signed-off-by: Rahul Parande <rparande@amazon.com>
Signed-off-by: Rahul Parande <rparande@amazon.com>
Signed-off-by: Rahul Parande <rparande@amazon.com>
@R4hul04
R4hul04 requested a review from kuntalghosh June 10, 2025 00:56
Comment thread src/bin/pg_dump/pg_dump.c Outdated
Comment thread src/bin/pg_dump/pg_dump.c Outdated
Comment thread src/bin/pg_dump/pg_dump.c
Comment thread src/backend/commands/dropcmds.c Outdated
@R4hul04
R4hul04 marked this pull request as ready for review June 16, 2025 19:05
@R4hul04
R4hul04 requested a review from tanscorpio7 June 16, 2025 19:05
Rahul Parande added 2 commits June 17, 2025 17:49
Signed-off-by: Rahul Parande <rparande@amazon.com>
instead added it's declaration at the top to access the function

Signed-off-by: Rahul Parande <rparande@amazon.com>
Comment thread src/backend/rewrite/rewriteHandler.c Outdated
Comment thread src/backend/commands/tablecmds.c Outdated
Comment thread src/backend/commands/tablecmds.c Outdated
Comment thread src/backend/commands/dropcmds.c Outdated
Comment thread src/backend/commands/tablecmds.c Outdated
Comment thread src/backend/commands/view.c Outdated
Comment thread src/backend/rewrite/rewriteHandler.c Outdated
Comment thread src/bin/pg_dump/pg_dump.c Outdated
Rahul Parande added 7 commits June 18, 2025 19:55
InvokeObjectDropHook.
2. Removed check_view_dependencies_hook from view.c and used existing
   post_parse_analyze_hook.
3. Renamed view_repair_hook to pre_QueryRewrite_hook

Signed-off-by: Rahul Parande <rparande@amazon.com>
Signed-off-by: Rahul Parande <rparande@amazon.com>
…Hook

Signed-off-by: Rahul Parande <rparande@amazon.com>
as special call for dependency check during function drop

Signed-off-by: Rahul Parande <rparande@amazon.com>
Signed-off-by: Rahul Parande <rparande@amazon.com>
Signed-off-by: Rahul Parande <rparande@amazon.com>
reuse the logic for weak binding view repair

Signed-off-by: Rahul Parande <rparande@amazon.com>
@R4hul04
R4hul04 requested a review from kuntalghosh July 2, 2025 17:53
@R4hul04
R4hul04 requested a review from tanscorpio7 July 2, 2025 17:54
forestkeeper
forestkeeper previously approved these changes Jul 2, 2025
Comment thread src/bin/pg_dump/pg_dump.c
Comment thread src/include/commands/view.h
Comment thread src/backend/rewrite/rewriteHandler.c Outdated
Comment thread src/backend/rewrite/rewriteHandler.c
Comment thread src/backend/commands/dropcmds.c Outdated
babelfish view repair

Signed-off-by: Rahul Parande <rparande@amazon.com>
Signed-off-by: Rahul Parande <rparande@amazon.com>
@forestkeeper
forestkeeper merged commit cd94e1f into babelfish-for-postgresql:BABEL_5_X_DEV__PG_17_X Jul 11, 2025
2 checks passed
forestkeeper pushed a commit that referenced this pull request Jul 14, 2025
#599)

Cherry picked commit from: #585

Description
This PR introduces improvements to Babelfish's view handling, focusing on weak binding views. The changes enable more SQL Server-compatible behavior for view dependencies.

This PR introduces the following changes:

1. Added hook in DROP codepath to allow dropping underlying objects (tables, functions, views) referenced by weak binding views without errors, while maintaining the view structure
2. Implemented a view repair mechanism hook that automatically fixes broken views when their referenced objects are recreated, eliminating the need for manual view recreation

Implementation Details

1. Added a new flags BBF_VIEW_DEF_FLAG_IS_BROKEN to track views with missing dependencies and BBF_VIEW_DEF_FLAG_IS_WEAK_VIEW to identify view's schemabinding property in babelfish_view_def catalog
2. Implemented hooks in object drop operations to detect and mark dependent views as broken
3. Added preQueryRewrtie hook for view repair mechanism that activates when a broken view is accessed during the rewriting
4. Wrapper function for DefineVirtualRelation

Issues Resolved: BABEL-1660
Signed-off-by: Rahul Parande rparande@amazon.com
R4hul04 added a commit to amazon-aurora/postgresql_modified_for_babelfish that referenced this pull request Jul 14, 2025
babelfish-for-postgresql#585)

This PR introduces improvements to Babelfish's view handling, focusing on weak binding views. The changes enable more SQL Server-compatible behavior for view dependencies.

This PR introduces the following changes:

Added hook in DROP codepath to allow dropping underlying objects (tables, functions, views) referenced by weak binding views without errors, while maintaining the view structure
Implemented a view repair mechanism hook that automatically fixes broken views when their referenced objects are recreated, eliminating the need for manual view recreation
Implementation Details

Added a new flags BBF_VIEW_DEF_FLAG_IS_BROKEN to track views with missing dependencies and BBF_VIEW_DEF_FLAG_IS_WEAK_VIEW to identify view's schemabinding property in babelfish_view_def catalog
Implemented hooks in object drop operations to detect and mark dependent views as broken
Added preQueryRewrtie hook for view repair mechanism that activates when a broken view is accessed during the rewriting
Issues Resolved
BABEL-1660

Signed-off-by: Rahul Parande <rparande@amazon.com>
R4hul04 added a commit to amazon-aurora/postgresql_modified_for_babelfish that referenced this pull request Jul 15, 2025
babelfish-for-postgresql#585)

This PR introduces improvements to Babelfish's view handling, focusing on weak binding views. The changes enable more SQL Server-compatible behavior for view dependencies.

This PR introduces the following changes:

Added hook in DROP codepath to allow dropping underlying objects (tables, functions, views) referenced by weak binding views without errors, while maintaining the view structure
Implemented a view repair mechanism hook that automatically fixes broken views when their referenced objects are recreated, eliminating the need for manual view recreation
Implementation Details

Added a new flags BBF_VIEW_DEF_FLAG_IS_BROKEN to track views with missing dependencies and BBF_VIEW_DEF_FLAG_IS_WEAK_VIEW to identify view's schemabinding property in babelfish_view_def catalog
Implemented hooks in object drop operations to detect and mark dependent views as broken
Added preQueryRewrtie hook for view repair mechanism that activates when a broken view is accessed during the rewriting
Issues Resolved
BABEL-1660

Signed-off-by: Rahul Parande <rparande@amazon.com>
jsudrik pushed a commit that referenced this pull request Jul 15, 2025
#585) (#602)

This PR introduces improvements to Babelfish's view handling, focusing on weak binding views. The changes enable more SQL Server-compatible behavior for view dependencies.

This PR introduces the following changes:

Added hook in DROP codepath to allow dropping underlying objects (tables, functions, views) referenced by weak binding views without errors, while maintaining the view structure
Implemented a view repair mechanism hook that automatically fixes broken views when their referenced objects are recreated, eliminating the need for manual view recreation
Implementation Details

Added a new flags BBF_VIEW_DEF_FLAG_IS_BROKEN to track views with missing dependencies and BBF_VIEW_DEF_FLAG_IS_WEAK_VIEW to identify view's schemabinding property in babelfish_view_def catalog
Implemented hooks in object drop operations to detect and mark dependent views as broken
Added preQueryRewrtie hook for view repair mechanism that activates when a broken view is accessed during the rewriting
Issues Resolved
BABEL-1660

Signed-off-by: Rahul Parande <rparande@amazon.com>
jsudrik pushed a commit that referenced this pull request Jul 15, 2025
#585) (#601)

This PR introduces improvements to Babelfish's view handling, focusing on weak binding views. The changes enable more SQL Server-compatible behavior for view dependencies.

This PR introduces the following changes:

Added hook in DROP codepath to allow dropping underlying objects (tables, functions, views) referenced by weak binding views without errors, while maintaining the view structure
Implemented a view repair mechanism hook that automatically fixes broken views when their referenced objects are recreated, eliminating the need for manual view recreation
Implementation Details

Added a new flags BBF_VIEW_DEF_FLAG_IS_BROKEN to track views with missing dependencies and BBF_VIEW_DEF_FLAG_IS_WEAK_VIEW to identify view's schemabinding property in babelfish_view_def catalog
Implemented hooks in object drop operations to detect and mark dependent views as broken
Added preQueryRewrtie hook for view repair mechanism that activates when a broken view is accessed during the rewriting
Issues Resolved
BABEL-1660

Signed-off-by: Rahul Parande <rparande@amazon.com>
shalinilohia50 pushed a commit to amazon-aurora/postgresql_modified_for_babelfish that referenced this pull request Sep 20, 2025
babelfish-for-postgresql#585)

This PR introduces improvements to Babelfish's view handling, focusing on weak binding views. The changes enable more SQL Server-compatible behavior for view dependencies.

This PR introduces the following changes:

Added hook in DROP codepath to allow dropping underlying objects (tables, functions, views) referenced by weak binding views without errors, while maintaining the view structure
Implemented a view repair mechanism hook that automatically fixes broken views when their referenced objects are recreated, eliminating the need for manual view recreation
Implementation Details

Added a new flags BBF_VIEW_DEF_FLAG_IS_BROKEN to track views with missing dependencies and BBF_VIEW_DEF_FLAG_IS_WEAK_VIEW to identify view's schemabinding property in babelfish_view_def catalog
Implemented hooks in object drop operations to detect and mark dependent views as broken
Added preQueryRewrtie hook for view repair mechanism that activates when a broken view is accessed during the rewriting
Issues Resolved
BABEL-1660

Signed-off-by: Rahul Parande <rparande@amazon.com>
(cherry picked from commit cd94e1f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants