From f44106da82fbbec9896b4092342ab831847fedd3 Mon Sep 17 00:00:00 2001 From: TianyuZhang1214 Date: Tue, 26 Nov 2024 10:46:22 +0800 Subject: [PATCH] to #119 fix: get lsn before transaction. --- pgserver/subscription_handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pgserver/subscription_handler.go b/pgserver/subscription_handler.go index 3c3c074b..22848b31 100644 --- a/pgserver/subscription_handler.go +++ b/pgserver/subscription_handler.go @@ -32,7 +32,7 @@ type SubscriptionConfig struct { LSN pglogrepl.LSN } -var lsnQueryIndex = 5 +var lsnQueryIndex = 1 var subscriptionRegex = regexp.MustCompile(`(?i)CREATE SUBSCRIPTION\s+(\w+)\s+CONNECTION\s+'([^']+)'\s+PUBLICATION\s+(\w+);`) var connectionRegex = regexp.MustCompile(`(\b\w+)=([\w\.\d]*)`) @@ -52,9 +52,9 @@ func (config *SubscriptionConfig) ToDNS() string { func (config *SubscriptionConfig) ToDuckDBQuery() []string { return []string{ fmt.Sprintf("ATTACH '%s' AS pg_postgres (TYPE POSTGRES);", config.ToConnectionInfo()), + "SELECT * FROM postgres_query('pg_postgres', 'SELECT pg_current_wal_lsn()');", "BEGIN;", "COPY FROM DATABASE pg_postgres TO mysql;", - "SELECT * FROM postgres_query('pg_postgres', 'SELECT pg_current_wal_lsn()');", "COMMIT;", "DETACH pg_postgres;", }