Обсуждение: Dynamic Loading Library! Extension using C Function
Dear PostgreSQL Community,
I just started learning PostgreSQL, and I am trying to develop a extension for postgre using SRF but I am stuck that how do I get the values by passing the constant integer value against a field/column without using the table name as argument. I already read the Xfunction document portion and successfully executed all most all the examples provided.
Suppose my query is
select get_all_greater_values(column_name, 2000) from table_name;
column_name
1000
2000
3000
4000
Result
3000
4000
Kindly help me for the above query and also suggest whether it is good to use the SRF or there is any other way to get results from this query. I want to implement extension code using C language as dynamic loading library. I really appreciate your concerns.
Regards
M. Bilal Sadiq
I just started learning PostgreSQL, and I am trying to develop a extension for postgre using SRF but I am stuck that how do I get the values by passing the constant integer value against a field/column without using the table name as argument. I already read the Xfunction document portion and successfully executed all most all the examples provided.
Suppose my query is
select get_all_greater_values(column_name, 2000) from table_name;
column_name
1000
2000
3000
4000
Result
3000
4000
Kindly help me for the above query and also suggest whether it is good to use the SRF or there is any other way to get results from this query. I want to implement extension code using C language as dynamic loading library. I really appreciate your concerns.
Regards
M. Bilal Sadiq
your description is somewhat unclear but it seems that you want to query several tables with a common column in one query.
maybe inheritance is useful for you?
http://www.postgresql.org/docs/9.1/static/ddl-inherit.html
the point is, a table can have "child tables" and you automatically query the child tables when you query the parent.
the parent can be empty, then you just have a bunch of tables that you can query separately, or all together.
the advantage would be that you don't have to write a function for everything you do... you can just use all of the usual functionality.
and if it is what you want and you are looking for performance improvement, you should look into partitioning and constraint exclusion.
HTH
WBL
--
"Patriotism is the conviction that your country is superior to all others because you were born in it." -- George Bernard Shaw
maybe inheritance is useful for you?
http://www.postgresql.org/docs/9.1/static/ddl-inherit.html
the point is, a table can have "child tables" and you automatically query the child tables when you query the parent.
the parent can be empty, then you just have a bunch of tables that you can query separately, or all together.
the advantage would be that you don't have to write a function for everything you do... you can just use all of the usual functionality.
and if it is what you want and you are looking for performance improvement, you should look into partitioning and constraint exclusion.
HTH
WBL
On Sat, Mar 31, 2012 at 3:36 PM, Bilal Sadiq <m_bilalsadiq@hotmail.com> wrote:
Dear PostgreSQL Community,
I just started learning PostgreSQL, and I am trying to develop a extension for postgre using SRF but I am stuck that how do I get the values by passing the constant integer value against a field/column without using the table name as argument. I already read the Xfunction document portion and successfully executed all most all the examples provided.
Suppose my query is
select get_all_greater_values(column_name, 2000) from table_name;
column_name
1000
2000
3000
4000
Result
3000
4000
Kindly help me for the above query and also suggest whether it is good to use the SRF or there is any other way to get results from this query. I want to implement extension code using C language as dynamic loading library. I really appreciate your concerns.
Regards
M. Bilal Sadiq
--
"Patriotism is the conviction that your country is superior to all others because you were born in it." -- George Bernard Shaw