MCPcopy Create free account
hub / github.com/pingcap/tidb / buildCompareClause

Function buildCompareClause

dumpling/export/sql.go:1113–1136  ·  view source on GitHub ↗

buildCompareClause build clause with specified bounds. Usually we will use the following two conditions: (compare, writeEqual) == (less, false), return quotaCols < bound clause. In other words, (-inf, bound) (compare, writeEqual) == (greater, true), return quotaCols >= bound clause. In other words,

(buf *bytes.Buffer, quotaCols []string, bound []string, compare byte, writeEqual bool)

Source from the content-addressed store, hash-verified

1111// (compare, writeEqual) == (less, false), return quotaCols < bound clause. In other words, (-inf, bound)
1112// (compare, writeEqual) == (greater, true), return quotaCols >= bound clause. In other words, [bound, +inf)
1113func buildCompareClause(buf *bytes.Buffer, quotaCols []string, bound []string, compare byte, writeEqual bool) { // revive:disable-line:flag-parameter
1114 for i, col := range quotaCols {
1115 if i > 0 {
1116 buf.WriteString("or(")
1117 }
1118 for j := 0; j < i; j++ {
1119 buf.WriteString(quotaCols[j])
1120 buf.WriteByte(equal)
1121 buf.WriteString(bound[j])
1122 buf.WriteString(" and ")
1123 }
1124 buf.WriteString(col)
1125 buf.WriteByte(compare)
1126 if writeEqual && i == len(quotaCols)-1 {
1127 buf.WriteByte(equal)
1128 }
1129 buf.WriteString(bound[i])
1130 if i > 0 {
1131 buf.WriteByte(')')
1132 } else if i != len(quotaCols)-1 {
1133 buf.WriteByte(' ')
1134 }
1135 }
1136}
1137
1138// getCommonLength returns the common length of low and up
1139func getCommonLength(low []string, up []string) int {

Callers 2

buildWhereClausesFunction · 0.85
buildBetweenClauseFunction · 0.85

Calls 1

WriteStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…