public inbox for pgsql-odbc@postgresql.org  
help / color / mirror / Atom feed
From: Dave Cramer <davecramer@postgres.rocks>
To: Igor Korot <ikorot01@gmail.com>
Cc: PostgreSQL ODBC list <pgsql-odbc@postgresql.org>
Subject: Re: How to properly perform this?
Date: Sat, 7 Mar 2026 06:40:43 -0500
Message-ID: <CADK3HHJLCxp+5Q48CatYqg02hBJs0qs8DS=x=Pg5Nx64rD1F7g@mail.gmail.com> (raw)
In-Reply-To: <CA+FnnTx+VJi6o9Y8HHUxb89REdNOxBtz1AVkbvM=TGMF_xa=oA@mail.gmail.com>
References: <CA+FnnTx+VJi6o9Y8HHUxb89REdNOxBtz1AVkbvM=TGMF_xa=oA@mail.gmail.com>

Dave Cramer
www.postgres.rocks


On Sat, 7 Mar 2026 at 01:10, Igor Korot <ikorot01@gmail.com> wrote:

> Hi, ALL,
> I'm trying to execute following query:
>
> draft=# SELECT c.relname AS name, ixs.tablespace, ARRAY(SELECT
> a.attname FROM pg_attribute a WHERE a.attrelid = idx.indrelid AND
> a.attnum = 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 =
> c.relname AND c.oid = idx.indexrelid AND t.oid = idx.indrelid AND
> n.oid = c.relnamespace AND idx.indisprimary AND n.nspname = 'public'
> AND t.relname = 'leagues';
>      name     | tablespace | included | storage
> --------------+------------+----------+---------
>  leagues_pkey |            | {}       |
> (1 row)
>
>
> My code is as follows:
>
>             while( ( ret = SQLGetData( m_hstmt, 4, SQL_C_WCHAR,
> index_param.get(), 255, &ind[3] ) ) != SQL_NO_DATA )
>             {
>                 if( ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO )
>                 {
>                     auto numBytes = ind[3];
>                     if( ind[3] == SQL_NO_TOTAL )
>                         numBytes = 255;
>                     else if( ind[3] > 255 )
>                         numBytes = 255;
>                     str_to_uc_cpy( options, index_param.get() );
>                 }
>                 else
>                 {
>                     GetErrorMessage( errorMsg, STMT_ERROR  );
>                     result = 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=Postgres
> Description=Postgres ODBC Driver
> UserId=postgres
> Password=XXX
> Servername=localhost
> Database=draft
> Port=5432
>
> [/code]
>
>
> What is the best way to proceed?
>

is the last column empty or null?

if not null then there is data there.

Dave


reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-odbc@postgresql.org
  Cc: davecramer@postgres.rocks, ikorot01@gmail.com
  Subject: Re: How to properly perform this?
  In-Reply-To: <CADK3HHJLCxp+5Q48CatYqg02hBJs0qs8DS=x=Pg5Nx64rD1F7g@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox