MCPcopy
hub / github.com/github/gh-ost / buildTwoColumnUnionParts

Function buildTwoColumnUnionParts

go/sql/builder.go:585–616  ·  view source on GitHub ↗
(
	selectClause, fromClause string,
	col1Name, col2Name string,
	col1StartVal, col2StartVal, col1EndVal, col2EndVal string,
	col2StartOp, partSuffix string,
	rangeStartArgs, rangeEndArgs []interface{},
)

Source from the content-addressed store, hash-verified

583}
584
585func buildTwoColumnUnionParts(
586 selectClause, fromClause string,
587 col1Name, col2Name string,
588 col1StartVal, col2StartVal, col1EndVal, col2EndVal string,
589 col2StartOp, partSuffix string,
590 rangeStartArgs, rangeEndArgs []interface{},
591) (part1, part2, part3 string, explodedArgs []interface{}) {
592 part1 = fmt.Sprintf(
593 `(select %s from %s where %s = %s and %s %s %s %s)`,
594 selectClause, fromClause,
595 col1Name, col1StartVal, col2Name, col2StartOp, col2StartVal,
596 partSuffix,
597 )
598 explodedArgs = append(explodedArgs, rangeStartArgs[0], rangeStartArgs[1])
599
600 part2 = fmt.Sprintf(
601 `(select %s from %s where %s > %s and %s < %s %s)`,
602 selectClause, fromClause,
603 col1Name, col1StartVal, col1Name, col1EndVal,
604 partSuffix,
605 )
606 explodedArgs = append(explodedArgs, rangeStartArgs[0], rangeEndArgs[0])
607
608 part3 = fmt.Sprintf(
609 `(select %s from %s where %s = %s and %s <= %s %s)`,
610 selectClause, fromClause,
611 col1Name, col1EndVal, col2Name, col2EndVal,
612 partSuffix,
613 )
614 explodedArgs = append(explodedArgs, rangeEndArgs[0], rangeEndArgs[1])
615 return
616}
617
618func buildUniqueKeyRangeEndTwoColumnViaOffset(
619 databaseName, tableName string,

Calls

no outgoing calls

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…