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

Function connectionForQuery

pgserver/logrepl/replication_test.go:839–857  ·  view source on GitHub ↗

connectionForQuery returns the connection to use for the given query

(t *testing.T, query string, connections map[string]*pgx.Conn, primaryDns string)

Source from the content-addressed store, hash-verified

837
838// connectionForQuery returns the connection to use for the given query
839func connectionForQuery(t *testing.T, query string, connections map[string]*pgx.Conn, primaryDns string) *pgx.Conn {
840 target, client := clientSpecFromQueryComment(query)
841 var conn *pgx.Conn
842 switch target {
843 case "primary":
844 conn = connections[client]
845 if conn == nil {
846 var err error
847 conn, err = pgx.Connect(context.Background(), primaryDns)
848 require.NoError(t, err)
849 connections[client] = conn
850 }
851 case "replica":
852 conn = connections["replica"]
853 default:
854 require.Fail(t, "Invalid target in setup script: ", target)
855 }
856 return conn
857}
858
859// handlePseudoQuery handles special pseudo-queries that are used to orchestrate replication tests and returns whether
860// one was handled.

Callers 1

runReplicationScriptFunction · 0.85

Calls 2

ConnectMethod · 0.45

Tested by

no test coverage detected