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

Function clientSpecFromQueryComment

testing/go/replication_test.go:730–747  ·  view source on GitHub ↗

clientSpecFromQueryComment returns "replica" if the query is meant to be run on the replica, and "primary" if it's meant to be run on the primary, based on the comment in the query. If not comment, the query runs on the primary

(query string)

Source from the content-addressed store, hash-verified

728// clientSpecFromQueryComment returns "replica" if the query is meant to be run on the replica, and "primary" if it's meant
729// to be run on the primary, based on the comment in the query. If not comment, the query runs on the primary
730func clientSpecFromQueryComment(query string) (string, string) {
731 startCommentIdx := strings.Index(query, "/*")
732 endCommentIdx := strings.Index(query, "*/")
733 if startCommentIdx < 0 || endCommentIdx < 0 {
734 return "primary", "a"
735 }
736
737 query = query[startCommentIdx+2 : endCommentIdx]
738 if strings.Contains(query, "replica") {
739 return "replica", "a"
740 }
741
742 if i := strings.Index(query, "primary "); i > 0 && i+len("primary ") < len(query) {
743 return "primary", query[i+len("primary "):]
744 }
745
746 return "primary", "a"
747}
748
749func waitForRunning(r *logrepl.LogicalReplicator) error {
750 start := time.Now()

Callers 2

runReplicationScriptFunction · 0.85
connectionForQueryFunction · 0.85

Calls 1

ContainsMethod · 0.45

Tested by

no test coverage detected