[GENERAL] Trigger function problem

2017-10-10 Thread Liglio Cavalcante
Hi, I am trying to migrate data from a master table to her partitions. I am using an update trigger to delete and insert into the master table, and so an insert trigger on the master table redirects the inserted registers to the respective parrtition table. The problem is that the update trigger i

Re: [GENERAL] Trigger problems/questions

2017-06-15 Thread Jim Fulton
On Thu, Jun 15, 2017 at 1:56 PM, Tom Lane wrote: > Jim Fulton writes: > > I have an object database that's mirrored to a table with data in a JSONB > > column. Data are organized into "communities". Community ids aren't > > stored directly in content but can be found by recursively following >

Re: [GENERAL] Trigger problems/questions

2017-06-15 Thread Tom Lane
Jim Fulton writes: > I have an object database that's mirrored to a table with data in a JSONB > column. Data are organized into "communities". Community ids aren't > stored directly in content but can be found by recursively following > __parent__ properties. I want to be able to index content

Re: [GENERAL] Trigger problems/questions

2017-06-15 Thread Jim Fulton
On Thu, Jun 15, 2017 at 1:44 PM, Adrian Klaver wrote: > On 06/15/2017 10:23 AM, Jim Fulton wrote: > ... > I do not pretend to fully understand what the the triggers/functions are > really doing, but I did notice this: > > create or replace function populate_community_zoid_triggerf() > > ... >

Re: [GENERAL] Trigger problems/questions

2017-06-15 Thread Adrian Klaver
On 06/15/2017 10:23 AM, Jim Fulton wrote: I have an object database that's mirrored to a table with data in a JSONB column. Data are organized into "communities". Community ids aren't stored directly in content but can be found by recursively following __parent__ properties. I want to be able

[GENERAL] Trigger problems/questions

2017-06-15 Thread Jim Fulton
I have an object database that's mirrored to a table with data in a JSONB column. Data are organized into "communities". Community ids aren't stored directly in content but can be found by recursively following __parent__ properties. I want to be able to index content records on their community i

Re: [GENERAL] Trigger based logging alternative to table_log

2017-03-28 Thread Glyn Astill
> From: Jeff Janes > To: "pgsql-general@postgresql.org" > Sent: Monday, 27 March 2017, 18:08 > Subject: [GENERAL] Trigger based logging alternative to table_log > > I have some code which uses table_log > (http://pgfoundry.org/projects/tablelog/) to keep a log o

Re: [GENERAL] Trigger based logging alternative to table_log

2017-03-27 Thread Thomas Kellerer
Jeff Janes schrieb am 27.03.2017 um 19:07: I have some code which uses table_log (http://pgfoundry.org/projects/tablelog/) to keep a log of changes to selected tables. I don't use the restore part, just the logging part. It creates a new table for each table being logged, with several additiona

Re: [GENERAL] Trigger based logging alternative to table_log

2017-03-27 Thread Felix Kunde
> I have some code which uses table_log > (http://pgfoundry.org/projects/tablelog/) to keep a log of changes to > selected tables.  > I don't use the restore part, just the logging part.   > It creates a new table for each table being logged, with several additional > columns, and adds triggers

[GENERAL] Trigger based logging alternative to table_log

2017-03-27 Thread Jeff Janes
I have some code which uses table_log ( http://pgfoundry.org/projects/tablelog/) to keep a log of changes to selected tables. I don't use the restore part, just the logging part. It creates a new table for each table being logged, with several additional columns, and adds triggers to insert rows

Re: [GENERAL] Trigger is not working for Inserts from the application

2016-09-11 Thread Kiran
Hi Jim, The issue is now resolved thanks to Tom and Adrian. regards Kiran On Sun, Sep 11, 2016 at 4:16 AM, Jim Nasby wrote: > On 9/10/16 6:03 AM, Kiran wrote: > >> If I insert a record from my application using following code : >> db.myschema.cf_question.insert({ >> cf_question_type_id:request

Re: [GENERAL] Trigger is not working for Inserts from the application

2016-09-10 Thread Jim Nasby
On 9/10/16 6:03 AM, Kiran wrote: If I insert a record from my application using following code : db.myschema.cf_question.insert({ cf_question_type_id:request.payload.type_id, cf_question_category_id:request.payload.cat_id, lang:request.payload.lang, body:request.payload.body } The above app code

Re: [GENERAL] Trigger is not working for Inserts from the application

2016-09-10 Thread Kiran
Dear Tom, Adrian, Excellent catch! Thank you very very much to both. It is resolved now. I can sleep now. Good night from Sweden. regards Kiran On Sat, Sep 10, 2016 at 11:18 PM, Adrian Klaver wrote: > On 09/10/2016 02:09 PM, Kiran wrote: > >> Hi Adrian, >> >> The JSON value is inserted into a

Re: [GENERAL] Trigger is not working for Inserts from the application

2016-09-10 Thread Adrian Klaver
On 09/10/2016 02:09 PM, Kiran wrote: Hi Adrian, The JSON value is inserted into a column in the database which I can see. But the trigger which has to convert this JSON value in not tsvector column is not updating that column. As Tom explained, in your trigger function you have: to_tsvector('

Re: [GENERAL] Trigger is not working for Inserts from the application

2016-09-10 Thread Kiran
Hi Adrian, The JSON value is inserted into a column in the database which I can see. But the trigger which has to convert this JSON value in not tsvector column is not updating that column. regards On Sat, Sep 10, 2016 at 10:27 PM, Tom Lane wrote: > Kiran writes: > > LOG: execute : INSERT IN

Re: [GENERAL] Trigger is not working for Inserts from the application

2016-09-10 Thread Adrian Klaver
On 09/10/2016 02:02 PM, Kiran wrote: Hi Tom, I have checked and the trigger is not disabled. and \drds results Role=blank database = mydatabase settings = default_text_search_config=pg_catalog.swedish Any other tips or suggestions please. Did you see this post?: https://www.postgresql.org/m

Re: [GENERAL] Trigger is not working for Inserts from the application

2016-09-10 Thread Kiran
Hi Tom, I have checked and the trigger is not disabled. and \drds results Role=blank database = mydatabase settings = default_text_search_config=pg_catalog.swedish Any other tips or suggestions please. regards Kiran On Sat, Sep 10, 2016 at 9:26 PM, Tom Lane wrote: > Kiran writes: > > But

Re: [GENERAL] Trigger is not working for Inserts from the application

2016-09-10 Thread Tom Lane
Kiran writes: > LOG: execute : INSERT INTO "myschema"."cf_question" > ("cf_question_type_id", "cf_question_category_id", "lang", "body") VALUES > ($1, $2, $3, $4) RETURNING * > DETAIL: parameters: $1 = '1', $2 = '9', $3 = 'swedish', $4 = '{"name": "Do > you like Pizza ?", "type": "cat", "store":

Re: [GENERAL] Trigger is not working for Inserts from the application

2016-09-10 Thread Kiran
Hi Adrian, This is the exact log in the file as it appears: DETAIL: parameters: $1 = '', $2 = '' LOG: connection received: host=localhost port=53284 LOG: connection authorized: user=deva database=mydatabase LOG: connection received: host=localhost port=53285 LOG: connection authorized: user=

Re: [GENERAL] Trigger is not working for Inserts from the application

2016-09-10 Thread Tom Lane
Kiran writes: > But I do not know how to check whether the application is subject to > different ALTER USER SET parameters. psql's \drds ("display role/database SETs") would help. BTW, have you checked that the trigger is not disabled, and that there isn't another trigger undoing its work?

Re: [GENERAL] Trigger is not working for Inserts from the application

2016-09-10 Thread Adrian Klaver
On 09/10/2016 11:39 AM, Kiran wrote: Hi Adrian, Thanks for your response. I tried with logging. The application is inserting the record that I am passing into the database. But the trigger is not firing. What is the text of the complete statement as it appears in the logs? When you do the INS

Re: [GENERAL] Trigger is not working for Inserts from the application

2016-09-10 Thread Kiran
Dear Tom, Thanks for your detailed reply. (1) Application is connecting to the same database. (2) Application is inserting to the same table without much luck with the trigger. (3) Application is issuing the right insert command. (4) I am not able to check this, is there any way I can check this?

Re: [GENERAL] Trigger is not working for Inserts from the application

2016-09-10 Thread Kiran
Hi Adrian, Thanks for your response. I tried with logging. The application is inserting the record that I am passing into the database. But the trigger is not firing. I have been looking into this issue since morning with out any positive outcome :(. If you have any other tips, it will be really h

Re: [GENERAL] Trigger is not working for Inserts from the application

2016-09-10 Thread Tom Lane
Adrian Klaver writes: > On 09/10/2016 03:59 AM, Kiran wrote: >> What could be the problem ? Why trigger is not working if I insert from the >> application ? Am I doing anything wrong ? > If you have not, turn on log_statement: > https://www.postgresql.org/docs/9.5/static/runtime-config-logging.ht

Re: [GENERAL] Trigger is not working for Inserts from the application

2016-09-10 Thread Adrian Klaver
On 09/10/2016 03:59 AM, Kiran wrote: Hi, *Problem background :* I have a *function in the DB* as follows CREATE FUNCTION question_tsv_trigger() RETURNS trigger AS $BODY$ begin New.weighted_tsv := to_tsvector('swedish',coalesce(New.body->>'qtext','')::text); RAISE NOTICE 'TRIGER called on %', TG_

[GENERAL] Trigger is not working for Inserts from the application

2016-09-10 Thread Kiran
Hi, *Problem background :* I have a *function in the DB* as follows CREATE FUNCTION question_tsv_trigger() RETURNS trigger AS $BODY$ begin New.weighted_tsv := to_tsvector('swedish',coalesce(New.body->>'qtext','')::text); RAISE NOTICE 'TRIGER called on %', TG_TABLE_NAME; return New; end $BODY$ LANG

[GENERAL] Trigger is not working for Inserts from the application

2016-09-10 Thread Kiran
Hi, *Problem background :* I have a *function in the DB* as follows CREATE FUNCTION question_tsv_trigger() RETURNS trigger AS $BODY$ begin New.weighted_tsv := to_tsvector('swedish',coalesce(New.body->>'qtext','')::text); RAISE NOTICE 'TRIGER called on %', TG_TABLE_NAME; return New; end $BODY$ LANG

Re: [GENERAL] Trigger function interface

2016-01-10 Thread Jim Nasby
On 1/7/16 6:15 PM, Tatsuo Ishii wrote: On 1/6/16 7:03 PM, Tatsuo Ishii wrote: Is it possible to get the parse tree in a C trigger function which is invoked when DML (INSERT/UPDATE/DELETE against a view) is executed? Yes, it's in fcinfo->flinfo->fn_expr. Thanks for the info. But is this the p

Re: [GENERAL] Trigger function interface

2016-01-07 Thread Tatsuo Ishii
> On 1/6/16 7:03 PM, Tatsuo Ishii wrote: >> Is it possible to get the parse tree in a C trigger function which is >> invoked when DML (INSERT/UPDATE/DELETE against a view) is executed? > > Yes, it's in fcinfo->flinfo->fn_expr. Thanks for the info. But is this the parse tree for the top level quer

Re: [GENERAL] Trigger function interface

2016-01-06 Thread Jim Nasby
On 1/6/16 7:03 PM, Tatsuo Ishii wrote: Is it possible to get the parse tree in a C trigger function which is invoked when DML (INSERT/UPDATE/DELETE against a view) is executed? Yes, it's in fcinfo->flinfo->fn_expr. -- Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX Experts in Analy

[GENERAL] Trigger function interface

2016-01-06 Thread Tatsuo Ishii
Is it possible to get the parse tree in a C trigger function which is invoked when DML (INSERT/UPDATE/DELETE against a view) is executed? Best regards, -- Tatsuo Ishii SRA OSS, Inc. Japan English: http://www.sraoss.co.jp/index_en.php Japanese:http://www.sraoss.co.jp -- Sent via pgsql-general ma

Re: [GENERAL] Trigger function, C, lookup of attribute type

2015-12-15 Thread Jim Nasby
On 12/15/15 4:42 AM, Paul wrote: I'm writing a trigger procedure in C to catch updates to a table and write them to a log file. You might find https://github.com/arkhipov/temporal_tables useful. Though, if you just want to log things to a file, you should check out http://pgaudit.org/. -- Ji

Re: [GENERAL] Trigger function, C, lookup of attribute type

2015-12-15 Thread Paul
I found the solution: SPI_gettype() does the job fine. I was led to that by rummaging through the slony source code to see how they handle the triggers in C. -- Paul Nicholson -- -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http:/

[GENERAL] Trigger function, C, lookup of attribute type

2015-12-15 Thread Paul
I'm writing a trigger procedure in C to catch updates to a table and write them to a log file. The function must walk along trigdata->tg_trigtuple pulling out the attributes, comparing them with those in trigdata->tg_newtuple and writing the diffs to a flat ASCII file. I've got a loop over the

Re: [GENERAL] TRIGGER TRUNCATE -- CASCADE or RESTRICT

2015-06-02 Thread Gavin Flower
On 03/06/15 08:40, Andreas Ulbrich wrote: On 02.06.2015 22:12, Melvin Davidson wrote: Your problem is in your design. If you do it like this: CREATE TABLE A ( p_col serial PRIMARY KEY, acol integer ); CREATE TABLE B() INHERITS (A); INSERT INTO A(acol) VALUES (1); INSERT INTO B(acol) VALUES

Re: [GENERAL] TRIGGER TRUNCATE -- CASCADE or RESTRICT

2015-06-02 Thread Andreas Ulbrich
On 02.06.2015 22:12, Melvin Davidson wrote: Your problem is in your design. If you do it like this: CREATE TABLE A ( p_col serial PRIMARY KEY, acol integer ); CREATE TABLE B() INHERITS (A); INSERT INTO A(acol) VALUES (1); INSERT INTO B(acol) VALUES (2); SELECT * FROM A; SELECT * FROM B; Th

Re: [GENERAL] TRIGGER TRUNCATE -- CASCADE or RESTRICT

2015-06-02 Thread Melvin Davidson
Your problem is in your design. If you do it like this: CREATE TABLE A ( p_col serial PRIMARY KEY, acol integer ); CREATE TABLE B() INHERITS (A); INSERT INTO A(acol) VALUES (1); INSERT INTO B(acol) VALUES (2); SELECT * FROM A; SELECT * FROM B; Then the sequence (p_col) will be UNIQUE across

Re: [GENERAL] TRIGGER TRUNCATE -- CASCADE or RESTRICT

2015-06-02 Thread Andreas Ulbrich
On 02.06.2015 16:20, Melvin Davidson wrote: You can use the following to list the triggers and see what functions they call. Then you can check pg_proc to see how TRUNCATE is used in prosrc. SELECT c.relname, t.tgname, p.pronameAS function_called, t.tgconstraint

Re: [GENERAL] TRIGGER TRUNCATE -- CASCADE or RESTRICT

2015-06-02 Thread Melvin Davidson
You can use the following to list the triggers and see what functions they call. Then you can check pg_proc to see how TRUNCATE is used in prosrc. SELECT c.relname, t.tgname, p.pronameAS function_called, t.tgconstraint AS is_constraint, CASE WHEN t.tgconstrre

Re: [GENERAL] TRIGGER TRUNCATE -- CASCADE or RESTRICT

2015-06-02 Thread Albe Laurenz
Andreas Ulbrich wrote: > I'm in a handle for a trigger for TRUNCATE. Is it possible to find out > whether the TRUNCATE TABLE ist called with CASCADE? I don't think there is. But you can find out the table where the trigger is defined and examine if any foreign key constraints are referring to it.

[GENERAL] TRIGGER TRUNCATE -- CASCADE or RESTRICT

2015-06-01 Thread Andreas Ulbrich
Salvete! I'm in a handle for a trigger for TRUNCATE. Is it possible to find out whether the TRUNCATE TABLE ist called with CASCADE? regads andreas -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/p

Re: [GENERAL] trigger Before or After

2014-11-11 Thread Adrian Klaver
On 11/10/2014 10:38 PM, avpro avpro wrote: hi, in the pgsql documentation (http://www.postgresql.org/docs/9.1/static/sql-createtrigger.html) i haven't seen anything referring to: how is affected the data inserted in the new table by a trigger Before Insert compared with a trigger After Insert?

Re: [GENERAL] trigger Before or After

2014-11-11 Thread Albe Laurenz
avpro avpro wrote: > in the pgsql documentation > (http://www.postgresql.org/docs/9.1/static/sql-createtrigger.html) > > > i haven't seen anything referring to: how is affected the data inserted in > the new table by a trigger > Before Insert compared with a trigger After Insert? and anything re

[GENERAL] trigger Before or After

2014-11-10 Thread avpro avpro
hi, in the pgsql documentation (http://www.postgresql.org/docs/9.1/static/sql-createtrigger.html) i haven't seen anything referring to: how is affected the data inserted in the new table by a trigger Before Insert compared with a trigger After Insert? and anything related to performance for exam

[GENERAL] Trigger to a queue for sending updates to a cache layer

2014-08-20 Thread Marcus Engene
Hi, I'm working with a retail site with tens of millions of products in several languages. For the detail pages, we try to cache in memcached. We also have quite a bit of keyword translation lookups (for international queries to solr). We're thinking of adding a nosql layer that takes the b

Re: [GENERAL] Trigger function cannot reference field name with capital letter

2014-08-14 Thread Alban Hertroys
On 14 August 2014 08:10, Patrick Dung wrote: > Thanks all for the help. > > BTW, letter casing is just a preference. > Some people liked to use all small caps, some liked to use all big caps. > I sometimes found that mixed case is more meaningful for the filed (eg. > serialnumber vs serialNumber)

Re: [GENERAL] Trigger function cannot reference field name with capital letter

2014-08-14 Thread Adrian Klaver
On 08/13/2014 11:10 PM, Patrick Dung wrote: Thanks all for the help. BTW, letter casing is just a preference. Some people liked to use all small caps, some liked to use all big caps. I sometimes found that mixed case is more meaningful for the filed (eg. serialnumber vs serialNumber) What is yo

Re: [GENERAL] Trigger function cannot reference field name with capital letter

2014-08-13 Thread Pavel Stehule
Hi 2014-08-14 8:10 GMT+02:00 Patrick Dung : > Thanks all for the help. > > BTW, letter casing is just a preference. > Some people liked to use all small caps, some liked to use all big caps. > I sometimes found that mixed case is more meaningful for the filed (eg. > serialnumber vs serialNumber)

Re: [GENERAL] Trigger function cannot reference field name with capital letter

2014-08-13 Thread Patrick Dung
Thanks all for the help. BTW, letter casing is just a preference. Some people liked to use all small caps, some liked to use all big caps. I sometimes found that mixed case is more meaningful for the filed (eg. serialnumber vs serialNumber) What is your preference or suggestion? On Thursday,

Re: [GENERAL] Trigger function cannot reference field name with capital letter

2014-08-13 Thread John R Pierce
On 8/13/2014 9:13 PM, John R Pierce wrote: SELECT * from tbl1 where new."postTimestamp' > timestamp '2014-01-01 00:00:00' oops. SELECT * from tbl1 where new."postTimestamp" > timestamp '2014-01-01 00:00:00' I meant. I should proof what I write, hah! -- john r pierce

Re: [GENERAL] Trigger function cannot reference field name with capital letter

2014-08-13 Thread John R Pierce
On 8/13/2014 8:52 PM, Patrick Dung wrote: I have a field called postTimestamp. The trigger function could not reference it. When I change my field to post_timestamp. I can reference it from the tigger function. Version is 9.3.5. Any comment? < 2014-08-14 00:23:32.717 HKT >ERROR: post "new" ha

Re: [GENERAL] Trigger function cannot reference field name with capital letter

2014-08-13 Thread Adrian Klaver
On 08/13/2014 08:52 PM, Patrick Dung wrote: Hello PGSQL users, I have a field called postTimestamp. The trigger function could not reference it. When I change my field to post_timestamp. I can reference it from the tigger function. Version is 9.3.5. Any comment? < 2014-08-14 00:23:32.717 HKT >E

[GENERAL] Trigger function cannot reference field name with capital letter

2014-08-13 Thread Patrick Dung
Hello PGSQL users, I have a field called postTimestamp. The trigger function could not reference it. When I change my field to post_timestamp. I can reference it from the tigger function. Version is 9.3.5. Any comment? < 2014-08-14 00:23:32.717 HKT >ERROR:  post "new" has no field "posttimestam

Re: [GENERAL] Trigger to convert UNIX time to timestamp without time zone.

2014-06-08 Thread Kevin Grittner
Andrew Sullivan wrote: > Are you sure you want this without time zone?  In my experience, > almost every time people think they want "without time zone" they > actually don't. +1 Basically, if you want to capture a moment in time, such as when some event happened or some measurement was taken,

[GENERAL] Trigger function permissions

2014-06-06 Thread Keith Fiske
Just want to make sure I'm understanding the permissions needed for trigger functions as well as making sure this is what the developers intended before I go assuming things will always work this way. Also as a sanity check for myself that I'm not missing something obvious. I have an extension (ht

Re: [GENERAL] Trigger to convert UNIX time to timestamp without time zone.

2014-06-06 Thread Andrew Sullivan
On Fri, Jun 06, 2014 at 02:19:50PM +0100, Alberto Olivares wrote: > How can I create a trigger to transform the time from UNIX to timestamp > without time zone every time a new record is inserted into my database? This is in the manual, section 9.8: to_timestamp(double precision) It's always a li

Re: [GENERAL] Trigger to convert UNIX time to timestamp without time zone.

2014-06-06 Thread Adrian Klaver
On 06/06/2014 06:19 AM, Alberto Olivares wrote: Hello, I want to insert data into a column "timestamp without time zone" data type. The problem is I am receiving the data in UNIX time. How can I create a trigger to transform the time from UNIX to timestamp without time zone every time a new rec

[GENERAL] Trigger to convert UNIX time to timestamp without time zone.

2014-06-06 Thread Alberto Olivares
Hello, I want to insert data into a column "timestamp without time zone" data type. The problem is I am receiving the data in UNIX time. How can I create a trigger to transform the time from UNIX to timestamp without time zone every time a new record is inserted into my database? Thank you in ad

Re: [GENERAL] Trigger Firing Order

2013-12-11 Thread Sameer Kumar
That sounds like a nice suggestion. I guess it could get rid of most of the issues I forsee. I should follow that for my cases too. I guess we can live without an ORDER clause. Thanks everyone for helping.

Re: [GENERAL] Trigger Firing Order

2013-12-11 Thread Kevin Grittner
Sameer Kumar wrote: > If I have a trigger which add primary key to my inserted row > ("before trigger"). Now if I plan to create new set of triggers > for AUDITING or replication (where either I have no flexibility > of choosing a name or the trigger name has to follow a standard), > then I need

Re: [GENERAL] Trigger Firing Order

2013-12-11 Thread Sameer Kumar
> > But with certain packaged products who create their own triggers, I won't >> have control over this. > I don't have a lot of sympathy for that argument. If the product is > capable of creating Postgres-compatible triggers at all, it should be > aware that the name is a significant property,

Re: [GENERAL] Trigger Firing Order

2013-12-10 Thread Tom Lane
Sameer Kumar writes: > Is it possible for me to define the order in which triggers will be fired? Sure: choose their names so that their alphabetical ordering is the firing order you want. But I see you knew that. > But with certain packaged products who create their own triggers, I won't > hav

Re: [GENERAL] Trigger Firing Order

2013-12-10 Thread David Johnston
Sameer Kumar wrote > Hi, > > Is it possible for me to define the order in which triggers will be fired? > > So far what I have understood from PostgreSQL documentation, in order to > fire 2 triggers in sequence (say trigger1 and trigger2) on a table, I need > to name them in that way. > But with

[GENERAL] Trigger Firing Order

2013-12-10 Thread Sameer Kumar
Hi, Is it possible for me to define the order in which triggers will be fired? So far what I have understood from PostgreSQL documentation, in order to fire 2 triggers in sequence (say trigger1 and trigger2) on a table, I need to name them in that way. But with certain packaged products who creat

Re: [GENERAL] trigger without trigger call

2013-10-14 Thread ChoonSoo Park
On Mon, Oct 14, 2013 at 6:02 AM, Philipp Kraus < philipp.kr...@tu-clausthal.de> wrote: > > Am 14.10.2013 um 11:49 schrieb Alban Hertroys : > > > On Oct 14, 2013, at 8:18, Philipp Kraus > wrote: > > > >> Hello, > >> > >> I have written a update & delete trigger of a table. > >> My delete trigger r

Re: [GENERAL] trigger without trigger call

2013-10-14 Thread Philipp Kraus
Am 14.10.2013 um 11:49 schrieb Alban Hertroys : > On Oct 14, 2013, at 8:18, Philipp Kraus wrote: > >> Hello, >> >> I have written a update & delete trigger of a table. >> My delete trigger runs an update statement but this create a (semantic) >> problem. >> How can I disable the update trigge

Re: [GENERAL] trigger without trigger call

2013-10-14 Thread Alban Hertroys
On Oct 14, 2013, at 8:18, Philipp Kraus wrote: > Hello, > > I have written a update & delete trigger of a table. > My delete trigger runs an update statement but this create a (semantic) > problem. > How can I disable the update trigger for only this update call within the > delete trigger? >

Re: [GENERAL] trigger without trigger call

2013-10-14 Thread Pavel Stehule
Hello you can disable trigger by ALTER TABLE tablename DISABLE TRIGGER triggername; but it should be executed with owner rights on table. This statement works perfect, but a fact, so you need it signalize so you do some wrong. Triggers should to be used primary for checking, logging, calculating

[GENERAL] trigger without trigger call

2013-10-13 Thread Philipp Kraus
Hello, I have written a update & delete trigger of a table. My delete trigger runs an update statement but this create a (semantic) problem. How can I disable the update trigger for only this update call within the delete trigger? So my delete trigger need not call the update trigger Thanks Phi

[GENERAL] trigger or logging

2013-09-13 Thread Jay Vee
Before running a script (invoked by .sh that will call stored procs which may invoke other triggers), I want to capture every change made in the database which includes the field value before the update and the field value after the update and also capture all inserts. With this data, I would be a

Re: [GENERAL] Trigger to update table info

2013-08-12 Thread Jayadevan M
Hi, In case you are not keen on getting the latest and really accurate counts/size, you could just refer the views readily available - http://stackoverflow.com/questions/2596670/how-do-you-find-the-row-count-for-all-your-tables-in-postgres You won't get the updatetime, though. Regards, Jayadevan

Re: [GENERAL] Trigger to update table info

2013-08-12 Thread raghu ram
On Mon, Aug 12, 2013 at 12:46 PM, Arvind Singh wrote: > Hello friends, > > I have a table with the following structure > > > Create table postablestatus > > ( > > tablename varchar(30) NOT NULL, > > updatetime timestamp, > > reccount int, > >

[GENERAL] Trigger to update table info

2013-08-12 Thread Arvind Singh
Hello friends, I have a table with the following structure Create table postablestatus ( tablename varchar(30) NOT NULL, updatetime timestamp, reccount int, size int, CONSTRAINT postablestatus_pkey PRIMARY KEY(tablenam

Re: [GENERAL] Trigger and deadlock

2013-07-30 Thread Albe Laurenz
Loïc Rollus wrote: > It's ok. > Before the insert, The foreign key constraint locked the row. If transaction > A and B lock the row with > FK, before doing UPDATE, they were stuck. > I found a solution by creating an "before insert" trigger with a simple > SELECT FROM UPDATE on the row. You mean

Re: [GENERAL] Trigger and deadlock

2013-07-30 Thread Loïc Rollus
Hi, It's ok. Before the insert, The foreign key constraint locked the row. If transaction A and B lock the row with FK, before doing UPDATE, they were stuck. I found a solution by creating an "before insert" trigger with a simple SELECT FROM UPDATE on the row. Loïc 2013/7/29 Loïc Rollus > He

Re: [GENERAL] Trigger and deadlock

2013-07-29 Thread Loïc Rollus
Here is pg_lock for relation Y (= 2027300) locktype | database | relation | page | tuple | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction | pid | mode | granted --+--+--+--+---++---+-+---+--

Re: [GENERAL] Trigger and deadlock

2013-07-28 Thread Loïc Rollus
Hi, Thanks for your quick reply! I found the table. But the ctid of the row has changed. But during my test, I update only 1 row from this table, so I know the row. I had already put log_statement to 'all'. It's strange because in the log, I only see simple "SELECT ... FROM" on this table (no UPD

Re: [GENERAL] Trigger and deadlock

2013-07-26 Thread Albe Laurenz
Loïc Rollus wrote: > I've try to make some concurrency robustness test with an web server app that > use Hibernate and > Postgres. > It seems that my trigger make deadlock when multiple thread use it. > > I will try to simplify examples: > I have a table "films"(id, title,director) and a table >

[GENERAL] Trigger and deadlock

2013-07-26 Thread Loïc Rollus
Hello, I've try to make some concurrency robustness test with an web server app that use Hibernate and Postgres. It seems that my trigger make deadlock when multiple thread use it. I will try to simplify examples: I have a table "films"(id, title,director) and a table "directors"(id,name,nbreFilm

Re: [GENERAL] TRIGGER EVENT

2013-05-29 Thread Alvaro Herrera
Sajeev Mayandi wrote: > Hi, > > I am process of porting from sybase to postgresql. Is there syntax equivalent > of the TRIGGER EVENT Statement (Please see the sybase help for trigger event > below) in Postgresql. NOTE the TRIGGER EVENT in sybase could be used to > trigger an user defined event.

[GENERAL] TRIGGER EVENT

2013-05-29 Thread Sajeev Mayandi
Hi, I am process of porting from sybase to postgresql. Is there syntax equivalent of the TRIGGER EVENT Statement (Please see the sybase help for trigger event below) in Postgresql. NOTE the TRIGGER EVENT in sybase could be used to trigger an user defined event. I am not seeing any similar synta

Re: [GENERAL] Trigger function on Warm Standby

2013-05-08 Thread Jerry Sievers
ning chan writes: > Hi all, > > I have a Primary Standby setup with streaming replication. > Trigger is created on a table, and all it does it to log a message. > > The trigger works as expected on Primary, however, I don't see the same on > standby. > > I alter the table to have ENABLE ALWAYS T

[GENERAL] Trigger function on Warm Standby

2013-05-08 Thread ning chan
Hi all, I have a Primary Standby setup with streaming replication. Trigger is created on a table, and all it does it to log a message. The trigger works as expected on Primary, however, I don't see the same on standby. I alter the table to have ENABLE ALWAYS TRIGGER, I verified the setting on bo

Re: [GENERAL] Trigger of Transaction

2013-04-02 Thread Joe Van Dyk
On Mon, Apr 1, 2013 at 8:41 PM, Juan Pablo Cook wrote: > Hi everyone! I need your help with this problem. > > I'm using PostgreSQL *9.2 Server* & the latest jdbc > driver: postgresql-9.2-1002.jdbc4.jar > > I have a many to one relation. I have this piece of code: > > con.setAutoCommit(false); //t

[GENERAL] Trigger of Transaction

2013-04-01 Thread Juan Pablo Cook
Hi everyone! I need your help with this problem. I'm using PostgreSQL *9.2 Server* & the latest jdbc driver: postgresql-9.2-1002.jdbc4.jar I have a many to one relation. I have this piece of code: con.setAutoCommit(false); //transaction block start // Make an insert to one table (Vector) // Aft

[GENERAL] trigger on adding / deleting / modify user on pg_authid

2012-12-31 Thread Philipp Kraus
Hello, can I create on PG 9.1 or newer a trigger or something other, that runs a function if a new user is added, changed, deleted to / on the database? I have got a "usertable" which stores some additional user information (full name, mail address, etc) and I would like to create default data i

Re: [GENERAL] Trigger / constraint issue

2012-12-06 Thread Adrian Klaver
On 12/06/2012 10:31 AM, Glenn Pierce wrote: OK I have got it down to a simple test #connect_string = 'dbname=bmos user=bmos' connect_string = 'dbname=bmos user=postgres' if __name__ == "__main__": conn = psycopg2.connect(connect_string) cur = conn.cursor(cursor_factory=psycopg2.extras

Re: [GENERAL] Trigger / constraint issue

2012-12-06 Thread Glenn Pierce
OK I have got it down to a simple test #connect_string = 'dbname=bmos user=bmos' connect_string = 'dbname=bmos user=postgres' if __name__ == "__main__": conn = psycopg2.connect(connect_string) cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor) cur.execute("INSERT INTO senso

Re: [GENERAL] Trigger / constraint issue

2012-12-05 Thread Adrian Klaver
On 12/05/2012 02:24 PM, Glenn Pierce wrote: The error I get is new row for relation "sensor_values_2011q3" violates check constraint "sensor_values_2011q3_timestamp_check"CONTEXT: SQL statement "INSERT INTO sensor_values_2011q3 VALUES (NEW.*)"PL/pgSQL function "sensor_values_timestamp_sensor_

[GENERAL] Trigger / constraint issue

2012-12-05 Thread Glenn Pierce
Hi I wonder if someone can help me I am getting a bit confused about an error I am getting. I have a partitioned table called sensor_values which is partitioned on a timestamp entry. The parent and some of the child tables are defined like so (The child tables are yearly quarters and in my actual

[GENERAL] Trigger based replication with ENABLE REPLICA triggers and session_replication_role best practice(s)

2012-11-19 Thread Achilleas Mantzios
Hello, we have based all our replication infrastructure on a heavily hacked version of DBMirror, which now runs in a single master (office DB) -> multiple slaves (vessels DBs) mode for 80+ slaves and about 300 tables and in multiple masters (the same vessels DBs as above) (having partitions of

Re: [GENERAL] trigger and plpgsq help needed

2012-09-27 Thread SUNDAY A. OLUTAYO
, 2012 2:04:46 PM Subject: Re: [GENERAL] trigger and plpgsq help needed RobR, I have tried it 'IF FOUND' but not getting the desired result Thanks, Sunday Olutayo - Original Message - From: "Rob Richardson" To: pgsql-general@postgresql.org Sent: Wednesday, Se

Re: [GENERAL] trigger and plpgsq help needed

2012-09-27 Thread SUNDAY A. OLUTAYO
sadeeb.com - Original Message - From: "Chris Ernst" To: pgsql-general@postgresql.org Sent: Wednesday, September 26, 2012 7:10:03 PM Subject: Re: [GENERAL] trigger and plpgsq help needed On 09/26/2012 10:42 AM, SUNDAY A. OLUTAYO wrote: > This IF last_id IS NULL THEN suppos

Re: [GENERAL] trigger and plpgsq help needed

2012-09-27 Thread SUNDAY A. OLUTAYO
RobR, I have tried it 'IF FOUND' but not getting the desired result Thanks, Sunday Olutayo - Original Message - From: "Rob Richardson" To: pgsql-general@postgresql.org Sent: Wednesday, September 26, 2012 7:14:46 PM Subject: Re: [GENERAL] trigger an

Re: [GENERAL] trigger and plpgsq help needed

2012-09-26 Thread Adrian Klaver
On 09/26/2012 09:42 AM, SUNDAY A. OLUTAYO wrote: Dear all, I have issue with the red portion function below; This IF last_id IS NULL THEN suppose to test if last_id is NULL, that is the select query did not found it then execute the rest of the red sql but it always fail to insert the *NEW.amou

Re: [GENERAL] trigger and plpgsq help needed

2012-09-26 Thread Chris Ernst
On 09/26/2012 10:42 AM, SUNDAY A. OLUTAYO wrote: > This IF last_id IS NULL THEN suppose to test if last_id is NULL, that is > the select query did not found it > then execute the rest of the red sql but it always fail to insert the > *NEW.amount *into*amount*, every other things fine. I believe wh

Re: [GENERAL] trigger and plpgsq help needed

2012-09-26 Thread Rob Richardson
Why not use IF FOUND? RobR From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of SUNDAY A. OLUTAYO Sent: Wednesday, September 26, 2012 12:43 PM To: pgsql-general@postgresql.org Subject: [GENERAL] trigger and plpgsq help needed Dear all, I have issue

[GENERAL] trigger and plpgsq help needed

2012-09-26 Thread SUNDAY A. OLUTAYO
Dear all, I have issue with the red portion function below; This IF last_id IS NULL THEN suppose to test if last_id is NULL, that is the select query did not found it then execute the rest of the red sql but it always fail to insert the NEW.amount into amount , every other things fine. Kin

Re: [GENERAL] trigger on view returning created serial

2012-06-12 Thread Jeff Davis
On Tue, 2012-06-12 at 22:35 +0200, Philipp Kraus wrote: > Hello, > > I have created a view and on this view a trigger, which is called on an > insert command on the view. > Within the trigger I run an insert on a table and one of the table fields > uses a serial sequence, that > creates values.

[GENERAL] trigger on view returning created serial

2012-06-12 Thread Philipp Kraus
Hello, I have created a view and on this view a trigger, which is called on an insert command on the view. Within the trigger I run an insert on a table and one of the table fields uses a serial sequence, that creates values. If I run in the trigger after the insert a "return NEW", the field (i

  1   2   3   4   5   6   >