pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feed[PATCH] Return the correct column names in SQLTables
9+ messages / 4 participants
[nested] [flat]
* [PATCH] Return the correct column names in SQLTables
@ 2014-08-09 16:29 David Hedberg <david.hedberg@gmail.com>
0 siblings, 2 replies; 9+ messages in thread
From: David Hedberg @ 2014-08-09 16:29 UTC (permalink / raw)
To: pgsql-odbc
As noted in bug #1007689, the column names returned from SQLTables
differs between ODBCv2 and ODBCv3. This patch was needed to be able to
list the tables when trying to import data in Excel 2010/PowerPivot.
A somewhat unrelated question:
There is one more "fix" needed to get the import of data in PowerPivot
working properly, and that is because PowerPivot insists on creating
the query with mssql-style quotes. (select [schema].[table].* instead
of select "schema"."table".* ..).
I have not managed to find any way of making it issue the query with
the correct form of quoting. Unless anyone reading this happens to
know of a way, would you accept a patch that adds an option to the
driver that makes it translate []-style quoting to ""-style quoting?
--
David Hedberg
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Attachments:
0001-Support-ODBCv3-column-names-in-SQLTables.patch (text/x-patch, 1.9K) download
From e52226e63ba0d151b46d35f6f60440f59e231baf Mon Sep 17 00:00:00 2001
From: David Hedberg <david.hedberg@gmail.com>
Date: Sat, 9 Aug 2014 18:24:57 +0200
Subject: Support ODBCv3 column names in SQLTables
---
info.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/info.c b/info.c
index 81bfe6d..ce00fc4 100644
--- a/info.c
+++ b/info.c
@@ -1557,6 +1557,7 @@ PGAPI_Tables(HSTMT hstmt,
BOOL search_pattern;
BOOL list_cat = FALSE, list_schemas = FALSE, list_table_types = FALSE, list_some = FALSE;
SQLLEN cbRelname, cbRelkind, cbSchName;
+ EnvironmentClass *env;
mylog("%s: entering...stmt=%p scnm=%p len=%d\n", func, stmt, szTableOwner, cbTableOwner);
@@ -1565,6 +1566,7 @@ PGAPI_Tables(HSTMT hstmt,
conn = SC_get_conn(stmt);
ci = &(conn->connInfo);
+ env = CC_get_env(conn);
result = PGAPI_AllocStmt(conn, &htbl_stmt, 0);
if (!SQL_SUCCEEDED(result))
@@ -1850,8 +1852,16 @@ retry_public_schema:
stmt->catalog_result = TRUE;
/* set the field names */
QR_set_num_fields(res, result_cols);
- QR_set_field_info_v(res, TABLES_CATALOG_NAME, "TABLE_QUALIFIER", PG_TYPE_VARCHAR, MAX_INFO_STRING);
- QR_set_field_info_v(res, TABLES_SCHEMA_NAME, "TABLE_OWNER", PG_TYPE_VARCHAR, MAX_INFO_STRING);
+ if (EN_is_odbc3(env))
+ {
+ QR_set_field_info_v(res, TABLES_CATALOG_NAME, "TABLE_CAT", PG_TYPE_VARCHAR, MAX_INFO_STRING);
+ QR_set_field_info_v(res, TABLES_SCHEMA_NAME, "TABLE_SCHEM", PG_TYPE_VARCHAR, MAX_INFO_STRING);
+ }
+ else
+ {
+ QR_set_field_info_v(res, TABLES_CATALOG_NAME, "TABLE_QUALIFIER", PG_TYPE_VARCHAR, MAX_INFO_STRING);
+ QR_set_field_info_v(res, TABLES_SCHEMA_NAME, "TABLE_OWNER", PG_TYPE_VARCHAR, MAX_INFO_STRING);
+ }
QR_set_field_info_v(res, TABLES_TABLE_NAME, "TABLE_NAME", PG_TYPE_VARCHAR, MAX_INFO_STRING);
QR_set_field_info_v(res, TABLES_TABLE_TYPE, "TABLE_TYPE", PG_TYPE_VARCHAR, MAX_INFO_STRING);
QR_set_field_info_v(res, TABLES_REMARKS, "REMARKS", PG_TYPE_VARCHAR, INFO_VARCHAR_SIZE);
--
1.9.1
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [PATCH] Return the correct column names in SQLTables
@ 2014-09-22 20:40 David Hedberg <david.hedberg@gmail.com>
parent: David Hedberg <david.hedberg@gmail.com>
1 sibling, 0 replies; 9+ messages in thread
From: David Hedberg @ 2014-09-22 20:40 UTC (permalink / raw)
To: pgsql-odbc
Any comments on this one?
On Sat, Aug 9, 2014 at 6:29 PM, David Hedberg <david.hedberg@gmail.com> wrote:
> As noted in bug #1007689, the column names returned from SQLTables
> differs between ODBCv2 and ODBCv3. This patch was needed to be able to
> list the tables when trying to import data in Excel 2010/PowerPivot.
>
> A somewhat unrelated question:
> There is one more "fix" needed to get the import of data in PowerPivot
> working properly, and that is because PowerPivot insists on creating
> the query with mssql-style quotes. (select [schema].[table].* instead
> of select "schema"."table".* ..).
>
> I have not managed to find any way of making it issue the query with
> the correct form of quoting. Unless anyone reading this happens to
> know of a way, would you accept a patch that adds an option to the
> driver that makes it translate []-style quoting to ""-style quoting?
>
> --
> David Hedberg
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [PATCH] Return the correct column names in SQLTables
@ 2014-09-23 09:46 Heikki Linnakangas <hlinnakangas@vmware.com>
parent: David Hedberg <david.hedberg@gmail.com>
1 sibling, 1 reply; 9+ messages in thread
From: Heikki Linnakangas @ 2014-09-23 09:46 UTC (permalink / raw)
To: David Hedberg <david.hedberg@gmail.com>; pgsql-odbc
On 08/09/2014 07:29 PM, David Hedberg wrote:
> As noted in bug #1007689, the column names returned from SQLTables
> differs between ODBCv2 and ODBCv3.
Yep, we should fix that.
> This patch was needed to be able to
> list the tables when trying to import data in Excel 2010/PowerPivot.
Hmm. According to the ODBC documentation on SQLTables:
"The following columns have been renamed for ODBC 3.x. The column name
changes do not affect backward compatibility because applications bind
by column number."
So, arguably this is a bug in Excel/PowerPivot, if it's binding by
column name rather than number. But it doesn't really matter, we should
fix the column names anyway.
> A somewhat unrelated question:
> There is one more "fix" needed to get the import of data in PowerPivot
> working properly, and that is because PowerPivot insists on creating
> the query with mssql-style quotes. (select [schema].[table].* instead
> of select "schema"."table".* ..).
Ugh. How does that work with any other ODBC driver than MS SQL Server?
- Heikki
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [PATCH] Return the correct column names in SQLTables
@ 2014-09-23 10:46 David Hedberg <david.hedberg@gmail.com>
parent: Heikki Linnakangas <hlinnakangas@vmware.com>
0 siblings, 1 reply; 9+ messages in thread
From: David Hedberg @ 2014-09-23 10:46 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnakangas@vmware.com>; +Cc: pgsql-odbc
On Tue, Sep 23, 2014 at 11:46 AM, Heikki Linnakangas
<hlinnakangas@vmware.com> wrote:
> On 08/09/2014 07:29 PM, David Hedberg wrote:
>>
>> This patch was needed to be able to
>> list the tables when trying to import data in Excel 2010/PowerPivot.
>
>
> Hmm. According to the ODBC documentation on SQLTables:
>
> "The following columns have been renamed for ODBC 3.x. The column name
> changes do not affect backward compatibility because applications bind by
> column number."
>
> So, arguably this is a bug in Excel/PowerPivot, if it's binding by column
> name rather than number. But it doesn't really matter, we should fix the
> column names anyway.
To the extent the problem falls on the driver side, what do you think
about the proposed patch? Feel free to amend it or throw it away if
you have a better fix.
>> A somewhat unrelated question:
>> There is one more "fix" needed to get the import of data in PowerPivot
>> working properly, and that is because PowerPivot insists on creating
>> the query with mssql-style quotes. (select [schema].[table].* instead
>> of select "schema"."table".* ..).
>
>
> Ugh. How does that work with any other ODBC driver than MS SQL Server?
>
I don't really use these products usually so I can't really comment,
but as far as I could tell there was no attempt made to get the
correct quoting style from the driver. I guess I will keep my ugly
hack for this to myself though unless asked otherwise. :-)
> - Heikki
>
/ David
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [PATCH] Return the correct column names in SQLTables
@ 2014-09-23 13:33 Adrian Klaver <adrian.klaver@aklaver.com>
parent: David Hedberg <david.hedberg@gmail.com>
0 siblings, 0 replies; 9+ messages in thread
From: Adrian Klaver @ 2014-09-23 13:33 UTC (permalink / raw)
To: David Hedberg <david.hedberg@gmail.com>; Heikki Linnakangas <hlinnakangas@vmware.com>; +Cc: pgsql-odbc
On 09/23/2014 03:46 AM, David Hedberg wrote:
> On Tue, Sep 23, 2014 at 11:46 AM, Heikki Linnakangas
> <hlinnakangas@vmware.com> wrote:
>> On 08/09/2014 07:29 PM, David Hedberg wrote:
>>>
>>> This patch was needed to be able to
>>> list the tables when trying to import data in Excel 2010/PowerPivot.
>>
>>
>> Hmm. According to the ODBC documentation on SQLTables:
>>
>> "The following columns have been renamed for ODBC 3.x. The column name
>> changes do not affect backward compatibility because applications bind by
>> column number."
>>
>> So, arguably this is a bug in Excel/PowerPivot, if it's binding by column
>> name rather than number. But it doesn't really matter, we should fix the
>> column names anyway.
>
> To the extent the problem falls on the driver side, what do you think
> about the proposed patch? Feel free to amend it or throw it away if
> you have a better fix.
>
>>> A somewhat unrelated question:
>>> There is one more "fix" needed to get the import of data in PowerPivot
>>> working properly, and that is because PowerPivot insists on creating
>>> the query with mssql-style quotes. (select [schema].[table].* instead
>>> of select "schema"."table".* ..).
>>
>>
>> Ugh. How does that work with any other ODBC driver than MS SQL Server?
>>
>
> I don't really use these products usually so I can't really comment,
> but as far as I could tell there was no attempt made to get the
> correct quoting style from the driver. I guess I will keep my ugly
> hack for this to myself though unless asked otherwise. :-)
This seems to be generic problem with PowerPivot and non-MS data
sources. Some searching found a possible solution, use the Power Query
add in:
http://www.microsoft.com/en-us/download/details.aspx?id=39379
http://office.microsoft.com/en-us/excel-help/introduction-to-microsoft-power-query-for-excel-HA10400...
>
>> - Heikki
>>
>
> / David
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 9+ messages in thread
* [PATCH] Return the correct column names in SQLTables (resend)
@ 2014-10-06 13:19 David Hedberg <david.hedberg@gmail.com>
0 siblings, 1 reply; 9+ messages in thread
From: David Hedberg @ 2014-10-06 13:19 UTC (permalink / raw)
To: pgsql-odbc
Resending this patch rebased on latest master. Please apply or tell me
if it looks wrong.
Original patch mail:
http://www.postgresql.org/message-id/CAB5ZCnSrt-b0SEBCU8d5O6TL7rFxo1zWFWDj86fGzhg0N4tZog@mail.gmail....
Thanks,
David
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Attachments:
0001-Support-ODBCv3-column-names-in-SQLTables.patch (text/x-patch, 2.0K) download
From a74aa5a7b0b331e207bc4af768607e86d9590406 Mon Sep 17 00:00:00 2001
From: David Hedberg <david.hedberg@gmail.com>
Date: Sat, 9 Aug 2014 18:24:57 +0200
Subject: [PATCH] Support ODBCv3 column names in SQLTables
---
info.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/info.c b/info.c
index 81bfe6d..ce00fc4 100644
--- a/info.c
+++ b/info.c
@@ -1557,6 +1557,7 @@ PGAPI_Tables(HSTMT hstmt,
BOOL search_pattern;
BOOL list_cat = FALSE, list_schemas = FALSE, list_table_types = FALSE, list_some = FALSE;
SQLLEN cbRelname, cbRelkind, cbSchName;
+ EnvironmentClass *env;
mylog("%s: entering...stmt=%p scnm=%p len=%d\n", func, stmt, szTableOwner, cbTableOwner);
@@ -1565,6 +1566,7 @@ PGAPI_Tables(HSTMT hstmt,
conn = SC_get_conn(stmt);
ci = &(conn->connInfo);
+ env = CC_get_env(conn);
result = PGAPI_AllocStmt(conn, &htbl_stmt, 0);
if (!SQL_SUCCEEDED(result))
@@ -1850,8 +1852,16 @@ retry_public_schema:
stmt->catalog_result = TRUE;
/* set the field names */
QR_set_num_fields(res, result_cols);
- QR_set_field_info_v(res, TABLES_CATALOG_NAME, "TABLE_QUALIFIER", PG_TYPE_VARCHAR, MAX_INFO_STRING);
- QR_set_field_info_v(res, TABLES_SCHEMA_NAME, "TABLE_OWNER", PG_TYPE_VARCHAR, MAX_INFO_STRING);
+ if (EN_is_odbc3(env))
+ {
+ QR_set_field_info_v(res, TABLES_CATALOG_NAME, "TABLE_CAT", PG_TYPE_VARCHAR, MAX_INFO_STRING);
+ QR_set_field_info_v(res, TABLES_SCHEMA_NAME, "TABLE_SCHEM", PG_TYPE_VARCHAR, MAX_INFO_STRING);
+ }
+ else
+ {
+ QR_set_field_info_v(res, TABLES_CATALOG_NAME, "TABLE_QUALIFIER", PG_TYPE_VARCHAR, MAX_INFO_STRING);
+ QR_set_field_info_v(res, TABLES_SCHEMA_NAME, "TABLE_OWNER", PG_TYPE_VARCHAR, MAX_INFO_STRING);
+ }
QR_set_field_info_v(res, TABLES_TABLE_NAME, "TABLE_NAME", PG_TYPE_VARCHAR, MAX_INFO_STRING);
QR_set_field_info_v(res, TABLES_TABLE_TYPE, "TABLE_TYPE", PG_TYPE_VARCHAR, MAX_INFO_STRING);
QR_set_field_info_v(res, TABLES_REMARKS, "REMARKS", PG_TYPE_VARCHAR, INFO_VARCHAR_SIZE);
--
1.9.1
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [PATCH] Return the correct column names in SQLTables (resend)
@ 2014-10-07 00:36 Michael Paquier <michael.paquier@gmail.com>
parent: David Hedberg <david.hedberg@gmail.com>
0 siblings, 1 reply; 9+ messages in thread
From: Michael Paquier @ 2014-10-07 00:36 UTC (permalink / raw)
To: David Hedberg <david.hedberg@gmail.com>; +Cc: pgsql-odbc
On Mon, Oct 6, 2014 at 10:19 PM, David Hedberg <david.hedberg@gmail.com>
wrote:
> Resending this patch rebased on latest master. Please apply or tell me
> if it looks wrong.
>
At quick glance this patch is correct, and that's actually the same as the
one you sent before.
Original patch mail:
>
> http://www.postgresql.org/message-id/CAB5ZCnSrt-b0SEBCU8d5O6TL7rFxo1zWFWDj86fGzhg0N4tZog@mail.gmail....
>
When sending patch updates, could you send them on the same thread or
directly ping on the thread? It makes easier to follow patch flow and their
review.
Regards,
--
Michael
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [PATCH] Return the correct column names in SQLTables (resend)
@ 2014-10-07 06:08 David Hedberg <david.hedberg@gmail.com>
parent: Michael Paquier <michael.paquier@gmail.com>
0 siblings, 1 reply; 9+ messages in thread
From: David Hedberg @ 2014-10-07 06:08 UTC (permalink / raw)
To: Michael Paquier <michael.paquier@gmail.com>; +Cc: pgsql-odbc
(Forgot to reply to the list)
On Tue, Oct 7, 2014 at 2:36 AM, Michael Paquier
<michael.paquier@gmail.com> wrote:
>
>
> On Mon, Oct 6, 2014 at 10:19 PM, David Hedberg <david.hedberg@gmail.com>
> wrote:
>>
>> Resending this patch rebased on latest master. Please apply or tell me
>> if it looks wrong.
>
> At quick glance this patch is correct, and that's actually the same as the
> one you sent before.
Thanks for looking. Since I've never sent a patch to this project
before I'm relying on my experience with development in another
project, which is basically "if it's not in git yet and no one has
said anything definite, resend or it will get lost". I don't know how
to proceed here.
>
>> Original patch mail:
>>
>> http://www.postgresql.org/message-id/CAB5ZCnSrt-b0SEBCU8d5O6TL7rFxo1zWFWDj86fGzhg0N4tZog@mail.gmail....
>
> When sending patch updates, could you send them on the same thread or
> directly ping on the thread? It makes easier to follow patch flow and their
> review.
Sorry, I will avoid creating new threads in the future.
> Regards,
> --
> Michael
/ David
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [PATCH] Return the correct column names in SQLTables (resend)
@ 2014-10-07 07:42 Heikki Linnakangas <hlinnakangas@vmware.com>
parent: David Hedberg <david.hedberg@gmail.com>
0 siblings, 0 replies; 9+ messages in thread
From: Heikki Linnakangas @ 2014-10-07 07:42 UTC (permalink / raw)
To: David Hedberg <david.hedberg@gmail.com>; Michael Paquier <michael.paquier@gmail.com>; +Cc: pgsql-odbc
On 10/07/2014 09:08 AM, David Hedberg wrote:
> (Forgot to reply to the list)
>
> On Tue, Oct 7, 2014 at 2:36 AM, Michael Paquier
> <michael.paquier@gmail.com> wrote:
>>
>>
>> On Mon, Oct 6, 2014 at 10:19 PM, David Hedberg <david.hedberg@gmail.com>
>> wrote:
>>>
>>> Resending this patch rebased on latest master. Please apply or tell me
>>> if it looks wrong.
>>
>> At quick glance this patch is correct, and that's actually the same as the
>> one you sent before.
>
> Thanks for looking. Since I've never sent a patch to this project
> before I'm relying on my experience with development in another
> project, which is basically "if it's not in git yet and no one has
> said anything definite, resend or it will get lost". I don't know how
> to proceed here.
Sorry for the slow response. I've had your email lying in my inbox, but
haven't gotten around to it.
In theory, it would be nicer to do changes like this in a major release,
i.e. when we bump from 9.3.XXXX to 9.4.XXXX. But then again, the
pgsql-odbc project has never made much distinction between minor and
major releases.
I'm not 100% sure the check for EN_is_odbc3 is correct. If an
application wants ODBC2 behavior, but the driver is an ODBC3 driver, the
driver manager is supposed to bridge the differences. But I'm not
convinced it's wrong either, so I left it as you wrote it. (Of course,
no-one uses ODBC2 anymore, so it doesn't matter in practice). I also
fixed the expected output for the catalogfunctions regression test - it
contained the old column names.
I've committed this now. The change will appear in the next release. Thanks!
- Heikki
--
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2014-10-07 07:42 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-08-09 16:29 [PATCH] Return the correct column names in SQLTables David Hedberg <david.hedberg@gmail.com>
2014-09-22 20:40 ` David Hedberg <david.hedberg@gmail.com>
2014-09-23 09:46 ` Heikki Linnakangas <hlinnakangas@vmware.com>
2014-09-23 10:46 ` David Hedberg <david.hedberg@gmail.com>
2014-09-23 13:33 ` Adrian Klaver <adrian.klaver@aklaver.com>
2014-10-06 13:19 [PATCH] Return the correct column names in SQLTables (resend) David Hedberg <david.hedberg@gmail.com>
2014-10-07 00:36 ` Re: [PATCH] Return the correct column names in SQLTables (resend) Michael Paquier <michael.paquier@gmail.com>
2014-10-07 06:08 ` Re: [PATCH] Return the correct column names in SQLTables (resend) David Hedberg <david.hedberg@gmail.com>
2014-10-07 07:42 ` Re: [PATCH] Return the correct column names in SQLTables (resend) Heikki Linnakangas <hlinnakangas@vmware.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox