From: Thomas Hill <Thomas.K.Hill@t-online.de>
To: pgsql-jdbc@postgresql.org
Subject: getMetaData().getUserName() implementation
Date: Sun, 07 Oct 2012 23:40:41 +0200
Message-ID: <5071F6D9.3010904@t-online.de> (raw)
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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: Thomas.K.Hill@t-online.de
Subject: Re: getMetaData().getUserName() implementation
In-Reply-To: <5071F6D9.3010904@t-online.de>
References: <5071F6D9.3010904@t-online.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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