KIM
KIM

Reputation: 1254

Accessing shared memory of postgres

I'm buliding my own C application on CentOS 5 and postgresql 9.2.

What I'm trying to do is to access shared memory area with shmat function and get the details of pg_stat_activity. I'm not going to use database connection but Direct Memory Access thing.

I've installed gdb and postgresql with source compilation though, I don't know which point I can start with.

Any advice would be appreciated, thanks in advance.

Upvotes: 0

Views: 755

Answers (1)

Pavel Stehule
Pavel Stehule

Reputation: 45930

First I agree with Jonathan Leffer - when you access a tables (or views) use a query statement - via SPI Server Programming Interface - It is simple, safe, fast, and doesn't consume some additional resources.

If you don't would to use it, look on pg_stat_activity view definition. It is based on calling pg_stat_get_activity function. Source code of this function, can be good start. This function is not too complex as is looking - almost all code is implementation of SRF (Set Returning Functions - function returning table).

Upvotes: 3

Related Questions