execute table query in backend

Started by Anh Phamabout 12 years ago3 messagesgeneral
Jump to latest
#1Anh Pham
atpham.wpi@gmail.com

Hi,
I am trying to extend the server backend by writing a new module.
Basically, it tries to retrieve tuples from a specific table using some
predefined qualifications (equivalent to "SELECT FROM WHERE" client sql
statement ).
Is there any quick or efficient way to do this?

Many thanks :)

#2Amit Langote
Langote_Amit_f8@lab.ntt.co.jp
In reply to: Anh Pham (#1)
Re: execute table query in backend

On Tue, Mar 4, 2014 at 12:38 AM, Anh Pham <atpham.wpi@gmail.com> wrote:

Hi,
I am trying to extend the server backend by writing a new module.
Basically, it tries to retrieve tuples from a specific table using some
predefined qualifications (equivalent to "SELECT FROM WHERE" client sql
statement ).
Is there any quick or efficient way to do this?

Assuming you're trying to write a server extension (and NOT a client
application), this is where you can start:

http://www.postgresql.org/docs/9.3/static/server-programming.html

Specifically, an interface called "server programming interface"
(chapter 44 on the above page) can be used to issue SQLs from a server
extension module. Read more about it here (documentation also includes
few examples to get started with):

http://www.postgresql.org/docs/9.3/static/spi.html

--
Amit

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

#3Anh Pham
atpham.wpi@gmail.com
In reply to: Amit Langote (#2)
Re: execute table query in backend

Thank you for you suggestion.
I actually took a look at SPI_ functions before. However, I believe using
this will bring quite an overhead.
I am trying to modify the Sequence scan node such that: each time the scan
returns a tuple,
we'll take some information from this tuple. And finally issue another scan
operation on a different table based on these information

On Thu, Mar 6, 2014 at 12:36 AM, Amit Langote <amitlangote09@gmail.com>wrote:

On Tue, Mar 4, 2014 at 12:38 AM, Anh Pham <atpham.wpi@gmail.com> wrote:

Hi,
I am trying to extend the server backend by writing a new module.
Basically, it tries to retrieve tuples from a specific table using some
predefined qualifications (equivalent to "SELECT FROM WHERE" client sql
statement ).
Is there any quick or efficient way to do this?

Assuming you're trying to write a server extension (and NOT a client
application), this is where you can start:

http://www.postgresql.org/docs/9.3/static/server-programming.html

Specifically, an interface called "server programming interface"
(chapter 44 on the above page) can be used to issue SQLs from a server
extension module. Read more about it here (documentation also includes
few examples to get started with):

http://www.postgresql.org/docs/9.3/static/spi.html

--
Amit

--
Anh T Pham
Computer Science
Worcester Polytechnic Institute