Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-05-09 Thread Marcelo de Moraes Serpa
Hi Manuel, Just replying to say a big thank you ... I compiled the C extension with the code you , did all the necessary logic and finally solved it. Thank you very much for your help! Thank you also to all the other who helped me! Marcelo. On 4/24/07, Manuel Sugawara [EMAIL PROTECTED] wrote:

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-05-09 Thread Tilmann Singer
* Marcelo de Moraes Serpa [EMAIL PROTECTED] [20070509 21:14]: Just replying to say a big thank you ... I compiled the C extension with the code you , did all the necessary logic and finally solved it. Thank you very much for your help! I second that! I finally settled with the simpler

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-25 Thread Marcelo de Moraes Serpa
: -- *From:* [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] *On Behalf Of *Marcelo de Moraes Serpa *Sent:* dinsdag 24 april 2007 21:06 *To:* pgsql-general@postgresql.org *Subject:* Re: [GENERAL] Audit-trail engine: getting the application's layer user_id Thank you for the replies

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-25 Thread Marcelo de Moraes Serpa
Hi Manuel, just a quick question: What C libraries do I need to compile this function? Or better: Where can I find a reference manual about db stored procedures written in C for PostgreSQL? Thanks! On 4/24/07, Manuel Sugawara [EMAIL PROTECTED] wrote: Marcelo de Moraes Serpa [EMAIL PROTECTED]

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-25 Thread Marcelo de Moraes Serpa
I'm sorry Manuel, but after some time trying to fully understand your approach, I think I really don't have the required elements to do so. How do you pass your application's usename to this table? Or you don't keep the username at all? Could you give a more concrete example? Maybe showing the

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-25 Thread Tilmann Singer
* Manuel Sugawara [EMAIL PROTECTED] [20070425 00:17]: I solved the problem using a C program and keeping all the information in the database, that means, users, passwords and ``sessions''. Each time a user opens a session the system register it in a table that looks like: This looks very

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-25 Thread Manuel Sugawara
Marcelo de Moraes Serpa [EMAIL PROTECTED] writes: I'm sorry Manuel, but after some time trying to fully understand your approach, I think I really don't have the required elements to do so. How do you pass your application's usename to this table? Or you don't keep the username at all?

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-25 Thread Manuel Sugawara
Tilmann Singer [EMAIL PROTECTED] writes: So the view will reference the original table and not the temporary table. Is there a way to achieve this kind of transaction local setting? A transaction based solution would give more security in a situation where a web app server uses a connection

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-25 Thread Tilmann Singer
* Manuel Sugawara [EMAIL PROTECTED] [20070425 17:14]: So the view will reference the original table and not the temporary table. Is there a way to achieve this kind of transaction local setting? A transaction based solution would give more security in a situation where a web app server

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-25 Thread Manuel Sugawara
Tilmann Singer [EMAIL PROTECTED] writes: Can I define a view which references a table in a way so that it will use a temporary table of the same name if it exists, otherwise the permanent table with that name? I think you can use a plpgsql function with execute. For instance, if the name of

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-25 Thread Tilmann Singer
* Manuel Sugawara [EMAIL PROTECTED] [20070425 17:57]: I think you can use a plpgsql function with execute. For instance, if the name of your temp table is current_user_id the function will be something like: create function get_current_user_id() returns int as $$ declare v_rec record;

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-25 Thread Marcelo de Moraes Serpa
Hi Manuel, each time the user sends a request I do more or less the following: Could a trigger be used to implement this ? Or are you doing this from the application layer? My problem is that, like Til, I don't have full control over my request cycle as I'm over a very high-level framework

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-25 Thread Manuel Sugawara
Marcelo de Moraes Serpa [EMAIL PROTECTED] writes: Hi Manuel, each time the user sends a request I do more or less the following: Could a trigger be used to implement this ? Or are you doing this from the application layer? I'm doing it form the application layer and I don't think it can

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-25 Thread Marcelo de Moraes Serpa
I'm doing it form the application layer and I don't think it can be done in the database layer, how the trigger will figure out which user is doing the query?, It's the same problem you are trying to solve! Duh! That is what happens when you start having high levels of caffeinne in your blood

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-25 Thread Marcelo de Moraes Serpa
Hello all, I know I may be asking too much, but I have a very limited C/C++ (as well as PostgreSQL internal architecture) knowledge. I've tried compiling the C source code Manuel sent as a PostgreSQL loadable module on Visual Studio .NET 2003 (C++) without success (lots of missing identifiers,

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-25 Thread Jorge Godoy
Marcelo de Moraes Serpa [EMAIL PROTECTED] writes: Hello all, I know I may be asking too much, but I have a very limited C/C++ (as well as PostgreSQL internal architecture) knowledge. I've tried compiling the C source code Manuel sent as a PostgreSQL loadable module on Visual Studio .NET

[GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-24 Thread Marcelo de Moraes Serpa
Hey guys, I needed to implement an audit trail engine and decided to do it on the database layer. I already have a basic but fully functional audit trail system implemented on my PostgreSQL 8.2 server. It has been done using PL/PGSQL and triggers and it works pretty well. Here's what I need to

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-24 Thread Marcelo de Moraes Serpa
I forgot to add the link to the article I've mentioned: http://www-128.ibm.com/developerworks/db2/library/techarticle/0302stolze/0302stolze.html#section2b This is what I'd like to do on PostgreSQL, Thanks, Marcelo. On 4/24/07, Marcelo de Moraes Serpa [EMAIL PROTECTED] wrote: Hey guys, I

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-24 Thread Richard Huxton
Marcelo de Moraes Serpa wrote: Here's what I need to do: Somehow save the user_id of the **application** user who have done the update/delete action to the log row. I've read an article on IBM's developer site which teaches how to do just that (get the application's user id and save it the

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-24 Thread Jorge Godoy
Marcelo de Moraes Serpa [EMAIL PROTECTED] writes: I forgot to add the link to the article I've mentioned: http://www-128.ibm.com/developerworks/db2/library/techarticle/0302stolze/0302stolze.html#section2b This is what I'd like to do on PostgreSQL, So, translating it to a simpler example:

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-24 Thread Marcelo de Moraes Serpa
Thank you for the replies. @Richard: I've thought about having one DB user for each APP user. However, a coworker told me that it would infeasible to do that on the web enviroment, specifically for J2EE where a DB connection pool is used, so I gave up on that. @Jorge: Is this connection id you

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-24 Thread Jorge Godoy
Marcelo de Moraes Serpa [EMAIL PROTECTED] writes: @Richard: I've thought about having one DB user for each APP user. However, a coworker told me that it would infeasible to do that on the web enviroment, specifically for J2EE where a DB connection pool is used, so I gave up on that. Why?

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-24 Thread Manuel Sugawara
Marcelo de Moraes Serpa [EMAIL PROTECTED] writes: Hey guys, Mine is an web application - three tier. The app connects to the db using only one user and it has it's own authentication system and doesn't rely on the database for user management. I solved the problem using a C program and

Re: [GENERAL] Audit-trail engine: getting the application's layer user_id

2007-04-24 Thread Joris Dobbelsteen
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Marcelo de Moraes Serpa Sent: dinsdag 24 april 2007 21:06 To: pgsql-general@postgresql.org Subject: Re: [GENERAL] Audit-trail engine: getting the application's