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

SELECT into localTable from FDW_Table for int4 types defaults to 0 when null #229

Open alanrigele opened 4 years ago

alanrigele commented 4 years ago

I have a table which is a direct copy of the table on the MS SQL Server (create l_table as select * from fdw_table).

When the data is inserted into the PG table, the fields that have a int4 type and has a value of NULL, will be inserted with a 0 value. The local PG table does not have a default value defined.

Details: PG Version: PostgreSQL 11.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit MSSql: Microsoft SQL Server 2017 (RTM-CU13) (KB4466404) - 14.0.3048.4 (X64) Nov 30 2018 12:57:58 Copyright (C) 2017 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2019 Datacenter 10.0 (Build 17763: ) (Hypervisor)

Installed FDW.

Installed Packages Name : freetds Arch : x86_64 Version : 1.1.11 Release : 1.el7 Size : 1.5 M Repo : installed From repo : epel Summary : Implementation of the TDS (Tabular DataStream) protocol URL : http://www.freetds.org/ License : LGPLv2+ and GPLv2+ Description : FreeTDS is a project to document and implement the TDS (Tabular : DataStream) protocol. TDS is used by Sybase(TM) and Microsoft(TM) for : client to database server communications. FreeTDS includes call : level interfaces for DB-Lib, CT-Lib, and ODBC.

SudoerWithAnOpinion commented 4 years ago

Does running a simple SELECT query also return 0 or does it, correctly, return NULL? Please post a sample query and result.