![配置 postgresql12-odbc 以使用正确的协议版本](https://linux22.com/image/754837/%E9%85%8D%E7%BD%AE%20postgresql12-odbc%20%E4%BB%A5%E4%BD%BF%E7%94%A8%E6%AD%A3%E7%A1%AE%E7%9A%84%E5%8D%8F%E8%AE%AE%E7%89%88%E6%9C%AC.png)
我有一个安装了 unixODBC 2.3.1 和 postgresql-odbc 12.02 的 Centos 7 机器,它正在连接到同样运行 v12 的 PostgreSQL 服务器。
虽然我相信我已经将 ODBC 配置为使用 v12.0 协议,但似乎并非如此。当连接到服务器并尝试获取表中的列列表时,我收到错误,column c.relhasoids does not exist
。此列已从 PostgreSQL v12 中删除pg_catalog.pg_class
。
postgresql-odbc 已特别更新至不使用此列当协议是 v12 时,我只能假设我不是。
我已经Protocol = 12.0
在我的/etc/odbcinst.ini
,如果我运行,我可以看到它按照配置strace isql my-connector
加载 postgresql12 库。/usr/pgsql-12
我困惑了!
# yum list installed | grep -i -e 'odbc' -e 'postgresql'
postgresql12-libs.x86_64 12.3-5PGDG.rhel7 @pgdg12
postgresql12-odbc.x86_64 12.02.0000-1PGDG.rhel7 @pgdg-common
unixODBC.x86_64 2.3.1-14.el7 @base
unixODBC-devel.x86_64 2.3.1-14.el7 @base
# cat /etc/odbc.ini
[my-connector]
Description = My PG connection
Driver = PostgreSQL12
Database = mydb
Servername = mydatabase.example.com
UserName = myself
Password = mypassword
Port = 25061
Protocol = 12.0
ReadOnly = No
RowVersioning = No
ShowSystemTables = No
ShowOidColumn = No
FakeOidIndex = No
SSLMode = require
UseServerSidePrepare = No
# cat /etc/odbcinst.ini
[PostgreSQL12]
Description=ODBC for PostgreSQL
Setup=/usr/lib/libodbcpsqlS.so
Setup64=/usr/lib64/libodbcpsqlS.so
Driver=/usr/pgsql-12/lib/psqlodbcw.so
Driver64=/usr/pgsql-12/lib/psqlodbcw.so
FileUsage=1
# isql my-connector -v -3
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select id from roles where name = 'admin';
+------------+
| id |
+------------+
| 2 |
+------------+
SQLRowCount returns 1
1 rows fetched
SQL> help roles
[HY000]Error while executing the query
[42703]ERROR: column c.relhasoids does not exist
[ISQL]ERROR: Could not SQLColumns