// Substr calls the stored procedure 'pg_catalog.substr(bytea, integer, text, integer, bytea, integer, integer, text, integer, integer) bytea' on db.
327601
func Substr(db XODB, v0 []byte, v1 int, v2 string, v3 int, v4 []byte, v5 int, v6 int, v7 string, v8 int, v9 int) ([]byte, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.substr($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)`

	// run query
	var ret []byte
	XOLog(sqlstr, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9)
	err = db.QueryRow(sqlstr, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9).Scan(&ret)
	if err != nil {
		return nil, err
	}

	return ret, nil
}
977277
func (bA *BitArray) Sub(o *BitArray) *BitArray {
	if bA == nil || o == nil {
		// TODO: Decide if we should do 1's complement here?
		return nil
	}
	bA.mtx.Lock()
	o.mtx.Lock()
	// output is the same size as bA
	c := bA.copyBits(bA.Bits)
	// Only iterate to the minimum size between the two.
	// If o is longer, those bits are ignored.
	// If bA is longer, then skipping those iterations is equivalent
	// to right padding with 0's
	smaller := MinInt(len(bA.Elems), len(o.Elems))
	for i := 0; i < smaller; i++ {
		// &^ is and not in golang
		c.Elems[i] &^= o.Elems[i]
	}
	bA.mtx.Unlock()
	o.mtx.Unlock()
	return c
}
1023519
func (tr Row) Str(nn int) (str string) {
	switch data := tr[nn].(type) {
	case nil:
		// str = ""
	case []byte:
		str = string(data)
	case *[]byte:
		str = string(*data)
	case time.Time:
		str = TimeString(data)
	case time.Duration:
		str = DurationString(data)
	default:
		str = fmt.Sprint(data)
	}
	return
}
1368277
func (s *DB) SubQuery() *expr {
	scope := s.NewScope(s.Value)
	scope.InstanceSet("skip_bindvar", true)
	scope.prepareQuerySQL()

	return Expr(fmt.Sprintf("(%v)", scope.SQL), scope.SQLVars...)
}
1332927
func Sub(value string) string {
	i := `{ "Fn::Sub" : "` + value + `" }`
	return base64.StdEncoding.EncodeToString([]byte(i))
}
186068
func Hashstr(sep string) int {
	hash := uint32(0)
	for i := 0; i < len(sep); i++ {
		hash = hash*primeRK + uint32(sep[i])
	}
	return int(hash)
}
67085
func (t *tableCommon) genIndexKeyStr(colVals []types.Datum) (string, error) {
	// Pass pre-composed error to txn.
	strVals := make([]string, 0, len(colVals))
	for _, cv := range colVals {
		cvs := "NULL"
		var err error
		if !cv.IsNull() {
			cvs, err = types.ToString(cv.GetValue())
			if err != nil {
				return "", err
			}
		}
		strVals = append(strVals, cvs)
	}
	return strings.Join(strVals, "-"), nil
}
107541
func Regprocsend(db XODB, v0 pgtypes.Regproc) ([]byte, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.regprocsend($1)`

	// run query
	var ret []byte
	XOLog(sqlstr, v0)
	err = db.QueryRow(sqlstr, v0).Scan(&ret)
	if err != nil {
		return nil, err
	}

	return ret, nil
}
171558
func Smgrne(db XODB, v0 pgtypes.Smgr, v1 pgtypes.Smgr) (bool, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.smgrne($1, $2)`

	// run query
	var ret bool
	XOLog(sqlstr, v0, v1)
	err = db.QueryRow(sqlstr, v0, v1).Scan(&ret)
	if err != nil {
		return false, err
	}

	return ret, nil
}
1042050
func ASCII(db XODB, v0 string) (int, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.ascii($1)`

	// run query
	var ret int
	XOLog(sqlstr, v0)
	err = db.QueryRow(sqlstr, v0).Scan(&ret)
	if err != nil {
		return 0, err
	}

	return ret, nil
}
607537
func (vm *Engine) subScript() []parsedOpcode {
	return vm.scripts[vm.scriptIdx][vm.lastCodeSep:]
}
1354248
func StringRGBA(renderer *sdl.Renderer, x, y int32, s string, r, g, b, a uint8) bool {
	_x := C.Sint16(x)
	_y := C.Sint16(y)
	_s := C.CString(s)
	_r := C.Uint8(r)
	_g := C.Uint8(g)
	_b := C.Uint8(b)
	_a := C.Uint8(a)
	return C.stringRGBA((*C.SDL_Renderer)(unsafe.Pointer(renderer)), _x, _y, _s, _r, _g, _b, _a) == 0
}
1194198
func (a *Array) Str(val string) *Array {
	a.buf = enc.AppendString(enc.AppendArrayDelim(a.buf), val)
	return a
}
1056338
func (r *Rand) Str(length int) string {
	chars := []byte{}
MAIN_LOOP:
	for {
		val := r.Int63()
		for i := 0; i < 10; i++ {
			v := int(val & 0x3f) // rightmost 6 bits
			if v >= 62 {         // only 62 characters in strChars
				val >>= 6
				continue
			} else {
				chars = append(chars, strChars[v])
				if len(chars) == length {
					break MAIN_LOOP
				}
				val >>= 6
			}
		}
	}

	return string(chars)
}
827605
func (statement *Statement) Decr(column string, arg ...interface{}) *Statement {
	k := strings.ToLower(column)
	if len(arg) > 0 {
		statement.decrColumns[k] = decrParam{column, arg[0]}
	} else {
		statement.decrColumns[k] = decrParam{column, 1}
	}
	return statement
}
257921
func (node *PartialStatement) String() string {
	return fmt.Sprintf("Partial{Name:%s, Pos:%d}", node.Name, node.Loc.Pos)
}
505558
func BstrToString(p *uint16) string {
	if p == nil {
		return ""
	}
	length := SysStringLen((*int16)(unsafe.Pointer(p)))
	a := make([]uint16, length)

	ptr := unsafe.Pointer(p)

	for i := 0; i < int(length); i++ {
		a[i] = *(*uint16)(ptr)
		ptr = unsafe.Pointer(uintptr(ptr) + 2)
	}
	return string(utf16.Decode(a))
}