From forums@existanze.com Thu Jun 22 09:19:17 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id E74229FA430 for ; Thu, 22 Jun 2006 06:19:17 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 42299-07 for ; Thu, 22 Jun 2006 06:19:06 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id E9E349F9ED6 for ; Thu, 22 Jun 2006 06:19:06 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from deliver.hol.gr (deliver.hol.gr [194.30.193.26]) by svr4.postgresql.org (Postfix) with ESMTP id 196C65AF024 for ; Thu, 22 Jun 2006 09:19:04 +0000 (GMT) Received: from auth-smtp.hol.gr (takeit01.mail.dc.hol.net [192.168.20.71]) by deliver.hol.gr (8.12.11/8.11.6) with ESMTP id k5M9IMqR024601 (using TLSv1/SSLv3 with cipher DHE-RSA-AES256-SHA (256 bits) verified OK) for ; Thu, 22 Jun 2006 12:18:22 +0300 Received: from pimp (static223128.dsl.hol.gr [62.38.223.129]) by auth-smtp.hol.gr (8.13.1/8.12.11) with ESMTP id k5M9IuAs001850 for ; Thu, 22 Jun 2006 12:18:59 +0300 Message-Id: <200606220918.k5M9IuAs001850@auth-smtp.hol.gr> From: "Forums @ Existanze" To: Subject: Start up question about triggers Date: Thu, 22 Jun 2006 12:19:00 +0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_002D_01C695F6.0C7EFC60" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Thread-Index: AcaV3OWJA7BamFQKTyKs/mlx8cNgEQ== X-Virus-Scanned: ClamAV 0.87/1559/Wed Jun 21 17:23:13 2006 on takeit01.mail.dc.hol.net X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/248 X-Sequence-Number: 25484 This is a multi-part message in MIME format. ------=_NextPart_000_002D_01C695F6.0C7EFC60 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello all, I know that this question may be really simple, but I have decided to ask here due to fact that I don't know how to search for this on google or on the docs. I created a trigger fuction which updates a specific row in some table A. Is it possible to retain the query that was used to trigger the function. For example Table A query_row_id query_row TABLE B id name ------=_NextPart_000_002D_01C695F6.0C7EFC60 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Hello=20 all,
 
I know = that this=20 question may be really simple, but I have decided to ask here due to = fact that I=20 don't know how to search for this on google or on the = docs.
 
I = created a trigger=20 fuction which updates a specific row in some table A. Is it possible to = retain=20 the query that was used to trigger the function. For = example
 
Table=20 A
query_row_id
query_row
 
 
 
TABLE=20 B
id
name
------=_NextPart_000_002D_01C695F6.0C7EFC60-- From forums@existanze.com Thu Jun 22 13:09:09 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 097449F9FE3 for ; Thu, 22 Jun 2006 10:09:09 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 75208-05 for ; Thu, 22 Jun 2006 10:09:03 -0300 (ADT) X-Greylist: delayed 03:49:56.519899 by SQLgrey- Received: from deliver.hol.gr (deliver.hol.gr [194.30.193.26]) by postgresql.org (Postfix) with ESMTP id E16919F9ED6 for ; Thu, 22 Jun 2006 10:09:03 -0300 (ADT) Received: from auth-smtp.hol.gr (takeit01.mail.dc.hol.net [192.168.20.71]) by deliver.hol.gr (8.12.11/8.11.6) with ESMTP id k5MD8N3T005925 (using TLSv1/SSLv3 with cipher DHE-RSA-AES256-SHA (256 bits) verified OK) for ; Thu, 22 Jun 2006 16:08:23 +0300 Received: from pimp (static223128.dsl.hol.gr [62.38.223.129]) by auth-smtp.hol.gr (8.13.1/8.12.11) with ESMTP id k5MD90S3007695 for ; Thu, 22 Jun 2006 16:09:00 +0300 Message-Id: <200606221309.k5MD90S3007695@auth-smtp.hol.gr> From: "Forums @ Existanze" To: Subject: Re: Start up question about triggers Date: Thu, 22 Jun 2006 16:09:04 +0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_003A_01C69616.2EC3F940" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Thread-Index: AcaV3OWJA7BamFQKTyKs/mlx8cNgEQAIBQyQ In-reply-to: <200606220918.k5M9IuAs001850@auth-smtp.hol.gr> X-Virus-Scanned: ClamAV 0.87/1560/Thu Jun 22 12:07:47 2006 on takeit01.mail.dc.hol.net X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/249 X-Sequence-Number: 25485 This is a multi-part message in MIME format. ------=_NextPart_000_003A_01C69616.2EC3F940 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sorry This is the complete message Hello all, I know that this question may be really simple, but I have decided to ask here due to fact that I don't know how to search for this on google or on the docs. I created a trigger fuction which updates a specific row in some table A. Is it possible to retain the query that was used to trigger the function. For example Table A query_row_id query_row TABLE B id name If I create a trigger on table B that says that after the insert command to write the query into table A. So if I do insert into B values(1,"Blah") this will trigger my trigger. Is there any way to get the "insert into B values(1,"Blah")? At the moment I can see only the type of query that it is (INSERT UPDATE DELETE) best regards, Fotis _____ From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Forums @ Existanze Sent: 22 June 2006 12:19 To: pgsql-sql@postgresql.org Subject: [SQL] Start up question about triggers Hello all, I know that this question may be really simple, but I have decided to ask here due to fact that I don't know how to search for this on google or on the docs. I created a trigger fuction which updates a specific row in some table A. Is it possible to retain the query that was used to trigger the function. For example Table A query_row_id query_row TABLE B id name ------=_NextPart_000_003A_01C69616.2EC3F940 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Sorry This is the complete = message
 
Hello=20 all,
 
I know = that this=20 question may be really simple, but I have decided to ask here due to = fact that I=20 don't know how to search for this on google or on the = docs.
 
I = created a trigger=20 fuction which updates a specific row in some table A. Is it possible to = retain=20 the query that was used to trigger the function. For = example
 
Table=20 A
query_row_id
query_row
 
 
 
TABLE=20 B
id
name
 
 
 
 
 
If I = create a=20 trigger on table B that says that after the insert command to write the = query=20 into  table A. So if I do
 
insert = into B=20 values(1,"Blah")
 
this = will trigger my=20 trigger. Is there any way to get the "insert into B values(1,"Blah")? At = the=20 moment I can see only the type of query that it is (INSERT UPDATE=20 DELETE)
 
best=20 regards,
Fotis


From: = pgsql-sql-owner@postgresql.org=20 [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Forums @=20 Existanze
Sent: 22 June 2006 12:19
To:=20 pgsql-sql@postgresql.org
Subject: [SQL] Start up question = about=20 triggers

Hello=20 all,
 
I = know that this=20 question may be really simple, but I have decided to ask here due to = fact that=20 I don't know how to search for this on google or on the=20 docs.
 
I = created a=20 trigger fuction which updates a specific row in some table A. Is it = possible=20 to retain the query that was used to trigger the function. For=20 example
 
Table=20 A
query_row_id
query_row
 
 
 
TABLE=20 B
id
name
= ------=_NextPart_000_003A_01C69616.2EC3F940-- From postgresql@aranya.com Thu Jun 22 16:03:28 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 35B009FA92E for ; Thu, 22 Jun 2006 13:03:28 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 03514-01 for ; Thu, 22 Jun 2006 13:03:18 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.196]) by postgresql.org (Postfix) with ESMTP id DAD329FA7BA for ; Thu, 22 Jun 2006 13:03:17 -0300 (ADT) Received: by wx-out-0102.google.com with SMTP id s13so337834wxc for ; Thu, 22 Jun 2006 09:03:17 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=tVczVJKUwExkp/d+to3aOYUWeXBdsXAKcweNw5PsduYP3nkvz+TnaVr8pvWhtXGjAGa1JGRu8Ull8ooUVZPcJzoG15Ec2nT/hVqGwqf6w2gHvXHOXiogJuJzXyKxRpxXC/TQgQGNckrhQw7wfnT9FViVG2XfcjQkv7LVUJJ3mAc= Received: by 10.70.103.17 with SMTP id a17mr3324163wxc; Thu, 22 Jun 2006 09:03:17 -0700 (PDT) Received: by 10.70.66.15 with HTTP; Thu, 22 Jun 2006 09:03:17 -0700 (PDT) Message-ID: Date: Thu, 22 Jun 2006 11:03:17 -0500 From: "Aaron Bono" To: "Forums @ Existanze" Subject: Re: Start up question about triggers Cc: pgsql-sql@postgresql.org In-Reply-To: <200606221309.k5MD90S3007695@auth-smtp.hol.gr> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_10149_20653731.1150992197025" References: <200606220918.k5M9IuAs001850@auth-smtp.hol.gr> <200606221309.k5MD90S3007695@auth-smtp.hol.gr> X-Google-Sender-Auth: 9939f1f4c4f12bc7 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/252 X-Sequence-Number: 25488 ------=_Part_10149_20653731.1150992197025 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Why not just create a history table and have the trigger copy the data out of the table into the history table with a time stamp of the change. Then you don't need the query. For example Table A a_id, a_value1, a_value2 Table A_hist a_id, a_dt, a_value1, a_value2 Then A_hist has a PK of a_id, a_dt This would also be a lot easier to see WHAT changed and WHEN. You can use the NEW.col and OLD.col to see the new and old values during inserts and updates. Of course, I don't know your need so this may not be achieving your goal. -Aaron Bono On 6/22/06, Forums @ Existanze wrote: > > Sorry This is the complete message > > Hello all, > > I know that this question may be really simple, but I have decided to ask > here due to fact that I don't know how to search for this on google or on > the docs. > > I created a trigger fuction which updates a specific row in some table A. > Is it possible to retain the query that was used to trigger the function. > For example > > Table A > query_row_id > query_row > > > > TABLE B > id > name > > > > > > If I create a trigger on table B that says that after the insert command > to write the query into table A. So if I do > > insert into B values(1,"Blah") > > this will trigger my trigger. Is there any way to get the "insert into B > values(1,"Blah")? At the moment I can see only the type of query that it is > (INSERT UPDATE DELETE) > > best regards, > Fotis > > ------------------------------ > *From:* pgsql-sql-owner@postgresql.org [mailto: > pgsql-sql-owner@postgresql.org] *On Behalf Of *Forums @ Existanze > *Sent:* 22 June 2006 12:19 > *To:* pgsql-sql@postgresql.org > *Subject:* [SQL] Start up question about triggers > > Hello all, > > I know that this question may be really simple, but I have decided to ask > here due to fact that I don't know how to search for this on google or on > the docs. > > I created a trigger fuction which updates a specific row in some table A. > Is it possible to retain the query that was used to trigger the function. > For example > > Table A > query_row_id > query_row > > > > TABLE B > id > name > ------=_Part_10149_20653731.1150992197025 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Why not just create a history table and have the trigger copy the data out of the table into the history table with a time stamp of the change.  Then you don't need the query.

For example
Table A
a_id,
a_value1,
a_value2

Table A_hist
a_id,
a_dt,
a_value1,
a_value2

Then A_hist has a PK of a_id, a_dt

This would also be a lot easier to see WHAT changed and WHEN.  You can use the NEW.col and OLD.col to see the new and old values during inserts and updates.

Of course, I don't know your need so this may not be achieving your goal.

-Aaron Bono

On 6/22/06, Forums @ Existanze <forums@existanze.com> wrote:
Sorry This is the complete message
 
Hello all,
 
I know that this question may be really simple, but I have decided to ask here due to fact that I don't know how to search for this on google or on the docs.
 
I created a trigger fuction which updates a specific row in some table A. Is it possible to retain the query that was used to trigger the function. For example
 
Table A
query_row_id
query_row
 
 
 
TABLE B
id
name
 
 
 
 
 
If I create a trigger on table B that says that after the insert command to write the query into  table A. So if I do
 
insert into B values(1,"Blah")
 
this will trigger my trigger. Is there any way to get the "insert into B values(1,"Blah")? At the moment I can see only the type of query that it is (INSERT UPDATE DELETE)
 
best regards,
Fotis


From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Forums @ Existanze
Sent: 22 June 2006 12:19
To: pgsql-sql@postgresql.org
Subject: [SQL] Start up question about triggers

Hello all,
 
I know that this question may be really simple, but I have decided to ask here due to fact that I don't know how to search for this on google or on the docs.
 
I created a trigger fuction which updates a specific row in some table A. Is it possible to retain the query that was used to trigger the function. For example
 
Table A
query_row_id
query_row
 
 
 
TABLE B
id
name

------=_Part_10149_20653731.1150992197025-- From forums@existanze.com Thu Jun 22 16:58:51 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 3DFEC9FA2F0 for ; Thu, 22 Jun 2006 13:58:51 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 10453-03 for ; Thu, 22 Jun 2006 13:58:29 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from deliver.hol.gr (deliver.hol.gr [194.30.193.26]) by postgresql.org (Postfix) with ESMTP id DD4309FA68D for ; Thu, 22 Jun 2006 13:58:28 -0300 (ADT) Received: from auth-smtp.hol.gr (takeit01.mail.dc.hol.net [192.168.20.71]) by deliver.hol.gr (8.12.11/8.11.6) with ESMTP id k5MGvnKC021054 (using TLSv1/SSLv3 with cipher DHE-RSA-AES256-SHA (256 bits) verified OK) for ; Thu, 22 Jun 2006 19:57:49 +0300 Received: from pimp (static223128.dsl.hol.gr [62.38.223.129]) by auth-smtp.hol.gr (8.13.1/8.12.11) with ESMTP id k5MGwPZH007877 for ; Thu, 22 Jun 2006 19:58:25 +0300 Message-Id: <200606221658.k5MGwPZH007877@auth-smtp.hol.gr> From: "Forums @ Existanze" To: Subject: Re: Start up question about triggers Date: Thu, 22 Jun 2006 19:58:30 +0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_005F_01C69636.3BD1E690" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Thread-Index: AcaWFdKy6rK/yyR1TeuloULe+5ixPwABYiYQ In-reply-to: X-Virus-Scanned: ClamAV 0.87/1560/Thu Jun 22 12:07:47 2006 on takeit01.mail.dc.hol.net X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/253 X-Sequence-Number: 25489 This is a multi-part message in MIME format. ------=_NextPart_000_005F_01C69636.3BD1E690 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Thank you for your answer, We had though about your solution, the problem is that we have around 80 tables at the moment so your method would suggest adding another 80. I was wondering if it was possible to retrieve the query in the trigger function, cause what we wanted to achieve was to trigger a query log when any insert or update or delete operation was made on any of the 80 tables. This way we would have something like a query log table. Which will have the queries in the order that they were executed by n number of clients. Say one client updates a row, and the next client deletes it, we want to know the queries that occurred in that particular order. I hope this makes some sense :-) I should also mention that what we are trying to achieve is some sort of partial backup operation. Because of bad initial design, we didn't foresee this comming. So now we have two options, changing all the tables,queries and code, to contain two timestamps columns representing created and updated row, a flag for deleted row, and have some sort of maintanance operation that will clean all the deleted records, and create insert/update statements for those records that have been updated ie( time_of_update > time_of_creation). This will give us a list of operation (INSERT OR UPDATE statements) that can be written to a file, and run from a file. So if I had 10 partiall backups and ran them sequencially I would in theory have the data that I originally had. At the moment we are doing full back using pgdump, but this is another type of requirement. Any ideas greatly appreciated. Best Regards, Fotis _____ From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Aaron Bono Sent: 22 June 2006 19:03 To: Forums @ Existanze Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Start up question about triggers Why not just create a history table and have the trigger copy the data out of the table into the history table with a time stamp of the change. Then you don't need the query. For example Table A a_id, a_value1, a_value2 Table A_hist a_id, a_dt, a_value1, a_value2 Then A_hist has a PK of a_id, a_dt This would also be a lot easier to see WHAT changed and WHEN. You can use the NEW.col and OLD.col to see the new and old values during inserts and updates. Of course, I don't know your need so this may not be achieving your goal. -Aaron Bono On 6/22/06, Forums @ Existanze wrote: Sorry This is the complete message Hello all, I know that this question may be really simple, but I have decided to ask here due to fact that I don't know how to search for this on google or on the docs. I created a trigger fuction which updates a specific row in some table A. Is it possible to retain the query that was used to trigger the function. For example Table A query_row_id query_row TABLE B id name If I create a trigger on table B that says that after the insert command to write the query into table A. So if I do insert into B values(1,"Blah") this will trigger my trigger. Is there any way to get the "insert into B values(1,"Blah")? At the moment I can see only the type of query that it is (INSERT UPDATE DELETE) best regards, Fotis _____ From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Forums @ Existanze Sent: 22 June 2006 12:19 To: pgsql-sql@postgresql.org Subject: [SQL] Start up question about triggers Hello all, I know that this question may be really simple, but I have decided to ask here due to fact that I don't know how to search for this on google or on the docs. I created a trigger fuction which updates a specific row in some table A. Is it possible to retain the query that was used to trigger the function. For example Table A query_row_id query_row TABLE B id name ------=_NextPart_000_005F_01C69636.3BD1E690 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Thank you for your answer,
 
We had though about your solution, the problem = is that we=20 have around 80 tables at the moment so your method would suggest adding = another=20 80.
 
I was wondering if it was possible to retrieve = the query in=20 the trigger function, cause what we wanted to achieve was to trigger a = query log=20 when any insert or update or delete operation was made on any of the 80 = tables.=20 This way we would have something like a query log table. Which will have = the=20 queries in the order that they were executed by n  number of = clients.=20
 
Say one client updates a row, and the next = client deletes=20 it, we want to know the queries that occurred in that particular=20 order.
 
I hope this makes some sense = :-)
 
I should also mention that what we are trying = to achieve is=20 some sort of partial backup operation. Because of bad initial design, we = didn't=20 foresee this comming. So now we have two options, changing all the=20 tables,queries and code, to contain two timestamps columns=20 representing created and updated row, a flag for deleted row, and = have some=20 sort of maintanance operation that will clean all the deleted records, = and=20 create insert/update statements for those records that have been updated = ie(=20 time_of_update > time_of_creation). This will give us a list of = operation=20 (INSERT OR UPDATE statements) that can be written to a file, and run = from a=20 file.
 
So if I had 10 partiall backups and ran them = sequencially I=20 would in theory have the data that I originally had. At the moment we = are doing=20 full back using pgdump, but this is another type of=20 requirement.
 
 
Any ideas greatly = appreciated.
 
Best Regards,
Fotis


From: = pgsql-sql-owner@postgresql.org=20 [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Aaron=20 Bono
Sent: 22 June 2006 19:03
To: Forums @=20 Existanze
Cc: pgsql-sql@postgresql.org
Subject: = Re: [SQL]=20 Start up question about triggers

Why not just create a history table and have the trigger = copy the=20 data out of the table into the history table with a time stamp of the=20 change.  Then you don't need the query.

For = example
Table=20 A
a_id,
a_value1,
a_value2

Table=20 A_hist
a_id,
a_dt,
a_value1,
a_value2

Then A_hist = has a PK=20 of a_id, a_dt

This would also be a lot easier to see WHAT = changed and=20 WHEN.  You can use the NEW.col and OLD.col to see the new and old = values=20 during inserts and updates.

Of course, I don't know your need = so this=20 may not be achieving your goal.

-Aaron Bono

On 6/22/06, Forums @=20 Existanze <forums@existanze.com> = wrote:
Sorry=20 This is the complete message
 
Hello = all,
 
I know that this question may = be really=20 simple, but I have decided to ask here due to fact that I don't know = how to=20 search for this on google or on the docs.
 
I created a trigger fuction = which updates=20 a specific row in some table A. Is it possible to retain the query = that was=20 used to trigger the function. For example
 
Table A
query_row_id
query_row
 
 
 
TABLE B
id
name
 
 
 
 
 
If I create a trigger on = table B that=20 says that after the insert command to write the query into  = table A. So=20 if I do
 
insert into B=20 values(1,"Blah")
 
this will trigger my trigger. = Is there=20 any way to get the "insert into B values(1,"Blah")? At the moment I = can see=20 only the type of query that it is (INSERT UPDATE = DELETE)
 
best = regards,
Fotis


From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf = Of=20 Forums @ Existanze
Sent: 22 June 2006 = 12:19
To: pgsql-sql@postgresql.org
Subject: = [SQL] Start=20 up question about triggers

Hello = all,
 
I know that this question may = be really=20 simple, but I have decided to ask here due to fact that I don't know = how to=20 search for this on google or on the docs.
 
I created a trigger fuction = which updates=20 a specific row in some table A. Is it possible to retain the query = that was=20 used to trigger the function. For example
 
Table A
query_row_id
query_row
 
 
 
TABLE B
id
name

------=_NextPart_000_005F_01C69636.3BD1E690-- From postgresql@aranya.com Fri Jun 23 03:17:49 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id F1D689FA5E6 for ; Fri, 23 Jun 2006 00:17:49 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 29949-01 for ; Fri, 23 Jun 2006 00:17:44 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.205]) by postgresql.org (Postfix) with ESMTP id 4997B9FA2F4 for ; Fri, 23 Jun 2006 00:17:44 -0300 (ADT) Received: by wx-out-0102.google.com with SMTP id i31so375753wxd for ; Thu, 22 Jun 2006 20:17:43 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=DLVDTVil/AGaa9ICz026Wq2IRHx1haWQCDTTCNLNlc5CFEVl9uzcc13rqhj7emnPYj3I7tLQmL3jR1A/EqL/3P6oxK7iSQuykmLFwc62E+chwk9Uc0siQv2LrmDJIVDewbLvA57I48+LkRnox7p8Y21/0j/Xh4vb6a2KPjJ0WAg= Received: by 10.70.16.4 with SMTP id 4mr3906441wxp; Thu, 22 Jun 2006 20:17:43 -0700 (PDT) Received: by 10.70.66.15 with HTTP; Thu, 22 Jun 2006 20:17:43 -0700 (PDT) Message-ID: Date: Thu, 22 Jun 2006 22:17:43 -0500 From: "Aaron Bono" To: pgsql-sql@postgresql.org Subject: Fwd: Start up question about triggers In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_18290_6812519.1151032663577" References: <200606221658.k5MGwPZH007877@auth-smtp.hol.gr> X-Google-Sender-Auth: a54e3a3e7f5c43a4 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/254 X-Sequence-Number: 25490 ------=_Part_18290_6812519.1151032663577 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I did some research and can't even find a way to get meta data in a trigger. In a trigger, is there a way to inspect OLD and NEW to see what columns are there and see what has changed? If so, you may not be able to grab the actual query but you could create a generic trigger that reconstructs a possible update/insert/delete for any table in your database. Does anyone know of a good place to go get information about using meta data in a stored procedure or trigger? Thanks, Aaron On 6/22/06, Forums @ Existanze wrote: > Thank you for your answer, > > We had though about your solution, the problem is that we have around 80 > tables at the moment so your method would suggest adding another 80. > > I was wondering if it was possible to retrieve the query in the trigger > function, cause what we wanted to achieve was to trigger a query log when > any insert or update or delete operation was made on any of the 80 tables. > This way we would have something like a query log table. Which will have the > queries in the order that they were executed by n number of clients. > > Say one client updates a row, and the next client deletes it, we want to > know the queries that occurred in that particular order. > > I hope this makes some sense :-) > > I should also mention that what we are trying to achieve is some sort of > partial backup operation. Because of bad initial design, we didn't foresee > this comming. So now we have two options, changing all the tables,queries > and code, to contain two timestamps columns representing created and updated > row, a flag for deleted row, and have some sort of maintanance operation > that will clean all the deleted records, and create insert/update statements > for those records that have been updated ie( time_of_update > > time_of_creation). This will give us a list of operation (INSERT OR UPDATE > statements) that can be written to a file, and run from a file. > > So if I had 10 partiall backups and ran them sequencially I would in > theory have the data that I originally had. At the moment we are doing full > back using pgdump, but this is another type of requirement. > > > Any ideas greatly appreciated. > > Best Regards, > Fotis > ------=_Part_18290_6812519.1151032663577 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I did some research and can't even find a way to get meta data in a trigger.

In a trigger, is there a way to inspect OLD and NEW to see what columns are there and see what has changed?  If so, you may not be able to grab the actual query but you could create a generic trigger that reconstructs a possible update/insert/delete for any table in your database.

Does anyone know of a good place to go get information about using meta data in a stored procedure or trigger?

Thanks,
Aaron

On 6/22/06, Forums @ Existanze <forums@existanze.com> wrote:
Thank you for your answer,
 
We had though about your solution, the problem is that we have around 80 tables at the moment so your method would suggest adding another 80.
 
I was wondering if it was possible to retrieve the query in the trigger function, cause what we wanted to achieve was to trigger a query log when any insert or update or delete operation was made on any of the 80 tables. This way we would have something like a query log table. Which will have the queries in the order that they were executed by n  number of clients.
 
Say one client updates a row, and the next client deletes it, we want to know the queries that occurred in that particular order.
 
I hope this makes some sense :-)
 
I should also mention that what we are trying to achieve is some sort of partial backup operation. Because of bad initial design, we didn't foresee this comming. So now we have two options, changing all the tables,queries and code, to contain two timestamps columns representing created and updated row, a flag for deleted row, and have some sort of maintanance operation that will clean all the deleted records, and create insert/update statements for those records that have been updated ie( time_of_update > time_of_creation). This will give us a list of operation (INSERT OR UPDATE statements) that can be written to a file, and run from a file.
 
So if I had 10 partiall backups and ran them sequencially I would in theory have the data that I originally had. At the moment we are doing full back using pgdump, but this is another type of requirement.
 
 
Any ideas greatly appreciated.
 
Best Regards,
Fotis


------=_Part_18290_6812519.1151032663577-- From rabroersma@yahoo.com Fri Jun 23 05:09:41 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 25DD69FA5E7 for ; Fri, 23 Jun 2006 02:09:41 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 42778-09 for ; Fri, 23 Jun 2006 02:09:32 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web31801.mail.mud.yahoo.com (web31801.mail.mud.yahoo.com [68.142.207.64]) by postgresql.org (Postfix) with SMTP id 137FA9FA395 for ; Fri, 23 Jun 2006 02:09:31 -0300 (ADT) Received: (qmail 29803 invoked by uid 60001); 23 Jun 2006 05:09:30 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=i9i2fkxAMYMWeEZj7fG17a7TP6iKs75zfuHa7Kp747ExET1knJqibk72WwwR0wXPZIMur2yghvVj6aDjgrgTq4KiAy0+39t4HDudxZm1sq2szV7XxR04GTXLwMLWIAFj6uvrqiFbJUdKozoi+eFISQ5ELVnlZNndRknpZHwNXZU= ; Message-ID: <20060623050930.29801.qmail@web31801.mail.mud.yahoo.com> Received: from [24.54.196.198] by web31801.mail.mud.yahoo.com via HTTP; Thu, 22 Jun 2006 22:09:30 PDT Date: Thu, 22 Jun 2006 22:09:30 -0700 (PDT) From: Richard Broersma Jr Subject: Re: Fwd: Start up question about triggers To: Aaron Bono , pgsql-sql@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/255 X-Sequence-Number: 25491 > I did some research and can't even find a way to get meta data in a trigger. > > In a trigger, is there a way to inspect OLD and NEW to see what columns are > there and see what has changed? If so, you may not be able to grab the > actual query but you could create a generic trigger that reconstructs a > possible update/insert/delete for any table in your database. > > Does anyone know of a good place to go get information about using meta data > in a stored procedure or trigger? yes. See the section "User Comments" at the very bottom of Chapter 33 after "Writing Trigger Functions in C". It is odd that a PL_PGSQL example is given at the end a chapter for triggers written in C. http://www.postgresql.org/docs/8.1/interactive/trigger-example.html Also see the entire chapter 36.10 "Trigger Procedures" http://www.postgresql.org/docs/8.1/interactive/plpgsql-trigger.html Hope this is what you are looking for. Regards, Richard Broersma Jr. From forums@existanze.com Fri Jun 23 07:15:25 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 084A79FA5E7 for ; Fri, 23 Jun 2006 04:15:25 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 60470-03 for ; Fri, 23 Jun 2006 04:15:21 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from deliver.hol.gr (deliver.hol.gr [194.30.193.27]) by postgresql.org (Postfix) with ESMTP id C9B219FA395 for ; Fri, 23 Jun 2006 04:15:20 -0300 (ADT) Received: from auth-smtp.hol.gr (takeit01.mail.dc.hol.net [192.168.20.71]) by deliver.hol.gr (8.12.11/8.11.6) with ESMTP id k5N7Ee2U002214 (using TLSv1/SSLv3 with cipher DHE-RSA-AES256-SHA (256 bits) verified OK) for ; Fri, 23 Jun 2006 10:14:40 +0300 Received: from pimp (static223128.dsl.hol.gr [62.38.223.129]) by auth-smtp.hol.gr (8.13.1/8.12.11) with ESMTP id k5N7FHjO007409 for ; Fri, 23 Jun 2006 10:15:17 +0300 Message-Id: <200606230715.k5N7FHjO007409@auth-smtp.hol.gr> From: "Forums @ Existanze" To: Subject: Re: Fwd: Start up question about triggers Date: Fri, 23 Jun 2006 10:15:22 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Thread-Index: AcaWg6dm4l5vWbX1TUidJ1nYRfK61QAELF8A In-Reply-To: <20060623050930.29801.qmail@web31801.mail.mud.yahoo.com> X-Virus-Scanned: ClamAV 0.87/1561/Thu Jun 22 18:40:00 2006 on takeit01.mail.dc.hol.net X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/256 X-Sequence-Number: 25492 Hello again aaron, Im really interested in the part where you say "generic trigger" can you give me some tips? As to how I will go about that? I had already read the links that Richard gave, I new I could get the values like that. So right now I will have to create a trigger for each of my tables to create the necessary queries, or I could do it "generically" :-) Best Regards, Fotis > -----Original Message----- > From: pgsql-sql-owner@postgresql.org > [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Richard > Broersma Jr > Sent: 23 June 2006 08:10 > To: Aaron Bono; pgsql-sql@postgresql.org > Subject: Re: Fwd: [SQL] Start up question about triggers > > > I did some research and can't even find a way to get meta > data in a trigger. > > > > In a trigger, is there a way to inspect OLD and NEW to see what > > columns are there and see what has changed? If so, you may not be > > able to grab the actual query but you could create a > generic trigger > > that reconstructs a possible update/insert/delete for any > table in your database. > > > > Does anyone know of a good place to go get information about using > > meta data in a stored procedure or trigger? > > yes. > See the section "User Comments" at the very bottom of Chapter > 33 after "Writing Trigger Functions in C". It is odd that a > PL_PGSQL example is given at the end a chapter for triggers > written in C. > > http://www.postgresql.org/docs/8.1/interactive/trigger-example.html > > Also see the entire chapter 36.10 "Trigger Procedures" > http://www.postgresql.org/docs/8.1/interactive/plpgsql-trigger.html > > Hope this is what you are looking for. > > Regards, > > Richard Broersma Jr. > > ---------------------------(end of > broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match > From gweaver@shaw.ca Fri Jun 23 12:37:48 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 3681D9FA5DD for ; Fri, 23 Jun 2006 09:37:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 05561-01 for ; Fri, 23 Jun 2006 09:37:40 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from pd6mo2no.prod.shaw.ca (idcmail-mo2no.cg.shawcable.net [64.59.134.9]) by postgresql.org (Postfix) with ESMTP id B251D9FA182 for ; Fri, 23 Jun 2006 09:37:40 -0300 (ADT) Received: from pd8mr4no.prod.shaw.ca (pd8mr4no-qfe2.prod.shaw.ca [10.0.144.161]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0J1B00GRDCEQD2F0@l-daemon> for pgsql-sql@postgresql.org; Fri, 23 Jun 2006 06:37:38 -0600 (MDT) Received: from pn7ml4no.prod.shaw.ca ([10.0.149.113]) by pd8mr4no.prod.shaw.ca (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0J1B00L9FCEQXK90@pd8mr4no.prod.shaw.ca> for pgsql-sql@postgresql.org; Fri, 23 Jun 2006 06:37:38 -0600 (MDT) Received: from Dell4500 ([24.77.157.242]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with SMTP id <0J1B0090XCEI5I70@l-daemon> for pgsql-sql@postgresql.org; Fri, 23 Jun 2006 06:37:38 -0600 (MDT) Date: Fri, 23 Jun 2006 07:37:41 -0500 From: George Weaver Subject: Re: Fwd: Start up question about triggers To: "Forums @ Existanze" Cc: pgsql-sql@postgresql.org Message-id: <006901c696c1$d2af82d0$6400a8c0@Dell4500> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-Mailer: Microsoft Outlook Express 6.00.2900.2869 Content-type: text/plain; format=flowed; charset=iso-8859-1; reply-type=original Content-transfer-encoding: 7bit X-Priority: 3 X-MSMail-priority: Normal References: <200606230715.k5N7FHjO007409@auth-smtp.hol.gr> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/257 X-Sequence-Number: 25493 Hi Fotis, If you end up having to create a solution for each of the 80 tables, you may want to check out the following (may also give you addtional ideas for what you're trying to achieve): http://www.varlena.com/GeneralBits/104.php (Logging Audit Changes with Composite Typed Columns). Regards, George ----- Original Message ----- From: "Forums @ Existanze" To: Sent: Friday, June 23, 2006 2:15 AM Subject: Re: Fwd: [SQL] Start up question about triggers > > Hello again aaron, > > Im really interested in the part where you say "generic trigger" can you > give me some tips? As to how I will go about that? I had already read the > links that Richard gave, I new I could get the values like that. So right > now I will have to create a trigger for each of my tables to create the > necessary queries, or I could do it "generically" :-) > > Best Regards, > Fotis > >> -----Original Message----- >> From: pgsql-sql-owner@postgresql.org >> [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Richard >> Broersma Jr >> Sent: 23 June 2006 08:10 >> To: Aaron Bono; pgsql-sql@postgresql.org >> Subject: Re: Fwd: [SQL] Start up question about triggers >> >> > I did some research and can't even find a way to get meta >> data in a trigger. >> > >> > In a trigger, is there a way to inspect OLD and NEW to see what >> > columns are there and see what has changed? If so, you may not be >> > able to grab the actual query but you could create a >> generic trigger >> > that reconstructs a possible update/insert/delete for any >> table in your database. >> > >> > Does anyone know of a good place to go get information about using >> > meta data in a stored procedure or trigger? >> >> yes. >> See the section "User Comments" at the very bottom of Chapter >> 33 after "Writing Trigger Functions in C". It is odd that a >> PL_PGSQL example is given at the end a chapter for triggers >> written in C. >> >> http://www.postgresql.org/docs/8.1/interactive/trigger-example.html >> >> Also see the entire chapter 36.10 "Trigger Procedures" >> http://www.postgresql.org/docs/8.1/interactive/plpgsql-trigger.html >> >> Hope this is what you are looking for. >> >> Regards, >> >> Richard Broersma Jr. >> >> ---------------------------(end of >> broadcast)--------------------------- >> TIP 9: In versions below 8.0, the planner will ignore your desire to >> choose an index scan if your joining column's datatypes do not >> match >> > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org > From rabroersma@yahoo.com Fri Jun 23 14:27:23 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 216249FA182 for ; Fri, 23 Jun 2006 11:27:23 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 18370-08 for ; Fri, 23 Jun 2006 11:27:15 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web31813.mail.mud.yahoo.com (web31813.mail.mud.yahoo.com [68.142.207.76]) by postgresql.org (Postfix) with SMTP id AAB219FA5DD for ; Fri, 23 Jun 2006 11:27:15 -0300 (ADT) Received: (qmail 99810 invoked by uid 60001); 23 Jun 2006 14:27:14 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=52Uj0LHgXjo/02j0WejdfRi9gGvCtsCu8n8IN00tzPSJTT8cAMBdlURQ3w9q++UPyT6qbkqiDtQFExN76LoOUDiYmoyN2jvSFDrK9G/oYRxAfQZVNROBtLteb4/jZWrVd3jE1roC7+weeBnykN6H6PSWvryO84pRix9d2CegugY= ; Message-ID: <20060623142714.99808.qmail@web31813.mail.mud.yahoo.com> Received: from [63.203.180.122] by web31813.mail.mud.yahoo.com via HTTP; Fri, 23 Jun 2006 07:27:14 PDT Date: Fri, 23 Jun 2006 07:27:14 -0700 (PDT) From: Richard Broersma Jr Subject: Re: Fwd: Start up question about triggers To: "Forums @ Existanze" , pgsql-sql@postgresql.org In-Reply-To: <200606230715.k5N7FHjO007409@auth-smtp.hol.gr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/258 X-Sequence-Number: 25494 > Im really interested in the part where you say "generic trigger" can you > give me some tips? As to how I will go about that? I had already read the > links that Richard gave, I new I could get the values like that. So right > now I will have to create a trigger for each of my tables to create the > necessary queries, or I could do it "generically" :-) Sorry, I guess I haven't kept up to speed with this thread. However, from chapter 36.10 http://www.postgresql.org/docs/8.1/interactive/plpgsql-trigger.html Notice the variables that you have to work with in a trigger function: TG_WHEN Data type text; a string of either BEFORE or AFTER depending on the trigger's definition. TG_RELNAME = Data type name; the name of the table that caused the trigger invocation. TG_OP = Data type text; a string of INSERT, UPDATE, or DELETE telling for which operation the trigger was fired. NEW Data type RECORD; variable holding the new database row for INSERT/UPDATE operations in row-level triggers. This variable is NULL in statement-level triggers. OLD Data type RECORD; variable holding the old database row for UPDATE/DELETE operations in row-level triggers. This variable is NULL in statement-level triggers. Also, notice chapter 9.19 http://www.postgresql.org/docs/8.1/interactive/functions-info.html current_user = user name of current execution context So with this information couldn't one (from a trigger function) insert a record in to a history table with the following columns?: Then for each column of the affect table if old.tbl_col1 != new.tbl_col1 then add a record to the history as follows. TG_WHEN : TG_RELNAME : current_user : TG_OP : old.tbl_col1 TG_WHEN : TG_RELNAME : current_user : TG_OP : old.tbl_col2 TG_WHEN : TG_RELNAME : current_user : TG_OP : old.tbl_col3 TG_WHEN : TG_RELNAME : current_user : TG_OP : old.tbl_coln is this something like what you had in mind? Regards, Richard Broersma Jr. From forums@existanze.com Fri Jun 23 15:48:56 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 387589FA65C for ; Fri, 23 Jun 2006 12:48:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 32240-06 for ; Fri, 23 Jun 2006 12:48:48 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from deliver.hol.gr (deliver.hol.gr [194.30.193.27]) by postgresql.org (Postfix) with ESMTP id 715B49FA182 for ; Fri, 23 Jun 2006 12:48:47 -0300 (ADT) Received: from auth-smtp.hol.gr (takeit01.mail.dc.hol.net [192.168.20.71]) by deliver.hol.gr (8.12.11/8.11.6) with ESMTP id k5NFm6rA029079 (using TLSv1/SSLv3 with cipher DHE-RSA-AES256-SHA (256 bits) verified OK) for ; Fri, 23 Jun 2006 18:48:06 +0300 Received: from pimp (static223128.dsl.hol.gr [62.38.223.129]) by auth-smtp.hol.gr (8.13.1/8.12.11) with ESMTP id k5NFmhSW028183 for ; Fri, 23 Jun 2006 18:48:43 +0300 Message-Id: <200606231548.k5NFmhSW028183@auth-smtp.hol.gr> From: "Forums @ Existanze" To: Subject: Re: Fwd: Start up question about triggers Date: Fri, 23 Jun 2006 18:48:49 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Thread-Index: AcaWwkFMkgH182ylQ4Ku1vnl8/sMxQAGA0Mg In-Reply-To: <006901c696c1$d2af82d0$6400a8c0@Dell4500> X-Virus-Scanned: ClamAV 0.87/1562/Fri Jun 23 10:50:07 2006 on takeit01.mail.dc.hol.net X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/259 X-Sequence-Number: 25495 Hello again, First of all thank you all for your effort in helping me solve this problem. George's link seems like a complete auditing framework for a database, so I will look into that, cuase it gives you a complete view of what is going on, and I can have undo opertaions :-) I have to say that this was not what I was looking for, but you guys helped realized that it is the way to go. Richard- Your suggestion also makes a lot of sense and thank you for your suggestion. What I have to point out is that no matter which solution we choose, we are going to need to have an auditing table that represents each of our tables, which as I mentioned are around 80 at the moment :-( so that is a lot of extra work, but what can you do! Image this scenario, and tell me if it wouldn't be awsome! I have "n" number of tables each of which has different number of columns,keys constraints and so on, and I have just ONE table with three columns: Logger ------ Log_id SERIAL PRIMARY KEY, User VARCHAR(100) NOT NULL, Query text Then there exist a TG_QUERY parameter that we could use to get the actual query ran by a user, so if I ran the imaginary query INSERT INTO blah VALUES(DEFAULT,one,"23-08-3000") I could use TG_QUERY and do //trigger code ......... INSERT INTO Logger VALUES(DEFAULT,user,TG_QUERY) .....// end of trigger This way I would end up with a log of the query ran on any of the tables so theoretically SELECT * FROM Logger ORDER BY Logger_id Would return Logger_id User Query --------- ---- ----- 2 fotis 'INSERT INTO blah VALUES(DEFAULT,one,"23-08-3000")' 4 fotis 'UPDATE seconblah SET parispo='hello' WHERE parispo_id=50' 9 fotis 'DELETE FROM blah WHERE id=30' 12 fotis 'INSERT INTO seconblah VALUES(DEFAULT,'another')' And so on.... This way I would have all the necessary queries to restore an incomplete database with the appropiate data from some point in time to another in the future. The only difference between the theoretical method and the ones already suggested is that I will still need "n" trigger function for each of the "n" tables, but only ONE auditing table. Would it be much nicer :-) Once again thank you very much for all your help, Fotis > -----Original Message----- > From: pgsql-sql-owner@postgresql.org > [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of George Weaver > Sent: 23 June 2006 15:38 > To: Forums @ Existanze > Cc: pgsql-sql@postgresql.org > Subject: Re: Fwd: [SQL] Start up question about triggers > > Hi Fotis, > > If you end up having to create a solution for each of the 80 > tables, you may want to check out the following (may also > give you addtional ideas for what you're trying to achieve): > > http://www.varlena.com/GeneralBits/104.php (Logging Audit > Changes with Composite Typed Columns). > > Regards, > George > > > ----- Original Message ----- > From: "Forums @ Existanze" > To: > Sent: Friday, June 23, 2006 2:15 AM > Subject: Re: Fwd: [SQL] Start up question about triggers > > > > > > Hello again aaron, > > > > Im really interested in the part where you say "generic > trigger" can you > > give me some tips? As to how I will go about that? I had > already read the > > links that Richard gave, I new I could get the values like > that. So right > > now I will have to create a trigger for each of my tables > to create the > > necessary queries, or I could do it "generically" :-) > > > > Best Regards, > > Fotis > > > >> -----Original Message----- > >> From: pgsql-sql-owner@postgresql.org > >> [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Richard > >> Broersma Jr > >> Sent: 23 June 2006 08:10 > >> To: Aaron Bono; pgsql-sql@postgresql.org > >> Subject: Re: Fwd: [SQL] Start up question about triggers > >> > >> > I did some research and can't even find a way to get meta > >> data in a trigger. > >> > > >> > In a trigger, is there a way to inspect OLD and NEW to see what > >> > columns are there and see what has changed? If so, you > may not be > >> > able to grab the actual query but you could create a > >> generic trigger > >> > that reconstructs a possible update/insert/delete for any > >> table in your database. > >> > > >> > Does anyone know of a good place to go get information > about using > >> > meta data in a stored procedure or trigger? > >> > >> yes. > >> See the section "User Comments" at the very bottom of Chapter > >> 33 after "Writing Trigger Functions in C". It is odd that a > >> PL_PGSQL example is given at the end a chapter for triggers > >> written in C. > >> > >> http://www.postgresql.org/docs/8.1/interactive/trigger-example.html > >> > >> Also see the entire chapter 36.10 "Trigger Procedures" > >> http://www.postgresql.org/docs/8.1/interactive/plpgsql-trigger.html > >> > >> Hope this is what you are looking for. > >> > >> Regards, > >> > >> Richard Broersma Jr. > >> > >> ---------------------------(end of > >> broadcast)--------------------------- > >> TIP 9: In versions below 8.0, the planner will ignore your > desire to > >> choose an index scan if your joining column's > datatypes do not > >> match > >> > > > > > > ---------------------------(end of > broadcast)--------------------------- > > TIP 4: Have you searched our list archives? > > > > http://archives.postgresql.org > > > > > > ---------------------------(end of > broadcast)--------------------------- > TIP 1: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org > so that your > message can get through to the mailing list cleanly > From forums@existanze.com Fri Jun 23 17:28:56 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id E20419FA64B for ; Fri, 23 Jun 2006 14:28:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 52482-07 for ; Fri, 23 Jun 2006 14:28:49 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from deliver.hol.gr (deliver.hol.gr [194.30.193.27]) by postgresql.org (Postfix) with ESMTP id DFA209FA60B for ; Fri, 23 Jun 2006 14:28:49 -0300 (ADT) Received: from auth-smtp.hol.gr (takeit01.mail.dc.hol.net [192.168.20.71]) by deliver.hol.gr (8.12.11/8.11.6) with ESMTP id k5NHS9QJ020280 (using TLSv1/SSLv3 with cipher DHE-RSA-AES256-SHA (256 bits) verified OK) for ; Fri, 23 Jun 2006 20:28:09 +0300 Received: from pimp (static223128.dsl.hol.gr [62.38.223.129]) by auth-smtp.hol.gr (8.13.1/8.12.11) with ESMTP id k5NHSklW014113 for ; Fri, 23 Jun 2006 20:28:46 +0300 Message-Id: <200606231728.k5NHSklW014113@auth-smtp.hol.gr> From: "Forums @ Existanze" To: Subject: Re: Fwd: Start up question about triggers Date: Fri, 23 Jun 2006 20:28:52 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Thread-Index: AcaWwkFMkgH182ylQ4Ku1vnl8/sMxQAGA0MgAAPLpZA= In-Reply-To: <200606231548.k5NFmhSW028183@auth-smtp.hol.gr> X-Virus-Scanned: ClamAV 0.87/1562/Fri Jun 23 10:50:07 2006 on takeit01.mail.dc.hol.net X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/260 X-Sequence-Number: 25496 Hello again, Just a thought! Do any of you know if this is possible? I have a table person CREATE TABLE person( person_id SERIAL PRIMARY KEY, person_name VARCHAR(100) NOT NULL, person_lastname VARCHAR(100) NOT NULL ); And a table audit CREATE TABLE audit( audit_id SERIAL PRIMARY KEY, audit_person person NOT NULL ); As you can see in the audit table, "audit_person" is of type "person" which is my second table. I have managed to save the NEW object in a trigger fuction which represent a person. So issuing INSERT INTO person VALUES(DEFAULT,'name','lastname'); WILL create a row for the audit table as such: SELECT * FROM audit; Returns Id Person -- ------ 1 (1,name,lastname) I then delete all from person and try to do this, I know it doesn't work but is it possible? DELETE FROM person; INSERT INTO person SELECT (audit_person::person) FROM audit; If the above was possible then I could theoretically just save the new object in the audit table for all my tables!! Any thoughts Best Regards, Fotis > -----Original Message----- > From: pgsql-sql-owner@postgresql.org > [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Forums @ > Existanze > Sent: 23 June 2006 18:49 > To: pgsql-sql@postgresql.org > Subject: Re: Fwd: [SQL] Start up question about triggers > > Hello again, > > First of all thank you all for your effort in helping me > solve this problem. > > George's link seems like a complete auditing framework for a > database, so I will look into that, cuase it gives you a > complete view of what is going on, and I can have undo opertaions :-) > > I have to say that this was not what I was looking for, but > you guys helped realized that it is the way to go. > > Richard- > Your suggestion also makes a lot of sense and thank you for > your suggestion. > > > What I have to point out is that no matter which solution we > choose, we are going to need to have an auditing table that > represents each of our tables, which as I mentioned are > around 80 at the moment :-( so that is a lot of extra work, > but what can you do! > > Image this scenario, and tell me if it wouldn't be awsome! > > I have "n" number of tables each of which has different > number of columns,keys constraints and so on, and I have just > ONE table with three > columns: > > Logger > ------ > Log_id SERIAL PRIMARY KEY, > User VARCHAR(100) NOT NULL, > Query text > > > Then there exist a TG_QUERY parameter that we could use to > get the actual query ran by a user, so if I ran the imaginary query > > INSERT INTO blah VALUES(DEFAULT,one,"23-08-3000") > > I could use TG_QUERY and do > > //trigger code > ......... > INSERT INTO Logger VALUES(DEFAULT,user,TG_QUERY) .....// end > of trigger > > This way I would end up with a log of the query ran on any of > the tables so theoretically > > SELECT * FROM Logger ORDER BY Logger_id > > Would return > > Logger_id User Query > --------- ---- ----- > 2 fotis 'INSERT INTO blah > VALUES(DEFAULT,one,"23-08-3000")' > 4 fotis 'UPDATE seconblah SET parispo='hello' WHERE > parispo_id=50' > 9 fotis 'DELETE FROM blah WHERE id=30' > 12 fotis 'INSERT INTO seconblah > VALUES(DEFAULT,'another')' > And so on.... > > > > This way I would have all the necessary queries to restore an > incomplete database with the appropiate data from some point > in time to another in the future. > > > The only difference between the theoretical method and the > ones already suggested is that I will still need "n" trigger > function for each of the "n" > tables, but only ONE auditing table. > > Would it be much nicer :-) > > Once again thank you very much for all your help, Fotis > > > -----Original Message----- > > From: pgsql-sql-owner@postgresql.org > > [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of George Weaver > > Sent: 23 June 2006 15:38 > > To: Forums @ Existanze > > Cc: pgsql-sql@postgresql.org > > Subject: Re: Fwd: [SQL] Start up question about triggers > > > > Hi Fotis, > > > > If you end up having to create a solution for each of the > 80 tables, > > you may want to check out the following (may also give you > addtional > > ideas for what you're trying to achieve): > > > > http://www.varlena.com/GeneralBits/104.php (Logging Audit > Changes with > > Composite Typed Columns). > > > > Regards, > > George > > > > > > ----- Original Message ----- > > From: "Forums @ Existanze" > > To: > > Sent: Friday, June 23, 2006 2:15 AM > > Subject: Re: Fwd: [SQL] Start up question about triggers > > > > > > > > > > Hello again aaron, > > > > > > Im really interested in the part where you say "generic > > trigger" can you > > > give me some tips? As to how I will go about that? I had > > already read the > > > links that Richard gave, I new I could get the values like > > that. So right > > > now I will have to create a trigger for each of my tables > > to create the > > > necessary queries, or I could do it "generically" :-) > > > > > > Best Regards, > > > Fotis > > > > > >> -----Original Message----- > > >> From: pgsql-sql-owner@postgresql.org > > >> [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Richard > > >> Broersma Jr > > >> Sent: 23 June 2006 08:10 > > >> To: Aaron Bono; pgsql-sql@postgresql.org > > >> Subject: Re: Fwd: [SQL] Start up question about triggers > > >> > > >> > I did some research and can't even find a way to get meta > > >> data in a trigger. > > >> > > > >> > In a trigger, is there a way to inspect OLD and NEW to > see what > > >> > columns are there and see what has changed? If so, you > > may not be > > >> > able to grab the actual query but you could create a > > >> generic trigger > > >> > that reconstructs a possible update/insert/delete for any > > >> table in your database. > > >> > > > >> > Does anyone know of a good place to go get information > > about using > > >> > meta data in a stored procedure or trigger? > > >> > > >> yes. > > >> See the section "User Comments" at the very bottom of Chapter > > >> 33 after "Writing Trigger Functions in C". It is odd that a > > >> PL_PGSQL example is given at the end a chapter for > triggers written > > >> in C. > > >> > > >> > http://www.postgresql.org/docs/8.1/interactive/trigger-example.html > > >> > > >> Also see the entire chapter 36.10 "Trigger Procedures" > > >> > http://www.postgresql.org/docs/8.1/interactive/plpgsql-trigger.html > > >> > > >> Hope this is what you are looking for. > > >> > > >> Regards, > > >> > > >> Richard Broersma Jr. > > >> > > >> ---------------------------(end of > > >> broadcast)--------------------------- > > >> TIP 9: In versions below 8.0, the planner will ignore your > > desire to > > >> choose an index scan if your joining column's > > datatypes do not > > >> match > > >> > > > > > > > > > ---------------------------(end of > > broadcast)--------------------------- > > > TIP 4: Have you searched our list archives? > > > > > > http://archives.postgresql.org > > > > > > > > > > > ---------------------------(end of > > broadcast)--------------------------- > > TIP 1: if posting/reading through Usenet, please send an appropriate > > subscribe-nomail command to majordomo@postgresql.org so that > > your > > message can get through to the mailing list cleanly > > > > > ---------------------------(end of > broadcast)--------------------------- > TIP 1: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org > so that your > message can get through to the mailing list cleanly > From ajs@crankycanuck.ca Fri Jun 23 17:35:21 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 7C1159FA60B for ; Fri, 23 Jun 2006 14:35:21 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 56867-10 for ; Fri, 23 Jun 2006 14:35:11 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 2CF359FB0D1 for ; Fri, 23 Jun 2006 14:35:11 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1Ftpei-0006A5-Bw for pgsql-sql@postgresql.org; Fri, 23 Jun 2006 13:41:20 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 8E7FA4051; Fri, 23 Jun 2006 13:35:04 -0400 (EDT) Date: Fri, 23 Jun 2006 13:35:04 -0400 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Fwd: Start up question about triggers Message-ID: <20060623173504.GC12422@phlogiston.dyndns.org> References: <006901c696c1$d2af82d0$6400a8c0@Dell4500> <200606231548.k5NFmhSW028183@auth-smtp.hol.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200606231548.k5NFmhSW028183@auth-smtp.hol.gr> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/261 X-Sequence-Number: 25497 On Fri, Jun 23, 2006 at 06:48:49PM +0300, Forums @ Existanze wrote: > > Then there exist a TG_QUERY parameter that we could use to get the actual > query ran by a user, so if I ran the imaginary query Which "actual query"? By the time the trigger fires, the query might already have been rewritten, I think. No? I _think_ that even BEFORE triggers happen after the rewriter stage is called, but someone who has more clue will be able to correct me if I'm wrong. A -- Andrew Sullivan | ajs@crankycanuck.ca Everything that happens in the world happens at some place. --Jane Jacobs From tgl@sss.pgh.pa.us Fri Jun 23 17:48:26 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 9066E9FA64B for ; Fri, 23 Jun 2006 14:48:26 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 69450-02 for ; Fri, 23 Jun 2006 14:48:15 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 60A059FA60B for ; Fri, 23 Jun 2006 14:48:16 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k5NHm89D017078; Fri, 23 Jun 2006 13:48:08 -0400 (EDT) To: Andrew Sullivan cc: pgsql-sql@postgresql.org Subject: Re: Fwd: Start up question about triggers In-reply-to: <20060623173504.GC12422@phlogiston.dyndns.org> References: <006901c696c1$d2af82d0$6400a8c0@Dell4500> <200606231548.k5NFmhSW028183@auth-smtp.hol.gr> <20060623173504.GC12422@phlogiston.dyndns.org> Comments: In-reply-to Andrew Sullivan message dated "Fri, 23 Jun 2006 13:35:04 -0400" Date: Fri, 23 Jun 2006 13:48:08 -0400 Message-ID: <17077.1151084888@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/262 X-Sequence-Number: 25498 Andrew Sullivan writes: > On Fri, Jun 23, 2006 at 06:48:49PM +0300, Forums @ Existanze wrote: >> Then there exist a TG_QUERY parameter that we could use to get the actual >> query ran by a user, so if I ran the imaginary query > Which "actual query"? By the time the trigger fires, the query might > already have been rewritten, I think. No? I _think_ that even > BEFORE triggers happen after the rewriter stage is called, but > someone who has more clue will be able to correct me if I'm wrong. Even if you could get hold of the user query text, it'd be a serious mistake to imagine that it tells you everything you need to know about the update. Aside from rule rewrites, previous BEFORE triggers could have changed fields that are mentioned nowhere in the query. The only safe way to determine what's going on is to compare the OLD and NEW row values. regards, tom lane From postgresql@aranya.com Sat Jun 24 03:29:41 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 89C069FA30D for ; Sat, 24 Jun 2006 00:29:41 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 70408-02 for ; Sat, 24 Jun 2006 00:29:36 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.170]) by postgresql.org (Postfix) with ESMTP id 5E16D9F9AD3 for ; Sat, 24 Jun 2006 00:29:35 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id a2so1321828ugf for ; Fri, 23 Jun 2006 20:29:34 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=DTgQ90qqIi/LnBz5+AEIag08bAJ7lrOF1YP0DJBZC27UgweTBI/RdHdDDo3TBtXWBzI0fu25FYCtzKk522yG1FcdoatM+OycyIKwrXhFICYdU55vDuUX79DSLXcfbzZ+Dg3ug8FhlhzpJS2LAyubQVj0S3F2A+6gehYIPJTwwMQ= Received: by 10.78.136.7 with SMTP id j7mr1503995hud; Fri, 23 Jun 2006 20:29:33 -0700 (PDT) Received: by 10.78.29.2 with HTTP; Fri, 23 Jun 2006 20:29:33 -0700 (PDT) Message-ID: Date: Fri, 23 Jun 2006 22:29:33 -0500 From: "Aaron Bono" To: "Tom Lane" Subject: Re: Fwd: Start up question about triggers Cc: "Andrew Sullivan" , pgsql-sql@postgresql.org In-Reply-To: <17077.1151084888@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_33439_15004662.1151119773842" References: <006901c696c1$d2af82d0$6400a8c0@Dell4500> <200606231548.k5NFmhSW028183@auth-smtp.hol.gr> <20060623173504.GC12422@phlogiston.dyndns.org> <17077.1151084888@sss.pgh.pa.us> X-Google-Sender-Auth: 32f10df978ca1b48 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/263 X-Sequence-Number: 25499 ------=_Part_33439_15004662.1151119773842 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline This is why I was searching for good meta data. Here is a thought. If your trigger has the OLD and NEW, is there a way to get a list of fields from OLD and NEW? If TG_RELNAME is the name of the table, could you just ask PostgreSQL what the columns are in that table, iterate through those columns, get the values for each of these columns out of OLD and NEW and save the old/new values? What I really cannot find is a way to _dynamically_ in the trigger ask what COLUMNS are in OLD and NEW. If we had: - table affected (TG_RELNAME?) - columns that are in the table - old values for each of these columns - new values for each of these columns Then you could store this information into two tables: modify_table modify_table_id modify_dt table_name modify_value modify_value_id modify_table_id old_value new_value I wish I had more experience with stored procedures - I know what I would try to do, just not if it is possible or how to implement it. Tom makes a very good point that having the actual query is not going to help in a general sense. If someone does an insert or update which fires a trigger that does further updates and inserts or even changes values on the fly, the inserts and updates you record will NOT reveal exactly what is going on. Keeping the values from OLD and NEW at the very end would be much more useful. -Aaron Bono On 6/23/06, Tom Lane wrote: > > Andrew Sullivan writes: > > On Fri, Jun 23, 2006 at 06:48:49PM +0300, Forums @ Existanze wrote: > >> Then there exist a TG_QUERY parameter that we could use to get the > actual > >> query ran by a user, so if I ran the imaginary query > > > Which "actual query"? By the time the trigger fires, the query might > > already have been rewritten, I think. No? I _think_ that even > > BEFORE triggers happen after the rewriter stage is called, but > > someone who has more clue will be able to correct me if I'm wrong. > > Even if you could get hold of the user query text, it'd be a serious > mistake to imagine that it tells you everything you need to know about > the update. Aside from rule rewrites, previous BEFORE triggers could > have changed fields that are mentioned nowhere in the query. The only > safe way to determine what's going on is to compare the OLD and NEW > row values. > > regards, tom lane > > ------=_Part_33439_15004662.1151119773842 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline This is why I was searching for good meta data.

Here is a thought.  If your trigger has the OLD and NEW, is there a way to get a list of fields from OLD and NEW?  If TG_RELNAME is the name of the table, could you just ask PostgreSQL what the columns are in that table, iterate through those columns, get the values for each of these columns out of OLD and NEW and save the old/new values?

What I really cannot find is a way to _dynamically_ in the trigger ask what COLUMNS are in OLD and NEW.  If we had:
  • table affected (TG_RELNAME?)
  • columns that are in the table
  • old values for each of these columns
  • new values for each of these columns
Then you could store this information into two tables:

modify_table
   modify_table_id
   modify_dt
   table_name

modify_value
   modify_value_id
   modify_table_id
   old_value
   new_value

I wish I had more experience with stored procedures - I know what I would try to do, just not if it is possible or how to implement it.

Tom makes a very good point that having the actual query is not going to help in a general sense.  If someone does an insert or update which fires a trigger that does further updates and inserts or even changes values on the fly, the inserts and updates you record will NOT reveal exactly what is going on.  Keeping the values from OLD and NEW at the very end would be much more useful.

-Aaron Bono

On 6/23/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Andrew Sullivan <ajs@crankycanuck.ca> writes:
> On Fri, Jun 23, 2006 at 06:48:49PM +0300, Forums @ Existanze wrote:
>> Then there exist a TG_QUERY parameter that we could use to get the actual
>> query ran by a user, so if I ran the imaginary query

> Which "actual query"?  By the time the trigger fires, the query might
> already have been rewritten, I think.  No?  I _think_ that even
> BEFORE triggers happen after the rewriter stage is called, but
> someone who has more clue will be able to correct me if I'm wrong.

Even if you could get hold of the user query text, it'd be a serious
mistake to imagine that it tells you everything you need to know about
the update.  Aside from rule rewrites, previous BEFORE triggers could
have changed fields that are mentioned nowhere in the query.  The only
safe way to determine what's going on is to compare the OLD and NEW
row values.

                        regards, tom lane

------=_Part_33439_15004662.1151119773842-- From ajs@crankycanuck.ca Mon Jun 26 12:33:54 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 009079FA68D for ; Mon, 26 Jun 2006 09:33:54 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 54634-03-3 for ; Mon, 26 Jun 2006 09:33:45 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 430E19FB6A0 for ; Mon, 26 Jun 2006 07:43:19 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1Fuof6-00015w-4a for pgsql-sql@postgresql.org; Mon, 26 Jun 2006 06:49:48 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 8C3FE4172; Mon, 26 Jun 2006 06:43:12 -0400 (EDT) Date: Mon, 26 Jun 2006 06:43:12 -0400 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Fwd: Start up question about triggers Message-ID: <20060626104312.GB15992@phlogiston.dyndns.org> References: <006901c696c1$d2af82d0$6400a8c0@Dell4500> <200606231548.k5NFmhSW028183@auth-smtp.hol.gr> <20060623173504.GC12422@phlogiston.dyndns.org> <17077.1151084888@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/264 X-Sequence-Number: 25500 On Fri, Jun 23, 2006 at 10:29:33PM -0500, Aaron Bono wrote: > > What I really cannot find is a way to _dynamically_ in the trigger ask what > COLUMNS are in OLD and NEW. If we had: All of the columns, of course. When the tuple is UPDATEd, even if you did not mention some columns in your UPDATE, there is an OLD value and a NEW value. They're the same. > I wish I had more experience with stored procedures - I know what I would > try to do, just not if it is possible or how to implement it. I think what Tom (but I don't want to put words in his mouth) and, certainly, I have been saying is that your plan to get the list of transform commands is fundamentally misguided. If you want to track changes, then that's what you should do: track what changed. Note that there is a project that already, in fact, does this for you as part of how it works: Slony-I. A -- Andrew Sullivan | ajs@crankycanuck.ca When my information changes, I alter my conclusions. What do you do sir? --attr. John Maynard Keynes From forums@existanze.com Mon Jun 26 13:59:26 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 4710C9F9FE3 for ; Mon, 26 Jun 2006 10:59:26 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 72852-04 for ; Mon, 26 Jun 2006 10:59:21 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from deliver.hol.gr (deliver.hol.gr [194.30.193.31]) by postgresql.org (Postfix) with ESMTP id 613D59F9AD3 for ; Mon, 26 Jun 2006 10:59:20 -0300 (ADT) Received: from auth-smtp.hol.gr (takeit01.mail.dc.hol.net [192.168.20.71]) by deliver.hol.gr (8.12.11/8.11.6) with ESMTP id k5QDwdef009515 (using TLSv1/SSLv3 with cipher DHE-RSA-AES256-SHA (256 bits) verified OK) for ; Mon, 26 Jun 2006 16:58:39 +0300 Received: from pimp (static223128.dsl.hol.gr [62.38.223.129]) by auth-smtp.hol.gr (8.13.1/8.12.11) with ESMTP id k5QDxE2p004593 for ; Mon, 26 Jun 2006 16:59:17 +0300 Message-Id: <200606261359.k5QDxE2p004593@auth-smtp.hol.gr> From: "Forums @ Existanze" To: Subject: Re: Fwd: Start up question about triggers Date: Mon, 26 Jun 2006 16:59:26 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Thread-Index: AcaZHUNepUKAfSvYS6SnjS1FphEz9wACX3Hg In-Reply-To: <20060626104312.GB15992@phlogiston.dyndns.org> X-Virus-Scanned: ClamAV 0.87/1563/Mon Jun 26 12:00:08 2006 on takeit01.mail.dc.hol.net X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/265 X-Sequence-Number: 25501 Hello again, The problem is not tracking WHAT changed, this can be done, as we have discussed in this thread, the problem is how to replicate the necessary commands that will alter a mirror database to reflect what has been changed, sequencially and in the order that it has occurred. I you can find my first question (I can repost), you will see that this problem has arisen due of lack of proper design. This is a requirement that has just come into the picture and we have to find a solution for it. My initial question was intended to figure out a way to track these changes AND create the necessary INSERT,DELETE and UPDATE statements for each of the changes that occurr in the entire database. I wanted to avoid having to create an audit table for each of the tables in the database. At the moment we are counting 82, this will mean another 82 tables, along with 82 triggers and so on. I personally don't believe that what I am trying to do is "fundamentally misguided", it may not be possible, but my theoretical suggestion a couple of posts back could be a very simple and fast way of doing this, given the necessary functionallity. ie. Recording the statement that we ran on the database. Once again, I am amassed at this mailing list for the wonderfull support, and lack of hesitasion in answering a lost soul's question, I just wished the rest of the mailing list could be like this. I am really gratefull for all your comments and suggestions. Best Regards, Fotis > -----Original Message----- > From: pgsql-sql-owner@postgresql.org > [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Andrew Sullivan > Sent: 26 June 2006 13:43 > To: pgsql-sql@postgresql.org > Subject: Re: Fwd: [SQL] Start up question about triggers > > On Fri, Jun 23, 2006 at 10:29:33PM -0500, Aaron Bono wrote: > > > > What I really cannot find is a way to _dynamically_ in the > trigger ask > > what COLUMNS are in OLD and NEW. If we had: > > All of the columns, of course. When the tuple is UPDATEd, > even if you did not mention some columns in your UPDATE, > there is an OLD value and a NEW value. They're the same. > > > I wish I had more experience with stored procedures - I know what I > > would try to do, just not if it is possible or how to implement it. > > I think what Tom (but I don't want to put words in his mouth) > and, certainly, I have been saying is that your plan to get > the list of transform commands is fundamentally misguided. > If you want to track changes, then that's what you should do: > track what changed. > > Note that there is a project that already, in fact, does this > for you as part of how it works: Slony-I. > > A > > -- > Andrew Sullivan | ajs@crankycanuck.ca > When my information changes, I alter my conclusions. What do > you do sir? > --attr. John Maynard Keynes > > ---------------------------(end of > broadcast)--------------------------- > TIP 6: explain analyze is your friend > From rabroersma@yahoo.com Mon Jun 26 14:15:39 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id AA35D9F9FE3 for ; Mon, 26 Jun 2006 11:15:39 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 75830-03 for ; Mon, 26 Jun 2006 11:15:20 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web31802.mail.mud.yahoo.com (web31802.mail.mud.yahoo.com [68.142.207.65]) by postgresql.org (Postfix) with SMTP id 72DD99F9AD3 for ; Mon, 26 Jun 2006 11:15:20 -0300 (ADT) Received: (qmail 56166 invoked by uid 60001); 26 Jun 2006 14:15:05 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=zmoEynj6P8QguLfcWNF5qaNF2gAPtEcPG2gksTxaHY2J0/VtvVJ5K4L3qjmifndwtNHVy/tBX81cKofDxF0kczkgrR5cjgoi0CC544vqK8AB5ZgH8DnJcdP/QReNUXjgafLswOG1ajceFi+5vjbX7RMzDH1ODgWa7UP8LZGaOZ4= ; Message-ID: <20060626141505.56164.qmail@web31802.mail.mud.yahoo.com> Received: from [63.203.180.122] by web31802.mail.mud.yahoo.com via HTTP; Mon, 26 Jun 2006 07:15:05 PDT Date: Mon, 26 Jun 2006 07:15:05 -0700 (PDT) From: Richard Broersma Jr Subject: Re: Fwd: Start up question about triggers To: "Forums @ Existanze" , pgsql-sql@postgresql.org In-Reply-To: <200606261359.k5QDxE2p004593@auth-smtp.hol.gr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/266 X-Sequence-Number: 25502 > The problem is not tracking WHAT changed, this can be done, as we have > discussed in this thread, the problem is how to replicate the necessary > commands that will alter a mirror database to reflect what has been changed, > sequencially and in the order that it has occurred. If your finial goal is just to achieve db server replication, wouldn't slony achieve what you want? Regards, Richard Broersma Jr. From ajs@crankycanuck.ca Mon Jun 26 14:43:19 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id D0FB89F9FE3 for ; Mon, 26 Jun 2006 11:43:19 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 76058-07 for ; Mon, 26 Jun 2006 11:43:15 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 195219F9AD3 for ; Mon, 26 Jun 2006 11:43:15 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1FusPJ-0002iN-UD for pgsql-sql@postgresql.org; Mon, 26 Jun 2006 10:49:46 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 147134172; Mon, 26 Jun 2006 10:43:09 -0400 (EDT) Date: Mon, 26 Jun 2006 10:43:09 -0400 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Fwd: Start up question about triggers Message-ID: <20060626144309.GA20519@phlogiston.dyndns.org> References: <20060626104312.GB15992@phlogiston.dyndns.org> <200606261359.k5QDxE2p004593@auth-smtp.hol.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200606261359.k5QDxE2p004593@auth-smtp.hol.gr> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/267 X-Sequence-Number: 25503 On Mon, Jun 26, 2006 at 04:59:26PM +0300, Forums @ Existanze wrote: > Hello again, > > The problem is not tracking WHAT changed, this can be done, as we have > discussed in this thread, the problem is how to replicate the necessary > commands that will alter a mirror database to reflect what has been changed, > sequencially and in the order that it has occurred. > > I you can find my first question (I can repost), you will see that this > problem has arisen due of lack of proper design. This is a requirement that > has just come into the picture and we have to find a solution for it. Ah. That was not, in fact, clear to me. What is it about Slony that doesn't solve this problem? You've checked it out, right? will get you there. A -- Andrew Sullivan | ajs@crankycanuck.ca If they don't do anything, we don't need their acronym. --Josh Hamilton, on the US FEMA From smarlowe@g2switchworks.com Mon Jun 26 15:38:29 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 2C0409FA226 for ; Mon, 26 Jun 2006 12:38:29 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 22087-07 for ; Mon, 26 Jun 2006 12:38:15 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 24F049F9AD3 for ; Mon, 26 Jun 2006 12:38:13 -0300 (ADT) Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; Mon, 26 Jun 2006 15:38:06 +0000 Received: from state.g2switchworks.com by mail.g2switchworks.com; 26 Jun 2006 10:38:06 -0500 Subject: Re: Fwd: Start up question about triggers From: Scott Marlowe To: "Forums @ Existanze" Cc: pgsql-sql@postgresql.org In-Reply-To: <200606261359.k5QDxE2p004593@auth-smtp.hol.gr> References: <200606261359.k5QDxE2p004593@auth-smtp.hol.gr> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1151336286.4215.35.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Mon, 26 Jun 2006 10:38:06 -0500 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/268 X-Sequence-Number: 25504 On Mon, 2006-06-26 at 08:59, Forums @ Existanze wrote: > Hello again, > > The problem is not tracking WHAT changed, this can be done, as we have > discussed in this thread, the problem is how to replicate the necessary > commands that will alter a mirror database to reflect what has been changed, > sequencially and in the order that it has occurred. > > I you can find my first question (I can repost), you will see that this > problem has arisen due of lack of proper design. This is a requirement that > has just come into the picture and we have to find a solution for it. > > My initial question was intended to figure out a way to track these changes > AND create the necessary INSERT,DELETE and UPDATE statements for each of the > changes that occurr in the entire database. I wanted to avoid having to > create an audit table for each of the tables in the database. At the moment > we are counting 82, this will mean another 82 tables, along with 82 triggers > and so on. I'm having a mad scientist moment. I bet it would be possible to hack pgpool to do this. Just have it shoot all the queries that come in to it at the normal database, AND at a text file or something like that. Not sure that's any better than using pgsql logging to do the same thing, but it certainly doesn't seem like it would be that hard to do. From ajs@crankycanuck.ca Mon Jun 26 18:50:28 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id AA2A99FB1C7 for ; Mon, 26 Jun 2006 15:50:28 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 81114-03 for ; Mon, 26 Jun 2006 15:50:18 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 4111C9FB29B for ; Mon, 26 Jun 2006 15:24:55 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1Fuvrn-0004ea-B2 for pgsql-sql@postgresql.org; Mon, 26 Jun 2006 14:31:23 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 5E995417B; Mon, 26 Jun 2006 14:24:45 -0400 (EDT) Date: Mon, 26 Jun 2006 14:24:45 -0400 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Fwd: Start up question about triggers Message-ID: <20060626182445.GD20519@phlogiston.dyndns.org> References: <200606261359.k5QDxE2p004593@auth-smtp.hol.gr> <1151336286.4215.35.camel@state.g2switchworks.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1151336286.4215.35.camel@state.g2switchworks.com> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/269 X-Sequence-Number: 25505 On Mon, Jun 26, 2006 at 10:38:06AM -0500, Scott Marlowe wrote: > I bet it would be possible to hack pgpool to do this. Just have it > shoot all the queries that come in to it at the normal database, AND at > a text file or something like that. Now you're back to the same problem: it doesn't tell you what the database looks like. It tells you what commands were sent. What about triggers? Rules? For that matter, what about SELECT now() or SELECT nextval() ? -- Andrew Sullivan | ajs@crankycanuck.ca This work was visionary and imaginative, and goes to show that visionary and imaginative work need not end up well. --Dennis Ritchie From forums@existanze.com Tue Jun 27 08:16:33 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 6426E9FA490 for ; Tue, 27 Jun 2006 05:16:33 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 30454-04 for ; Tue, 27 Jun 2006 05:16:23 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from deliver.hol.gr (deliver.hol.gr [194.30.193.32]) by postgresql.org (Postfix) with ESMTP id BBD3C9FA395 for ; Tue, 27 Jun 2006 05:16:22 -0300 (ADT) Received: from auth-smtp.hol.gr (takeit01.mail.dc.hol.net [192.168.20.71]) by deliver.hol.gr (8.12.11/8.11.6) with ESMTP id k5R8FdgZ006929 (using TLSv1/SSLv3 with cipher DHE-RSA-AES256-SHA (256 bits) verified OK) for ; Tue, 27 Jun 2006 11:15:39 +0300 Received: from pimp (static223128.dsl.hol.gr [62.38.223.129]) by auth-smtp.hol.gr (8.13.1/8.12.11) with ESMTP id k5R8GHfk023493 for ; Tue, 27 Jun 2006 11:16:17 +0300 Message-Id: <200606270816.k5R8GHfk023493@auth-smtp.hol.gr> From: "Forums @ Existanze" To: Subject: Re: Fwd: Start up question about triggers Date: Tue, 27 Jun 2006 11:16:17 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Thread-index: AcaZL1cSuh1UGcj7T9CTPHyJWHceBgAkiBYA In-Reply-To: <20060626144309.GA20519@phlogiston.dyndns.org> X-Virus-Scanned: ClamAV 0.87/1564/Mon Jun 26 17:55:16 2006 on takeit01.mail.dc.hol.net X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/281 X-Sequence-Number: 25517 Hello again, I looked into slony, I have a question though, how would I go about controlling slony via a jdbc driver? See this whole problem has arisen because for some reason my client wants to keep to separate databases in two separate locations with the same data. So he would call this partiall backup function via a GUI client we provide, and with this information he would go to the same GUI client in this other location and import this partiall backup. Best Regards, Fotis PS- Hacking pgtool is way out my leage :-) But thanks for the suggestion!!! > -----Original Message----- > From: pgsql-sql-owner@postgresql.org > [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Andrew Sullivan > Sent: 26 June 2006 17:43 > To: pgsql-sql@postgresql.org > Subject: Re: Fwd: [SQL] Start up question about triggers > > On Mon, Jun 26, 2006 at 04:59:26PM +0300, Forums @ Existanze wrote: > > Hello again, > > > > The problem is not tracking WHAT changed, this can be done, > as we have > > discussed in this thread, the problem is how to replicate the > > necessary commands that will alter a mirror database to > reflect what > > has been changed, sequencially and in the order that it has > occurred. > > > > I you can find my first question (I can repost), you will see that > > this problem has arisen due of lack of proper design. This is a > > requirement that has just come into the picture and we have > to find a solution for it. > > Ah. That was not, in fact, clear to me. What is it about > Slony that doesn't solve this problem? You've checked it out, right? > will get you there. > > A > > > -- > Andrew Sullivan | ajs@crankycanuck.ca > If they don't do anything, we don't need their acronym. > --Josh Hamilton, on the US FEMA > > ---------------------------(end of > broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq > From ajs@crankycanuck.ca Tue Jun 27 11:39:50 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 633149FA50D for ; Tue, 27 Jun 2006 08:39:50 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 78214-07 for ; Tue, 27 Jun 2006 08:39:45 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 10F2C9FA10A for ; Tue, 27 Jun 2006 08:39:45 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1FvC1M-0001fw-22 for pgsql-sql@postgresql.org; Tue, 27 Jun 2006 07:46:20 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id DE79D3FAF; Tue, 27 Jun 2006 07:39:36 -0400 (EDT) Date: Tue, 27 Jun 2006 07:39:36 -0400 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Fwd: Start up question about triggers Message-ID: <20060627113936.GA27997@phlogiston.dyndns.org> References: <20060626144309.GA20519@phlogiston.dyndns.org> <200606270816.k5R8GHfk023493@auth-smtp.hol.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200606270816.k5R8GHfk023493@auth-smtp.hol.gr> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/282 X-Sequence-Number: 25518 On Tue, Jun 27, 2006 at 11:16:17AM +0300, Forums @ Existanze wrote: > > I looked into slony, I have a question though, how would I go about > controlling slony via a jdbc driver? See this whole problem has arisen > because for some reason my client wants to keep to separate databases in two > separate locations with the same data. So he would call this partiall backup > function via a GUI client we provide, and with this information he would go > to the same GUI client in this other location and import this partiall > backup. It is totally normal to want to keep two databases in two locations: that's a matter of safety. Slony does it automatically, as long as the daemon is running. No need to control it. _Unless_ you want to be able to write in the second database. That's a different problem. You can't do that with Slony. A -- Andrew Sullivan | ajs@crankycanuck.ca The fact that technology doesn't work is no bar to success in the marketplace. --Philip Greenspun From forums@existanze.com Tue Jun 27 11:48:46 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 15E169FA50D for ; Tue, 27 Jun 2006 08:48:46 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 78315-09 for ; Tue, 27 Jun 2006 08:48:41 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from deliver.hol.gr (deliver.hol.gr [194.30.193.32]) by postgresql.org (Postfix) with ESMTP id 4418D9FA10A for ; Tue, 27 Jun 2006 08:48:40 -0300 (ADT) Received: from auth-smtp.hol.gr (takeit01.mail.dc.hol.net [192.168.20.71]) by deliver.hol.gr (8.12.11/8.11.6) with ESMTP id k5RBm0U9024863 (using TLSv1/SSLv3 with cipher DHE-RSA-AES256-SHA (256 bits) verified OK) for ; Tue, 27 Jun 2006 14:48:00 +0300 Received: from pimp (static223128.dsl.hol.gr [62.38.223.129]) by auth-smtp.hol.gr (8.13.1/8.12.11) with ESMTP id k5RBmcQV027906 for ; Tue, 27 Jun 2006 14:48:38 +0300 Message-Id: <200606271148.k5RBmcQV027906@auth-smtp.hol.gr> From: "Forums @ Existanze" To: Subject: Re: Fwd: Start up question about triggers Date: Tue, 27 Jun 2006 14:48:38 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Thread-index: AcaZ3t+cMNfdunGRRciijcTwU7QsnQAAFCjg In-Reply-To: <20060627113936.GA27997@phlogiston.dyndns.org> X-Virus-Scanned: ClamAV 0.87/1564/Mon Jun 26 17:55:16 2006 on takeit01.mail.dc.hol.net X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/283 X-Sequence-Number: 25519 Hello again andrew, Actually man I do need to be able to write to both databases, and keep them synchronized, and all this because of the recurring xenofobia for technology and the fear of "hackers" (I know the difference between hackers and crackers) on the internet, I actually said, it will cost less to have an adsl line on both location connecting to the same database than to pay me to create the synchronization framework, but hey what can you do! Best Regards, Fotis > -----Original Message----- > From: pgsql-sql-owner@postgresql.org > [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Andrew Sullivan > Sent: 27 June 2006 14:40 > To: pgsql-sql@postgresql.org > Subject: Re: Fwd: [SQL] Start up question about triggers > > On Tue, Jun 27, 2006 at 11:16:17AM +0300, Forums @ Existanze wrote: > > > > I looked into slony, I have a question though, how would I go about > > controlling slony via a jdbc driver? See this whole problem > has arisen > > because for some reason my client wants to keep to separate > databases > > in two separate locations with the same data. So he would call this > > partiall backup function via a GUI client we provide, and with this > > information he would go to the same GUI client in this > other location > > and import this partiall backup. > > It is totally normal to want to keep two databases in two locations: > that's a matter of safety. Slony does it automatically, as > long as the daemon is running. No need to control it. > > _Unless_ you want to be able to write in the second database. > That's a different problem. You can't do that with Slony. > > A > > -- > Andrew Sullivan | ajs@crankycanuck.ca > The fact that technology doesn't work is no bar to success in > the marketplace. > --Philip Greenspun > > ---------------------------(end of > broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org > From dev@freedomcircle.net Tue Jun 27 12:13:37 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 6C61D9FA5E6 for ; Tue, 27 Jun 2006 09:13:37 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 87338-01 for ; Tue, 27 Jun 2006 09:13:32 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from vms048pub.verizon.net (vms048pub.verizon.net [206.46.252.48]) by postgresql.org (Postfix) with ESMTP id 17A1D9FA10A for ; Tue, 27 Jun 2006 09:13:33 -0300 (ADT) Received: from [192.168.7.2] ([71.101.5.108]) by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPA id <0J1I00IOEPYJR9I3@vms048.mailsrvcs.net> for pgsql-sql@postgresql.org; Tue, 27 Jun 2006 07:13:31 -0500 (CDT) Date: Tue, 27 Jun 2006 08:14:34 -0400 From: Joe Subject: Re: Fwd: Start up question about triggers In-reply-to: <20060627113936.GA27997@phlogiston.dyndns.org> To: Andrew Sullivan Cc: pgsql-sql@postgresql.org Message-id: <44A1212A.1050500@freedomcircle.net> Organization: Freedom Circle, LLC MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit References: <20060626144309.GA20519@phlogiston.dyndns.org> <200606270816.k5R8GHfk023493@auth-smtp.hol.gr> <20060627113936.GA27997@phlogiston.dyndns.org> User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/284 X-Sequence-Number: 25520 Andrew Sullivan wrote: > On Tue, Jun 27, 2006 at 11:16:17AM +0300, Forums @ Existanze wrote: >> I looked into slony, I have a question though, how would I go about >> controlling slony via a jdbc driver? See this whole problem has arisen >> because for some reason my client wants to keep to separate databases in two >> separate locations with the same data. So he would call this partiall backup >> function via a GUI client we provide, and with this information he would go >> to the same GUI client in this other location and import this partiall >> backup. > > It is totally normal to want to keep two databases in two locations: > that's a matter of safety. Slony does it automatically, as long as > the daemon is running. No need to control it. But with file-based log shipping (see http://linuxfinances.info/info/logshipping.html) one could write a Java app to control when the updates are applied. Joe From ajs@crankycanuck.ca Tue Jun 27 18:37:56 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id DF69D9FA502 for ; Tue, 27 Jun 2006 15:37:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 20244-02 for ; Tue, 27 Jun 2006 15:37:47 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id EC5049FA10A for ; Tue, 27 Jun 2006 15:37:46 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1FvIXw-00075Z-Um for pgsql-sql@postgresql.org; Tue, 27 Jun 2006 14:44:25 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 8A4C94172; Tue, 27 Jun 2006 14:37:39 -0400 (EDT) Date: Tue, 27 Jun 2006 14:37:39 -0400 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Fwd: Start up question about triggers Message-ID: <20060627183739.GM27997@phlogiston.dyndns.org> References: <20060627113936.GA27997@phlogiston.dyndns.org> <200606271148.k5RBmcQV027906@auth-smtp.hol.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200606271148.k5RBmcQV027906@auth-smtp.hol.gr> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/288 X-Sequence-Number: 25524 On Tue, Jun 27, 2006 at 02:48:38PM +0300, Forums @ Existanze wrote: > Hello again andrew, > > Actually man I do need to be able to write to both databases, and keep them > synchronized, and all this because of the recurring xenofobia for technology Then sorry, but this can't be done out of the box by anything. You have all manner of race conditions here. > and the fear of "hackers" (I know the difference between hackers and Moreover, this won't solve their problem: if someone compromised the application, both databases would be corrupted. There's no way to avoid that in such a design. Better to use Slony in log-shipping mode (or PITR) and keep backups of all the change sets. Then if someone broke in, you'd at least be able to roll back to the known-good state. A -- Andrew Sullivan | ajs@crankycanuck.ca The fact that technology doesn't work is no bar to success in the marketplace. --Philip Greenspun From ajs@crankycanuck.ca Tue Jun 27 18:39:03 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id D4A869FA437 for ; Tue, 27 Jun 2006 15:39:03 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 22206-02 for ; Tue, 27 Jun 2006 15:38:55 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 254EE9FA10A for ; Tue, 27 Jun 2006 15:38:54 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1FvIZ2-00079G-Vs for pgsql-sql@postgresql.org; Tue, 27 Jun 2006 14:45:33 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id B91B94172; Tue, 27 Jun 2006 14:38:47 -0400 (EDT) Date: Tue, 27 Jun 2006 14:38:47 -0400 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Fwd: Start up question about triggers Message-ID: <20060627183847.GN27997@phlogiston.dyndns.org> References: <20060626144309.GA20519@phlogiston.dyndns.org> <200606270816.k5R8GHfk023493@auth-smtp.hol.gr> <20060627113936.GA27997@phlogiston.dyndns.org> <44A1212A.1050500@freedomcircle.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <44A1212A.1050500@freedomcircle.net> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/289 X-Sequence-Number: 25525 On Tue, Jun 27, 2006 at 08:14:34AM -0400, Joe wrote: > > But with file-based log shipping (see > http://linuxfinances.info/info/logshipping.html) one could write a Java > app to control when the updates are applied. Well, sure. I mean, if you decide first, "I'll use Java," and then start asking what problems you can solve, you can do anything ;-) I prefer the strategy whereby one asks what the problem is to be solved first, then choose the technology. A -- Andrew Sullivan | ajs@crankycanuck.ca I remember when computers were frustrating because they *did* exactly what you told them to. That actually seems sort of quaint now. --J.D. Baldwin From rabroersma@yahoo.com Tue Jun 27 20:13:29 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 951659FA10A for ; Tue, 27 Jun 2006 17:13:29 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 60902-09 for ; Tue, 27 Jun 2006 17:13:22 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web31811.mail.mud.yahoo.com (web31811.mail.mud.yahoo.com [68.142.207.74]) by postgresql.org (Postfix) with SMTP id A32F19FA437 for ; Tue, 27 Jun 2006 17:13:21 -0300 (ADT) Received: (qmail 93334 invoked by uid 60001); 27 Jun 2006 20:13:20 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=0t0kqgaN1MP+PYrDlzyoMPeLuv8lwLR7iXN82OyV2N9/ULCADF8VWhBq7nNACQpNMrFttB/zPPSJz1anqXoavUWW/Iy9e/5X0aX1oXgKm+3q4F6Eq3Q7riZ4jVYKzVJ33wtjk/VDsxBIQBq1QhYTXqPfOWQYOEjbLNs/B4zSMt0= ; Message-ID: <20060627201320.93332.qmail@web31811.mail.mud.yahoo.com> Received: from [63.203.180.122] by web31811.mail.mud.yahoo.com via HTTP; Tue, 27 Jun 2006 13:13:20 PDT Date: Tue, 27 Jun 2006 13:13:20 -0700 (PDT) From: Richard Broersma Jr Subject: Re: Fwd: Start up question about triggers To: Andrew Sullivan , pgsql-sql@postgresql.org In-Reply-To: <20060627183739.GM27997@phlogiston.dyndns.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/290 X-Sequence-Number: 25526 > > Actually man I do need to be able to write to both databases, and keep them > > synchronized, and all this because of the recurring xenofobia for technology > > Then sorry, but this can't be done out of the box by anything. You > have all manner of race conditions here. Doesn't PGcluster allow for multiple master databases that are kept synchronized? http://pgfoundry.org/projects/pgcluster/ I thought that Mammoth replicator might support synchronous masters but it appears to be an Asynchronous system like Slony. http://www.commandprompt.com/products/mammothreplicator Regards, Richard Broersma Jr. From alvherre@commandprompt.com Tue Jun 27 20:25:48 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id A53819FA10A for ; Tue, 27 Jun 2006 17:25:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 83286-07 for ; Tue, 27 Jun 2006 17:25:43 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mx2.surnet.cl (mx2.surnet.cl [216.155.73.181]) by postgresql.org (Postfix) with ESMTP id 1E7539FA437 for ; Tue, 27 Jun 2006 17:25:41 -0300 (ADT) Received: from unknown (HELO alvh.no-ip.org) ([201.221.201.100]) by mx2.surnet.cl with ESMTP; 27 Jun 2006 16:25:37 -0400 X-IronPort-AV: i="4.06,184,1149480000"; d="scan'208"; a="62074600:sNHT19351856" Received: by alvh.no-ip.org (Postfix, from userid 1000) id 5BEABC22E96; Tue, 27 Jun 2006 16:25:36 -0400 (CLT) Date: Tue, 27 Jun 2006 16:25:36 -0400 From: Alvaro Herrera To: Richard Broersma Jr Cc: Andrew Sullivan , pgsql-sql@postgresql.org Subject: Re: Fwd: Start up question about triggers Message-ID: <20060627202536.GE17752@surnet.cl> Mail-Followup-To: Richard Broersma Jr , Andrew Sullivan , pgsql-sql@postgresql.org References: <20060627183739.GM27997@phlogiston.dyndns.org> <20060627201320.93332.qmail@web31811.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060627201320.93332.qmail@web31811.mail.mud.yahoo.com> User-Agent: Mutt/1.5.11+cvs20060403 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/291 X-Sequence-Number: 25527 Richard Broersma Jr wrote: > I thought that Mammoth replicator might support synchronous masters > but it appears to be an Asynchronous system like Slony. > http://www.commandprompt.com/products/mammothreplicator You are right, Mammoth Replicator is asynchronous single master, just like Slony. -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc. From forums@existanze.com Mon Jul 3 12:20:26 2006 X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 2E1EA9FA357 for ; Mon, 3 Jul 2006 09:20:26 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 87731-01 for ; Mon, 3 Jul 2006 09:20:17 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id C8B9C9FA232 for ; Mon, 3 Jul 2006 09:20:17 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from deliver.hol.gr (unknown [62.38.3.82]) by svr4.postgresql.org (Postfix) with ESMTP id 950B75AF031 for ; Mon, 3 Jul 2006 12:20:15 +0000 (GMT) Received: from auth-smtp.hol.gr (takeit01.mail.dc.hol.net [192.168.20.71]) by deliver.hol.gr (8.12.11/8.11.6) with ESMTP id k63CJVP9003903 (using TLSv1/SSLv3 with cipher DHE-RSA-AES256-SHA (256 bits) verified OK) for ; Mon, 3 Jul 2006 15:19:31 +0300 Received: from pimp (static223128.dsl.hol.gr [62.38.223.129]) by auth-smtp.hol.gr (8.13.1/8.12.11) with ESMTP id k63CKAWY010255 for ; Mon, 3 Jul 2006 15:20:10 +0300 Message-Id: <200607031220.k63CKAWY010255@auth-smtp.hol.gr> From: "Forums @ Existanze" To: Subject: Re: Fwd: Start up question about triggers Date: Mon, 3 Jul 2006 15:20:21 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 In-Reply-To: <44A1212A.1050500@freedomcircle.net> thread-index: AcaZ45ouleztV3NqSM6uOpqxeh41AgEtq5Sw X-Virus-Scanned: ClamAV 0.87/1579/Sat Jul 1 13:20:41 2006 on takeit01.mail.dc.hol.net X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/26 X-Sequence-Number: 25600 Hello again, I did some research on your suggestions with Slony-I and logshipping, one major drawback we just realized is that the server where postgres will sit on runs Windows XP. Our client has this techie that only knows how to manage a windows box, and he runs some other services that we cannot port to linux. Is there anything similar to slony-I that we could run on windows? On the install notes of Slony 1.1.5 we didn't find any information about compiling and running Slony-I on windows and we know that it will be available in version 1.2 Best Regards, Fotis > -----Original Message----- > From: pgsql-sql-owner@postgresql.org > [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Joe > Sent: 27 June 2006 15:15 > To: Andrew Sullivan > Cc: pgsql-sql@postgresql.org > Subject: Re: Fwd: [SQL] Start up question about triggers > > Andrew Sullivan wrote: > > On Tue, Jun 27, 2006 at 11:16:17AM +0300, Forums @ Existanze wrote: > >> I looked into slony, I have a question though, how would I > go about > >> controlling slony via a jdbc driver? See this whole problem has > >> arisen because for some reason my client wants to keep to separate > >> databases in two separate locations with the same data. So > he would > >> call this partiall backup function via a GUI client we > provide, and > >> with this information he would go to the same GUI client in this > >> other location and import this partiall backup. > > > > It is totally normal to want to keep two databases in two locations: > > that's a matter of safety. Slony does it automatically, as long as > > the daemon is running. No need to control it. > > But with file-based log shipping (see > http://linuxfinances.info/info/logshipping.html) one could > write a Java app to control when the updates are applied. > > Joe > > ---------------------------(end of > broadcast)--------------------------- > TIP 1: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org > so that your > message can get through to the mailing list cleanly >