@@ -796,9 +796,8 @@ def _sync_execute_many():
796796
797797 try :
798798 # Feature 022: Apply PostgreSQL→IRIS transaction verb translation
799- transaction_translator = TransactionTranslator ()
800- transaction_translated_sql = transaction_translator .translate_transaction_command (
801- sql
799+ transaction_translated_sql = (
800+ self .transaction_translator .translate_transaction_command (sql )
802801 )
803802
804803 # Feature 021: Apply PostgreSQL→IRIS SQL normalization
@@ -920,12 +919,11 @@ def _sync_execute_many():
920919
921920 try :
922921 # Get pooled connection
923- connection = self ._get_pooled_connection ()
922+ connection = self ._get_pooled_connection (session_id = session_id )
924923
925924 # Feature 022: Apply PostgreSQL→IRIS transaction verb translation
926- transaction_translator = TransactionTranslator ()
927- transaction_translated_sql = transaction_translator .translate_transaction_command (
928- sql
925+ transaction_translated_sql = (
926+ self .transaction_translator .translate_transaction_command (sql )
929927 )
930928
931929 # Feature 021: Apply PostgreSQL→IRIS SQL normalization
@@ -1080,7 +1078,13 @@ def _split_multi_row_insert(self, sql: str) -> list[str]:
10801078
10811079 return statements
10821080
1083- def _safe_execute (self , sql : str , params : list | None = None , is_embedded : bool = True ) -> Any :
1081+ def _safe_execute (
1082+ self ,
1083+ sql : str ,
1084+ params : list | None = None ,
1085+ is_embedded : bool = True ,
1086+ session_id : str | None = None ,
1087+ ) -> Any :
10841088 """Execute SQL with DDL idempotency handling."""
10851089 import iris
10861090
@@ -1127,7 +1131,7 @@ def __iter__(self):
11271131
11281132 else :
11291133 # External mode - use DBAPI cursor
1130- connection = self ._get_pooled_connection ()
1134+ connection = self ._get_pooled_connection (session_id = session_id )
11311135 cursor = connection .cursor ()
11321136 try :
11331137 if params :
@@ -2854,9 +2858,8 @@ def _sync_execute():
28542858 self ._get_iris_connection ()
28552859
28562860 # 1. Transaction Translation
2857- transaction_translator = TransactionTranslator ()
2858- transaction_translated_sql = transaction_translator .translate_transaction_command (
2859- sql
2861+ transaction_translated_sql = (
2862+ self .transaction_translator .translate_transaction_command (sql )
28602863 )
28612864
28622865 # 2. SQL Normalization
@@ -2866,7 +2869,7 @@ def _sync_execute():
28662869 optimized_sql = normalized_sql
28672870
28682871 # Log transaction translation metrics
2869- txn_metrics = transaction_translator .get_translation_metrics ()
2872+ txn_metrics = self . transaction_translator .get_translation_metrics ()
28702873 logger .info (
28712874 "Transaction verb translation applied" ,
28722875 total_translations = txn_metrics ["total_translations" ],
@@ -2878,7 +2881,7 @@ def _sync_execute():
28782881 )
28792882
28802883 # Log normalization metrics
2881- norm_metrics = translator .get_normalization_metrics ()
2884+ norm_metrics = self . sql_translator .get_normalization_metrics ()
28822885 logger .info (
28832886 "SQL normalization applied" ,
28842887 identifiers_normalized = norm_metrics ["identifier_count" ],
@@ -3078,17 +3081,23 @@ def _sync_execute():
30783081 f"Executing intermediate statement: { stmt [:80 ]} ..." ,
30793082 session_id = session_id ,
30803083 )
3081- self ._safe_execute (stmt , optimized_params , is_embedded = True )
3084+ self ._safe_execute (
3085+ stmt , optimized_params , is_embedded = True , session_id = session_id
3086+ )
30823087
30833088 # Execute last statement and capture results
30843089 last_stmt = statements [- 1 ]
30853090 logger .debug (
30863091 f"Executing final statement: { last_stmt [:80 ]} ..." , session_id = session_id
30873092 )
3088- result = self ._safe_execute (last_stmt , optimized_params , is_embedded = True )
3093+ result = self ._safe_execute (
3094+ last_stmt , optimized_params , is_embedded = True , session_id = session_id
3095+ )
30893096 else :
30903097 # Single statement - execute normally
3091- result = self ._safe_execute (optimized_sql , optimized_params , is_embedded = True )
3098+ result = self ._safe_execute (
3099+ optimized_sql , optimized_params , is_embedded = True , session_id = session_id
3100+ )
30923101
30933102 # RETURNING emulation: After INSERT/UPDATE/DELETE, fetch the affected row(s)
30943103 if returning_operation and returning_columns :
@@ -3684,10 +3693,14 @@ def _sync_external_execute():
36843693
36853694 # Execute all statements except the last
36863695 for stmt in statements [:- 1 ]:
3687- self ._safe_execute (stmt , optimized_params , is_embedded = False )
3696+ self ._safe_execute (
3697+ stmt , optimized_params , is_embedded = False , session_id = session_id
3698+ )
36883699
36893700 # Execute last statement and capture cursor
3690- cursor = self ._safe_execute (statements [- 1 ], optimized_params , is_embedded = False )
3701+ cursor = self ._safe_execute (
3702+ statements [- 1 ], optimized_params , is_embedded = False , session_id = session_id
3703+ )
36913704
36923705 # RETURNING emulation
36933706 if returning_operation and returning_columns :
0 commit comments