Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0gkU-0000Rw-5g for pgsql-bugs@arkaria.postgresql.org; Sat, 07 Oct 2017 04:30:02 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e0gkT-000326-Jr for pgsql-bugs@arkaria.postgresql.org; Sat, 07 Oct 2017 04:30:01 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e0gjh-0001h4-V9 for pgsql-bugs@postgresql.org; Sat, 07 Oct 2017 04:29:14 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e0gje-00005u-Pp for pgsql-bugs@postgresql.org; Sat, 07 Oct 2017 04:29:12 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id C530120DCE; Sat, 7 Oct 2017 00:29:09 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Sat, 07 Oct 2017 00:29:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=OJGXSX5T2qPa/tew/5 SCgSw/qf0iJoziTgLWatkR+E8=; b=ZmEfvptwFE5Ual0R/x4SQ5b37aqY8JLyQD UmwlzZcf51GB3gg1oKeaU+ZUm8sAk5IX+yeE7NE8FaX8p0Y7DC8/jbe+hTjMh8o7 KEwyst5H9yxxyTjDSbPe0ZcfuW5t2b9Zz+CxMMTqItPeK5nxaeiHR9r5UkKPX33Q jK5cAfb8X25LXKKc7xX014TuKIl1AESeQe8AezcXlzZ0c5WPf/ZoEyRon3P6U8NC w+4Y0Pgj3G58fx6mie4U+RJfzFbFEblz5pKEsiN4M1xorgCxyLzIwpDrYPTFu8xx hnTR/4t0So3wSJW9aqxEFQhEUe2OIieWK/td40dM8w7axlXVaEmA== X-ME-Sender: X-Sasl-enc: YWmbqZ/QrNcKlh0xvwc0PNCzx21F0hF8Yjzx6uzukjMI 1507350549 Received: from intern.anarazel.de (unknown [136.24.76.72]) by mail.messagingengine.com (Postfix) with ESMTPA id 7E35B7E3E1; Sat, 7 Oct 2017 00:29:09 -0400 (EDT) Date: Fri, 6 Oct 2017 21:29:08 -0700 From: Andres Freund To: Ben Chobot Cc: Tom Lane , Michael Paquier , PostgreSQL mailing lists Subject: Re: pg_logical_slot_peek_changes crashes postgres when called from inside pl/pgsql Message-ID: <20171007042908.edlsalmkm2ksac4y@alap3.anarazel.de> References: <8637.1507217920@sss.pgh.pa.us> <20171005211058.z5obk2c2e7zvauk6@alap3.anarazel.de> <32374.1507239819@sss.pgh.pa.us> <20171005230105.qv2yrtadbkbc5y5r@alap3.anarazel.de> <4563.1507246950@sss.pgh.pa.us> <20171006052105.jfxllpi6lcu7q2a7@alap3.anarazel.de> <409.1507325342@sss.pgh.pa.us> <32118.1507332070@sss.pgh.pa.us> <34F8B14B-ABA4-45A3-92CE-2E1B755398EF@silentmedia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <34F8B14B-ABA4-45A3-92CE-2E1B755398EF@silentmedia.com> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 2017-10-06 21:24:34 -0700, Ben Chobot wrote: > > > On Oct 6, 2017, at 4:21 PM, Tom Lane wrote: > > > > I wrote: > >> I thought of a better way, as attached. > > > > Pushed. Ben, could you confirm that the committed patch fixes your > > original use-case? The 9.5 version of the patch is at > > > > https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=13d2ed921035f2d88adf87d796373e920bdd56ee > > Not quickly, to be honest. But the test case is not hard. If you can do this without crashing, I'm convinced you've fixed the problem as I've seen it: > > > SELECT * FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding'); > > CREATE TABLE public.foo(i int); > > insert into public.foo(i) values(1); > > CREATE OR REPLACE FUNCTION logical_replication_slot_lsn_delta(slot text) RETURNS pg_lsn AS > $$ > BEGIN > return location from pg_logical_slot_peek_changes(slot,null,1) limit 1; > END > $$ language plpgsql; > > select logical_replication_slot_lsn_delta('regression_slot'); Yep, that one's definitely fixed now. Greetings, Andres Freund -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs