jackc / pglogrepl

PostgreSQL logical replication library for Go.
MIT License
330 stars 62 forks source link

Always failed when passing wal2json plugin parameter #19

Closed devwlw closed 3 years ago

devwlw commented 3 years ago

I got an error when trying to pass parameters to the wal2json plugin.But it's ok without any parameters and run pg_recvlogical with parameters

postgresql version: 13 wal2json :2.3

golang code

slot := "slot_test"
args := []string{"pretty-print '1'", "add-tables 'public.book,public.users'"}
err = pglogrepl.StartReplication(context.Background(), s.con, slot, sysident.XLogPos, pglogrepl.StartReplicationOptions{PluginArgs: args})
if err != nil {
    panic(err)  
}

postgresql log(failed)

LOCATION:  exec_replication_command, walsender.c:1571
ERROR:  42601: syntax error
LOCATION:  replication_yyerror, repl_scanner.l:225

pg_recvlogical command

pg_recvlogical -d test --slot slot_test  --start -o pretty-print=1 -o add-tables="public.users,public.book"  -f -

pg_recvlogical command log(succssful)

LOG:  00000: statement: SELECT pg_catalog.set_config('search_path', '', false);
LOCATION:  exec_simple_query, postgres.c:1044
LOG:  00000: received replication command: SHOW data_directory_mode
LOCATION:  exec_replication_command, walsender.c:1571
LOG:  00000: received replication command: IDENTIFY_SYSTEM
LOCATION:  exec_replication_command, walsender.c:1571
LOG:  00000: received replication command: START_REPLICATION SLOT "slot_test" LOGICAL 0/0 ("pretty-print" '1', "add-tables" 'public.users,public.book')
LOCATION:  exec_replication_command, walsender.c:1571
LOG:  00000: starting logical decoding for slot "slot_test"
DETAIL:  Streaming transactions committing after 0/1636AA0, reading WAL from 0/16368E8.
LOCATION:  CreateDecodingContext, logical.c:450
LOG:  00000: logical decoding found consistent point at 0/16368E8
DETAIL:  There are no running transactions.
LOCATION:  SnapBuildFindSnapshot, snapbuild.c:1267
devwlw commented 3 years ago

I figured it out. Closing.

args := []string{"\"pretty-print\" '1'", "\"add-tables\" 'public.book,public.users'"}