babelfish-for-postgresql / babelfish_extensions

Babelfish for PostgreSQL provides the capability for PostgreSQL to work with applications written for Microsoft SQL Server. Babelfish understands the SQL Server wire-protocol and T-SQL, the Microsoft SQL Server query and procedural language, so you don’t have to switch database drivers or rewrite all of your application queries.
https://babelfishpg.org/
Apache License 2.0
265 stars 87 forks source link

Include ordering for constraints on babelfish tables #2688

Open rishabhtanwar29 opened 1 week ago

rishabhtanwar29 commented 1 week ago

Description

Babelfish supports column ordering and NULLs ordering in table constraints but PG does not. It was implemented through special grammar rule and few dialect T-SQL dialect dependent logic in engine. Currently this is not handled in pg_dump so the information about column/nulls ordering gets lost during dump. Although, this information is available in the underlying index for a UNIQUE/PRIMARY KEY constraint but this information anyway gets lost since the underlying index does not get dumped for a UNIQUE/PRIMARY KEY constraint, instead it is dumped as a constraint.

To fix this issue, we will now dump the underlying index of a UNIQUE/PRIMARY KEY constraint and make use of ALTER TABLE ADD CONSTRAINT USING snytax to add that as constraint. Postgres disallows creation of an constraint using index like this for non default sort ordering as native pg_dump does not handle such constraints. So we will need to bypass that check for Babelfish dump/restore with this special handling in bbf_dump.

Task: BABEL-4888 Signed-off-by: Rishabh Tanwar ritanwar@amazon.com

Engine PR: https://github.com/babelfish-for-postgresql/postgresql_modified_for_babelfish/pull/395

Test Scenarios Covered

Check List

By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, 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.

coveralls commented 1 week ago

Pull Request Test Coverage Report for Build 9677146965

Details


Totals Coverage Status
Change from base Build 9647525510: 0.003%
Covered Lines: 42827
Relevant Lines: 58498

πŸ’› - Coveralls
coveralls commented 14 hours ago

Pull Request Test Coverage Report for Build 9778707911

Details


Totals Coverage Status
Change from base Build 9766489889: 0.0%
Covered Lines: 42837
Relevant Lines: 58523

πŸ’› - Coveralls
coveralls commented 14 hours ago

Pull Request Test Coverage Report for Build 9779466154

Details


Totals Coverage Status
Change from base Build 9766489889: 0.0%
Covered Lines: 42837
Relevant Lines: 58523

πŸ’› - Coveralls
coveralls commented 13 hours ago

Pull Request Test Coverage Report for Build 9780105085

Details


Totals Coverage Status
Change from base Build 9766489889: 0.0%
Covered Lines: 42837
Relevant Lines: 58523

πŸ’› - Coveralls
coveralls commented 13 hours ago

Pull Request Test Coverage Report for Build 9780532730

Details


Totals Coverage Status
Change from base Build 9766489889: 0.0%
Covered Lines: 42837
Relevant Lines: 58523

πŸ’› - Coveralls
coveralls commented 10 hours ago

Pull Request Test Coverage Report for Build 9782258623

Details


Totals Coverage Status
Change from base Build 9766489889: 0.0%
Covered Lines: 42837
Relevant Lines: 58523

πŸ’› - Coveralls