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

Identifier problem in IBM System i #45

Open
boskowski opened this issue Nov 18, 2016 · 5 comments
Open

Identifier problem in IBM System i #45

boskowski opened this issue Nov 18, 2016 · 5 comments

Comments

@boskowski
Copy link

An IBM System i is connected to PostgreSQL 9.6 on Ubuntu 16.04 via IBM ODBC Driver and (patched) odbc_fdw. After successfully importing the table definition with IMPORT FOREIGN SCHEMA, I'm unable to query the table, e.g.:

# select * from notes;
ERROR:  Executing ODBC query

Independently of the query issued, the wrapper executes a count on the table. The ODBC trace file shows the following:

[ODBC][9958][1479471907.875547][SQLExecDirect.c][240]
  Entry:
    Statement = 0x558aa88944b0
    SQL = [SELECT COUNT(*) FROM (SELECT * FROM NOTES) AS _odbc_fwd_count_wrapped][length = 69 (SQL_NTS)]
[ODBC][9958][1479471907.882163][SQLExecDirect.c][503]
    Exit:[SQL_ERROR]
    DIAG [42000] [IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0104 - Token _ was not valid. Valid tokens: CL ID IN ASC LOG OUT DATA UNIT COLLECT <IDENTIFIER>.

DB2/i5 identifiers cannot start with an underscore.

Ideas for a workaround? Thank you!

@g-r-u
Copy link

g-r-u commented Dec 20, 2016

Go to line 849 in odbc_fdw.c and remove the underscore from the column alias. You'll probably have to rebuild and compile. Does anyone know of a good reason not to remove the underscore for good?

@vazeswapnil
Copy link

vazeswapnil commented Jun 29, 2017

Hello,

I am trying to access DB2 table from postgresql 9.5 using odbc_fdw. I was receiving same error, so I modified underscore as suggested and rebuild it. Now whenever I select data from foreign table it crashes with below error.
postgres=# select * from odbc_table;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!> \q

I ran the trace command on odbc and attached is output.
trace.docx

@rafatower
Copy link

Please share the traces in plain text if you don't mind

@vazeswapnil
Copy link

Hello,
I have copied output to text file.
trace.txt

@vazeswapnil
Copy link

Hello,

Just wanted to check if we had any solution or alternative for this.

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

4 participants