Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TKyaf-0001nq-OQ for pgsql-jdbc@postgresql.org; Sun, 07 Oct 2012 21:40:49 +0000 Received: from mailout10.t-online.de ([194.25.134.21]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TKyae-0001Rx-2o for pgsql-jdbc@postgresql.org; Sun, 07 Oct 2012 21:40:49 +0000 Received: from fwd06.aul.t-online.de (fwd06.aul.t-online.de ) by mailout10.t-online.de with smtp id 1TKyab-0007oq-6U; Sun, 07 Oct 2012 23:40:45 +0200 Received: from [127.0.0.1] (r3JnqoZGohiU5BBn9-vfKXNBY3vaN24f7jxERwuuTKQ7srihYe9W4O8Z55I9YPVZvc@[79.211.181.49]) by fwd06.t-online.de with esmtp id 1TKyaU-0RDI5w0; Sun, 7 Oct 2012 23:40:38 +0200 Message-ID: <5071F6D9.3010904@t-online.de> Date: Sun, 07 Oct 2012 23:40:41 +0200 From: Thomas Hill User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: getMetaData().getUserName() implementation Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-ID: r3JnqoZGohiU5BBn9-vfKXNBY3vaN24f7jxERwuuTKQ7srihYe9W4O8Z55I9YPVZvc X-TOI-MSGID: c3c573d2-eb68-417c-9bf5-d13bf8879c31 X-Pg-Spam-Score: -4.0 (----) X-Archive-Number: 201210/20 X-Sequence-Number: 23344 Hello, I have been using Apache Derby as data base backend for an application over the past years and am looking into adding PostgreSQL as an additional backend the application could be run against. Obviously all stored procedure code I have written is in Java. All procedures/functions are defined with "Security definer" so they are executed with the privileges of the user that defined them. So in a first step I installed the latest version of plJava on PostgreSQL 8.4 running on a Debian 6 Squeeze server and uploaded the jar files into the server. In one of my procedures I am however noticing that the Apache Derby implementation and the PostgreSQL implementation are leading to different results. When logging in as "Thomas" and then using jdbc function getMetaData().getUserName() *within* a stored procedure and returning the result to the calling program - Apache Derby returns the session user, i.e. Thomas (and not the name of the data base or procedure owner [which is what CURRENT_USER when being called within the proc would return / but which is not what I need) - PostgreSQL returns "postgres" whereas I would have expected it to also return "Thomas". I am wondering if someone can explain why this is the case? and how I can get around this "compatibility" issue? If the driver implementations are different, any suggestion how to modify the java code so it would actually for both data base systems return the session_user? Thanks a lot in advance. Kind regards Thomas