Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rONWO-003hG7-H5 for pgsql-general@arkaria.postgresql.org; Fri, 12 Jan 2024 19:48:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rONWN-0054Sk-Cw for pgsql-general@arkaria.postgresql.org; Fri, 12 Jan 2024 19:48:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rONWL-0054Sb-IQ for pgsql-general@lists.postgresql.org; Fri, 12 Jan 2024 19:48:51 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rONWI-001EHw-E0 for pgsql-general@lists.postgresql.org; Fri, 12 Jan 2024 19:48:48 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id DF7905C01BF; Fri, 12 Jan 2024 14:48:43 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Fri, 12 Jan 2024 14:48:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1705088923; x=1705175323; bh=0RFr3+StnvL4qSG4/v3dTTCmy4v6xUwpgtEJnCzksPo=; b= dNKawxKM0fvd6oLqPTVcxRqB64IYV8cAZqtCZl47nhpNSCGlYTIqZS1xZWx5+uDo Ejmrpc2gDHuVCTl8EA0RsXwdf+Z0KlNaoCVDJLjiEgoVRLqA0X1pjf2EgQqZ8SZD 2iOtzMipLqxEu6Zml4iAqcb9Ebes+16xeTqFIMzciW0w36PTUt5jB6ZWiZ+BDAHg 5zM7vZJVhOHNdsnb0gbCyqKqy17tgBtoHh4LXppXsIn3HChhaDtC/oKDfmknBBqr mRxsmn3HJRqnqS6Q2KNWH9mYpc9WPxm50EeJ5WTLO1v78NoeN210flxUQQ/MA16/ 5RwCsvO+F1YjTQtcalqXzw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1705088923; x= 1705175323; bh=0RFr3+StnvL4qSG4/v3dTTCmy4v6xUwpgtEJnCzksPo=; b=2 8yRNuHGP5r41jZNpcpG1V6hbqJZrFudI/Xhycc8XJeCf0QuEr8gPXHyWa6qDzO5d UIYXOiYWUqdJOxHLaM6wurUNOLDKASJd2frf/cbh6cMLrjoKz2mlKVHMBnkjHy0f N5+YihERbMT4AiljOFkId/sTA31g2NlPVKmtQt7s2/LLeHyOzjOytodLOI1fjvhj bWbTgRoUBJB0xykZRabnYfqn39uCzo8HLLuuCJ1z0byhSvw/YgLMTZ3ZR1hOLYCn iHaKJWbDq/EF3H74KPklSSAe2+mSAJKX2zZXuZnSXl9DPXrDHCwrEC4vyGvtVL0k JPb15FJJ3+O16QrGTXr0w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdeihedguddvjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuggftrfgrthhtvghrnhepffelgeeifefgveduhedthfekuedtffejveegffeg jeevtdehgfduieetfeehjeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 12 Jan 2024 14:48:43 -0500 (EST) Message-ID: Date: Fri, 12 Jan 2024 11:48:42 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: How to redirect output from PostgreSQL pg_recvlogical to a file or a pipe? Content-Language: en-US To: David Ventimiglia , pgsql-general@lists.postgresql.org References: From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/12/24 11:34, David Ventimiglia wrote: > Hello! How do I redirect logical decoding output from the PostgreSQL CLI > tool |pg_recvlogical| either to a file or to another command via a pipe? > I ask because when I try the obvious, no output is recorded or sent: > > |pg_recvlogical -d postgres --slot test --start -f - >> sample.jsonl | > > Lest there be any confusion, I already created the slot in an earlier > step. Moreover, I can verify that if I omit the output redirection |>> > sample| then it does work, insofar as it emits the expected change > events when I perform DML in another terminal window. When I include the > redirection (or alternatively, set up a pipeline), then nothing happens. You left out the important part of the SO question: pg_recvlogical -d postgres --slot test --create-slot -P wal2json I can get: pg_recvlogical -d postgres --slot test --start -f - >> sample.jsonl to work when I do: pg_recvlogical -d postgres --slot test --create-slot wal2json seems to be the issue. > > Note that I am aware of the option to pass a filename to the -f switch > to write to a file.  That works, but it's not what I'm after because it > doesn't help update my mental model of how this is supposed to work. > Based on my current (flawed) mental model built up from command line > experience with other tools, this /should/ work.  I should be able to > send the output to stdout and then redirect it to a file.  It surprises > me that I cannot. > > Anyway, thanks! > > Best, > > David > -- Adrian Klaver adrian.klaver@aklaver.com