Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start gives (SQLSTATE 42601) #4

Open
greigwise opened this issue Oct 29, 2018 · 1 comment
Open

Start gives (SQLSTATE 42601) #4

greigwise opened this issue Oct 29, 2018 · 1 comment

Comments

@greigwise
Copy link

Hi there. Thanks for putting this code out here, it's been super helpful in understanding how the logical replication works. But a couple problems/questions:

  1. I found a problem with your example code. The last couple lines in the example look like this:
    replication := pgoutput.LogicalReplication{
    Subscription: "sub2",
    Publication: "pub2",
    WaitTimeout: time.Second * 10,
    StatusTimeout: time.Second * 10,
    Handler: handler,
    }

    if err := replication.Start(ctx, conn); err != nil {
    log.Fatal(err)
    }

     I think it should be written this way instead:
    

    replication := pgoutput.NewSubscription("test_subscription", "test_provider")

    if err := replication.Start(ctx, conn, handler); err != nil {
    log.Fatal(err)
    }

  2. The other thing is that when I make that fix and try to call Start, I get this:

2018/10/29 15:20:12 failed to start replication: ERROR: syntax error (SQLSTATE 42601)

I think that is because calling START REPLICATION on a slot with the pgoutput decoder type requires the pglogical extension to be present and for that publisher node to be created. It looks like pgoutput as a decoder is really only intended to be used if you're using the pglogical replication and not as a standalone decoder. I'm running on Postgres version 10.. maybe this works on an older version of postgres?

If I'm misunderstanding something I'd sure appreciate any clarification you could provide.

Thanks,
Greig Wise

@dgtony
Copy link

dgtony commented Nov 2, 2018

I've encountered this problem as well, seems that double parentheses breaks lexer.
It could be fixed by replacing sub.go:33:

return fmt.Sprintf(`("proto_version" '%s', "publication_names" '%s')`, version, publication)

with

return fmt.Sprintf(`"proto_version" '%s', "publication_names" '%s'`, version, publication)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants