Asynchronous commands

Поиск
Список
Период
Сортировка
От Nathaniel Trellice
Тема Asynchronous commands
Дата
Msg-id 910911.50867.qm@web25005.mail.ukl.yahoo.com
обсуждение исходный текст
Список pgsql-novice
Can anyone point me to examples for using libpq's asynchronous command processing?

My client C program needs to perform a bulk load. I've written code to do this by both:

1. Dumping data to file and loading it into a table using "COPY table_name FROM 'file_name'", and
2. Writing directly into PG using "COPY table_name FROM STDIN" and then making buffered calls to PQputCopyData.

Using binary communication, I'm feeling pretty smug about my bulkload times, but they're still of the order of a
minute.However, my program must be able to do other things during this period. So I'm investigating the possibility of
rejigging(1) so that I: 

a. Dump binary data into a file,
b. Instruct PG to copy this data into a table asynchronously,
c. Go away and do other exciting things,
d. Upon completion of the load, a callback of mine is triggered.

I have this (kind of) implemented by forking a child process that sends the "COPY table_name FROM 'file_name'" command
sothe main process can keep on trucking, but I'm not happy with it. 

Is this the kind of thing that I should be able to achieve more elegantly using libpq's asynchronous functions
(PQsendQuery,PQgetResult etc)? Can anyone give me a clue how to arrange the function calls? 

Many thanks,

Nathaniel





В списке pgsql-novice по дате отправления:

Предыдущее
От: vikas vashista
Дата:
Сообщение: user defined data type
Следующее
От: richard terry
Дата:
Сообщение: creating view - conditional testing in construct