Re: libpq pipelining

Поиск
Список
Период
Сортировка
От Matt Newell
Тема Re: libpq pipelining
Дата
Msg-id 2193114.W6sD3Nzkqp@obsidian
обсуждение исходный текст
Ответ на Re: libpq pipelining  (Matt Newell <newellm@blur.com>)
Ответы Re: libpq pipelining  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Список pgsql-hackers
> 
> > The explanation of PQgetFirstQuery makes it sound pretty hard to match
> > up the result with the query. You have to pay attention to PQisBusy.
> 
> PQgetFirstQuery should also be valid after
> calling PQgetResult and then you don't have to worry about PQisBusy, so I
> should probably change the documentation to indicate that is the preferred
> usage, or maybe make that the only guaranteed usage, and say the results
> are undefined if you call it before calling PQgetResult.  That usage also
> makes it consistent with PQgetLastQuery being called immediately after
> PQsendQuery.
> 
I changed my second example to call PQgetFirstQuery after PQgetResult instead 
of before, and that removes the need to call PQconsumeInput and PQisBusy when 
you don't mind blocking.  It makes the example super simple:
PQsendQuery(conn, "INSERT INTO test(id) VALUES (DEFAULT),(DEFAULT) 
RETURNING id");query1 = PQgetLastQuery(conn);/* Duplicate primary key error */PQsendQuery(conn, "UPDATE test SET id=2
WHEREid=1");query2 = PQgetLastQuery(conn);PQsendQuery(conn, "SELECT * FROM test");query3 = PQgetLastQuery(conn);while(
(result= PQgetResult(conn)) != NULL ){    curQuery = PQgetFirstQuery(conn);        if (curQuery == query1)
checkResult(conn,result,curQuery,PGRES_TUPLES_OK);   if (curQuery == query2)
checkResult(conn,result,curQuery,PGRES_FATAL_ERROR);   if (curQuery == query3)
checkResult(conn,result,curQuery,PGRES_TUPLES_OK);}

Note that the curQuery == queryX check will work no matter how many results a 
query produces.

Matt Newell




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

Предыдущее
От: Andres Freund
Дата:
Сообщение: pg_basebackup -x/X doesn't play well with archive_mode & wal_keep_segments
Следующее
От: Andres Freund
Дата:
Сообщение: Re: New wal format distorts pg_xlogdump --stats