Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL info module fails with Cannot execute SQL syntax error at or near "b'oid'" #790

Open
chriscroome opened this issue Jan 13, 2025 · 2 comments

Comments

@chriscroome
Copy link

chriscroome commented Jan 13, 2025

SUMMARY

On a new Debian 12 server the info module is failing for me with:

Cannot execute SQL 'SELECT s.b'oid', s.b'subdbid', s.b'subskiplsn', s.b'subname', s.b'subowner', s.b'subenabled', s.b'subbinary', s.b'substream', s.b'subtwophasestate', s.b'subdisableonerr', s.b'subconninfo', s.b'subslotname', s.b'subsynccommit', s.b'subpublications', r.rolname AS ownername, d.datname AS dbname FROM pg_catalog.pg_subscription s JOIN pg_catalog.pg_database d ON s.subdbid = d.oid JOIN pg_catalog.pg_roles AS r ON s.subowner = r.oid': syntax error at or near "b'oid'"
LINE 1: SELECT s.b'oid', s.b'subdbid', s.b'subskiplsn', s.b'subname'...
ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.postgresql.postgresql_info module

ANSIBLE VERSION
ansible [core 2.17.7]
  config file = /home/chris/animorph-coop/servers/ansible.cfg
  configured module search path = ['/home/chris/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/chris/.local/pipx/venvs/ansible/lib/python3.11/site-packages/ansible
  ansible collection location = /home/chris/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/chris/.local/bin/ansible
  python version = 3.11.2 (main, Nov 30 2024, 21:22:50) [GCC 12.2.0] (/home/chris/.local/pipx/venvs/ansible/bin/python)
  jinja version = 3.1.5
  libyaml = True
COLLECTION VERSION
# /home/chris/.ansible/collections/ansible_collections
Collection           Version
-------------------- -------
community.postgresql 3.9.1  

# /home/chris/.local/pipx/venvs/ansible/lib/python3.11/site-packages/ansible_collections
Collection           Version
-------------------- -------
community.postgresql 3.9.0  
CONFIGURATION
ANSIBLE_FORCE_COLOR(/home/chris/animorph-coop/servers/ansible.cfg) = True
ANSIBLE_NOCOWS(/home/chris/animorph-coop/servers/ansible.cfg) = True
ANSIBLE_PIPELINING(/home/chris/animorph-coop/servers/ansible.cfg) = True
COLOR_DEBUG(env: ANSIBLE_COLOR_DEBUG) = blue
CONFIG_FILE() = /home/chris/animorph-coop/servers/ansible.cfg
DEFAULT_HOST_LIST(/home/chris/animorph-coop/servers/ansible.cfg) = ['/home/chris/animorph-coop/servers/hosts.yml']
DEFAULT_ROLES_PATH(/home/chris/animorph-coop/servers/ansible.cfg) = ['/home/chris/animorph-coop/servers/galaxy/roles']
DEFAULT_TIMEOUT(/home/chris/animorph-coop/servers/ansible.cfg) = 60
DEFAULT_VAULT_PASSWORD_FILE(/home/chris/animorph-coop/servers/ansible.cfg) = /home/chris/animorph-coop/servers/.vault.passwd
DISPLAY_SKIPPED_HOSTS(/home/chris/animorph-coop/servers/ansible.cfg) = False
DUPLICATE_YAML_DICT_KEY(/home/chris/animorph-coop/servers/ansible.cfg) = error
EDITOR(env: EDITOR) = /usr/bin/vim
RETRY_FILES_ENABLED(/home/chris/animorph-coop/servers/ansible.cfg) = False
OS / ENVIRONMENT

Debian 12.9

apt info postgresql
Package: postgresql
Version: 15+248
Priority: optional
Section: database
Source: postgresql-common (248)
Maintainer: Debian PostgreSQL Maintainers <[email protected]>
Installed-Size: 15.4 kB
Depends: postgresql-15
Suggests: postgresql-doc
Tag: devel::lang:sql, interface::daemon, network::server, network::service,
 role::metapackage, role::program, suite::postgresql, works-with::db
Download-Size: 10.1 kB
APT-Manual-Installed: yes
APT-Sources: https://deb.debian.org/debian bookworm/main amd64 Packages
Description: object-relational SQL database (supported version)
 This metapackage always depends on the currently supported PostgreSQL
 database server version.
 .
 PostgreSQL is a fully featured object-relational database management
 system.  It supports a large part of the SQL standard and is designed
 to be extensible by users in many aspects.  Some of the features are:
 ACID transactions, foreign keys, views, sequences, subqueries,
 triggers, user-defined types and functions, outer joins, multiversion
 concurrency control.  Graphical user interfaces and bindings for many
 programming languages are available as well.
STEPS TO REPRODUCE

I'm using this role with the following config:

postgresql: true
postgresql_db: plane
postgresql_db_owner: plane
postgresql_db_state: present
postgresql_user: plane

This is the task in question.

EXPECTED RESULTS

Not a failure, the thing I don't understand is that the tests I have for this role that are run via Molecule / GitLab CI don't fail.

ACTUAL RESULTS
TASK [postgresql : PostgreSQL info] ************************************************************************************************************************************************
fatal: [plane.webarch.coop]: FAILED! => 
    changed: false
    msg: |-
        Cannot execute SQL 'SELECT s.b'oid', s.b'subdbid', s.b'subskiplsn', s.b'subname', s.b'subowner', s.b'subenabled', s.b'subbinary', s.b'substream', s.b'subtwophasestate', s.b'subdisableonerr', s.b'subconninfo', s.b'subslotname', s.b'subsynccommit', s.b'subpublications', r.rolname AS ownername, d.datname AS dbname FROM pg_catalog.pg_subscription s JOIN pg_catalog.pg_database d ON s.subdbid = d.oid JOIN pg_catalog.pg_roles AS r ON s.subowner = r.oid': syntax error at or near "b'oid'"
        LINE 1: SELECT s.b'oid', s.b'subdbid', s.b'subskiplsn', s.b'subname'...
                         ^
betanummeric pushed a commit to betanummeric/community.postgresql that referenced this issue Jan 13, 2025
@betanummeric
Copy link
Member

Hi @chriscroome , which version of psycopg are you using? psycopg2 or psycopg (version 3)?

@chriscroome
Copy link
Author

Thanks @betanummeric the server had both versions:

aptitude search psycopg
p   python-psycopg-doc                                                                                                              - PostgreSQL database adapter for Python 3 (documentation package)                                                                          
p   python-psycopg2-doc                                                                                                             - Python module for PostgreSQL (documentation package)                                                                                      
i   python3-psycopg                                                                                                                 - PostgreSQL database adapter for Python 3                                                                                                  
p   python3-psycopg-pool                                                                                                            - PostgreSQL database adapter for Python 3: connection pool                                                                                 
i   python3-psycopg2                                                                                                                - Python 3 module for PostgreSQL                                                                                                            
p   python3-psycopg2cffi                                                                                                            - implementation of the psycopg2 module using cffi                                                                                          
v   python3-types-psycopg2                                                                                                          -                                                                                                                                           

Doing apt purge python3-psycopg solved it, thanks!

chriscroome added a commit to webarch-coop/ansible-role-postgresql that referenced this issue Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants