tds-fdw / tds_fdw

A PostgreSQL foreign data wrapper to connect to TDS databases (Sybase and Microsoft SQL Server)
Other
380 stars 102 forks source link

problem with WHERE clause #116

Open ale2317 opened 7 years ago

ale2317 commented 7 years ago

Hello,

when i run this query:

SELECT * from table WHERE doku_id = 'J0000100';

i get this error:

NOTICE:  DB-Library notice: Msg #: 5701, Msg state: 2, Msg: Der Datenbankkontext wurde in 'd5j_in_test' geändert., Server: DMS-DB\D5_DMS, Process: , Line: 1, Level: 0
NOTICE:  DB-Library notice: Msg #: 5703, Msg state: 1, Msg: Changed language setting to us_english., Server: DMS-DB\D5_DMS, Process: , Line: 1, Level: 0
NOTICE:  DB-Library notice: Msg #: 102, Msg state: 1, Msg: Incorrect syntax near '::'., Server: DMS-DB\D3_DMS, Process: , Line: 1, Level: 15

ERROR:  DB-Library error: DB #: 102, DB Msg: General SQL Server error: Check messages from the SQL Server, OS #: -1, OS Msg: (null), Level: 15

********** Fehler **********

ERROR: DB-Library error: DB #: 102, DB Msg: General SQL Server error: Check messages from the SQL Server, OS #: -1, OS Msg: (null), Level: 15
SQL Status:HV00L

If I leave out the WHERE clause the query executes with no issue.

I use MS SQL Server 2014, Postgres 9.5 and tds_fdw 2.0.0

Width tds_fdw 1.0.7 everything works fine, but i need pushdown for where clause.

SQL Server receive this query:

SELECT Table, more_table, and_a_lot_of_more_table WHERE ((doku_id = 'J0000100'::text)) AND ((doku_id = 'J0000100'::text))

Problem seems to be the ::text .

GeoffMontee commented 7 years ago

This looks like issue #73. Please build the current master branch instead of the 2.0.0 release to avoid this problem.