tds-fdw / tds_fdw

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

NOT LIKE operator #76

Open lorenati opened 8 years ago

lorenati commented 8 years ago

Hello, I'm using the last commit 091853f in windows; when I perform this query (foreign table to sql server):

select * from mytable where mycolumn not like '%avalue%';

This gets translated to:

select * from mytable where mycolumn !~~ '%avalue%';

This is correct in postgres but the operator !~~ is not compatible in sql server

The extension and pg crashes. Is there a way to configure what group of operators tds_fdw can use?

GeoffMontee commented 8 years ago

Thanks for the bug report!

Is there a way to configure what group of operators tds_fdw can use?

Unfortunately not at the moment.

For now, you should be able to disable all WHERE pushdowns for a given table by setting match_column_names to 0 for the foreign table. This will also mean that tds_fdw will match columns in the order that they appear in the result set, rather than by name.

lorenati commented 8 years ago

I'm having a similar issue with aggregate functions and order by when I want to do "select column from mytable order by column desc" because of this line in deparse.c:

if (pathkey->pk_nulls_first)
    appendStringInfoString(buf, " NULLS FIRST");

NULLS FIRST is not recognized in sql server

GeoffMontee commented 8 years ago

This should be fixed in the latest commit.