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 1tvCT7-001umr-UC for pgsql-general@arkaria.postgresql.org; Thu, 20 Mar 2025 09:45:42 +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 1tvCT6-00107j-PP for pgsql-general@arkaria.postgresql.org; Thu, 20 Mar 2025 09:45:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tucc9-003iHd-Ue for pgsql-general@lists.postgresql.org; Tue, 18 Mar 2025 19:28:38 +0000 Received: from smtpout04.dka.mailcore.net ([185.138.56.204]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tucc6-003cX6-01 for pgsql-general@postgresql.org; Tue, 18 Mar 2025 19:28:37 +0000 Received: from SMTP.DKA.mailcore.net (unknown [10.1.0.52]) by SMTPOUT01.DKA.mailcore.net (Postfix) with ESMTP id CBE9FE0035 for ; Tue, 18 Mar 2025 20:28:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=online.ee; s=mailcore; t=1742326113; bh=qRTpOQhFnAiKvgY4UydtLnBcQeoj2jpD51ci00KlQUM=; h=Date:To:From:Subject:From; b=JUKySaJznqunZxEWuB0kg++g6wWhqj3lYDO2yPf1w0Bycc+1yQ8HrM+D3L+AMTa70 UU+w71l3LqXrlCZvhrRsq4lOEhR0aAx0mzPRicG9SKzyVWxbsLc2xEpo1woqlRZlKe oMoD2oLlsdmuKGWD2n4FqYNnjFCbMYyNmqYgAtZYsOXuXFsb/TuMwarhYtLOMhoXXU GSRz0/ZADrFNYZdDST8SmSN0YwBZ1M+4PJNRLFc2X3sE3tUeOgbwc8U0XAlGvAqYcV RI2qJaog2g7zpxq99VKyy4jAnrBiznkwPZIarEJFqDFZwis3WtadJ0jL4tS3QsTGkB s/irP4nP22ORA== Received: from [192.168.1.38] (73-142-35-213.sta.estpak.ee [213.35.142.73]) by SMTP.DKA.mailcore.net (Postfix) with ESMTPSA id B70C2400F2 for ; Tue, 18 Mar 2025 20:28:33 +0100 (CET) Content-Type: multipart/alternative; boundary="------------Y05GE0H7iUfzpazjlQfz050T" Message-ID: <3b0f2745-39dc-4b62-94ff-45641cef65c3@hot.ee> Date: Tue, 18 Mar 2025 21:28:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: et To: pgsql-general From: Andrus Subject: How to convert wal log to sql commands starting from specified time List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------Y05GE0H7iUfzpazjlQfz050T Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi! Postgres 14 hot standby server server is running in Debian Linux under WSL. It saves wal log from master to pg_wal directory. wal_keep size is 100GB. Command  pg_recvlogical -P pgoutput -o proto_version=1 -o publication_names=koiktabelid_pub --create-slot --start --slot=naitategevust --dbname=sba --file=tulem.log writes modification commands to file Command pg_recvlogical --create-slot --start --slot=naitategevust --dbname=sba --file=- show modification commands in screen. How to specify start time and number of commands to decode as pg_recvlogical parameters? Output is too verbose, contains data types. How show next 100 sql commands starting from from some date, eq from March 18,2025 14:21:00 ? If there is no ready solution, I can create ASP.NET MVC 9 controller for this. Controller should probably ask wal contents from server starting at this time using replication protocol or directly read wal files from pg_wal directory and decode them. Replication sample in https://www.npgsql.org/doc/replication.html shows how to decode realtime replication messages for single table. How to specify start time from which replication commands are retured? Or is there some exisising wal decoder in C# or as command-line utility? Posted also in https://stackoverflow.com/questions/79518438/how-to-convert-wal-log-to-sql-commands-from-given-time Andrus --------------Y05GE0H7iUfzpazjlQfz050T Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi!

Postgres 14 hot standby server server is running in Debian Linux under WSL. It saves wal log from master to pg_wal directory. wal_keep size is 100GB.

Command

 pg_recvlogical -P pgoutput -o proto_version=1 -o publication_names=koiktabelid_pub --create-slot --start --slot=naitategevust --dbname=sba --file=tulem.log

writes modification commands to file

Command

pg_recvlogical --create-slot --start --slot=naitategevust --dbname=sba --file=-

show modification commands in screen.

How to specify start time and number of commands to decode as pg_recvlogical parameters?

Output is too verbose, contains data types.

How show next 100 sql commands starting from from some date, eq from March 18,2025 14:21:00 ?

If there is no ready solution, I can create ASP.NET MVC 9 controller for this. Controller should probably ask wal contents from server starting at this time using replication protocol or directly read wal files from pg_wal directory and decode them.

Replication sample in https://www.npgsql.org/doc/replication.html
shows how to decode realtime replication messages for single table.

How to specify start time from which replication commands are retured? Or is there some exisising wal decoder in C# or as command-line utility?

Posted also in

https://stackoverflow.com/questions/79518438/how-to-convert-wal-log-to-sql-commands-from-given-time

Andrus

--------------Y05GE0H7iUfzpazjlQfz050T--