Re: Parameter passing in trigger function write in C

2018-04-26 Thread a
hey thanks mate, I have red that. But the actual data retirement seems to be combination of that and the SPI_get* functions. I'm still testing on it. By the way, if I can pass parameters that is out of the scope of sql statement?? -- Original -- From: "Adrian K

Re: Parameter passing in trigger function write in C

2018-04-26 Thread Adrian Klaver
On 04/26/2018 06:13 PM, a wrote: Hey everyone: I was request to write a trigger that perform the following function: 1, The trigger will be set to exam all statement that will result change of datas 2, The trigger will exam three information other than the data updated or inserted: user nam

Parameter passing in trigger function write in C

2018-04-26 Thread a
Hey everyone: I was request to write a trigger that perform the following function: 1, The trigger will be set to exam all statement that will result change of datas 2, The trigger will exam three information other than the data updated or inserted: user name, password and reasons of change

Re: PGAdmin4 debugger - unable to call ltree functions

2018-04-26 Thread Tom Lane
"Ian Bell" writes: > My function TestLtree() is being executed in the PGAdmin debugger. The > debugger requires I define the argument being passed, I set this to 'a.b.c' > and I have confirmed in the debugger that this is indeed what is passed into > the function. > I do not understand what

RE: PGAdmin4 debugger - unable to call ltree functions

2018-04-26 Thread Ian Bell
My function TestLtree() is being executed in the PGAdmin debugger. The debugger requires I define the argument being passed, I set this to 'a.b.c' and I have confirmed in the debugger that this is indeed what is passed into the function. I do not understand what you mean by "You haven't show

Re: PGAdmin4 debugger - unable to call ltree functions

2018-04-26 Thread Tom Lane
"Ian Bell" writes: > I just tried your suggestion and it generates the same error. For > verification, here is the function run in the debugger. I just realized that "syntax error at position N" is *not* the exact spelling you would get from a syntax error in PG's main parser, which I think is w

Re: PGAdmin4 debugger - unable to call ltree functions

2018-04-26 Thread Adrian Klaver
On 04/26/2018 02:54 PM, Ian Bell wrote: Hello Adrian, I just tried your suggestion and it generates the same error.  For verification, here is the function run in the debugger. create or replace function TestLtreeV2( MyArg text ) returns void as $$ declare _testVar integer; begin S

RE: PGAdmin4 debugger - unable to call ltree functions

2018-04-26 Thread Ian Bell
Hello Adrian, I just tried your suggestion and it generates the same error. For verification, here is the function run in the debugger. create or replace function TestLtreeV2( MyArg text ) returns void as $$ declare _testVar integer; begin SELECT 1 INTO _testvar FROM TableLtree W

Re: Long running INSERT+SELECT query

2018-04-26 Thread Adrian Klaver
On 04/26/2018 01:32 PM, Vitaliy Garnashevich wrote: Have not worked through all of the above, but a first draft suggestion: Move the SELECT minus the aggregation functions into a sub-query that uses FOR UPDATE. Then do the aggregation on the results of the sub-query. The aggregated table h

Re: PGAdmin4 debugger - unable to call ltree functions

2018-04-26 Thread Adrian Klaver
On 04/26/2018 01:22 PM, Ian Bell wrote: I have recently started working with the PGAdmin4 debugger and have encountered a particular problem when testing my own functions that, in turn, call functions from the ltree module.   The sample code below successfully runs in  PSQL.  However, it fails

Re: Long running INSERT+SELECT query

2018-04-26 Thread Alvaro Herrera
Vitaliy Garnashevich wrote: > > > Have not worked through all of the above, but a first draft suggestion: > > > > Move the SELECT minus the aggregation functions into a sub-query that > > uses FOR UPDATE. Then do the aggregation on the results of the > > sub-query. > > The aggregated table has h

Re: Long running INSERT+SELECT query

2018-04-26 Thread David G. Johnston
On Thu, Apr 26, 2018 at 1:32 PM, Vitaliy Garnashevich < vgarnashev...@gmail.com> wrote: > The aggregated table has hundreds of millions of rows, and the query runs > for many hours (which is one of the reasons why it's better not to fail) > ​[...]​ > Maybe this could be solved by calculating res

PGAdmin4 debugger - unable to call ltree functions

2018-04-26 Thread Ian Bell
I have recently started working with the PGAdmin4 debugger and have encountered a particular problem when testing my own functions that, in turn, call functions from the ltree module. The sample code below successfully runs in PSQL. However, it fails when run in the PGAdmin4 debugger. Specifi

Re: Long running INSERT+SELECT query

2018-04-26 Thread Vitaliy Garnashevich
Have not worked through all of the above, but a first draft suggestion: Move the SELECT minus the aggregation functions into a sub-query that uses FOR UPDATE. Then do the aggregation on the results of the sub-query. The aggregated table has hundreds of millions of rows, and the query runs

pg_stat_statements : how to catch non successfully finished statements ?

2018-04-26 Thread legrand legrand
Hello all, I was wondering if there is a hook to collect non successfully finished SQL statements in pg_stat_statements (timed-out, cancelled, killed, or simply errored) ? Thanks in advance Regards PAscal -- Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html

Re: Long running INSERT+SELECT query

2018-04-26 Thread Adrian Klaver
On 04/26/2018 11:08 AM, Vitaliy Garnashevich wrote: Without the query we are flying blind, so suggestions will have a ? Here is one such query:     INSERT INTO cmdb_sp_usage_history   (created_by, updated_by, created_on, updated_on, mod_count,   summary_on, quarter, product, used_

Re: Long running INSERT+SELECT query

2018-04-26 Thread Vitaliy Garnashevich
Without the query we are flying blind, so suggestions will have a ? Here is one such query:     INSERT INTO cmdb_sp_usage_history   (created_by, updated_by, created_on, updated_on, mod_count,   summary_on, quarter, product, used_from, "user",   keystrokes, minutes_in_use, times_st

Re: Long running INSERT+SELECT query

2018-04-26 Thread Adrian Klaver
On 04/26/2018 10:45 AM, Vitaliy Garnashevich wrote: SELECT .. FOR UPDATE?: https://www.postgresql.org/docs/10/static/sql-select.html#SQL-FOR-UPDATE-SHARE https://www.postgresql.org/docs/10/static/explicit-locking.html#LOCKING-ROWS It says: "Currently, FOR NO KEY UPDATE, FOR UPDATE, FOR

Re: Long running INSERT+SELECT query

2018-04-26 Thread Vitaliy Garnashevich
SELECT .. FOR UPDATE?: https://www.postgresql.org/docs/10/static/sql-select.html#SQL-FOR-UPDATE-SHARE https://www.postgresql.org/docs/10/static/explicit-locking.html#LOCKING-ROWS It says: "Currently, FOR NO KEY UPDATE, FOR UPDATE, FOR SHARE and FOR KEY SHARE cannot be specified with GR

Re: Issue on public schéma with Pg_restore

2018-04-26 Thread Adrian Klaver
On 04/26/2018 07:52 AM, Thomas Poty wrote: Hi, About the minor version, we will plan the upgrade soon . So how did you revoke the privileges for PUBLIC in the above? [db source] => After creation of the database, I executed:     revoke all on schema public from public; Hmm: https://git.post

Re: Long running INSERT+SELECT query

2018-04-26 Thread Adrian Klaver
On 04/26/2018 09:13 AM, Vitaliy Garnashevich wrote: Hi, We're trying to populate a table with aggregated data from other tables. For that we're running a huge INSERT+SELECT query which joins several tables, aggregates values, and then inserts the results into another table. The problem we're

Long running INSERT+SELECT query

2018-04-26 Thread Vitaliy Garnashevich
Hi, We're trying to populate a table with aggregated data from other tables. For that we're running a huge INSERT+SELECT query which joins several tables, aggregates values, and then inserts the results into another table. The problem we're facing is that while the query is running , some rec

Re: Issue on public schéma with Pg_restore

2018-04-26 Thread Thomas Poty
Hi, About the minor version, we will plan the upgrade soon . So how did you revoke the privileges for PUBLIC in the above? [db source] => After creation of the database, I executed: revoke all on schema public from public; Thanks for the 'no-op' . Thomas 2018-04-26 16:28 GMT+02:00 Adrian

Re: Issue on public schéma with Pg_restore

2018-04-26 Thread Adrian Klaver
On 04/26/2018 12:03 AM, Thomas Poty wrote: Hi, Comments in line below. *About version :* This is the same on both server _ + source  server  :_ [[local]] thomasproot@serverconfig=# select version(); ┌

Re: Same condition in the CTE and in the subsequent JOIN using it

2018-04-26 Thread Alexander Farber
s/ I can trust / I can't trust /

Re: Same condition in the CTE and in the subsequent JOIN using it

2018-04-26 Thread Alexander Farber
Thank you for the insightful comments. Actually in my specific case I have managed to get rid of the (almost) same condition in the outer query: CREATE OR REPLACE FUNCTION words_stat_scores_2( in_social integer, in_sidtext ) RETURNS TABLE (

Re: Issue on public schéma with Pg_restore

2018-04-26 Thread Thomas Poty
I have run this command (same of previous one without -d and with -f argument : /bin/pg_restore --username=backup --host=VM38 --port=5432 --no-password --disable-triggers --verbose --clean --create --if-exists -f /tmp/thomasp.log /mnt/backupPostgreSQL/serverco nfig_prod/backup_in_progress/serverc

Re: Issue on public schéma with Pg_restore

2018-04-26 Thread Thomas Poty
Hi, *About version :* This is the same on both server * + source server :* [[local]] thomasproot@serverconfig=# select version(); ┌──┐ │ version