tds-fdw / tds_fdw

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

Columns names / Select columns #90

Open andrerjesus opened 8 years ago

andrerjesus commented 8 years ago

First of all this is not a bug, just reporting a change.

Previously in 1.0.7 computed columns didn't require alias. I just updated to 2.0 Alpha 1 and the foreign (MSSQL 2016) tables broke. I had to recreate them using alias whenever I have computed columns (i.e.: geometry.STAsText() now have to be geometry.STAsText() [geometry]).

Also, columns names are now case-sensitive, forcing the created PG table to have matching column name with the column name written in the QUERY option

This is something to add to the readme.md


How do I use a TDS_VERSION higher than 7.1? I can create a server using 7.2 but I can't query any table, It says I need to downgrade to 7.1. If I set anything higher than 7.2 I get error in the create server process


I noticed when you don't select everything select * I get message about the other columns not used in the select:

AVISO: Table definition mismatch: Foreign source has column named objectid, but target table does not. Column will be ignored. AVISO: Table definition mismatch: Foreign source has column named geometry, but target table does not. Column will be ignored. AVISO: Table definition mismatch: Could not match local column objectid with column from foreign table AVISO: Table definition mismatch: Could not match local column geometry with column from foreign table

Total query runtime: 455 msec 74 rows retrieved.

GeoffMontee commented 8 years ago

Thanks for the report!

Previously in 1.0.7 computed columns didn't require alias. I just updated to 2.0 Alpha 1 and the foreign (MSSQL 2016) tables broke. I had to recreate them using alias whenever I have computed columns (i.e.: geometry.STAsText() now have to be geometry.STAsText() [geometry]).

Ah, thanks for pointing that out. You might be able to get the old behavior by disabling match_column_names on the foreign table. e.g.:

ALTER FOREIGN TABLE tab
   OPTIONS (ADD match_column_names '0');

How do I use a TDS_VERSION higher than 7.1?

Does your version of FreeTDS support 7.2 or higher? tds_fdw has compile-time checks to only enable TDS versions that are supported by your version of FreeTDS. e.g.:

https://github.com/tds-fdw/tds_fdw/blob/8cf65d614afc211be410ac80a8c5c0f32f29e755/src/tds_fdw.c#L458

I noticed when you don't select everything select * I get message about the other columns not used in the select

Yeah, I don't have a workaround to avoid those messages at the moment, but they are warnings, so they shouldn't cause serious problems.

andrerjesus commented 8 years ago

Does your version of FreeTDS support 7.2 or higher? tds_fdw has compile-time checks to only enable TDS versions that are supported by your version of FreeTDS. e.g.:

I installed FreeTDS from the Ubuntu (Ubuntu Server 16.04) repository as readme.md discribed: sudo apt-get install libsybdb5 freetds-dev freetds-common I'll install FreeTDS bin, maybe It what is missing. I'll report back

Yeah, I don't have a workaround to avoid those messages at the moment, but they are warnings, so they shouldn't cause serious problems.

It's not a problem but for the inexperienced user (like me) If feels like something is not right although everything is working. I have to create a "real" table anyway to get spatial working because PG doesn't allow to create PK constraint in foreign tables.

And thank you for the really fast reply

andrerjesus commented 7 years ago

Sorry for the late reply, FreeTDS bin did the trick. Thank you

ale2317 commented 7 years ago

Thank you very much. This is really great work you do. This solve my biggest problem.