microsoft / pgtoolsservice

PostgreSQL Tools Service that provides PostgreSQL Server data management capabilities.
Other
83 stars 36 forks source link

Psycopg3 Transactions update #448

Closed nasc17 closed 1 year ago

nasc17 commented 1 year ago

Psycopg 3 update, auto commit set to true automatically. Need to check for user defined transaction. addressing: #433

image

Edit messaging:

image
DaeunYim commented 1 year ago

the new changes lgtm. Is the reason why we have disable_auto_commit and user_transaction because of

if bool(self._execution_plan_options):
                if self._execution_plan_options.include_estimated_execution_plan_xml:
                    sql_statement_text = Query.EXPLAIN_QUERY_TEMPLATE.format(sql_statement_text)
                elif self._execution_plan_options.include_actual_execution_plan_xml:
                    self._disable_auto_commit = True
                    sql_statement_text = Query.ANALYZE_EXPLAIN_QUERY_TEMPLATE.format(sql_statement_text)

in query.py? I was wondering why we have two variables for the same purpose.

nasc17 commented 1 year ago

the new changes lgtm. Is the reason why we have disable_auto_commit and user_transaction because of

if bool(self._execution_plan_options):
                if self._execution_plan_options.include_estimated_execution_plan_xml:
                    sql_statement_text = Query.EXPLAIN_QUERY_TEMPLATE.format(sql_statement_text)
                elif self._execution_plan_options.include_actual_execution_plan_xml:
                    self._disable_auto_commit = True
                    sql_statement_text = Query.ANALYZE_EXPLAIN_QUERY_TEMPLATE.format(sql_statement_text)

in query.py? I was wondering why we have two variables for the same purpose.

We were resetting auto commit based on Analyze Explain, which I did not believe had anything to do with transactions. So added the user transaction property. Also use this particular property to determine if we should force rollback command if error found. (We do not do this for user transaction, raise error to end block manual)