public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Hughes <[email protected]>
To: [email protected]
Subject: [PATCH] Allow catalog (database) enumeration with SQLTables
Date: Tue, 20 Jun 2023 13:47:11 +0100
Message-ID: <[email protected]> (raw)

The attached patch fixed SQLTables to make enumeration of
databases (catalogs in ODBC speak) work.

Tom

-- 
Tom Hughes ([email protected])
http://compton.nu/

Attachments:

  [text/x-patch] all-catalogs.patch (968B, 2-all-catalogs.patch)
  download | inline diff:
commit 02ac7130865765b5dc1080f99399ac339145d685
Author: Tom Hughes <[email protected]>
Date:   Wed Jun 14 13:07:33 2023 +0100

    Make catalog enumeration with SQLTables work.

diff --git a/info.c b/info.c
index 37f1d49..23db5a3 100644
--- a/info.c
+++ b/info.c
@@ -1898,7 +1898,8 @@ retry_public_schema:
 	initPQExpBuffer(&tables_query);
 #define	return	DONT_CALL_RETURN_FROM_HERE???
 	if (list_cat)
-		appendPQExpBufferStr(&tables_query, "select NULL, NULL, NULL");
+		appendPQExpBufferStr(&tables_query, "select datname, NULL, NULL"
+			" from pg_catalog.pg_database");
 	else if (list_table_types)
 	{
 		/*
@@ -2165,7 +2166,9 @@ retry_public_schema:
 		{
 			tuple = QR_AddNew(res);
 
-			if (list_cat || !list_some)
+			if (list_cat)
+				set_tuplefield_string(&tuple[TABLES_CATALOG_NAME], table_name);
+			else if (!list_some)
 				set_tuplefield_string(&tuple[TABLES_CATALOG_NAME], CurrCat(conn));
 			else
 				set_tuplefield_null(&tuple[TABLES_CATALOG_NAME]);


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: [email protected]
  Cc: [email protected]
  Subject: Re: [PATCH] Allow catalog (database) enumeration with SQLTables
  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