Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vz0qg-000cU5-1T for pgsql-odbc@arkaria.postgresql.org; Sat, 07 Mar 2026 23:14:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vz0qe-009tdI-2a for pgsql-odbc@arkaria.postgresql.org; Sat, 07 Mar 2026 23:14:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vz0qe-009tdA-1o for pgsql-odbc@lists.postgresql.org; Sat, 07 Mar 2026 23:14:17 +0000 Received: from mail-yw1-x1136.google.com ([2607:f8b0:4864:20::1136]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vz0qc-00000001PLM-1LUd for pgsql-odbc@postgresql.org; Sat, 07 Mar 2026 23:14:16 +0000 Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-798374d0f44so151043117b3.0 for ; Sat, 07 Mar 2026 15:14:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772925252; cv=none; d=google.com; s=arc-20240605; b=NOWbRBmfm8gDl+Uk5v7D9wsJMxm1Lw8VxaK3JT3VokPdiisj77pLFpV41g64tDLqxR YFB8yBBi3JqPdUqe1sLzxoFHVfHIbhHx6K2uwl9/Bru/NhuoGSpTlhkbEEJ2Iyctzty/ PgKRTewDMmmdsyUXkgiU5O5TAz+quLflTR2jF8PdBP/PPh+U+w1o1gyJqqEGwyDi4OOI sy0qSLOWlsLQ1Q9BhfYtAIpVO/+dafiYOfRrx8JONY5K5zJKc2wFQqmiLJTf4BKfVxuU DRzgGysExuQghmLWbO4zD7KWBuz+Jz8UyonjY/JRz/JnpO6GjYO4GUYPzBCVhyOgey3+ 82xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=7OWgI7ozCS5RgV2jzoogV+t+m1GC2PtHgnHBihipN+c=; fh=25X4gWOMe56pFp0sYe0brxxA7ZQQDzwf5jpX83cSVK8=; b=jFaFRyT826Se1b4Or9dIjMoh5Np38Va8cL0oBfKqLArPL6oM4gxVuNNRHGs+LF78hk p5qWPkmC390Ohbfi1T2ky99gLxBxy2gmTuw4/9rpCUMEaFZcJJ3A+jyH2/zjN+iQxLkh Lv481XDomvlqoRRN1DrYnzzvO78luBmfUFwSDRtVujcubi5jtHBsEN6xxwVanqs8Dv0b P20bvbTQfND4mJQmIPmjgM8acfbNijCTsbT7W2k3OYkFxOLPZPc91i1SNULQ+fE1KfMO Ho9XOzHIzSVSVcM2lpySRasFgdjbtna9tG9+fWGX05DSHBMv800tOCedK1nedzLOpn40 rJjg==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772925252; x=1773530052; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=7OWgI7ozCS5RgV2jzoogV+t+m1GC2PtHgnHBihipN+c=; b=RByiqnlsjK3sZhN8e1bbKFwITTuq33XQWTxY/iv1dptOB0Re5h1F6kN3VPptvdbl3E 6BSgSuSeJVV2csHunOUzaa1ZpG5ZEbg2sPejHQ0LT+3GIp5Jb3bWXO3IhDDM8ldDoqnS p6KojSzOWolChhWtisLsrf7GdQ/lP7jHMmg7FemNCKDQLGpeDr9ruiVA2dEoio/AZ8A3 xBihdFpPFNbRLZHddQJJEIr4GFgoVXBTBKZP490d0kXGZExSJC5V33ZvknplCjGcIOuO 36Ny33vvnXWcfuiUoS7XGSHvtpimuxqrBUb8B/2AKDRTfvp8WzX8NIi38Z9J6stdlBF6 JE0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772925252; x=1773530052; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7OWgI7ozCS5RgV2jzoogV+t+m1GC2PtHgnHBihipN+c=; b=FmkgMKO/CwA6fZQxUh1k6Wy6VaIbcjhDjn6Djn3KzvhkpywR/1dFKBo0pO64gxHQ7n sh3Bqiee9mJID1GIXPYKSuaZ9sUAGBZm6xyzEev+inwfcrU371yCZDKm84dtDSn4WaY9 /qdXmrTKsQA1u5kbMl2un5z+2mn0WD5mgM9T3+WS/x8G7bIZhFJKlB5hi+dmWf3VZRoz 0yU15ecp7ZCh7ra/wThYpYMcf9FukJVwVcimwDY69yh2DadxceyE5Ty8Wz+7jVBZ7vuA CIYkZegbmRcu6AeJv5lnO4OueP3fg49ERkQzTnAJwh0eZxtXvN2k0FnehCr9gnxzQFQ9 WRCA== X-Gm-Message-State: AOJu0Yxcy/CJQlTSUMg5y9ZL7g9G/M7/CCIqr/hRg0cpXzRwxM+dJB57 41I0vFVpXDmmtZDEyF9qksxQhDBLh/kz0zsv/nPlWYaf7ApVqkTOB2XqxW7GdvsBOgdtDLFTQzp /ALFI7BNaMwTPYryqaVE3/98wiMXuowqnFd+L X-Gm-Gg: ATEYQzy7ckAYIjnVGK0X/3e+DKKgguMOSR3PWD5EBLSIsAj5KbimXrhPs3cKDOgtny5 MWbwfsD8aMDv/SEIjofdig1LOptHmjM/wP8dsEEt1pZjowm0jE3WibYuFOZrBeSVlypmEE89q/B QoxrDxXR4B5vTL8xK6eY/w7AMllG7utOI9OfnRydpkIvZ2BLmIW0mAgVmidIOBpD9Ko3JEws+dS 9E82G0/Pj+PQC3ERfuTon2U+5n0iXA95Mxlcmpx2bIFmsKSKn+F5deXJyv3HPeFwL4A+EkwGBlJ 7Zg= X-Received: by 2002:a05:690c:7107:b0:798:e4b1:2b52 with SMTP id 00721157ae682-798e4b13039mr45644697b3.31.1772925252442; Sat, 07 Mar 2026 15:14:12 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Igor Korot Date: Sat, 7 Mar 2026 17:14:00 -0600 X-Gm-Features: AaiRm51ovf64cbsvUDkFEymc3JB-KjewnCPrOG-jtbhmuUT5M6Q2Il4bNP8zROY Message-ID: Subject: Re: How to properly perform this? To: Dave Cramer Cc: PostgreSQL ODBC list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dave, This is from the gdb session: Hi, David, On Sat, Mar 7, 2026 at 1:06=E2=80=AFPM Igor Korot wrot= e: > > Hi, Dave, > I think its just an empty column. > > Is there a way to treat it as NULL? > > P.S.: Sorry for top-posting. > > On Sat, Mar 7, 2026 at 5:41=E2=80=AFAM Dave Cramer wrote: > > > > > > Dave Cramer > > www.postgres.rocks > > > > > > On Sat, 7 Mar 2026 at 01:10, Igor Korot wrote: > >> > >> Hi, ALL, > >> I'm trying to execute following query: > >> > >> draft=3D# SELECT c.relname AS name, ixs.tablespace, ARRAY(SELECT > >> a.attname FROM pg_attribute a WHERE a.attrelid =3D idx.indrelid AND > >> a.attnum =3D ANY(idx.indkey) AND a.attnum > 0 ORDER BY > >> array_position(idx.indkey, a.attnum) OFFSET idx.indnkeyatts) AS > >> included, c.reloptions AS storage FROM pg_index idx, pg_class c, > >> pg_namespace n, pg_class t, pg_indexes ixs WHERE ixs.indexname =3D > >> c.relname AND c.oid =3D idx.indexrelid AND t.oid =3D idx.indrelid AND > >> n.oid =3D c.relnamespace AND idx.indisprimary AND n.nspname =3D 'publi= c' > >> AND t.relname =3D 'leagues'; > >> name | tablespace | included | storage > >> --------------+------------+----------+--------- > >> leagues_pkey | | {} | > >> (1 row) > >> > >> > >> My code is as follows: > >> > >> while( ( ret =3D SQLGetData( m_hstmt, 4, SQL_C_WCHAR, > >> index_param.get(), 255, &ind[3] ) ) !=3D SQL_NO_DATA ) > >> { > >> if( ret =3D=3D SQL_SUCCESS || ret =3D=3D SQL_SUCCESS_W= ITH_INFO ) > >> { > >> auto numBytes =3D ind[3]; > >> if( ind[3] =3D=3D SQL_NO_TOTAL ) > >> numBytes =3D 255; > >> else if( ind[3] > 255 ) > >> numBytes =3D 255; > >> str_to_uc_cpy( options, index_param.get() ); > >> } > >> else > >> { > >> GetErrorMessage( errorMsg, STMT_ERROR ); > >> result =3D 1; > >> } > >> } > >> Unfortunately it goes into the loop because apparently the driver or > >> the server keeps seeing the last column as having data and returns > >> SQL_SUCCESS. > >> > >> What is the proper way to resolve this? > >> > >> I'm using unixODBC with PostgreSQL 16. > >> > >> My odbc.ini looks like this: > >> > >> [code] > >> [postgres] > >> Driver=3DPostgres > >> Description=3DPostgres ODBC Driver > >> UserId=3Dpostgres > >> Password=3DXXX > >> Servername=3Dlocalhost > >> Database=3Ddraft > >> Port=3D5432 > >> > >> [/code] > >> > >> > >> What is the best way to proceed? > > > > > > is the last column empty or null? > > > > if not null then there is data there. 3754 while( ( ret =3D SQLGetData( m_hstmt, 3, SQL_C_WCHAR, included.get(), 255, &ind[2] ) ) !=3D SQL_NO_DATA ) (gdb) n 3756 if( ret =3D=3D SQL_SUCCESS || ret =3D=3D SQL_SUCCES= S_WITH_INFO ) (gdb) p ind[2] $1 =3D 4 (gdb) n 3758 auto numBytes =3D ind[2]; (gdb) 3759 if( ind[2] =3D=3D SQL_NO_TOTAL ) (gdb) 3761 else if( ind[2] > 255 ) (gdb) 3763 str_to_uc_cpy( includedCol, included.get() ); (gdb) 3764 } (gdb) 3754 while( ( ret =3D SQLGetData( m_hstmt, 3, SQL_C_WCHAR, included.get(), 255, &ind[2] ) ) !=3D SQL_NO_DATA ) (gdb) 3771 includedCol.erase( 0, 1 ); (gdb) p ind[2] $2 =3D 4 (gdb) p ret $3 =3D 100 (gdb) n This is what happens with column 3 when the array is empty. 3779 while( ( ret =3D SQLGetData( m_hstmt, pos, SQL_C_WCHAR, index_param.get(), 255, &ind[3] ) ) !=3D SQL_NO_DATA ) (gdb) 3781 if( ret =3D=3D SQL_SUCCESS || ret =3D=3D SQL_SUCCESS_WI= TH_INFO ) (gdb) p ind[3] $4 =3D -1 (gdb) p ret $5 =3D 0 (gdb) n 3783 auto numBytes =3D ind[3]; (gdb) 3784 if( ind[3] =3D=3D SQL_NO_TOTAL ) (gdb) 3786 else if( ind[3] > 255 ) (gdb) 3788 str_to_uc_cpy( options, index_param.get() ); (gdb) 3789 } (gdb) 3779 while( ( ret =3D SQLGetData( m_hstmt, pos, SQL_C_WCHAR, index_param.get(), 255, &ind[3] ) ) !=3D SQL_NO_DATA ) (gdb) 3781 if( ret =3D=3D SQL_SUCCESS || ret =3D=3D SQL_SUCCESS_WI= TH_INFO ) (gdb) p ind[3] $6 =3D -1 (gdb) p ret $7 =3D 0 (gdb) And this one is for column 4 of the query. The column is NULL, so no data is there. I think it's a bug in the driver as it should return SQL_NO_DATA on the very first call.... Thank you. > > > > Dave