MCPcopy Create free account
hub / github.com/dolthub/doltgresql / connectionForQuery

Function connectionForQuery

testing/go/replication_test.go:679–697  ·  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

677
678// connectionForQuery returns the connection to use for the given query
679func connectionForQuery(t *testing.T, query string, connections map[string]*pgx.Conn, primaryDns string) *pgx.Conn {
680 target, client := clientSpecFromQueryComment(query)
681 var conn *pgx.Conn
682 switch target {
683 case "primary":
684 conn = connections[client]
685 if conn == nil {
686 var err error
687 conn, err = pgx.Connect(context.Background(), primaryDns)
688 require.NoError(t, err)
689 connections[client] = conn
690 }
691 case "replica":
692 conn = connections["replica"]
693 default:
694 require.Fail(t, "Invalid target in setup script: ", target)
695 }
696 return conn
697}
698
699// handlePseudoQuery handles special pseudo-queries that are used to orchestrate replication tests and returns whether
700// one was handled.

Callers 1

runReplicationScriptFunction · 0.85

Calls 2

ConnectMethod · 0.80

Tested by

no test coverage detected