Aurora Babelfish transaction across PostgreSQL and TFS port

0

Hi. Given an application that used to run multiple DB scripts against SQL Server in a single transaction, how can I implement the same when moving the Aurora Postgres?

The challenge is as follows: Some DB scripts use features not supported by Babelfish (e.g., XML parsing-related TSQL functionality); thus, these scripts must be translated to PL/pgSQL and executed against Aurora's Postgres endpoint.

A sample problematic use case: An application opens a SQL Server transaction against the TDS endpoint, runs a TSQL script to create a SQL Server schema, and then the application attempts to run a PL/pgSQL script against the Postgres using the schema created in the previous script, this will fail. The reason for the failure is that the first script was executed inside a transaction that yet to be committed; thus, the second script executed a different Aurora endpoint is executed outside of that transaction and cannot see the schema created and yet to be committed. Another problem with this scenario is that rolling back the transaction against the TDS port doesn't affect scripts executed against the Postgres endpoint.

Is it possible to open a transaction spanning scripts executed against both the TDS and Postgres endpoints; thus, allowing the scripts executed against the different endpoints to be aware of the changes made by each other, and also implement a true (true="all or nothing") transaction across endpoints?

Liroy
질문됨 8달 전244회 조회
2개 답변
1

Hello,

In addition to the above, please let me inform you that XML parsing functionality does not require translation to PL/pgSQL. Many operations can be solved with the combination of using PG XPATH and UNNEST functions within T-SQL. This way you can avoid the nested transaction problem.

Using PG native XPATH() - https://www.postgresql.org/docs/15/functions-xml.html#FUNCTIONS-XML-PROCESSING

With PG native UNNEST() - https://www.postgresql.org/docs/15/functions-array.html

I would recommend you to please replicate on your instance and let us know if you face any issues over support case.

Thank you.

AWS
지원 엔지니어
답변함 8달 전
  • Thanks, Lakshmi.

    Even if the XML-related functions you mentioned allow to workaround the particular use case of using TSQL XML functions, there are still a lot of other Babelfish incompatibilities listed in the Babel Compass report that require a workaround through the usage of PL/pgSQL scripts; thus, the ability to have a nested transaction is still relevant.

0

Short answer: no. One cannot combine T-SQL and PostgreSQL transaction semantics in the same transaction.

A common approach is to invoke a function in pg/PLsql from T-SQL, and implement the pg/PLsql function without transaction control commands.

답변함 8달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠