plugin dev, oid to pointer map

Started by Attila Sokialmost 10 years ago3 messagesgeneral
Jump to latest
#1Attila Soki
atiware@gmx.net

Hi all,

i am about to begin with postgresql plugin development.
Currently i'm trying to become somewhat familiar with the postgresql sources.

Without going too deep into details about the plugin, i want to use
many Oid to pointer relations.
The pointer is a pointer to my own struct (allocated with palloc).
There will be approx. 1000 unique oid/pointer pairs.

Basically, what i want is, to be able to get the pointer to my struct by Oid.

Is there is a suitable hashmap or key-value storage solution in the pg code?
if so, please point me to the right part of the source.

thanks,
Attila Soki

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

#2Julien Rouhaud
rjuju123@gmail.com
In reply to: Attila Soki (#1)
Re: plugin dev, oid to pointer map

On 29/05/2016 22:10, Attila Soki wrote:

Hi all,

Hello,

i am about to begin with postgresql plugin development.
H Currently i'm trying to become somewhat familiar with the postgresql sources.

Without going too deep into details about the plugin, i want to use
many Oid to pointer relations.
The pointer is a pointer to my own struct (allocated with palloc).
There will be approx. 1000 unique oid/pointer pairs.

Basically, what i want is, to be able to get the pointer to my struct by Oid.

Is there is a suitable hashmap or key-value storage solution in the pg code?
if so, please point me to the right part of the source.

Yes, there's an hashtable implementation, see dynahash.c

If you want to use that in shared memory in your extension, you can look
at the pg_stat_statements extension (look for pgss_hash) for an example.

Regards.

--
Julien Rouhaud
http://dalibo.com - http://dalibo.org

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

#3Attila Soki
atiware@gmx.net
In reply to: Julien Rouhaud (#2)
Re: plugin dev, oid to pointer map

On 30 May 2016, at 02:43, Julien Rouhaud <julien.rouhaud@dalibo.com> wrote:

On 29/05/2016 22:10, Attila Soki wrote:

i am about to begin with postgresql plugin development.
H Currently i'm trying to become somewhat familiar with the postgresql sources.

Without going too deep into details about the plugin, i want to use
many Oid to pointer relations.
The pointer is a pointer to my own struct (allocated with palloc).
There will be approx. 1000 unique oid/pointer pairs.

Basically, what i want is, to be able to get the pointer to my struct by Oid.

Is there is a suitable hashmap or key-value storage solution in the pg code?
if so, please point me to the right part of the source.

Yes, there's an hashtable implementation, see dynahash.c

If you want to use that in shared memory in your extension, you can look
at the pg_stat_statements extension (look for pgss_hash) for an example.

Hello Julien,

exactly what i need

Thank you

Attila Soki

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