mirror of https://github.com/jackc/pgx.git
Merge pull request #389 from steampunkcoder/FixStartReplicationSyntaxError
Fix syntax error in replication protocol msg issued by StartReplication()pull/392/head
commit
606697ffdf
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
@ -401,15 +402,14 @@ func (rc *ReplicationConn) TimelineHistory(timeline int) (r *Rows, err error) {
|
|||
// This function assumes that slotName has already been created. In order to omit the timeline argument
|
||||
// pass a -1 for the timeline to get the server default behavior.
|
||||
func (rc *ReplicationConn) StartReplication(slotName string, startLsn uint64, timeline int64, pluginArguments ...string) (err error) {
|
||||
var queryString string
|
||||
queryString := fmt.Sprintf("START_REPLICATION SLOT %s LOGICAL %s", slotName, FormatLSN(startLsn))
|
||||
if timeline >= 0 {
|
||||
queryString = fmt.Sprintf("START_REPLICATION SLOT %s LOGICAL %s TIMELINE %d", slotName, FormatLSN(startLsn), timeline)
|
||||
} else {
|
||||
queryString = fmt.Sprintf("START_REPLICATION SLOT %s LOGICAL %s", slotName, FormatLSN(startLsn))
|
||||
timelineOption := fmt.Sprintf("TIMELINE %d", timeline)
|
||||
pluginArguments = append(pluginArguments, timelineOption)
|
||||
}
|
||||
|
||||
for _, arg := range pluginArguments {
|
||||
queryString += fmt.Sprintf(" %s", arg)
|
||||
if len(pluginArguments) > 0 {
|
||||
queryString += fmt.Sprintf(" ( %s )", strings.Join(pluginArguments, ", "))
|
||||
}
|
||||
|
||||
if err = rc.c.sendQuery(queryString); err != nil {
|
||||
|
|
Loading…
Reference in New Issue