Re: When use triggers?

2018-05-16 Thread Michael Stephenson
On Wed, May 16, 2018 at 6:36 PM, Adrian Klaver wrote: > On 05/16/2018 03:19 PM, hmidi slim wrote: >> >> HI, >> >> I'm working on a microservice application and I avoid using triggers >> because they will not be easy to maintain and need an experimented person in >>

Re: Function to set up variable inside it

2018-05-16 Thread Łukasz Jarych
Thank you Pavel! I wilk set Up variable before function and use it Inside function , best jacek Pobierz aplikację Outlook dla systemu iOS From: Pavel Stehule Sent: Wednesday, May 16, 2018 9:07:15 AM To: Łukasz

Re: sql function with empty row

2018-05-16 Thread Laurenz Albe
Philipp Kraus wrote: > I have defined a SQL function > > CREATE OR REPLACE FUNCTION substancetrivialname(text) > RETURNS substance > LANGUAGE 'sql' > COST 100 > VOLATILE > AS $BODY$ > select s.* from substancetrivialname n > join substance s on s.id = n.idsubstance >

Re: What is the C function to modify attribute

2018-05-16 Thread David Rowley
On 17 May 2018 at 15:36, a <372660...@qq.com> wrote: > I am writing a trigger that will record all adjustment of the row into the > last column of the row. I have done a iterator to produce text record and > the last step would be add the text record into the last column (which > designed as an

What is the C function to modify attribute

2018-05-16 Thread a
Hi: I am writing a trigger that will record all adjustment of the row into the last column of the row. I have done a iterator to produce text record and the last step would be add the text record into the last column (which designed as an array of user defined type, with the output function

Re: When use triggers?

2018-05-16 Thread Benjamin Scherrey
I've always found it most useful to consider the difference between "what the system is" vs. "what the system does". The core data entities and their stable relationships comprise most of what the system is. These are the things that should be enforced at the lowest level possible (in a db schema)

Re: When use triggers?

2018-05-16 Thread Adrian Klaver
On 05/16/2018 03:19 PM, hmidi slim wrote: HI, I'm working on a microservice application and I avoid using triggers because they will not be easy to maintain and need an experimented person in database administration to manage them. So I prefer to manage the work in the application using ORM

When use triggers?

2018-05-16 Thread hmidi slim
HI, I'm working on a microservice application and I avoid using triggers because they will not be easy to maintain and need an experimented person in database administration to manage them. So I prefer to manage the work in the application using ORM and javascript. However I want to get some

Re: sql function with empty row

2018-05-16 Thread David G. Johnston
On Wed, May 16, 2018 at 11:49 AM, Philipp Kraus < philipp.kr...@tu-clausthal.de> wrote: > I have tested it on my data and it works also, but that is a little bit > confusing, because imho setof is >= 0 rows and > without setof it is [0,1]. ​Without setof it will always return exactly 1 row,

Re: Rapid disk usage spikes when updating large tables with GIN indexes

2018-05-16 Thread Nikolay Samokhvalov
Why not set up a spot EC2 instance with Postgres 10.1, load database from a dump (yes you’ll need to create one from RDS because they don’t provide direct access to dumps/backups; probably you need to get only specific tables) and repeat your actions, closely looking at filesystem. ср, 16 мая

Re: Rapid disk usage spikes when updating large tables with GIN indexes

2018-05-16 Thread Tom Lane
Jonathan Marks writes: > We turned on log_temp_files and since the last stats reset (about a week ago) > we’re seeing 0 temp files altogether (grabbing that info from > pg_stat_database). Hm. > Another thread we found suggested pg_subtrans — this seems less

Re: Rapid disk usage spikes when updating large tables with GIN indexes

2018-05-16 Thread Jonathan Marks
Hi Tom — We turned on log_temp_files and since the last stats reset (about a week ago) we’re seeing 0 temp files altogether (grabbing that info from pg_stat_database). So, as far as we know: 1) It’s not WAL 2) It’s not tempfiles 3) It’s not the size of the error logs 4) It’s not the size of

Re: sql function with empty row

2018-05-16 Thread Adrian Klaver
On 05/16/2018 11:49 AM, Philipp Kraus wrote: Am 16.05.2018 um 20:40 schrieb Adrian Klaver : I have tested it on my data and it works also, but that is a little bit confusing, because imho setof is >= 0 rows and without setof it is [0,1]. On this I know there

Re: sql function with empty row

2018-05-16 Thread Philipp Kraus
> Am 16.05.2018 um 20:40 schrieb Adrian Klaver : > > On 05/16/2018 11:07 AM, Philipp Kraus wrote: >> Hello, >> I have defined a SQL function >> CREATE OR REPLACE FUNCTION substancetrivialname(text) >> RETURNS substance >> LANGUAGE 'sql' >> COST 100 >>

Re: sql function with empty row

2018-05-16 Thread Adrian Klaver
On 05/16/2018 11:07 AM, Philipp Kraus wrote: Hello, I have defined a SQL function CREATE OR REPLACE FUNCTION substancetrivialname(text) RETURNS substance LANGUAGE 'sql' COST 100 VOLATILE AS $BODY$ select s.* from substancetrivialname n join substance s on s.id =

Re: sql function with empty row

2018-05-16 Thread Melvin Davidson
On Wed, May 16, 2018 at 2:25 PM, Adrian Klaver wrote: > On 05/16/2018 11:07 AM, Philipp Kraus wrote: > >> Hello, >> >> I have defined a SQL function >> >> CREATE OR REPLACE FUNCTION substancetrivialname(text) >> RETURNS substance >> LANGUAGE 'sql' >>

Re: sql function with empty row

2018-05-16 Thread Adrian Klaver
On 05/16/2018 11:07 AM, Philipp Kraus wrote: Hello, I have defined a SQL function CREATE OR REPLACE FUNCTION substancetrivialname(text) RETURNS substance LANGUAGE 'sql' COST 100 VOLATILE AS $BODY$ select s.* from substancetrivialname n join substance s on s.id =

Re: sql function with empty row

2018-05-16 Thread Adrian Klaver
On 05/16/2018 11:07 AM, Philipp Kraus wrote: Hello, I have defined a SQL function CREATE OR REPLACE FUNCTION substancetrivialname(text) RETURNS substance LANGUAGE 'sql' COST 100 VOLATILE AS $BODY$ select s.* from substancetrivialname n join substance s on s.id =

sql function with empty row

2018-05-16 Thread Philipp Kraus
Hello, I have defined a SQL function CREATE OR REPLACE FUNCTION substancetrivialname(text) RETURNS substance LANGUAGE 'sql' COST 100 VOLATILE AS $BODY$ select s.* from substancetrivialname n join substance s on s.id = n.idsubstance where lower(btrim(n.name)) =

Re: Out of memory error with PG10.3, 10.4 but not 9.3.19

2018-05-16 Thread Michael Paquier
On Tue, May 15, 2018 at 03:02:48PM +, ChatPristi wrote: > I got the error with PG 10.3 and 10.4 on CentOS 7 up-to-date.The > command works with a smaller size database. > The command works with the same database with PG 9.3.19 on RHEL 6.9 > up-to-date. > > I attach the EXPLAIN SELECT

Re: array_agg to array

2018-05-16 Thread Philipp Kraus
> Am 16.05.2018 um 09:10 schrieb Torsten Förtsch : > > select array_agg(i[1]) as e from regexp_matches( 'H2O', > '[0-9]*[A-Z][a-z]?\d*|\((?:[^()]*(?:\(.*\))?[^()]*)+\)\d+', 'g') t(i); perfect, this helps with the t(i) call Phil signature.asc Description: Message

Re: array_agg to array

2018-05-16 Thread Torsten Förtsch
On Wed, May 16, 2018 at 8:14 AM, Philipp Kraus < philipp.kr...@tu-clausthal.de> wrote: > Hello, > > I have got a function with a reg expr to split chemical formulas e.g. H2O > -> H2 O. > > CREATE OR REPLACE FUNCTION daimon.text2sumformula(text) RETURNS text[] AS > $$ > select

Re: Function to set up variable inside it

2018-05-16 Thread Pavel Stehule
Hi 2018-05-16 6:52 GMT+02:00 Łukasz Jarych : > Hi Guys, > > thank you for your help ! > > Hmm yes something like this. > > I was wondering if is possible to pass variable into function: > > CREATE FUNCTION change_trigger() RETURNS trigger AS $$ > > BEGIN > >

Re: array_agg to array

2018-05-16 Thread Pavel Stehule
Hi 2018-05-16 8:14 GMT+02:00 Philipp Kraus : > Hello, > > I have got a function with a reg expr to split chemical formulas e.g. H2O > -> H2 O. > > CREATE OR REPLACE FUNCTION daimon.text2sumformula(text) RETURNS text[] AS > $$ > select array_agg(i::text) as e

array_agg to array

2018-05-16 Thread Philipp Kraus
Hello, I have got a function with a reg expr to split chemical formulas e.g. H2O -> H2 O. CREATE OR REPLACE FUNCTION daimon.text2sumformula(text) RETURNS text[] AS $$ select array_agg(i::text) as e from ( select unnest( regexp_matches( $1,