tds_fdw icon indicating copy to clipboard operation
tds_fdw copied to clipboard

IMPORT FOREIGN SCHEMA fails due to syntax error (MSSQL)

Open AndrewGrossman opened this issue 7 years ago • 4 comments

ERROR: syntax error at or near ")" at character 470 QUERY: SELECT t.table_name, c.column_name, c.data_type, c.column_default, c.is_nullable, c.character_maximum_length, c.numeric_precision, c.numeric_precision_radix, c.numeric_scale, c.datetime_precision FROM information_schema.tables t LEFT JOIN information_schema.columns c ON t.table_schema = c.table_schema AND t.table_name = c.table_name WHERE t.table_type = 'BASE TABLE' AND t.table_schema = 'dbo' ORDER BY t.table_name, c.ordinal_position ) SERVER mssqlforeignserver OPTIONS (schema_name 'dbo', table_name ''); STATEMENT: IMPORT FOREIGN SCHEMA dbo FROM SERVER mssqlforeignserver INTO mssql_dbo;

This is off of the current master, built on CentOS 7, PostgreSQL 9.6.

AndrewGrossman avatar Oct 06 '17 18:10 AndrewGrossman

I found the problem--in my case, the user did not have permission to see anything in the target database, so the information schema query returned no rows. The code fell through that section and attempted then to run the problem query I encountered. A no-rows found case should probably be checked for and handled.

AndrewGrossman avatar Oct 06 '17 20:10 AndrewGrossman

@AndrewGrossman what version of tds_fdw are you using? I get an error:

ERROR: foreign-data wrapper "tds_fdw" does not support IMPORT FOREIGN SCHEMA

Running the version that comes from BIGSQL and labeled as 1.0.8 https://www.openscg.com/bigsql/docs/tds_fdw.jsp/

isapir avatar Nov 06 '17 21:11 isapir

I was running off of the master branch at the time, I think that's something like 2.0.0 alpha.

AndrewGrossman avatar Nov 06 '17 21:11 AndrewGrossman

I see. Thank you.

isapir avatar Nov 06 '17 21:11 isapir