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 1vz0y4-000caY-1m for pgsql-odbc@arkaria.postgresql.org; Sat, 07 Mar 2026 23:21:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vz0y2-009uII-2B for pgsql-odbc@arkaria.postgresql.org; Sat, 07 Mar 2026 23:21:55 +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 1vz0y2-009uIA-1Q for pgsql-odbc@lists.postgresql.org; Sat, 07 Mar 2026 23:21:54 +0000 Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vz0y0-00000001PO2-1A6V for pgsql-odbc@postgresql.org; Sat, 07 Mar 2026 23:21:54 +0000 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-79800183233so143197947b3.1 for ; Sat, 07 Mar 2026 15:21:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772925710; cv=none; d=google.com; s=arc-20240605; b=GvWvI6M681dDFTZKAi1Cy67nXEA3Qxou2a47r+FHh2KBM+v87vbUmt5ICPpFqsuRWn nA05mqaxQ6HkhJTRyHa/LozacjSdhRv3wKc395mRDo2Jwaljmgw2ou3zfteCwYyO6kPR yCR/cwTaIo4eebT6CWsrTTVpY3RWsmA7sjXyj68rRoRkbn3grxcyau9IvRuhY/vaepwu EImnVbu/ePKvGrIeqLeoLsxCa6YkuYoV3cvPs6+vK5cZZpGaWPq9koxLdCakXjxoy56i V54aG4MZyUsHZ1repjQ8337AMItrAg7+b2rJuCfB7jsfKlI3aaZ4L6+P0T8yhaHZwifm A4Ng== 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=Ff7bGVTV9NSoBmb3Tnkd7Yxf9fKnPVAVPJsRun2pBhk=; fh=25X4gWOMe56pFp0sYe0brxxA7ZQQDzwf5jpX83cSVK8=; b=Kue1eMXJJBcZ8qTKp67Y8wa5HywHzrNRBchH+hZuIYx6uH+1Zk2QSWe32OVyljknbn al22gx4oWe2UBaxmuFBCThE8VpvaCb4cnY4hx2HEqusKvha8mW7MNaPXWakXBJFmdaS6 Pbm0gAHD3xAoJqGlcBvTPN+5RjhshqEtByjjrRSTrjU8gZtsZfMDqOwXjHYQGuqdSDnF eiTDCshrGI4HUAH1YkWA/KMLR4WEP4C9bZSR7cHDv7UBtSBNhudXaZKhzW62+xvawlaD mHBUS5P+tX6FpPYv0WnX+eLKBZQQ0RFX7LMSPWCsAw+EjRYbkuT7TcTX1r1H/YvjVlXN amqQ==; 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=1772925710; x=1773530510; 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=Ff7bGVTV9NSoBmb3Tnkd7Yxf9fKnPVAVPJsRun2pBhk=; b=BgdC2CqsaRBkX1tetaOUD9nJatXizRW3Yv7vggw/LlA7lF62IAaVMTt6TL3d9cclJt NcASctnF2WSwwBZ2nEU5mar1H3uZgDKlQ0UV+JSSYSPXm2d3ZpcglfvPNMW0Vqf96fFI V1Vl+DhFfukyPiZ+ukG39y9H3Lr/my1igWhi+W8TM58sOPo5aqqCcinZabTPOG2HqdFt 80pFV7KlgNLZU9/g5pkqjnMAiD0SjhJU6Hm+LhefTXMH8qoc1SZ1dl5ThOz11TyJ/PTW Duti9kQwK9DeHA/ckhGw9AHW5ug149IU4g3Z7NqBZq8tasrOuEuLF8BzdPyUWNYG8tK8 bQ9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772925710; x=1773530510; 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=Ff7bGVTV9NSoBmb3Tnkd7Yxf9fKnPVAVPJsRun2pBhk=; b=cr6shRj0XeRhGDqHAISDHxhXSxDNyvrCShlo41KZlsgN37RTiKizYvsIVCg4rRbisZ D0sw3o+oxPCHDY9XgnKiOgZ5q6BF5IJsuVIRuyla3yHE789kaQm9w26WM7dotzA6J5et ScvV2Aa8FJucn+MSNMeILFiCIKnPtwUBvnspk/nlErlpopQuRYmCRh+MtFX1F+fVoG8q QarcG2LpDHB1jibSo2GXMCaxnNdcsoFaPN2LgouBa3gYRc1Ywy0ETKg2oBPe0L4Dlpxp wcvTQrAW0/Y0o5fAw8uM87XYIvpcMxTekRwT3SGPwu/aDK0Gc6wN9sj3aaigYMV4WHkm utbA== X-Gm-Message-State: AOJu0Yyi8Bu0hPjAYLLSHjVZjMDBNCEkkPwDbz+o2DiyOppYUQ9tBmQG rt3F8R9iRxCDZnguW4BcYxxtTpprOYlzhVahUeGvrkSs3AvN2aV8JQ3zWxZl+63MvlIrZ6xEHxD xzP0VYpDke+bSAXhZVuNoxE9wz83lZlU= X-Gm-Gg: ATEYQzzr4oHXrMO2aEB/zO+5SiQ0y461H6wy7nXJzUIt+i3KWBmyp+9eEjFcXeRolnY jEvTEr9oE6tr/L/98zgVqTo9EhDGLe//aeC92jqa1nPdupgVDJUrfmz6WKAnLpUrV4LhTYRmMED cJ4yl3RgY+ZbT2LWhDnnBaWhSrNqyYiZvxqAbLqEyS6/uMpwMRxcOaITLu3ymQXkPaJ6eya4vgR h3bPdrIIwVYagv4fLlkbuyEEFbJm7J8dOP3KdhtrLPajnKxZBjSB+E/oKgugPsDUELpBwcjH1R4 XOk= X-Received: by 2002:a05:690c:2602:b0:796:2f6c:70b7 with SMTP id 00721157ae682-798d1eebf8emr85866557b3.27.1772925710458; Sat, 07 Mar 2026 15:21:50 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Igor Korot Date: Sat, 7 Mar 2026 17:21:37 -0600 X-Gm-Features: AaiRm533W-kzj2mefO4ErfpOluUX1Y6KHIaGQZDapugVxq3f37xYtvMXLIZhbnY 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, On Sat, Mar 7, 2026 at 5:14=E2=80=AFPM Igor Korot wrot= e: > > Dave, > > This is from the gdb session: > > Hi, David, > > On Sat, Mar 7, 2026 at 1:06=E2=80=AFPM Igor Korot wr= ote: > > > > 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 AN= D > > >> n.oid =3D c.relnamespace AND idx.indisprimary AND n.nspname =3D 'pub= lic' > > >> 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= _WITH_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_SUCC= ESS_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_= WITH_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_= WITH_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. Using following: [quote] WaylandGnome /home/igor/dbhandler/Debug # emerge -pv psqlodbc * Last emerge --sync was 1y 348d 19h 34m 58s ago. * IMPORTANT: config file '/etc/portage/package.keywords' needs updating. * See the CONFIGURATION FILES and CONFIGURATION FILES UPDATE TOOLS * sections of the emerge man page to learn how to update config files. These are the packages that would be merged, in order: Calculating dependencies... done! Dependency resolution took 30.63 s (backtrack: 0/20). [ebuild R ] dev-db/psqlodbc-11.01.0000::gentoo USE=3D"ssl -doc -iodbc -threads" 0 KiB Total: 1 package (1 reinstall), Size of downloads: 0 KiB WaylandGnome /home/igor/dbhandler/Debug # [/quote] Thank you. > > > > > > > Dave