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

2017-05-12 Thread Tom Lane
Sairam Gaddam  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


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] Is there any way to access heap_open() from _PG_init ??

2017-05-11 Thread Sairam Gaddam
Hello people,

I was trying to build an extension(Index related) on top of postgres.

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.

To accomplish that, In _PG_init() function,  I tried to use the function
heap_open() so that I can get the necessary table/relation info from that
relation object, But I was not able to use, and the program is waiting in
the heap_open() function indefinitely and postgres quits! Why am I not able
to access?

Any workaround to access table relation object/Any way to get that info by
some other means?

Thanks,
Sai Ram