tds-fdw / tds_fdw

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

Query with BIT Type does not convert correctly #278

Open Linreg-gmx-net opened 3 years ago

Linreg-gmx-net commented 3 years ago

Issue report

PG-Query: SELECT * FROM table WHERE column = '1'::BIT(1)

Wrong MSSQL-Query SELECT * FROM table column = B'1'

correct MSSQL-Query SELECT * FROM table column = CAST('1' AS BIT(1))

Logic error in deparse.c Line: 1412 bool needlabel; // it does have an initial value ==> bool needlabel = true;

Line: 1502/ 1503 case BITOID: case VARBITOID: appendStringInfo(buf, "B'%s'", extval); <== remove B it "B" an convert syntax from sybase? MSSQL dont know it.

Operating system

OpenSuse 15.2

Version of tds_fdw 2.0.2

From a psql session, paste the outputs of running \dx Liste der installierten Erweiterungen Name | Version | Schema | Beschreibung
--------------+---------+------------+----------------------------------------------------------------------------------- file_fdw | 1.0 | public | foreign-data wrapper for flat file access hstore | 1.3 | public | data type for storing sets of (key, value) pairs plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language postgres_fdw | 1.0 | public | foreign-data wrapper for remote PostgreSQL servers tablefunc | 1.0 | public | functions that manipulate whole tables, including crosstab tds_fdw | 2.0.2 | public | Foreign data wrapper for querying a TDS database (Sybase or Microsoft SQL Server) uuid-ossp | 1.0 | public | generate universally unique identifiers (UUIDs)

If you built the package from Git sources, also paste the output of running git log --source -n 1 on your git clone from a console

ESC[33mcommit 012350f68cea6159d1667b30d939afed05399e4aESC[m HEADESC[33m (ESC[mESC[1;36mHEAD -> ESC[mESC[1;32mmasterESC[mESC[33m, ESC[mESC[1;31morigin/masterESC[mESC[33m, ESC[mESC[1;31morigin/HEADESC[mESC[33m) > Author: RAFAELDEV2016 rafael.dev2016@gmail.com Date: Fri Nov 27 21:44:34 2020 +0100

Created Logo Designs #217 - Vector version of the logo added into the "logo" folder and in the README (#274)

Version of PostgreSQL

From a psql session, paste the output of running SELECT version();

foxpro=# SELECT version(); version

PostgreSQL 10.16 on x86_64-suse-linux-gnu, compiled by gcc (SUSE Linux) 7.5.0, 64-bit

Version of FreeTDS

freetds-config-1.1.36-lp152.1.1.x86_64 freetds-tools-1.1.36-lp152.1.1.x86_64 freetds-devel-1.1.36-lp152.1.1.x86_64