tds-fdw / tds_fdw

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

There is no support for user-defined data types #323

Open vitalca opened 1 year ago

vitalca commented 1 year ago

Description

There are lots of user-defined data types in my Sybase AES 15.5 database. They are based on all possible standard types, e.g. integer, float, varchar, etc.

When importing a foreign schema, tds_fdw always falls back to text for fields declared with user-defined types. As a result, you can't apply filters to the query, because of type conversion errors, e.g.:

=> select id from some_table limit 1;

-------------
| id (text) |
-------------
| 1         |
-------------
(1 Row)

=> select * from some_table where id = 1;

ERROR: operator does not exist: text = integer
Hint: No operator matches the given name and argument types. You might need to add explicit type casts.

=> select * from some_table where id = '1';

General SQL Server Error: Implicit conversion from datatype 'VARCHAR' to 'INT' is not allowed.
Use the CONVERT function to run this query.

The original data type for the field in Sybase:

=> exec sp_help id_t;

Type_name: id_t
Storage_type: int
Length: 4
...

Version of tds_fdw

2.0.3