postgresql-interfaces/psqlodbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: JacoboSanchez (@JacoboSanchez) <[email protected]>
To: postgresql-interfaces/psqlodbc <[email protected]>
Subject: [postgresql-interfaces/psqlodbc] issue #83: SQLDescribeCol returning size 0 on bytea column if bytea as LO is enabled
Date: Tue, 17 Dec 2024 22:48:16 +0000
Message-ID: <[email protected]> (raw)

When I prepare a select on a table with a bytea column and execute the SQLDescribeCol column I get a -3 type (VARBINARY) and size 255. However with bytea active I get 0 size. 

The [SQLDEscribeCol documentation](https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqldescribecol-function?view=sql-server-...) states that 0 is a valid value for sizes that can not be determined. However it seems a bit inconsistent the difference between VARBINARY and LONGVARBINARY. Is this expected?

### Test on bytea column describe with default configuration
```
odbct32w        68bc-95dc	EXIT  SQLDescribeColW  with return code 0 (SQL_SUCCESS)
		HSTMT               0x0000000006EC28D0
		UWORD                        2 
		WCHAR *             0x000000000051EA20 [      11] "binary_data"
		SWORD                      600 
		SWORD *             0x00000000004F6D90 (11)
		SWORD *             0x0000000000576E20 (-3) <<< SQL_VARBINARY
		SQLULEN *           0x0000000000576E50 (255)  <<< SIZE 255
		SWORD *             0x0000000000576E80 (0)
		SWORD *             0x0000000000576EB0 (1)

```

mylog output:
```
38364-13.412] results.c[PGAPI_DescribeCol]369: PARSE: fieldtype=17, col_name='binary_data', column_size=255
[38364-13.412] results.c[PGAPI_DescribeCol]380: col 1 fieldname = 'binary_data'
[38364-13.412] results.c[PGAPI_DescribeCol]381: col 1 fieldtype = 17
[38364-13.412] results.c[PGAPI_DescribeCol]382: col 1 column_size = 255
[38364-13.412] results.c[PGAPI_DescribeCol]415: col 1 *pfSqlType = -3
[38364-13.412] results.c[PGAPI_DescribeCol]428: Col: col 1  *pcbColDef = 255
[38364-13.412] results.c[PGAPI_DescribeCol]440: col 1  *pibScale = 0
[38364-13.412] results.c[PGAPI_DescribeCol]453: col 1  *pfNullable = 1
```


### However when I enable "bytea as LO":

```
odbct32w        68bc-95dc	EXIT  SQLDescribeColW  with return code 0 (SQL_SUCCESS)
		HSTMT               0x0000000006ECAD50
		UWORD                        2 
		WCHAR *             0x0000000000577590 [      11] "binary_data"
		SWORD                      600 
		SWORD *             0x00000000004F6D90 (11)
		SWORD *             0x0000000000576E20 (-4) <<<  SQL_LONGVARBINARY
		SQLULEN *           0x0000000000576E50 (0) <<<  SIZE IS 0
		SWORD *             0x0000000000576E80 (0)
		SWORD *             0x0000000000576EB0 (1)
```

mylog output:

```
[38364-28.194] results.c[PGAPI_DescribeCol]369: PARSE: fieldtype=17, col_name='binary_data', column_size=-4
[38364-28.194] results.c[PGAPI_DescribeCol]380: col 1 fieldname = 'binary_data'
[38364-28.194] results.c[PGAPI_DescribeCol]381: col 1 fieldtype = 17
[38364-28.194] results.c[PGAPI_DescribeCol]382: col 1 column_size = -4
[38364-28.194] results.c[PGAPI_DescribeCol]415: col 1 *pfSqlType = -4
[38364-28.194] results.c[PGAPI_DescribeCol]428: Col: col 1  *pcbColDef = 0
[38364-28.194] results.c[PGAPI_DescribeCol]440: col 1  *pibScale = 0
[38364-28.194] results.c[PGAPI_DescribeCol]453: col 1  *pfNullable = 1
```

view thread (4+ messages)  latest in thread

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: github://postgresql-interfaces/psqlodbc
  Cc: [email protected], [email protected]
  Subject: Re: [postgresql-interfaces/psqlodbc] issue #83: SQLDescribeCol returning size 0 on bytea column if bytea as LO is enabled
  In-Reply-To: <<[email protected]>>

* 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