Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XHKFS-0001zJ-CV for pgsql-interfaces@arkaria.postgresql.org; Tue, 12 Aug 2014 22:08:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XHKFR-0006Ms-Rl for pgsql-interfaces@arkaria.postgresql.org; Tue, 12 Aug 2014 22:08:53 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XHKFQ-0006Ll-TL for pgsql-interfaces@postgresql.org; Tue, 12 Aug 2014 22:08:53 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XHKFN-0006gQ-QB for pgsql-interfaces@postgresql.org; Tue, 12 Aug 2014 22:08:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s7CM8m16009845; Tue, 12 Aug 2014 18:08:48 -0400 From: Tom Lane To: Thomas Heller cc: pgsql-interfaces@postgresql.org Subject: Re: Protocol Question In-reply-to: References: <22826.1407769579@sss.pgh.pa.us> Comments: In-reply-to Thomas Heller message dated "Tue, 12 Aug 2014 17:58:45 +0200" Date: Tue, 12 Aug 2014 18:08:48 -0400 Message-ID: <9844.1407881328@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-interfaces Precedence: bulk Sender: pgsql-interfaces-owner@postgresql.org Thomas Heller writes: > In an Extended Query Lifecycle, in order to prepare a query I send the > Commands > Parse('P') / Describe('D') / Sync('S') > read 1/t/T/Z then to execute > Bind('B') / Execute('E') / Flush('H') This is not a good idea. You *need* to use Sync to terminate a command sequence in order to be sure of proper error recovery (because if there's an error during the Execute, the backend will discard subsequent messages until it sees Sync). > If I skip the Flush after Execute I receive no data, if I Execute and Sync > I receive the the Limit of rows and a ReadyForQuery('Z'). That's probably because you're not wrapping this in a transaction so the Sync implicitly does a commit, discarding the open portal. If you want to read from a portal in multiple steps then you should issue a BEGIN first and a COMMIT (or ROLLBACK) after you're done. However, have you considered just processing the data on-the-fly instead of using a limit? regards, tom lane -- Sent via pgsql-interfaces mailing list (pgsql-interfaces@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-interfaces