Re: batching commands with libpq

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: yamt(at)mwd(dot)biglobe(dot)ne(dot)jp (YAMAMOTO Takashi)
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: batching commands with libpq
Date: 2010-12-28 16:16:44
Message-ID: 3318.1293553004@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

yamt(at)mwd(dot)biglobe(dot)ne(dot)jp (YAMAMOTO Takashi) writes:
> is there any way to send multiple commands together (ideally in a single
> network packet), and then wait for their results, using libpq? i want to
> save extra round-trips. while postgresql's fe-be on-wire protocol seems
> to allow it (is it right?), i couldn't find a way with libpq.

> PQsendQuery(conn, "select timeofday();select timeofday();select timeofday();");
> seems to work, but i want to use extended protocol.

You're out of luck: extended protocol intentionally doesn't allow
multiple queries per string.

The wire protocol does in theory allow you to send more commands before
waiting for the results of the first one, but that's not supported in
libpq. The only case you can do in libpq is multiple commands in a
PQexec string.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message wolfang 2010-12-28 16:44:34 Re: Send parameters using Shell script to PostgreSQL
Previous Message Aarni 2010-12-28 14:43:21 Re: Send parameters using Shell script to PostgreSQL