pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Can't query system tables during transaction
4+ messages / 3 participants
[nested] [flat]

* Can't query system tables during transaction
@ 2020-10-04 20:14 Igor Korot <ikorot01@gmail.com>
  2020-10-04 20:24 ` Re: Can't query system tables during transaction Adrian Klaver <adrian.klaver@aklaver.com>
  2020-10-04 20:30 ` Re: Can't query system tables during transaction Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 4+ messages in thread

From: Igor Korot @ 2020-10-04 20:14 UTC (permalink / raw)
  To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

Hi, ALL,
I'm trying to execute following:

SELECT 1 FROM pg_class c, pg_namespace n WHERE n.oid = c.relnamespace
AND c.relname = 'foo' AND n.nspname = public;

inside the transaction.

I'm getting the following error:

ERROR:  current transaction is aborted, commands ignored until end of
transaction block

Does this mean I can't query system tables during the transaction?
What is the problem here if it's not and how do I find out the reason?
And if it is - how to work around it?

I can probably commit it and start a new transaction, but I fear I will
have the same issue there...

Thank you.

If it matters - I'm working with C++ and libpq.





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Can't query system tables during transaction
  2020-10-04 20:14 Can't query system tables during transaction Igor Korot <ikorot01@gmail.com>
@ 2020-10-04 20:24 ` Adrian Klaver <adrian.klaver@aklaver.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Adrian Klaver @ 2020-10-04 20:24 UTC (permalink / raw)
  To: Igor Korot <ikorot01@gmail.com>; pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

On 10/4/20 1:14 PM, Igor Korot wrote:
> Hi, ALL,
> I'm trying to execute following:
> 
> SELECT 1 FROM pg_class c, pg_namespace n WHERE n.oid = c.relnamespace
> AND c.relname = 'foo' AND n.nspname = public;
> 
> inside the transaction.
> 
> I'm getting the following error:
> 
> ERROR:  current transaction is aborted, commands ignored until end of
> transaction block

No it means another statement before this one threw an error and the 
transaction needs to be rolled back. Something like this:

track_stocks(5442)=> begin ;
BEGIN
track_stocks(5442)=> SELECT 1 FROM pg_class c, pg_namespace n WHERE 
n.oid = c.relnamespace
AND c.relname = 'stock-info' AND n.nspname = public;
ERROR:  column "public" does not exist
LINE 2: AND c.relname = 'stock-info' AND n.nspname = public;
                                                      ^
track_stocks(5442)=> SELECT 1 FROM pg_class c, pg_namespace n WHERE 
n.oid = c.relnamespace
AND c.relname = 'stock-info' AND n.nspname = 'public';
ERROR:  current transaction is aborted, commands ignored until end of 
transaction block

track_stocks(5442)=> rollback ;
ROLLBACK

And now the correct query(Note the quoted schema name):

track_stocks(5442)=> begin ;
BEGIN
track_stocks(5442)=> SELECT 1 FROM pg_class c, pg_namespace n WHERE 
n.oid = c.relnamespace
AND c.relname = 'stock-info' AND n.nspname = 'public';
  ?column?
----------
(0 rows)

> 
> Does this mean I can't query system tables during the transaction?
> What is the problem here if it's not and how do I find out the reason?
> And if it is - how to work around it?
> 
> I can probably commit it and start a new transaction, but I fear I will
> have the same issue there...
> 
> Thank you.
> 
> If it matters - I'm working with C++ and libpq.
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Can't query system tables during transaction
  2020-10-04 20:14 Can't query system tables during transaction Igor Korot <ikorot01@gmail.com>
@ 2020-10-04 20:30 ` Tom Lane <tgl@sss.pgh.pa.us>
  2020-10-04 20:58   ` Re: Can't query system tables during transaction Igor Korot <ikorot01@gmail.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Tom Lane @ 2020-10-04 20:30 UTC (permalink / raw)
  To: Igor Korot <ikorot01@gmail.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

Igor Korot <ikorot01@gmail.com> writes:
> I'm trying to execute following:

> SELECT 1 FROM pg_class c, pg_namespace n WHERE n.oid = c.relnamespace
> AND c.relname = 'foo' AND n.nspname = public;

I suppose you meant to put quotes around 'public'?

> I'm getting the following error:
> ERROR:  current transaction is aborted, commands ignored until end of
> transaction block

This has nothing to do with the current command, but with failure
of some previous command in the transaction.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Can't query system tables during transaction
  2020-10-04 20:14 Can't query system tables during transaction Igor Korot <ikorot01@gmail.com>
  2020-10-04 20:30 ` Re: Can't query system tables during transaction Tom Lane <tgl@sss.pgh.pa.us>
@ 2020-10-04 20:58   ` Igor Korot <ikorot01@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Igor Korot @ 2020-10-04 20:58 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

Hi,

On Sun, Oct 4, 2020 at 3:30 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Igor Korot <ikorot01@gmail.com> writes:
> > I'm trying to execute following:
>
> > SELECT 1 FROM pg_class c, pg_namespace n WHERE n.oid = c.relnamespace
> > AND c.relname = 'foo' AND n.nspname = public;
>
> I suppose you meant to put quotes around 'public'?

I suppose so as well. ;-)

>
> > I'm getting the following error:
> > ERROR:  current transaction is aborted, commands ignored until end of
> > transaction block
>
> This has nothing to do with the current command, but with failure
> of some previous command in the transaction.

Thank you.
I will try to track down the error.

>
>                         regards, tom lane





^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2020-10-04 20:58 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-10-04 20:14 Can't query system tables during transaction Igor Korot <ikorot01@gmail.com>
2020-10-04 20:24 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-10-04 20:30 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-10-04 20:58   ` Igor Korot <ikorot01@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox