In which session context is a trigger run?

2018-12-28 Thread Mitar
Hi! It seems to me that triggers on a table are run in the session context of the user who made a change in the table, but not of the user who defined the trigger? So I create a temporary function: CREATE OR REPLACE FUNCTION pg_temp.my_function() And a temporary table: CREATE TEMPORARY TABLE p

Re: In which session context is a trigger run?

2018-12-28 Thread Adrian Klaver
On 12/28/18 12:47 PM, Mitar wrote: Hi! It seems to me that triggers on a table are run in the session context of the user who made a change in the table, but not of the user who defined the trigger? So I create a temporary function: CREATE OR REPLACE FUNCTION pg_temp.my_function() And it doe

Re: In which session context is a trigger run?

2018-12-28 Thread Mitar
Hi! On Fri, Dec 28, 2018 at 12:57 PM Adrian Klaver wrote: > > CREATE OR REPLACE FUNCTION pg_temp.my_function() > > And it does what? Copies/transforms data from posts into posts_temp. > > When a row is added to "posts" table outside of my session, function > > "my_function" is called, but it se

libpq bug?

2018-12-28 Thread Igor Korot
Hi, ALL, Following code: int PostgresDatabase::GetTableOwner (const std::wstring &schemaName, const std::wstring &tableName, std::wstring &owner, std::vector &errorMsg) { int result = 0; std::wstring query = L"SELECT u.usename FROM pg_class c, pg_user u, pg_namespace n WHERE n.oid = c.relna

Re: libpq bug?

2018-12-28 Thread patrick keshishian
On Fri, Dec 28, 2018 at 2:00 PM Igor Korot wrote: > Hi, ALL, > Following code: > > int PostgresDatabase::GetTableOwner (const std::wstring &schemaName, > const std::wstring &tableName, std::wstring &owner, > std::vector &errorMsg) > { >int result = 0; > std::wstring query = L"SELECT u.use

Re: libpq bug?

2018-12-28 Thread Igor Korot
Hi, On Fri, Dec 28, 2018 at 4:51 PM patrick keshishian wrote: > > > On Fri, Dec 28, 2018 at 2:00 PM Igor Korot wrote: >> >> Hi, ALL, >> Following code: >> >> int PostgresDatabase::GetTableOwner (const std::wstring &schemaName, >> const std::wstring &tableName, std::wstring &owner, >> std::vector

Re: libpq bug?

2018-12-28 Thread Igor Korot
Hi, On Fri, Dec 28, 2018 at 5:07 PM Igor Korot wrote: > > Hi, > > On Fri, Dec 28, 2018 at 4:51 PM patrick keshishian wrote: > > > > > > On Fri, Dec 28, 2018 at 2:00 PM Igor Korot wrote: > >> > >> Hi, ALL, > >> Following code: > >> > >> int PostgresDatabase::GetTableOwner (const std::wstring &sc

Re: In which session context is a trigger run?

2018-12-28 Thread Adrian Klaver
On 12/28/18 12:59 PM, Mitar wrote: Hi! On Fri, Dec 28, 2018 at 12:57 PM Adrian Klaver wrote: CREATE OR REPLACE FUNCTION pg_temp.my_function() And it does what? Copies/transforms data from posts into posts_temp. When a row is added to "posts" table outside of my session, function "my_func

Re: libpq bug?

2018-12-28 Thread patrick keshishian
On Fri, Dec 28, 2018 at 3:07 PM Igor Korot wrote: > Hi, > > On Fri, Dec 28, 2018 at 4:51 PM patrick keshishian > wrote: > > > > > > On Fri, Dec 28, 2018 at 2:00 PM Igor Korot wrote: > >> > >> Hi, ALL, > >> Following code: > >> > >> int PostgresDatabase::GetTableOwner (const std::wstring &schema

ERROR: found multixact XX from before relminmxid YY

2018-12-28 Thread Mark Fletcher
Hi, Starting yesterday morning, auto vacuuming of one of our postgresql 9.6.10 (CentOS 7) table's started failing: ERROR: found multixact 370350365 from before relminmxid 765860874 CONTEXT: automatic vacuum of table "userdb.public.subs" This is about as plain and simple a table as there is. No

Re: ERROR: found multixact XX from before relminmxid YY

2018-12-28 Thread Tom Lane
Mark Fletcher writes: > Starting yesterday morning, auto vacuuming of one of our postgresql 9.6.10 > (CentOS 7) table's started failing: > ERROR: found multixact 370350365 from before relminmxid 765860874 > CONTEXT: automatic vacuum of table "userdb.public.subs" Ugh. > Reading the various disc

Re: ERROR: found multixact XX from before relminmxid YY

2018-12-28 Thread Mark Fletcher
On Fri, Dec 28, 2018 at 4:49 PM Tom Lane wrote: > > Yeah, SELECT FOR UPDATE should overwrite the broken xmax value and thereby > fix it, I expect. However, I don't see anything in the release notes > suggesting that we've fixed any related bugs since 9.6.10, so if this > just appeared then we've

Re: libpq bug?

2018-12-28 Thread Igor Korot
Hi, Patrick, Here is my new code: int PostgresDatabase::GetTableOwner (const std::wstring &schemaName, const std::wstring &tableName, std::wstring &owner, std::vector &errorMsg) { int result = 0; std::wstring query = L"SELECT u.usename FROM pg_class c, pg_user u, pg_namespace n WHERE n.oi

Re: In which session context is a trigger run?

2018-12-28 Thread Mitar
Hi! On Fri, Dec 28, 2018 at 3:25 PM Adrian Klaver wrote: > > Sure, but why is a temporary function used as a temporary trigger made > > There is no such thing as a temporary trigger. A trigger defined using a temporary function gets deleted once a function gets deleted, which is at the end of th

Re: In which session context is a trigger run?

2018-12-28 Thread Adrian Klaver
On 12/28/18 7:56 PM, Mitar wrote: Hi! On Fri, Dec 28, 2018 at 3:25 PM Adrian Klaver wrote: Sure, but why is a temporary function used as a temporary trigger made There is no such thing as a temporary trigger. A trigger defined using a temporary function gets deleted once a function gets de

Re: libpq bug?

2018-12-28 Thread patrick keshishian
On Fri, Dec 28, 2018 at 5:40 PM Igor Korot wrote: > Hi, Patrick, > > Here is my new code: > > int PostgresDatabase::GetTableOwner (const std::wstring &schemaName, > const std::wstring &tableName, std::wstring &owner, > std::vector &errorMsg) > { > int result = 0; > std::wstring query = L"

Re: In which session context is a trigger run?

2018-12-28 Thread Mitar
Hi! On Fri, Dec 28, 2018 at 9:36 PM Adrian Klaver wrote: > When you create the temporary function it is 'pinned' to a particular > session/pg_temp_nn. Running the trigger in another session 'pins' it to > that session and it is not able to see the posts_temp table in the > original session. Yes.