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.