MCPcopy Create free account
hub / github.com/apecloud/myduckserver / handlePseudoQuery

Function handlePseudoQuery

pgserver/logrepl/replication_test.go:861–886  ·  view source on GitHub ↗

handlePseudoQuery handles special pseudo-queries that are used to orchestrate replication tests and returns whether one was handled.

(t *testing.T, server *pgserver.Server, query string, r *logrepl.LogicalReplicator)

Source from the content-addressed store, hash-verified

859// handlePseudoQuery handles special pseudo-queries that are used to orchestrate replication tests and returns whether
860// one was handled.
861func handlePseudoQuery(t *testing.T, server *pgserver.Server, query string, r *logrepl.LogicalReplicator) bool {
862 switch query {
863 case createReplicationSlot:
864 require.NoError(t, r.CreateReplicationSlotIfNotExists(slotName))
865 return true
866 case dropReplicationSlot:
867 require.NoError(t, r.DropReplicationSlotIfExists(slotName))
868 return true
869 case startReplication:
870 go func() {
871 require.NoError(t, r.StartReplication(server.NewInternalCtx(), slotName))
872 }()
873 require.NoError(t, waitForRunning(r))
874 return true
875 case stopReplication:
876 r.Stop()
877 return true
878 case waitForCatchup:
879 require.NoError(t, waitForCaughtUp(r))
880 return true
881 case sleep:
882 time.Sleep(200 * time.Millisecond)
883 return true
884 }
885 return false
886}
887
888// clientSpecFromQueryComment returns "replica" if the query is meant to be run on the replica, and "primary" if it's meant
889// to be run on the primary, based on the comment in the query. If not comment, the query runs on the primary

Callers 1

runReplicationScriptFunction · 0.85

Calls 6

waitForRunningFunction · 0.85
waitForCaughtUpFunction · 0.85
StartReplicationMethod · 0.80
StopMethod · 0.45

Tested by

no test coverage detected