From d7f248fb019a66e228f9238a5b09cc3389617393 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sun, 3 May 2026 12:47:49 +1200 Subject: [PATCH] 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 Co-Authored-By: Claude Sonnet 4.6 * chore(odbc): add changelog fragment for PR #11972 Co-Authored-By: Claude Sonnet 4.6 --------- 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 3ca0ef5684..d33e87233c 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}")