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)
| 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 |
| 730 | func 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 | |
| 749 | func waitForRunning(r *logrepl.LogicalReplicator) error { |
| 750 | start := time.Now() |
no test coverage detected