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

Function clientSpecFromQueryComment

pgserver/logrepl/replication_test.go:890–907  ·  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

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
890func clientSpecFromQueryComment(query string) (string, string) {
891 startCommentIdx := strings.Index(query, "/*")
892 endCommentIdx := strings.Index(query, "*/")
893 if startCommentIdx < 0 || endCommentIdx < 0 {
894 return "primary", "a"
895 }
896
897 query = query[startCommentIdx+2 : endCommentIdx]
898 if strings.Contains(query, "replica") {
899 return "replica", "a"
900 }
901
902 if i := strings.Index(query, "primary "); i > 0 && i+len("primary ") < len(query) {
903 return "primary", query[i+len("primary "):]
904 }
905
906 return "primary", "a"
907}
908
909func waitForRunning(r *logrepl.LogicalReplicator) error {
910 start := time.Now()

Callers 2

runReplicationScriptFunction · 0.85
connectionForQueryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected