pg.ddx.io pgsql-interfaces@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Example of Asynchronous Query Processing in C? 2+ messages / 2 participants [nested] [flat]
* Example of Asynchronous Query Processing in C? @ 1999-02-12 03:56 Matthew Hagerty <matthew@venux.net> 0 siblings, 1 reply; 2+ messages in thread From: Matthew Hagerty @ 1999-02-12 03:56 UTC (permalink / raw) To: pgsql-interfaces Greetings, I was reading through the docs for libpq and in the Asynchronous Query Processing section there is mention of an example program that demonstrates the use of select(2) to wait for the backend. I could not find the example, does anyone have one? I understand what needs to be done, however it is always nice to have some sort of reference program to follow. What I am hoping to accomplish is to have my frontend accept a query, pass it to the backend, and build the output based on the query. I would also like the user to be able to limit the number of records (tuples) returned and cancel the query if necessary; hence the use of the async functions and select(2). I know psql does this and I'm about to go poking around in its source, but the Asynchronous Query Processing doc mentions the psql uses the PQexec function in conjunction with PQrequestCancel, so I'm not sure if it will give me the example I'm looking for. If someone has a function that does what I'm looking for, hey that would be swell ;), or just a simple example of async processing would be nice too. Thanks, Matthew ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [INTERFACES] Example of Asynchronous Query Processing in C? @ 1999-02-12 15:18 Tom Lane <tgl@sss.pgh.pa.us> parent: Matthew Hagerty <matthew@venux.net> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 1999-02-12 15:18 UTC (permalink / raw) To: Matthew Hagerty <matthew@venux.net>; +Cc: pgsql-interfaces Matthew Hagerty <matthew@venux.net> writes: > I was reading through the docs for libpq and in the Asynchronous Query > Processing section there is mention of an example program that demonstrates > the use of select(2) to wait for the backend. I could not find the > example, does anyone have one? Hmm, it does promise one doesn't it? What I was actually intending to do was just modify the second sample program to wait for a NOTIFY with select() rather than sleep(). But I forgot :-( As I was explaining to someone else recently, a reasonable sample program for async query processing is hard to come up with. The only reason you'd do it is because your app has something else it needs to do concurrently, which is tough to demonstrate in a simple program. The actual use of select() is not hard --- you can use pqWait() in interfaces/libpq/fe-misc.c as an example. The issue that's hard to show in a small program is what sort of control structure all this is likely to be embedded in. > What I am hoping to accomplish is to have my frontend accept a query, pass > it to the backend, and build the output based on the query. I would also > like the user to be able to limit the number of records (tuples) returned > and cancel the query if necessary; hence the use of the async functions and > select(2). Limiting the tuple count will be a feature in 6.5 but is not really possible without backend support. As for cancel, if you can issue the cancel from a signal handler like psql does, you don't really need the async query interface ... regards, tom lane ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1999-02-12 15:18 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 1999-02-12 03:56 Example of Asynchronous Query Processing in C? Matthew Hagerty <matthew@venux.net> 1999-02-12 15:18 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox