Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g4dmK-0001Jb-3r for pgsql-odbc@arkaria.postgresql.org; Tue, 25 Sep 2018 03:12:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g4dmH-00070p-Lr for pgsql-odbc@arkaria.postgresql.org; Tue, 25 Sep 2018 03:12:45 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g4dmH-00070h-1c for pgsql-odbc@lists.postgresql.org; Tue, 25 Sep 2018 03:12:45 +0000 Received: from mail03.asahi-net.or.jp ([202.224.55.15]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g4dm7-0005iC-Gc for pgsql-odbc@lists.postgresql.org; Tue, 25 Sep 2018 03:12:42 +0000 Received: from [192.168.1.9] (p201070-ipngn200204fukui.fukui.ocn.ne.jp [114.173.34.70]) (Authenticated sender: GQ9H-INUE) by mail03.asahi-net.or.jp (Postfix) with ESMTPA id 6C8E6F2C25; Tue, 25 Sep 2018 12:12:31 +0900 (JST) Subject: Re: Wrong column size using MIN/MAX without return result To: fabriziomello@gmail.com References: Cc: pgsql-odbc@lists.postgresql.org From: "Inoue, Hiroshi" Message-ID: Date: Tue, 25 Sep 2018 12:12:30 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------A353D5393187BA5A050056DF" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------A353D5393187BA5A050056DF Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi, On 2018/09/24 23:49, Fabrízio de Royes Mello wrote: > Hi all, > > We've experiencing an issue using the driver version 10.03.0000 under > unixODBC 2.3.1 environment. > > When we use MIN/MAX functions in a query returning CHAR without > results,  the column size is wrong. Seems if we use any function that > return "text types" without returning tuples the column size is wrong. SQL returns NULL for MIN/MAX functions without results. regards, Hiroshi Inoue > > Below there are some self contained testcases: > > ** SQL testcase 1 (ERROR): > > SQL> DROP TABLE IF EXISTS T1; > SQL> CREATE TABLE T1 ( FLD char(10) NOT NULL DEFAULT '         ' ); > SQL> INSERT INTO T1 VALUES('1'); > SQL> INSERT INTO T1 VALUES('22'); > SQL> INSERT INTO T1 VALUES('333'); > SQL> SELECT MAX(FLD) AS OK FROM T1; > +-----------+ > | ok        | > +-----------+ > | 333       | > +-----------+ > SQLRowCount returns 1 > 1 rows fetched > SQL> SELECT MAX(FLD) AS ERROR FROM T1 WHERE 1 = 0; > +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ > | error | > +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ > | | > +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ > SQLRowCount returns 1 > 1 rows fetched > > > ** SQL testcase 2 (ERROR): > SQL> DROP TABLE IF EXISTS T1; > SQL> CREATE TABLE T1 ( FLD char(10) NOT NULL DEFAULT '         ' ); > SQL> INSERT INTO T1 VALUES('1'); > SQL> INSERT INTO T1 VALUES('22'); > SQL> INSERT INTO T1 VALUES('333'); > SQL> SELECT SUBSTR(FLD,1,5) AS OK FROM T1 WHERE FLD = '333'; > +----+ > | ok | > +----+ > | 333| > +----+ > SQLRowCount returns 1 > 1 rows fetched > SQL> SELECT SUBSTR(FLD,1,5) AS ERROR FROM T1 WHERE 1 = 0; > +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ > | error      | > +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ > +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ > SQLRowCount returns 0 > > > ** SQL testcase 3 (OK): > SQL> DROP TABLE IF EXISTS T1; > SQL> CREATE TABLE T1 ( FLD char(10) NOT NULL DEFAULT '         ' ); > SQL> INSERT INTO T1 VALUES('1'); > SQL> INSERT INTO T1 VALUES('22'); > SQL> INSERT INTO T1 VALUES('333'); > SQL> SELECT FLD AS OK FROM T1 WHERE FLD = '333'; > +-----------+ > | ok        | > +-----------+ > | 333       | > +-----------+ > SQLRowCount returns 1 > 1 rows fetched > SQL> SELECT FLD AS ERROR FROM T1 WHERE 1 = 0; > +-----------+ > | error     | > +-----------+ > +-----------+ > SQLRowCount returns 0 > > There are some config to fix this weird behaviour? > > Regards, > > -- >    Fabrízio de Royes Mello       Timbira - http://www.timbira.com.br/ >    PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento --------------A353D5393187BA5A050056DF Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

Hi,


On 2018/09/24 23:49, Fabrízio de Royes Mello wrote:
Hi all,

We've experiencing an issue using the driver version 10.03.0000 under unixODBC 2.3.1 environment. 

When we use MIN/MAX functions in a query returning CHAR without results,  the column size is wrong. Seems if we use any function that return "text types" without returning tuples the column size is wrong.

SQL returns NULL for MIN/MAX functions without results.

regards,
Hiroshi Inoue
 

Below there are some self contained testcases:

** SQL testcase 1 (ERROR):

SQL> DROP TABLE IF EXISTS T1;
SQL> CREATE TABLE T1 ( FLD char(10) NOT NULL DEFAULT '         ' );
SQL> INSERT INTO T1 VALUES('1');
SQL> INSERT INTO T1 VALUES('22');
SQL> INSERT INTO T1 VALUES('333');
SQL> SELECT MAX(FLD) AS OK FROM T1;
+-----------+
| ok        |
+-----------+
| 333       |
+-----------+
SQLRowCount returns 1
1 rows fetched
SQL> SELECT MAX(FLD) AS ERROR FROM T1 WHERE 1 = 0;
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| error                                                                                                                                                                                                                                                          |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                                                                                                                                                                                                                                |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
SQLRowCount returns 1
1 rows fetched


** SQL testcase 2 (ERROR):
SQL> DROP TABLE IF EXISTS T1;
SQL> CREATE TABLE T1 ( FLD char(10) NOT NULL DEFAULT '         ' );
SQL> INSERT INTO T1 VALUES('1');
SQL> INSERT INTO T1 VALUES('22');
SQL> INSERT INTO T1 VALUES('333');
SQL> SELECT SUBSTR(FLD,1,5) AS OK FROM T1 WHERE FLD = '333';
+----+
| ok |
+----+
| 333|
+----+
SQLRowCount returns 1
1 rows fetched
SQL> SELECT SUBSTR(FLD,1,5) AS ERROR FROM T1 WHERE 1 = 0;
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| error                                                                                                                                                                                                                                                                                                       |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
SQLRowCount returns 0


** SQL testcase 3 (OK):
SQL> DROP TABLE IF EXISTS T1;
SQL> CREATE TABLE T1 ( FLD char(10) NOT NULL DEFAULT '         ' );
SQL> INSERT INTO T1 VALUES('1');
SQL> INSERT INTO T1 VALUES('22');
SQL> INSERT INTO T1 VALUES('333');
SQL> SELECT FLD AS OK FROM T1 WHERE FLD = '333';
+-----------+
| ok        |
+-----------+
| 333       |
+-----------+
SQLRowCount returns 1
1 rows fetched
SQL> SELECT FLD AS ERROR FROM T1 WHERE 1 = 0;
+-----------+
| error     |
+-----------+
+-----------+
SQLRowCount returns 0

There are some config to fix this weird behaviour?

Regards,

--
   Fabrízio de Royes Mello         Timbira - http://www.timbira.com.br/
   PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento
--------------A353D5393187BA5A050056DF--