Re: Is there any way to access heap_open() from _PG_init ??

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sairam Gaddam <gaddamsairam(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Is there any way to access heap_open() from _PG_init ??
Date: 2017-05-12 14:30:58
Message-ID: 18569.1494599458@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Sairam Gaddam <gaddamsairam(at)gmail(dot)com> writes:
> During startup (_PG_init), I need to access some meta info of
> table/relation (like PK Column Position, FK Column Positions, Index Column
> Positions etc...) and load it into memory.

Why not fetch that info at first use, instead?

If you insist on doing it at _PG_init, you'll never be able to make the
extension work as a shared_preload_libraries item, where _PG_init
would be run in the postmaster. (I think local_preload_libraries would
be problematic too; not sure that you're inside a transaction there.)
You won't be able to retry after an error, or more generally to cope with
post-load-time changes in the data you want to cache.

It's probably possible to make it work as long as the library gets loaded
during a transaction, ie in response to some SQL command. Without seeing
your code we can't guess why its crashing though.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2017-05-12 14:35:56 Re: [HACKERS] Concurrent ALTER SEQUENCE RESTART Regression
Previous Message Peter Eisentraut 2017-05-12 14:28:10 Re: [BUGS] Concurrent ALTER SEQUENCE RESTART Regression