Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1akkf8-0003ZR-7X for pgsql-odbc@arkaria.postgresql.org; Tue, 29 Mar 2016 03:49:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1akkf7-0005b8-PR for pgsql-odbc@arkaria.postgresql.org; Tue, 29 Mar 2016 03:49:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1akkej-0005CG-Rc for pgsql-odbc@postgresql.org; Tue, 29 Mar 2016 03:49:25 +0000 Received: from mail1.asahi-net.or.jp ([202.224.39.197]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1akkeZ-0007iN-LA for pgsql-odbc@postgresql.org; Tue, 29 Mar 2016 03:49:25 +0000 Received: from [192.168.1.22] (p201056-ipngn200204fukui.fukui.ocn.ne.jp [114.173.34.56]) by mail1.asahi-net.or.jp (Postfix) with ESMTP id EE667ED7F; Tue, 29 Mar 2016 12:49:09 +0900 (JST) Subject: Re: Question regarding accessing only tables to which the user has access To: Fernando Luna References: <479BB3381124DA41AC6539F10BBF788E2212E727@LWEXMB4.usa.int> Cc: "'pgsql-odbc@postgresql.org'" From: "Inoue, Hiroshi" Message-ID: <56F9FB35.1000801@dream.email.ne.jp> Date: Tue, 29 Mar 2016 12:49:09 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <479BB3381124DA41AC6539F10BBF788E2212E727@LWEXMB4.usa.int> Content-Type: multipart/alternative; boundary="------------080008010002070900030700" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org This is a multi-part message in MIME format. --------------080008010002070900030700 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Hi Fernando, On 2016/03/29 2:40, Fernando Luna wrote: > > I am using Tableau version 9.2 to connect to a PostgreSQL database > (version 9.4). This database resides in a VM running Redhat CentOS and > I am connecting from my Windows 7 box using the latest Windows driver > found under http://www.postgresql.org/ftp/odbc/versions/msi/ . The > zipfile name is psqlodbc_09_05_0100-x64.zip > > > My question is this. When Tableau connects it retrieves a list of > tables/views to use. My problem is that Tableau is listing tables to > which the connected user has no privileges and it makes for a poor > user experience to allow Tableau to do that in our case. We want to > only list those tables/views to which the connected user has at the > very least select privileges. At first I thought it was Tableau doing > this and after a while I decided to turn on logging on PostgreSQL and > found that the following query is issued whenever I connect using Tableau. > > select relname, nspname, relkind > > from pg_catalog.pg_class c, pg_catalog.pg_namespace n > > where relkind in ('r', 'v') > > and nspname not in ('pg_catalog', 'information_schema', 'pg_toast', > 'pg_temp_1') > > and n.oid = relnamespace > > order by nspname, relname > > I discovered that this query is executed by the postgres odbc driver > on connect. I looked at the source code for the latest driver and > found this code snippet in info.c: > > if (!list_some) > > { > > if (CC_accessible_only(conn)) > > strcat(tables_query, " and has_table_privilege(c.oid, 'select')"); > > } > > My question is, how can I get the driver to add this snippet to the > query? Please bear in mind that I know nearly nothing about Postgres > and ODBC and would appreciate being pointed in the right direction as > to how to influence pgsql odbc to issue the query like this: > > select relname, nspname, relkind > > from pg_catalog.pg_class c, pg_catalog.pg_namespace n > > where relkind in ('r', 'v') > > and nspname not in ('pg_catalog', 'information_schema', 'pg_toast', > 'pg_temp_1') > > and has_table_privilege(c.oid, 'select') > > and n.oid = relnamespace > > order by nspname, relname > Please set the "Extra Opts" option of Advanced Options(Datasource) Page 2 using ODBC Data Source Administrator. Try to set Extra Opts to 0x10. regards, Hiroshi Inoue --------------080008010002070900030700 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: 8bit Hi Fernando,

On 2016/03/29 2:40, Fernando Luna wrote:

I am using Tableau version 9.2 to connect to a PostgreSQL database (version 9.4). This database resides in a VM running Redhat CentOS and I am connecting from my Windows 7 box using the latest Windows driver found under http://www.postgresql.org/ftp/odbc/versions/msi/ . The zipfile name is psqlodbc_09_05_0100-x64.zip

 

My question is this. When Tableau connects it retrieves a list of tables/views to use. My problem is that Tableau is listing tables to which the connected user has no privileges and it makes for a poor user experience to allow Tableau to do that in our case. We want to only list those tables/views to which the connected user has at the very least select privileges. At first I thought it was Tableau doing this and after a while I decided to turn on logging on PostgreSQL and found that the following query is issued whenever I connect using Tableau.

 

select relname, nspname, relkind

  from pg_catalog.pg_class c, pg_catalog.pg_namespace n

where relkind in ('r', 'v')

   and nspname not in ('pg_catalog', 'information_schema', 'pg_toast', 'pg_temp_1')

   and n.oid = relnamespace

order by nspname, relname

 

I discovered that this query is executed by the postgres odbc driver on connect. I looked at the source code for the latest driver and found this code snippet in info.c:

 

       if (!list_some)

       {

              if (CC_accessible_only(conn))

                     strcat(tables_query, " and has_table_privilege(c.oid, 'select')");

       }

 

My question is, how can I get the driver to add this snippet to the query? Please bear in mind that I know nearly nothing about Postgres and ODBC and would appreciate being pointed in the right direction as to how to influence pgsql odbc to issue the query like this:

 

select relname, nspname, relkind

  from pg_catalog.pg_class c, pg_catalog.pg_namespace n

where relkind in ('r', 'v')

   and nspname not in ('pg_catalog', 'information_schema', 'pg_toast', 'pg_temp_1')

   and has_table_privilege(c.oid, 'select')

   and n.oid = relnamespace

order by nspname, relname

 


Please set the "Extra Opts" option of  Advanced Options(Datasource) Page 2 using ODBC Data Source Administrator.
Try to set Extra Opts to 0x10.

regards,
Hiroshi Inoue
--------------080008010002070900030700--