From c2c1899359e19c0c3bb4b0bf723e1a60e1b27593 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 3 May 2026 12:07:27 +0200 Subject: [PATCH] [PR #11972/d7f248fb backport][stable-12] odbc: fetch rows before commit to fix HY010 function sequence error (#11983) odbc: fetch rows before commit to fix HY010 function sequence error (#11972) * fix(odbc): fetch rows before committing to fix HY010 function sequence error Fixes #5395 * chore(odbc): add changelog fragment for PR #11972 --------- (cherry picked from commit d7f248fb019a66e228f9238a5b09cc3389617393) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 --- changelogs/fragments/11972-odbc-fix-commit-fetch-order.yml | 2 ++ plugins/modules/odbc.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/11972-odbc-fix-commit-fetch-order.yml diff --git a/changelogs/fragments/11972-odbc-fix-commit-fetch-order.yml b/changelogs/fragments/11972-odbc-fix-commit-fetch-order.yml new file mode 100644 index 0000000000..a7022fe82c --- /dev/null +++ b/changelogs/fragments/11972-odbc-fix-commit-fetch-order.yml @@ -0,0 +1,2 @@ +bugfixes: + - odbc - fetch rows before committing to fix ``HY010`` function sequence error (https://github.com/ansible-collections/community.general/issues/5395, https://github.com/ansible-collections/community.general/pull/11972). diff --git a/plugins/modules/odbc.py b/plugins/modules/odbc.py index 883dd60d56..d329916419 100644 --- a/plugins/modules/odbc.py +++ b/plugins/modules/odbc.py @@ -132,8 +132,6 @@ def main(): cursor.execute(query, params) else: cursor.execute(query) - if commit: - cursor.commit() try: # Get the rows out into an 2d array for row in cursor.fetchall(): @@ -158,6 +156,8 @@ def main(): except Exception as e: module.fail_json(msg=f"Exception while reading rows: {e}") + if commit: + cursor.commit() cursor.close() except Exception as e: module.fail_json(msg=f"Failed to execute query: {e}")