tds_fdw icon indicating copy to clipboard operation
tds_fdw copied to clipboard

Columns names / Select columns

Open andrerjesus opened this issue 7 years ago • 4 comments

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.

andrerjesus avatar Aug 31 '16 18:08 andrerjesus

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.

GeoffMontee avatar Aug 31 '16 19:08 GeoffMontee

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 avatar Aug 31 '16 20:08 andrerjesus

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

andrerjesus avatar Dec 13 '16 13:12 andrerjesus

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

ale2317 avatar Jan 13 '17 09:01 ale2317