// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. //go:build (linux && arm64) || (linux && ppc64le) || (linux && riscv64) package sqlite3 import ( "unsafe" "modernc.org/libc" ) // C documentation // // /* // ** Render a string given by "fmt" into the StrAccum object. // */ func Xsqlite3_str_vappendf(tls *libc.TLS, pAccum uintptr, fmt uintptr, ap Tva_list) { bp := tls.Alloc(128) defer tls.Free(128) var adj, c, e2, exp, iRound, idx, ii, ix, j, length, nOut, needQuote, nn, nn1, nn2, nn3, precision, width, x, v2, v3 int32 var bArgList, base Tu8 var bufpt, cset, escarg, infop, pArgList, pExpr, pItem, pSel, pToken, pre, z, zExtra, zOut, v4 uintptr var cThousand, done, flag_alternateform, flag_altform2, flag_dp, flag_leftjustify, flag_long, flag_prefix, flag_rtz, flag_zeropad, xtype, v5, v6, v7, v8, v9 TetByte var ch, px, wx uint32 var ch1, prefix, q, x1, v54 uint8 var i, j1, k, n1, nBack, nCopyBytes, nCtrl, nPad, nPrior, szBufNeeded, v, v90 Ti64 var longvalue Tsqlite_uint64 var n Tu64 var realvalue float64 var v12 bool var _ /* buf at bp+0 */ [70]uint8 var _ /* s at bp+72 */ TFpDecode _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = adj, bArgList, base, bufpt, c, cThousand, ch, ch1, cset, done, e2, escarg, exp, flag_alternateform, flag_altform2, flag_dp, flag_leftjustify, flag_long, flag_prefix, flag_rtz, flag_zeropad, i, iRound, idx, ii, infop, ix, j, j1, k, length, longvalue, n, n1, nBack, nCopyBytes, nCtrl, nOut, nPad, nPrior, needQuote, nn, nn1, nn2, nn3, pArgList, pExpr, pItem, pSel, pToken, pre, precision, prefix, px, q, realvalue, szBufNeeded, v, width, wx, x, x1, xtype, z, zExtra, zOut, v12, v2, v3, v4, v5, v54, v6, v7, v8, v9, v90 /* Thousands separator for %d and %u */ xtype = uint8(etINVALID) /* Size of the rendering buffer */ zExtra = uintptr(0) /* True if trailing zeros should be removed */ pArgList = uintptr(0) /* Conversion buffer */ /* pAccum never starts out with an empty buffer that was obtained from ** malloc(). This precondition is required by the mprintf("%z...") ** optimization. */ bufpt = uintptr(0) if libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags)&int32(SQLITE_PRINTF_SQLFUNC) != 0 { pArgList = libc.VaUintptr(&ap) bArgList = uint8(1) } else { bArgList = uint8(0) } for { v2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(fmt))) c = v2 if !(v2 != 0) { break } if c != int32('%') { bufpt = fmt fmt = libc.Xstrchr(tls, fmt, int32('%')) if fmt == uintptr(0) { fmt = bufpt + uintptr(libc.Xstrlen(tls, bufpt)) } Xsqlite3_str_append(tls, pAccum, bufpt, int32(int64(fmt)-int64(bufpt))) if libc.Int32FromUint8(**(**uint8)(__ccgo_up(fmt))) == 0 { break } } fmt = fmt + 1 v4 = fmt v2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) c = v2 if v2 == 0 { Xsqlite3_str_append(tls, pAccum, __ccgo_ts+1688, int32(1)) break } /* Find out what flags are present */ v9 = libc.Uint8FromInt32(0) flag_zeropad = v9 v8 = v9 flag_altform2 = v8 v7 = v8 flag_alternateform = v7 v6 = v7 cThousand = v6 v5 = v6 flag_prefix = v5 flag_leftjustify = v5 done = uint8(0) width = 0 flag_long = uint8(0) precision = -int32(1) for { switch c { case int32('-'): flag_leftjustify = uint8(1) case int32('+'): flag_prefix = uint8('+') case int32(' '): flag_prefix = uint8(' ') case int32('#'): flag_alternateform = uint8(1) case int32('!'): flag_altform2 = uint8(1) case int32('0'): flag_zeropad = uint8(1) case int32(','): cThousand = uint8(',') default: done = uint8(1) case int32('l'): flag_long = uint8(1) fmt = fmt + 1 v4 = fmt c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) if c == int32('l') { fmt = fmt + 1 v4 = fmt c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) flag_long = uint8(2) } done = uint8(1) case int32('1'): fallthrough case int32('2'): fallthrough case int32('3'): fallthrough case int32('4'): fallthrough case int32('5'): fallthrough case int32('6'): fallthrough case int32('7'): fallthrough case int32('8'): fallthrough case int32('9'): wx = libc.Uint32FromInt32(c - int32('0')) for { fmt = fmt + 1 v4 = fmt v2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) c = v2 if !(v2 >= int32('0') && c <= int32('9')) { break } wx = wx*uint32(10) + libc.Uint32FromInt32(c) - uint32('0') } width = libc.Int32FromUint32(wx & uint32(0x7fffffff)) if c != int32('.') && c != int32('l') { done = uint8(1) } else { fmt = fmt - 1 } case int32('*'): if bArgList != 0 { width = int32(_getIntArg(tls, pArgList)) } else { width = libc.VaInt32(&ap) } if width < 0 { flag_leftjustify = uint8(1) if width >= -int32(2147483647) { v2 = -width } else { v2 = 0 } width = v2 } v2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(fmt + 1))) c = v2 if v2 != int32('.') && c != int32('l') { fmt = fmt + 1 v4 = fmt c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) done = uint8(1) } case int32('.'): fmt = fmt + 1 v4 = fmt c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) if c == int32('*') { if bArgList != 0 { precision = int32(_getIntArg(tls, pArgList)) } else { precision = libc.VaInt32(&ap) } if precision < 0 { if precision >= -int32(2147483647) { v2 = -precision } else { v2 = -int32(1) } precision = v2 } fmt = fmt + 1 v4 = fmt c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) } else { px = uint32(0) for c >= int32('0') && c <= int32('9') { px = px*uint32(10) + libc.Uint32FromInt32(c) - uint32('0') fmt = fmt + 1 v4 = fmt c = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) } precision = libc.Int32FromUint32(px & uint32(0x7fffffff)) } if c == int32('l') { fmt = fmt - 1 } else { done = uint8(1) } break } goto _13 _13: ; if v12 = !(done != 0); v12 { fmt = fmt + 1 v4 = fmt v2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) c = v2 } if !(v12 && v2 != 0) { break } } /* Fetch the info entry for the field */ /* Fast hash-table lookup */ idx = libc.Int32FromUint32(libc.Uint32FromInt32(c) % uint32(23)) if v12 = libc.Int32FromUint8(_fmtinfo[idx].Ffmttype) == c; !v12 { v2 = libc.Int32FromUint8(_fmtinfo[idx].FiNxt) idx = v2 } if v12 || libc.Int32FromUint8(_fmtinfo[v2].Ffmttype) == c { infop = uintptr(unsafe.Pointer(&_fmtinfo)) + uintptr(idx)*7 xtype = (*Tet_info)(unsafe.Pointer(infop)).Ftype1 } else { infop = uintptr(unsafe.Pointer(&_fmtinfo)) xtype = uint8(etINVALID) } /* ** At this point, variables are initialized as follows: ** ** flag_alternateform TRUE if a '#' is present. ** flag_altform2 TRUE if a '!' is present. ** flag_prefix '+' or ' ' or zero ** flag_leftjustify TRUE if a '-' is present or if the ** field width was negative. ** flag_zeropad TRUE if the width began with 0. ** flag_long 1 for "l", 2 for "ll" ** width The specified field width. This is ** always non-negative. Zero is the default. ** precision The specified precision. The default ** is -1. ** xtype The class of the conversion. ** infop Pointer to the appropriate info struct. */ switch libc.Int32FromUint8(xtype) { case int32(etPOINTER): goto _27 case etRADIX: goto _28 case int32(etORDINAL): goto _29 case int32(etDECIMAL): goto _30 case int32(etGENERIC): goto _31 case int32(etEXP): goto _32 case int32(etFLOAT): goto _33 case int32(etSIZE): goto _34 case int32(etPERCENT): goto _35 case int32(etCHARX): goto _36 case int32(etDYNSTRING): goto _37 case int32(etSTRING): goto _38 case int32(etESCAPE_w): goto _39 case int32(etESCAPE_Q): goto _40 case int32(etESCAPE_q): goto _41 case int32(etTOKEN): goto _42 case int32(etSRCITEM): goto _43 default: goto _44 } goto _45 _27: ; flag_long = uint8(2) _29: ; _28: ; cThousand = uint8(0) _30: ; if libc.Int32FromUint8((*Tet_info)(unsafe.Pointer(infop)).Fflags)&int32(FLAG_SIGNED) != 0 { if bArgList != 0 { v = _getIntArg(tls, pArgList) } else { if flag_long != 0 { if libc.Int32FromUint8(flag_long) == int32(2) { v = libc.VaInt64(&ap) } else { v = int64(libc.VaInt64(&ap)) } } else { v = int64(libc.VaInt32(&ap)) } } if v < 0 { longvalue = libc.Uint64FromInt64(^v) longvalue = longvalue + 1 prefix = uint8('-') } else { longvalue = libc.Uint64FromInt64(v) prefix = flag_prefix } } else { if bArgList != 0 { longvalue = libc.Uint64FromInt64(_getIntArg(tls, pArgList)) } else { if flag_long != 0 { if libc.Int32FromUint8(flag_long) == int32(2) { longvalue = libc.VaUint64(&ap) } else { longvalue = uint64(libc.VaUint64(&ap)) } } else { longvalue = uint64(libc.VaUint32(&ap)) } } prefix = uint8(0) } if longvalue == uint64(0) { flag_alternateform = uint8(0) } if flag_zeropad != 0 && precision < width-libc.BoolInt32(libc.Int32FromUint8(prefix) != 0) { precision = width - libc.BoolInt32(libc.Int32FromUint8(prefix) != 0) } if precision < libc.Int32FromInt32(SQLITE_PRINT_BUF_SIZE)-libc.Int32FromInt32(10)-libc.Int32FromInt32(SQLITE_PRINT_BUF_SIZE)/libc.Int32FromInt32(3) { nOut = int32(SQLITE_PRINT_BUF_SIZE) zOut = bp } else { n = libc.Uint64FromInt32(precision) + uint64(10) if cThousand != 0 { n = n + libc.Uint64FromInt32(precision/int32(3)) } v4 = _printfTempBuf(tls, pAccum, libc.Int64FromUint64(n)) zExtra = v4 zOut = v4 if zOut == uintptr(0) { return } nOut = libc.Int32FromUint64(n) } bufpt = zOut + uintptr(nOut-int32(1)) if libc.Int32FromUint8(xtype) == int32(etORDINAL) { x = libc.Int32FromUint64(longvalue % libc.Uint64FromInt32(10)) if x >= int32(4) || longvalue/uint64(10)%uint64(10) == uint64(1) { x = 0 } bufpt = bufpt - 1 v4 = bufpt **(**uint8)(__ccgo_up(v4)) = _zOrd[x*int32(2)+int32(1)] bufpt = bufpt - 1 v4 = bufpt **(**uint8)(__ccgo_up(v4)) = _zOrd[x*int32(2)] } cset = uintptr(unsafe.Pointer(&_aDigits)) + uintptr((*Tet_info)(unsafe.Pointer(infop)).Fcharset) base = (*Tet_info)(unsafe.Pointer(infop)).Fbase for cond := true; cond; cond = longvalue > uint64(0) { /* Convert to ascii */ bufpt = bufpt - 1 v4 = bufpt **(**uint8)(__ccgo_up(v4)) = **(**uint8)(__ccgo_up(cset + uintptr(longvalue%uint64(base)))) longvalue = longvalue / uint64(base) } length = int32(t__predefined_ptrdiff_t(zOut+uintptr(nOut-int32(1))) - int64(bufpt)) if precision > length { /* zero pad */ nn = precision - length bufpt = bufpt - uintptr(nn) libc.Xmemset(tls, bufpt, int32('0'), libc.Uint64FromInt32(nn)) length = precision } if cThousand != 0 { nn1 = (length - int32(1)) / int32(3) /* Number of "," to insert */ ix = (length-int32(1))%int32(3) + int32(1) bufpt = bufpt - uintptr(nn1) idx = 0 for { if !(nn1 > 0) { break } **(**uint8)(__ccgo_up(bufpt + uintptr(idx))) = **(**uint8)(__ccgo_up(bufpt + uintptr(idx+nn1))) ix = ix - 1 if ix == 0 { idx = idx + 1 v2 = idx **(**uint8)(__ccgo_up(bufpt + uintptr(v2))) = cThousand nn1 = nn1 - 1 ix = int32(3) } goto _50 _50: ; idx = idx + 1 } } if prefix != 0 { bufpt = bufpt - 1 v4 = bufpt **(**uint8)(__ccgo_up(v4)) = prefix } /* Add sign */ if flag_alternateform != 0 && (*Tet_info)(unsafe.Pointer(infop)).Fprefix != 0 { pre = uintptr(unsafe.Pointer(&_aPrefix)) + uintptr((*Tet_info)(unsafe.Pointer(infop)).Fprefix) for { v54 = **(**uint8)(__ccgo_up(pre)) x1 = v54 if !(libc.Int32FromUint8(v54) != 0) { break } bufpt = bufpt - 1 v4 = bufpt **(**uint8)(__ccgo_up(v4)) = x1 goto _53 _53: ; pre = pre + 1 } } length = int32(t__predefined_ptrdiff_t(zOut+uintptr(nOut-int32(1))) - int64(bufpt)) goto _45 _33: ; _32: ; _31: ; /* Size needed to hold the output */ if bArgList != 0 { realvalue = _getDoubleArg(tls, pArgList) } else { realvalue = libc.VaFloat64(&ap) } if precision < 0 { precision = int32(6) } /* Set default precision */ if precision > int32(SQLITE_FP_PRECISION_LIMIT) { precision = int32(SQLITE_FP_PRECISION_LIMIT) } if libc.Int32FromUint8(xtype) == int32(etFLOAT) { iRound = -precision } else { if libc.Int32FromUint8(xtype) == int32(etGENERIC) { if precision == 0 { precision = int32(1) } iRound = precision } else { iRound = precision + int32(1) } } if flag_altform2 != 0 { v2 = int32(20) } else { v2 = int32(16) } _sqlite3FpDecode(tls, bp+72, realvalue, iRound, v2) if (**(**TFpDecode)(__ccgo_up(bp + 72))).FisSpecial != 0 { if libc.Int32FromUint8((**(**TFpDecode)(__ccgo_up(bp + 72))).FisSpecial) == int32(2) { if flag_zeropad != 0 { v4 = __ccgo_ts + 1690 } else { v4 = __ccgo_ts + 1695 } bufpt = v4 length = _sqlite3Strlen30(tls, bufpt) goto _45 } else { if flag_zeropad != 0 { **(**uint8)(__ccgo_up((**(**TFpDecode)(__ccgo_up(bp + 72))).Fz)) = uint8('9') (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP = int32(1000) (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn = int32(1) } else { libc.Xmemcpy(tls, bp, __ccgo_ts+1699, uint64(5)) bufpt = bp if libc.Int32FromUint8((**(**TFpDecode)(__ccgo_up(bp + 72))).Fsign) == int32('-') { /* no-op */ } else { if flag_prefix != 0 { (**(**[70]uint8)(__ccgo_up(bp)))[0] = flag_prefix } else { bufpt = bufpt + 1 } } length = _sqlite3Strlen30(tls, bufpt) goto _45 } } } if libc.Int32FromUint8((**(**TFpDecode)(__ccgo_up(bp + 72))).Fsign) == int32('-') { if flag_alternateform != 0 && !(flag_prefix != 0) && libc.Int32FromUint8(xtype) == int32(etFLOAT) && (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP <= iRound { /* Suppress the minus sign if all of the following are true: ** * The value displayed is zero ** * The '#' flag is used ** * The '+' flag is not used, and ** * The format is %f */ prefix = uint8(0) } else { prefix = uint8('-') } } else { prefix = flag_prefix } exp = (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP - int32(1) /* ** If the field type is etGENERIC, then convert to either etEXP ** or etFLOAT, as appropriate. */ if libc.Int32FromUint8(xtype) == int32(etGENERIC) { precision = precision - 1 flag_rtz = libc.BoolUint8(!(flag_alternateform != 0)) if exp < -int32(4) || exp > precision { xtype = uint8(etEXP) } else { precision = precision - exp xtype = uint8(etFLOAT) } } else { flag_rtz = flag_altform2 } if libc.Int32FromUint8(xtype) == int32(etEXP) { e2 = 0 } else { e2 = (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP - int32(1) } if e2 > 0 { v2 = e2 } else { v2 = 0 } szBufNeeded = int64(v2) + int64(precision) + int64(width) + int64(10) if cThousand != 0 && e2 > 0 { szBufNeeded = szBufNeeded + int64((e2+int32(2))/int32(3)) } if szBufNeeded+libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar) >= libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnAlloc) { if (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FmxAlloc == uint32(0) && libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == 0 { /* Unable to allocate space in pAccum, perhaps because it ** is coming from sqlite3_snprintf() or similar. We'll have ** to render into temporary space and the memcpy() it over. */ bufpt = Xsqlite3_malloc(tls, int32(szBufNeeded)) if bufpt == uintptr(0) { _sqlite3StrAccumSetError(tls, pAccum, uint8(SQLITE_NOMEM)) return } zExtra = bufpt } else { if int64(_sqlite3StrAccumEnlarge(tls, pAccum, szBufNeeded)) < szBufNeeded { v2 = libc.Int32FromInt32(0) length = v2 width = v2 goto _45 } else { bufpt = (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FzText + uintptr((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar) } } } else { bufpt = (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FzText + uintptr((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar) } zOut = bufpt if precision > 0 { v2 = int32(1) } else { v2 = 0 } flag_dp = libc.Uint8FromInt32(v2 | libc.Int32FromUint8(flag_alternateform) | libc.Int32FromUint8(flag_altform2)) /* The sign in front of the number */ if prefix != 0 { v4 = bufpt bufpt = bufpt + 1 **(**uint8)(__ccgo_up(v4)) = prefix } /* Digits prior to the decimal point */ j = 0 if e2 < 0 { v4 = bufpt bufpt = bufpt + 1 **(**uint8)(__ccgo_up(v4)) = uint8('0') } else { if cThousand != 0 { for { if !(e2 >= 0) { break } v4 = bufpt bufpt = bufpt + 1 if j < (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn { v3 = j j = j + 1 v2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up((**(**TFpDecode)(__ccgo_up(bp + 72))).Fz + uintptr(v3)))) } else { v2 = int32('0') } **(**uint8)(__ccgo_up(v4)) = libc.Uint8FromInt32(v2) if e2%int32(3) == 0 && e2 > int32(1) { v4 = bufpt bufpt = bufpt + 1 **(**uint8)(__ccgo_up(v4)) = uint8(',') } goto _63 _63: ; e2 = e2 - 1 } } else { j = e2 + int32(1) if j > (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn { j = (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn } libc.Xmemcpy(tls, bufpt, (**(**TFpDecode)(__ccgo_up(bp + 72))).Fz, libc.Uint64FromInt32(j)) bufpt = bufpt + uintptr(j) e2 = e2 - j if e2 >= 0 { libc.Xmemset(tls, bufpt, int32('0'), libc.Uint64FromInt32(e2+int32(1))) bufpt = bufpt + uintptr(e2+int32(1)) e2 = -int32(1) } } } /* The decimal point */ if flag_dp != 0 { v4 = bufpt bufpt = bufpt + 1 **(**uint8)(__ccgo_up(v4)) = uint8('.') } /* "0" digits after the decimal point but before the first ** significant digit of the number */ if e2 < -int32(1) && precision > 0 { nn2 = -int32(1) - e2 if nn2 > precision { nn2 = precision } libc.Xmemset(tls, bufpt, int32('0'), libc.Uint64FromInt32(nn2)) bufpt = bufpt + uintptr(nn2) precision = precision - nn2 } /* Significant digits after the decimal point */ if precision > 0 { nn3 = (**(**TFpDecode)(__ccgo_up(bp + 72))).Fn - j if nn3 > precision { nn3 = precision } if nn3 > 0 { libc.Xmemcpy(tls, bufpt, (**(**TFpDecode)(__ccgo_up(bp + 72))).Fz+uintptr(j), libc.Uint64FromInt32(nn3)) bufpt = bufpt + uintptr(nn3) precision = precision - nn3 } if precision > 0 && !(flag_rtz != 0) { libc.Xmemset(tls, bufpt, int32('0'), libc.Uint64FromInt32(precision)) bufpt = bufpt + uintptr(precision) } } /* Remove trailing zeros and the "." if no digits follow the "." */ if flag_rtz != 0 && flag_dp != 0 { for libc.Int32FromUint8(**(**uint8)(__ccgo_up(bufpt + uintptr(-libc.Int32FromInt32(1))))) == int32('0') { bufpt = bufpt - 1 v4 = bufpt **(**uint8)(__ccgo_up(v4)) = uint8(0) } if libc.Int32FromUint8(**(**uint8)(__ccgo_up(bufpt + uintptr(-libc.Int32FromInt32(1))))) == int32('.') { if flag_altform2 != 0 { v4 = bufpt bufpt = bufpt + 1 **(**uint8)(__ccgo_up(v4)) = uint8('0') } else { bufpt = bufpt - 1 v4 = bufpt **(**uint8)(__ccgo_up(v4)) = uint8(0) } } } /* Add the "eNNN" suffix */ if libc.Int32FromUint8(xtype) == int32(etEXP) { exp = (**(**TFpDecode)(__ccgo_up(bp + 72))).FiDP - int32(1) v4 = bufpt bufpt = bufpt + 1 **(**uint8)(__ccgo_up(v4)) = _aDigits[(*Tet_info)(unsafe.Pointer(infop)).Fcharset] if exp < 0 { v4 = bufpt bufpt = bufpt + 1 **(**uint8)(__ccgo_up(v4)) = uint8('-') exp = -exp } else { v4 = bufpt bufpt = bufpt + 1 **(**uint8)(__ccgo_up(v4)) = uint8('+') } if exp >= int32(100) { v4 = bufpt bufpt = bufpt + 1 **(**uint8)(__ccgo_up(v4)) = libc.Uint8FromInt32(exp/libc.Int32FromInt32(100) + libc.Int32FromUint8('0')) /* 100's digit */ exp = exp % int32(100) } v4 = bufpt bufpt = bufpt + 1 **(**uint8)(__ccgo_up(v4)) = libc.Uint8FromInt32(exp/libc.Int32FromInt32(10) + libc.Int32FromUint8('0')) /* 10's digit */ v4 = bufpt bufpt = bufpt + 1 **(**uint8)(__ccgo_up(v4)) = libc.Uint8FromInt32(exp%libc.Int32FromInt32(10) + libc.Int32FromUint8('0')) /* 1's digit */ } length = int32(int64(bufpt) - int64(zOut)) if length < width { nPad = int64(width - length) if flag_leftjustify != 0 { libc.Xmemset(tls, bufpt, int32(' '), libc.Uint64FromInt64(nPad)) } else { if !(flag_zeropad != 0) { libc.Xmemmove(tls, zOut+uintptr(nPad), zOut, libc.Uint64FromInt32(length)) libc.Xmemset(tls, zOut, int32(' '), libc.Uint64FromInt64(nPad)) } else { adj = libc.BoolInt32(libc.Int32FromUint8(prefix) != 0) libc.Xmemmove(tls, zOut+uintptr(nPad)+uintptr(adj), zOut+uintptr(adj), libc.Uint64FromInt32(length-adj)) libc.Xmemset(tls, zOut+uintptr(adj), int32('0'), libc.Uint64FromInt64(nPad)) } } length = width } if zExtra == uintptr(0) { /* The result is being rendered directory into pAccum. This ** is the command and fast case */ **(**Tu32)(__ccgo_up(pAccum + 24)) += libc.Uint32FromInt32(length) **(**uint8)(__ccgo_up(zOut + uintptr(length))) = uint8(0) goto _1 } else { /* We were unable to render directly into pAccum because we ** couldn't allocate sufficient memory. We need to memcpy() ** the rendering (or some prefix thereof) into the output ** buffer. */ **(**uint8)(__ccgo_up(bufpt)) = uint8(0) bufpt = zExtra goto _45 } _34: ; if !(bArgList != 0) { **(**int32)(__ccgo_up(libc.VaUintptr(&ap))) = libc.Int32FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar) } v2 = libc.Int32FromInt32(0) width = v2 length = v2 goto _45 _35: ; (**(**[70]uint8)(__ccgo_up(bp)))[0] = uint8('%') bufpt = bp length = int32(1) goto _45 _36: ; if bArgList != 0 { bufpt = _getTextArg(tls, pArgList) length = int32(1) if bufpt != 0 { v4 = bufpt bufpt = bufpt + 1 v2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) c = v2 (**(**[70]uint8)(__ccgo_up(bp)))[0] = libc.Uint8FromInt32(v2) if c&int32(0xc0) == int32(0xc0) { for length < int32(4) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(bufpt)))&int32(0xc0) == int32(0x80) { v2 = length length = length + 1 v4 = bufpt bufpt = bufpt + 1 (**(**[70]uint8)(__ccgo_up(bp)))[v2] = **(**uint8)(__ccgo_up(v4)) } } } else { (**(**[70]uint8)(__ccgo_up(bp)))[0] = uint8(0) } } else { ch = libc.VaUint32(&ap) length = _sqlite3AppendOneUtf8Character(tls, bp, ch) } if precision > int32(1) { nPrior = int64(1) width = width - (precision - int32(1)) if width > int32(1) && !(flag_leftjustify != 0) { Xsqlite3_str_appendchar(tls, pAccum, width-int32(1), uint8(' ')) width = 0 } Xsqlite3_str_append(tls, pAccum, bp, length) precision = precision - 1 for precision > int32(1) { if nPrior > int64(precision-int32(1)) { nPrior = int64(precision - int32(1)) } nCopyBytes = int64(length) * nPrior if _sqlite3StrAccumEnlargeIfNeeded(tls, pAccum, nCopyBytes) != 0 { break } Xsqlite3_str_append(tls, pAccum, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FzText+uintptr(libc.Int64FromUint32((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar)-nCopyBytes), int32(nCopyBytes)) precision = int32(int64(precision) - nPrior) nPrior = nPrior * int64(2) } } bufpt = bp flag_altform2 = uint8(1) goto adjust_width_for_utf8 _38: ; _37: ; if bArgList != 0 { bufpt = _getTextArg(tls, pArgList) xtype = uint8(etSTRING) } else { bufpt = libc.VaUintptr(&ap) } if bufpt == uintptr(0) { bufpt = __ccgo_ts + 1704 } else { if libc.Int32FromUint8(xtype) == int32(etDYNSTRING) { if (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar == uint32(0) && (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FmxAlloc != 0 && width == 0 && precision < 0 && libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FaccError) == 0 { /* Special optimization for sqlite3_mprintf("%z..."): ** Extend an existing memory allocation rather than creating ** a new one. */ (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FzText = bufpt (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnAlloc = libc.Uint32FromInt32(_sqlite3DbMallocSize(tls, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).Fdb, bufpt)) (*Tsqlite3_str)(unsafe.Pointer(pAccum)).FnChar = libc.Uint32FromInt32(int32(0x7fffffff) & libc.Int32FromUint64(libc.Xstrlen(tls, bufpt))) v4 = pAccum + 29 *(*Tu8)(unsafe.Pointer(v4)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v4))) | libc.Int32FromInt32(SQLITE_PRINTF_MALLOCED)) length = 0 goto _45 } zExtra = bufpt } } if precision >= 0 { if flag_altform2 != 0 { /* Set length to the number of bytes needed in order to display ** precision characters */ z = bufpt for { v2 = precision precision = precision - 1 if !(v2 > 0 && **(**uint8)(__ccgo_up(z)) != 0) { break } v4 = z z = z + 1 if libc.Int32FromUint8(**(**uint8)(__ccgo_up(v4))) >= int32(0xc0) { for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z)))&int32(0xc0) == int32(0x80) { z = z + 1 } } } length = int32(int64(z) - int64(bufpt)) } else { length = 0 for { if !(length < precision && **(**uint8)(__ccgo_up(bufpt + uintptr(length))) != 0) { break } goto _86 _86: ; length = length + 1 } } } else { length = int32(0x7fffffff) & libc.Int32FromUint64(libc.Xstrlen(tls, bufpt)) } goto adjust_width_for_utf8 adjust_width_for_utf8: ; if flag_altform2 != 0 && width > 0 { /* Adjust width to account for extra bytes in UTF-8 characters */ ii = length - int32(1) for ii >= 0 { v2 = ii ii = ii - 1 if libc.Int32FromUint8(**(**uint8)(__ccgo_up(bufpt + uintptr(v2))))&int32(0xc0) == int32(0x80) { width = width + 1 } } } goto _45 _41: ; /* %q: Escape ' characters */ _40: ; /* %Q: Escape ' and enclose in '...' */ _39: ; needQuote = 0 if bArgList != 0 { escarg = _getTextArg(tls, pArgList) } else { escarg = libc.VaUintptr(&ap) } if escarg == uintptr(0) { if libc.Int32FromUint8(xtype) == int32(etESCAPE_Q) { v4 = __ccgo_ts + 1705 } else { v4 = __ccgo_ts + 1710 } escarg = v4 } else { if libc.Int32FromUint8(xtype) == int32(etESCAPE_Q) { needQuote = int32(1) } } if libc.Int32FromUint8(xtype) == int32(etESCAPE_w) { q = uint8('"') flag_alternateform = uint8(0) } else { q = uint8('\'') } /* For %q, %Q, and %w, the precision is the number of bytes (or ** characters if the ! flags is present) to use from the input. ** Because of the extra quoting characters inserted, the number ** of output characters may be larger than the precision. */ k = int64(precision) v90 = libc.Int64FromInt32(0) n1 = v90 i = v90 for { if v12 = k != 0; v12 { v54 = **(**uint8)(__ccgo_up(escarg + uintptr(i))) ch1 = v54 } if !(v12 && libc.Int32FromUint8(v54) != 0) { break } if libc.Int32FromUint8(ch1) == libc.Int32FromUint8(q) { n1 = n1 + 1 } if flag_altform2 != 0 && libc.Int32FromUint8(ch1)&int32(0xc0) == int32(0xc0) { for libc.Int32FromUint8(**(**uint8)(__ccgo_up(escarg + uintptr(i+int64(1)))))&int32(0xc0) == int32(0x80) { i = i + 1 } } goto _89 _89: ; i = i + 1 k = k - 1 } if flag_alternateform != 0 { /* For %#q, do unistr()-style backslash escapes for ** all control characters, and for backslash itself. ** For %#Q, do the same but only if there is at least ** one control character. */ nBack = 0 nCtrl = 0 k = 0 for { if !(k < i) { break } if libc.Int32FromUint8(**(**uint8)(__ccgo_up(escarg + uintptr(k)))) == int32('\\') { nBack = nBack + 1 } else { if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(escarg + uintptr(k)))) <= int32(0x1f) { nCtrl = nCtrl + 1 } } goto _93 _93: ; k = k + 1 } if nCtrl != 0 || libc.Int32FromUint8(xtype) == int32(etESCAPE_q) { n1 = n1 + (nBack + int64(5)*nCtrl) if libc.Int32FromUint8(xtype) == int32(etESCAPE_Q) { n1 = n1 + int64(10) needQuote = int32(2) } } else { flag_alternateform = uint8(0) } } n1 = n1 + (i + int64(3)) if n1 > int64(SQLITE_PRINT_BUF_SIZE) { v4 = _printfTempBuf(tls, pAccum, n1) zExtra = v4 bufpt = v4 if bufpt == uintptr(0) { return } } else { bufpt = bp } j1 = 0 if needQuote != 0 { if needQuote == int32(2) { libc.Xmemcpy(tls, bufpt+uintptr(j1), __ccgo_ts+1717, uint64(8)) j1 = j1 + int64(8) } else { v90 = j1 j1 = j1 + 1 **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = uint8('\'') } } k = i if flag_alternateform != 0 { i = 0 for { if !(i < k) { break } v90 = j1 j1 = j1 + 1 v54 = **(**uint8)(__ccgo_up(escarg + uintptr(i))) ch1 = v54 **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = v54 if libc.Int32FromUint8(ch1) == libc.Int32FromUint8(q) { v90 = j1 j1 = j1 + 1 **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = ch1 } else { if libc.Int32FromUint8(ch1) == int32('\\') { v90 = j1 j1 = j1 + 1 **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = uint8('\\') } else { if libc.Int32FromUint8(ch1) <= int32(0x1f) { **(**uint8)(__ccgo_up(bufpt + uintptr(j1-int64(1)))) = uint8('\\') v90 = j1 j1 = j1 + 1 **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = uint8('u') v90 = j1 j1 = j1 + 1 **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = uint8('0') v90 = j1 j1 = j1 + 1 **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = uint8('0') v90 = j1 j1 = j1 + 1 if libc.Int32FromUint8(ch1) >= int32(0x10) { v2 = int32('1') } else { v2 = int32('0') } **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = libc.Uint8FromInt32(v2) v90 = j1 j1 = j1 + 1 **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = **(**uint8)(__ccgo_up(__ccgo_ts + 1726 + uintptr(libc.Int32FromUint8(ch1)&int32(0xf)))) } } } goto _96 _96: ; i = i + 1 } } else { i = 0 for { if !(i < k) { break } v90 = j1 j1 = j1 + 1 v54 = **(**uint8)(__ccgo_up(escarg + uintptr(i))) ch1 = v54 **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = v54 if libc.Int32FromUint8(ch1) == libc.Int32FromUint8(q) { v90 = j1 j1 = j1 + 1 **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = ch1 } goto _107 _107: ; i = i + 1 } } if needQuote != 0 { v90 = j1 j1 = j1 + 1 **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = uint8('\'') if needQuote == int32(2) { v90 = j1 j1 = j1 + 1 **(**uint8)(__ccgo_up(bufpt + uintptr(v90))) = uint8(')') } } **(**uint8)(__ccgo_up(bufpt + uintptr(j1))) = uint8(0) length = int32(j1) goto adjust_width_for_utf8 _42: ; if libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags)&int32(SQLITE_PRINTF_INTERNAL) == 0 { return } if flag_alternateform != 0 { /* %#T means an Expr pointer that uses Expr.u.zToken */ pExpr = libc.VaUintptr(&ap) if pExpr != 0 && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue)) != libc.Uint32FromInt32(0)) { Xsqlite3_str_appendall(tls, pAccum, *(*uintptr)(unsafe.Pointer(pExpr + 8))) _sqlite3RecordErrorOffsetOfExpr(tls, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).Fdb, pExpr) } } else { /* %T means a Token pointer */ pToken = libc.VaUintptr(&ap) if pToken != 0 && (*TToken)(unsafe.Pointer(pToken)).Fn != 0 { Xsqlite3_str_append(tls, pAccum, (*TToken)(unsafe.Pointer(pToken)).Fz, libc.Int32FromUint32((*TToken)(unsafe.Pointer(pToken)).Fn)) _sqlite3RecordErrorByteOffset(tls, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).Fdb, (*TToken)(unsafe.Pointer(pToken)).Fz) } } v2 = libc.Int32FromInt32(0) width = v2 length = v2 goto _45 _43: ; if libc.Int32FromUint8((*Tsqlite3_str)(unsafe.Pointer(pAccum)).FprintfFlags)&int32(SQLITE_PRINTF_INTERNAL) == 0 { return } pItem = libc.VaUintptr(&ap) if (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != 0 && !(flag_altform2 != 0) { Xsqlite3_str_appendall(tls, pAccum, (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias) } else { if (*TSrcItem)(unsafe.Pointer(pItem)).FzName != 0 { if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x10000>>16) == 0 && int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) == 0 && *(*uintptr)(unsafe.Pointer(pItem + 72)) != uintptr(0) { Xsqlite3_str_appendall(tls, pAccum, *(*uintptr)(unsafe.Pointer(pItem + 72))) Xsqlite3_str_append(tls, pAccum, __ccgo_ts+1743, int32(1)) } Xsqlite3_str_appendall(tls, pAccum, (*TSrcItem)(unsafe.Pointer(pItem)).FzName) } else { if (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != 0 { Xsqlite3_str_appendall(tls, pAccum, (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias) } else { if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4>>2) != 0 { /* Because of tag-20240424-1 */ pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect if (*TSelect)(unsafe.Pointer(pSel)).FselFlags&uint32(SF_NestedFrom) != 0 { Xsqlite3_str_appendf(tls, pAccum, __ccgo_ts+1745, libc.VaList(bp+120, (*TSelect)(unsafe.Pointer(pSel)).FselId)) } else { if (*TSelect)(unsafe.Pointer(pSel)).FselFlags&uint32(SF_MultiValue) != 0 { Xsqlite3_str_appendf(tls, pAccum, __ccgo_ts+1755, libc.VaList(bp+120, *(*Tu32)(unsafe.Pointer(&(*TSrcItem)(unsafe.Pointer(pItem)).Fu1)))) } else { Xsqlite3_str_appendf(tls, pAccum, __ccgo_ts+1776, libc.VaList(bp+120, (*TSelect)(unsafe.Pointer(pSel)).FselId)) } } } } } } v2 = libc.Int32FromInt32(0) width = v2 length = v2 goto _45 _44: ; return _45: ; /* End switch over the format type */ /* ** The text of the conversion is pointed to by "bufpt" and is ** "length" characters long. The field width is "width". Do ** the output. Both length and width are in bytes, not characters, ** at this point. If the "!" flag was present on string conversions ** indicating that width and precision should be expressed in characters, ** then the values have been translated prior to reaching this point. */ width = width - length if width > 0 { if !(flag_leftjustify != 0) { Xsqlite3_str_appendchar(tls, pAccum, width, uint8(' ')) } Xsqlite3_str_append(tls, pAccum, bufpt, length) if flag_leftjustify != 0 { Xsqlite3_str_appendchar(tls, pAccum, width, uint8(' ')) } } else { Xsqlite3_str_append(tls, pAccum, bufpt, length) } if zExtra != 0 { _sqlite3DbFree(tls, (*Tsqlite3_str)(unsafe.Pointer(pAccum)).Fdb, zExtra) zExtra = uintptr(0) } goto _1 _1: ; fmt = fmt + 1 } /* End for loop over the format string */ } // C documentation // // /* // ** Generate code to construct the Index object for an automatic index // ** and to set up the WhereLevel object pLevel so that the code generator // ** makes use of the automatic index. // */ func _constructAutomaticIndex(tls *libc.TLS, pParse uintptr, pWC uintptr, notReady TBitmask, pLevel uintptr) { bp := tls.Alloc(32) defer tls.Free(32) var addrCounter, addrInit, addrTop, i, iCol, iCol1, iContinue, mxBitCol, n, nKeyCol, regBase, regRecord, regYield, v3 int32 var cMask, cMask1, extraCols, idxCols TBitmask var pColl, pExpr, pIdx, pLoop, pPartial, pSrc, pSubq, pTabList, pTable, pTerm, pWCEnd, pX, v, v10 uintptr var sentWarning, useBloomFilter Tu8 var v2 uint64 var v4 Tu16 var _ /* zNotUsed at bp+0 */ uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrCounter, addrInit, addrTop, cMask, cMask1, extraCols, i, iCol, iCol1, iContinue, idxCols, mxBitCol, n, nKeyCol, pColl, pExpr, pIdx, pLoop, pPartial, pSrc, pSubq, pTabList, pTable, pTerm, pWCEnd, pX, regBase, regRecord, regYield, sentWarning, useBloomFilter, v, v10, v2, v3, v4 /* Bitmap of additional columns */ sentWarning = uint8(0) /* True if a warning has been issued */ useBloomFilter = uint8(0) /* True to also add a Bloom filter */ pPartial = uintptr(0) /* Partial Index Expression */ iContinue = 0 /* The FROM clause term to get the next index */ addrCounter = 0 /* Array of registers where record is assembled */ /* Generate code to skip over the creation and initialization of the ** transient index on 2nd and subsequent iterations of the loop. */ v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe addrInit = _sqlite3VdbeAddOp0(tls, v, int32(OP_Once)) /* Count the number of columns that will be added to the index ** and used to match WHERE clause constraints */ nKeyCol = 0 pTabList = (*TWhereInfo)(unsafe.Pointer((*TWhereClause)(unsafe.Pointer(pWC)).FpWInfo)).FpTabList pSrc = pTabList + 8 + uintptr((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom)*80 pTable = (*TSrcItem)(unsafe.Pointer(pSrc)).FpSTab pWCEnd = (*TWhereClause)(unsafe.Pointer(pWC)).Fa + uintptr((*TWhereClause)(unsafe.Pointer(pWC)).FnTerm)*56 pLoop = (*TWhereLevel)(unsafe.Pointer(pLevel)).FpWLoop idxCols = uint64(0) pTerm = (*TWhereClause)(unsafe.Pointer(pWC)).Fa for { if !(pTerm < pWCEnd) { break } pExpr = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr /* Make the automatic index a partial index if there are terms in the ** WHERE clause (or the ON clause of a LEFT join) that constrain which ** rows of the target table (pSrc) that can be used. */ if libc.Int32FromUint16((*TWhereTerm)(unsafe.Pointer(pTerm)).FwtFlags)&int32(TERM_VIRTUAL) == 0 && _sqlite3ExprIsSingleTableConstraint(tls, pExpr, pTabList, libc.Int32FromUint8((*TWhereLevel)(unsafe.Pointer(pLevel)).FiFrom), 0) != 0 { pPartial = _sqlite3ExprAnd(tls, pParse, pPartial, _sqlite3ExprDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr, 0)) } if _termCanDriveIndex(tls, pTerm, pSrc, notReady) != 0 { iCol = (*(*struct { FleftColumn int32 FiField int32 })(unsafe.Pointer(pTerm + 32))).FleftColumn if iCol >= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { v2 = libc.Uint64FromInt32(1) << (libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) - libc.Int32FromInt32(1)) } else { v2 = libc.Uint64FromInt32(1) << iCol } cMask = v2 if !(sentWarning != 0) { Xsqlite3_log(tls, libc.Int32FromInt32(SQLITE_WARNING)|libc.Int32FromInt32(1)<= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1) { extraCols = extraCols | libc.Uint64FromInt32(1)<<(libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8))-libc.Int32FromInt32(1)) break } if idxCols&(libc.Uint64FromInt32(1)<= libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) { v2 = libc.Uint64FromInt32(1) << (libc.Int32FromUint64(libc.Uint64FromInt64(8)*libc.Uint64FromInt32(8)) - libc.Int32FromInt32(1)) } else { v2 = libc.Uint64FromInt32(1) << iCol1 } cMask1 = v2 if idxCols&cMask1 == uint64(0) { pX = (*TWhereTerm)(unsafe.Pointer(pTerm)).FpExpr idxCols = idxCols | cMask1 **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(n)*2)) = int16((*(*struct { FleftColumn int32 FiField int32 })(unsafe.Pointer(pTerm + 32))).FleftColumn) pColl = _sqlite3ExprCompareCollSeq(tls, pParse, pX) /* TH3 collate01.800 */ if pColl != 0 { v10 = (*TCollSeq)(unsafe.Pointer(pColl)).FzName } else { v10 = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) } **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(n)*8)) = v10 n = n + 1 if (*TExpr)(unsafe.Pointer(pX)).FpLeft != uintptr(0) && libc.Int32FromUint8(_sqlite3ExprAffinity(tls, (*TExpr)(unsafe.Pointer(pX)).FpLeft)) != int32(SQLITE_AFF_TEXT) { /* TUNING: only use a Bloom filter on an automatic index ** if one or more key columns has the ability to hold numeric ** values, since strings all have the same hash in the Bloom ** filter implementation and hence a Bloom filter on a text column ** is not usually helpful. */ useBloomFilter = uint8(1) } } } goto _8 _8: ; pTerm += 56 } /* Add additional columns needed to make the automatic index into ** a covering index */ i = 0 for { if !(i < mxBitCol) { break } if extraCols&(libc.Uint64FromInt32(1)<>6) != 0 { pSubq = *(*uintptr)(unsafe.Pointer(pSrc + 72)) regYield = (*TSubquery)(unsafe.Pointer(pSubq)).FregReturn addrCounter = _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, 0) _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), regYield, 0, (*TSubquery)(unsafe.Pointer(pSubq)).FaddrFillSub) addrTop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), regYield) } else { addrTop = _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, (*TWhereLevel)(unsafe.Pointer(pLevel)).FaddrHalt) } if pPartial != 0 { iContinue = _sqlite3VdbeMakeLabel(tls, pParse) _sqlite3ExprIfFalse(tls, pParse, pPartial, iContinue, int32(SQLITE_JUMPIFNULL)) **(**Tu32)(__ccgo_up(pLoop + 48)) |= uint32(WHERE_PARTIALIDX) } regRecord = _sqlite3GetTempReg(tls, pParse) regBase = _sqlite3GenerateIndexKey(tls, pParse, pIdx, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, regRecord, 0, uintptr(0), uintptr(0), 0) if (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter != 0 { _sqlite3VdbeAddOp4Int(tls, v, int32(OP_FilterAdd), (*TWhereLevel)(unsafe.Pointer(pLevel)).FregFilter, 0, regBase, libc.Int32FromUint16((*(*struct { FnEq Tu16 FnBtm Tu16 FnTop Tu16 FnDistinctCol Tu16 FpIndex uintptr FpOrderBy uintptr })(unsafe.Pointer(pLoop + 24))).FnEq)) } _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxInsert), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur, regRecord) _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_USESEEKRESULT)) if pPartial != 0 { _sqlite3VdbeResolveLabel(tls, v, iContinue) } if int32(*(*uint32)(unsafe.Pointer(pSrc + 24 + 4))&0x40>>6) != 0 { _sqlite3VdbeChangeP2(tls, v, addrCounter, regBase+n) _translateColumnToCopy(tls, pParse, addrTop, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pSrc + 72)))).FregResult, (*TWhereLevel)(unsafe.Pointer(pLevel)).FiIdxCur) _sqlite3VdbeGoto(tls, v, addrTop) libc.SetBitFieldPtr32Uint32(pSrc+24+4, libc.Uint32FromInt32(0), 6, 0x40) _sqlite3VdbeJumpHere(tls, v, addrTop) } else { _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), (*TWhereLevel)(unsafe.Pointer(pLevel)).FiTabCur, addrTop+int32(1)) _sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_STMTSTATUS_AUTOINDEX)) if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pSrc)).Ffg.Fjointype)&int32(JT_LEFT) != 0 { _sqlite3VdbeJumpHere(tls, v, addrTop) } } _sqlite3ReleaseTempReg(tls, pParse, regRecord) /* Jump here when skipping the initialization */ _sqlite3VdbeJumpHere(tls, v, addrInit) goto end_auto_index_create end_auto_index_create: ; _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pPartial) } // C documentation // // /* // ** The first argument points to a nul-terminated string containing a // ** list of space separated integers. Read the first nOut of these into // ** the array aOut[]. // */ func _decodeIntArray(tls *libc.TLS, zIntArray uintptr, nOut int32, aOut uintptr, aLog uintptr, pIndex uintptr) { var c, i, sz, v2 int32 var v TtRowcnt var z uintptr _, _, _, _, _, _ = c, i, sz, v, z, v2 z = zIntArray if z == uintptr(0) { z = __ccgo_ts + 1704 } i = 0 for { if !(**(**uint8)(__ccgo_up(z)) != 0 && i < nOut) { break } v = uint64(0) for { v2 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) c = v2 if !(v2 >= int32('0') && c <= int32('9')) { break } v = v*uint64(10) + libc.Uint64FromInt32(c) - uint64('0') z = z + 1 } if aOut != 0 { **(**TtRowcnt)(__ccgo_up(aOut + uintptr(i)*8)) = v } if aLog != 0 { **(**TLogEst)(__ccgo_up(aLog + uintptr(i)*2)) = _sqlite3LogEst(tls, v) } if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) == int32(' ') { z = z + 1 } goto _1 _1: ; i = i + 1 } if pIndex != 0 { libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 2, 0x4) libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 6, 0x40) for **(**uint8)(__ccgo_up(z)) != 0 { if Xsqlite3_strglob(tls, __ccgo_ts+13080, z) == 0 { libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 2, 0x4) } else { if Xsqlite3_strglob(tls, __ccgo_ts+13091, z) == 0 { sz = _sqlite3Atoi(tls, z+uintptr(3)) if sz < int32(2) { sz = int32(2) } (*TIndex)(unsafe.Pointer(pIndex)).FszIdxRow = _sqlite3LogEst(tls, libc.Uint64FromInt32(sz)) } else { if Xsqlite3_strglob(tls, __ccgo_ts+13101, z) == 0 { libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 6, 0x40) } } } for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) != 0 && libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) != int32(' ') { z = z + 1 } for libc.Int32FromUint8(**(**uint8)(__ccgo_up(z))) == int32(' ') { z = z + 1 } } } } // C documentation // // /* // ** This function is called when an UPDATE or DELETE operation is being // ** compiled on table pTab, which is the parent table of foreign-key pFKey. // ** If the current operation is an UPDATE, then the pChanges parameter is // ** passed a pointer to the list of columns being modified. If it is a // ** DELETE, pChanges is passed a NULL pointer. // ** // ** It returns a pointer to a Trigger structure containing a trigger // ** equivalent to the ON UPDATE or ON DELETE action specified by pFKey. // ** If the action is "NO ACTION" then a NULL pointer is returned (these actions // ** require no special handling by the triggers sub-system, code for them is // ** created by fkScanChildren()). // ** // ** For example, if pFKey is the foreign key and pTab is table "p" in // ** the following schema: // ** // ** CREATE TABLE p(pk PRIMARY KEY); // ** CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE); // ** // ** then the returned trigger structure is equivalent to: // ** // ** CREATE TRIGGER ... DELETE ON p BEGIN // ** DELETE FROM c WHERE ck = old.pk; // ** END; // ** // ** The returned pointer is cached as part of the foreign key object. It // ** is eventually freed along with the rest of the foreign key object by // ** sqlite3FkDelete(). // */ func _fkActionTrigger(tls *libc.TLS, pParse uintptr, pTab uintptr, pFKey uintptr, pChanges uintptr) (r uintptr) { bp := tls.Alloc(80) defer tls.Free(80) var action, i, iAction, iFromCol, nFrom, v2 int32 var db, pCol, pDflt, pEq, pItem, pItem1, pList, pNew, pRaise, pSelect, pSrc, pStep, pTrigger, pWhen, pWhere, zFrom, v4 uintptr var _ /* aiCol at bp+8 */ uintptr var _ /* pIdx at bp+0 */ uintptr var _ /* tFromCol at bp+48 */ TToken var _ /* tNew at bp+32 */ TToken var _ /* tOld at bp+16 */ TToken var _ /* tToCol at bp+64 */ TToken _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = action, db, i, iAction, iFromCol, nFrom, pCol, pDflt, pEq, pItem, pItem1, pList, pNew, pRaise, pSelect, pSrc, pStep, pTrigger, pWhen, pWhere, zFrom, v2, v4 db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Trigger definition to return */ iAction = libc.BoolInt32(pChanges != uintptr(0)) /* 1 for UPDATE, 0 for DELETE */ action = libc.Int32FromUint8(**(**Tu8)(__ccgo_up(pFKey + 45 + uintptr(iAction)))) if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00008))< parent key cols */ pStep = uintptr(0) /* First (only) step of trigger program */ pWhere = uintptr(0) /* WHERE clause of trigger step */ pList = uintptr(0) /* Changes list if ON UPDATE CASCADE */ pSelect = uintptr(0) /* Iterator variable */ pWhen = uintptr(0) /* WHEN clause for the trigger */ if _sqlite3FkLocateIndex(tls, pParse, pTab, pFKey, bp, bp+8) != 0 { return uintptr(0) } i = 0 for { if !(i < (*TFKey)(unsafe.Pointer(pFKey)).FnCol) { break } **(**TToken)(__ccgo_up(bp + 16)) = TToken{ Fz: __ccgo_ts + 6855, Fn: uint32(3), } /* Literal "old" token */ **(**TToken)(__ccgo_up(bp + 32)) = TToken{ Fz: __ccgo_ts + 6851, Fn: uint32(3), } /* tFromCol = OLD.tToCol */ if **(**uintptr)(__ccgo_up(bp + 8)) != 0 { v2 = **(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 8)) + uintptr(i)*4)) } else { v2 = (*(*TsColMap)(unsafe.Pointer(pFKey + 64))).FiFrom } iFromCol = v2 if **(**uintptr)(__ccgo_up(bp)) != 0 { v2 = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaiColumn + uintptr(i)*2))) } else { v2 = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) } _sqlite3TokenInit(tls, bp+64, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(v2)*16))).FzCnName) _sqlite3TokenInit(tls, bp+48, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol + uintptr(iFromCol)*16))).FzCnName) /* Create the expression "OLD.zToCol = zFromCol". It is important ** that the "OLD.zToCol" term is on the LHS of the = operator, so ** that the affinity and collation sequence associated with the ** parent table are used for the comparison. */ pEq = _sqlite3PExpr(tls, pParse, int32(TK_EQ), _sqlite3PExpr(tls, pParse, int32(TK_DOT), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+16, 0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+64, 0)), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+48, 0)) pWhere = _sqlite3ExprAnd(tls, pParse, pWhere, pEq) /* For ON UPDATE, construct the next term of the WHEN clause. ** The final WHEN clause will be like this: ** ** WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN) */ if pChanges != 0 { pEq = _sqlite3PExpr(tls, pParse, int32(TK_IS), _sqlite3PExpr(tls, pParse, int32(TK_DOT), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+16, 0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+64, 0)), _sqlite3PExpr(tls, pParse, int32(TK_DOT), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+32, 0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+64, 0))) pWhen = _sqlite3ExprAnd(tls, pParse, pWhen, pEq) } if action != int32(OE_Restrict) && (action != int32(OE_Cascade) || pChanges != 0) { if action == int32(OE_Cascade) { pNew = _sqlite3PExpr(tls, pParse, int32(TK_DOT), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+32, 0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+64, 0)) } else { if action == int32(OE_SetDflt) { pCol = (*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FaCol + uintptr(iFromCol)*16 if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { pDflt = uintptr(0) } else { pDflt = _sqlite3ColumnExpr(tls, (*TFKey)(unsafe.Pointer(pFKey)).FpFrom, pCol) } if pDflt != 0 { pNew = _sqlite3ExprDup(tls, db, pDflt, 0) } else { pNew = _sqlite3ExprAlloc(tls, db, int32(TK_NULL), uintptr(0), 0) } } else { pNew = _sqlite3ExprAlloc(tls, db, int32(TK_NULL), uintptr(0), 0) } } pList = _sqlite3ExprListAppend(tls, pParse, pList, pNew) _sqlite3ExprListSetName(tls, pParse, pList, bp+48, 0) } goto _1 _1: ; i = i + 1 } _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp + 8))) zFrom = (*TTable)(unsafe.Pointer((*TFKey)(unsafe.Pointer(pFKey)).FpFrom)).FzName nFrom = _sqlite3Strlen30(tls, zFrom) if action == int32(OE_Restrict) { pRaise = _sqlite3Expr(tls, db, int32(TK_STRING), __ccgo_ts+5420) pRaise = _sqlite3PExpr(tls, pParse, int32(TK_RAISE), pRaise, uintptr(0)) if pRaise != 0 { (*TExpr)(unsafe.Pointer(pRaise)).FaffExpr = uint8(OE_Abort) } pSrc = _sqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) if pSrc != 0 { pItem = pSrc + 8 (*TSrcItem)(unsafe.Pointer(pItem)).FzName = _sqlite3DbStrDup(tls, db, zFrom) libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 16, 0x10000) *(*uintptr)(unsafe.Pointer(pItem + 72)) = (*TTable)(unsafe.Pointer(pTab)).FpSchema } pSelect = _sqlite3SelectNew(tls, pParse, _sqlite3ExprListAppend(tls, pParse, uintptr(0), pRaise), pSrc, pWhere, uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) pWhere = uintptr(0) } /* Disable lookaside memory allocation */ (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) pTrigger = _sqlite3DbMallocZero(tls, db, uint64(libc.Uint64FromInt64(72)+libc.Uint64FromInt64(88))) if pTrigger != 0 { v4 = pTrigger + 1*72 (*TTrigger)(unsafe.Pointer(pTrigger)).Fstep_list = v4 pStep = v4 (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc = _sqlite3SrcListAppend(tls, pParse, uintptr(0), uintptr(0), uintptr(0)) if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != 0 { pItem1 = (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc + 8 (*TSrcItem)(unsafe.Pointer(pItem1)).FzName = _sqlite3DbStrNDup(tls, db, zFrom, libc.Uint64FromInt32(nFrom)) *(*uintptr)(unsafe.Pointer(pItem1 + 72)) = (*TTable)(unsafe.Pointer(pTab)).FpSchema libc.SetBitFieldPtr32Uint32(pItem1+24+4, libc.Uint32FromInt32(1), 16, 0x10000) } (*TTriggerStep)(unsafe.Pointer(pStep)).FpWhere = _sqlite3ExprDup(tls, db, pWhere, int32(EXPRDUP_REDUCE)) (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList = _sqlite3ExprListDup(tls, db, pList, int32(EXPRDUP_REDUCE)) (*TTriggerStep)(unsafe.Pointer(pStep)).FpSelect = _sqlite3SelectDup(tls, db, pSelect, int32(EXPRDUP_REDUCE)) if pWhen != 0 { pWhen = _sqlite3PExpr(tls, pParse, int32(TK_NOT), pWhen, uintptr(0)) (*TTrigger)(unsafe.Pointer(pTrigger)).FpWhen = _sqlite3ExprDup(tls, db, pWhen, int32(EXPRDUP_REDUCE)) } } /* Re-enable the lookaside buffer, if it was disabled earlier. */ (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable - 1 if (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable != 0 { v2 = 0 } else { v2 = libc.Int32FromUint16((*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FszTrue) } (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = libc.Uint16FromInt32(v2) _sqlite3ExprDelete(tls, db, pWhere) _sqlite3ExprDelete(tls, db, pWhen) _sqlite3ExprListDelete(tls, db, pList) _sqlite3SelectDelete(tls, db, pSelect) if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == int32(1) { _fkTriggerDelete(tls, db, pTrigger) return uintptr(0) } switch action { case int32(OE_Restrict): (*TTriggerStep)(unsafe.Pointer(pStep)).Fop = uint8(TK_SELECT) case int32(OE_Cascade): if !(pChanges != 0) { (*TTriggerStep)(unsafe.Pointer(pStep)).Fop = uint8(TK_DELETE) break } fallthrough default: (*TTriggerStep)(unsafe.Pointer(pStep)).Fop = uint8(TK_UPDATE) } (*TTriggerStep)(unsafe.Pointer(pStep)).FpTrig = pTrigger (*TTrigger)(unsafe.Pointer(pTrigger)).FpSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema (*TTrigger)(unsafe.Pointer(pTrigger)).FpTabSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema **(**uintptr)(__ccgo_up(pFKey + 48 + uintptr(iAction)*8)) = pTrigger if pChanges != 0 { v2 = int32(TK_UPDATE) } else { v2 = int32(TK_DELETE) } (*TTrigger)(unsafe.Pointer(pTrigger)).Fop = libc.Uint8FromInt32(v2) } return pTrigger } // C documentation // // /* // ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up // ** that name in the set of source tables in pSrcList and make the pExpr // ** expression node refer back to that source column. The following changes // ** are made to pExpr: // ** // ** pExpr->iDb Set the index in db->aDb[] of the database X // ** (even if X is implied). // ** pExpr->iTable Set to the cursor number for the table obtained // ** from pSrcList. // ** pExpr->y.pTab Points to the Table structure of X.Y (even if // ** X and/or Y are implied.) // ** pExpr->iColumn Set to the column number within the table. // ** pExpr->op Set to TK_COLUMN. // ** pExpr->pLeft Any expression this points to is deleted // ** pExpr->pRight Any expression this points to is deleted. // ** // ** The zDb variable is the name of the database (the "X"). This value may be // ** NULL meaning that name is of the form Y.Z or Z. Any available database // ** can be used. The zTable variable is the name of the table (the "Y"). This // ** value can be NULL if zDb is also NULL. If zTable is NULL it // ** means that the form of the name is Z and that columns from any table // ** can be used. // ** // ** If the name cannot be resolved unambiguously, leave an error message // ** in pParse and return WRC_Abort. Return WRC_Prune on success. // */ func _lookupName(tls *libc.TLS, pParse uintptr, zDb uintptr, zTab uintptr, pRight uintptr, pNC uintptr, pExpr uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) var cnt, cntTab, eNewExprOp, hit, i, iCol, j, nSubquery, op, v4 int32 var db, pEList, pItem, pMatch, pOrig, pSchema, pSel, pSrcList, pTab, pTopNC, pUpsert, zAs, zCol, zErr, v8 uintptr var v5 uint32 var _ /* bRowid at bp+8 */ int32 var _ /* pFJMatch at bp+0 */ uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = cnt, cntTab, db, eNewExprOp, hit, i, iCol, j, nSubquery, op, pEList, pItem, pMatch, pOrig, pSchema, pSel, pSrcList, pTab, pTopNC, pUpsert, zAs, zCol, zErr, v4, v5, v8 /* Loop counters */ cnt = 0 /* Number of matching column names */ cntTab = 0 /* Number of potential "rowid" matches */ nSubquery = 0 /* How many levels of subquery */ db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Use for looping over pSrcList items */ pMatch = uintptr(0) /* The matching pSrcList item */ pTopNC = pNC /* First namecontext in the list */ pSchema = uintptr(0) /* Schema of the expression */ eNewExprOp = int32(TK_COLUMN) /* New value for pExpr->op on success */ pTab = uintptr(0) /* Table holding the row */ **(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Matches for FULL JOIN .. USING */ zCol = *(*uintptr)(unsafe.Pointer(pRight + 8)) /* the name context cannot be NULL. */ /* The Z in X.Y.Z cannot be NULL */ /* Initialize the node to no-match */ (*TExpr)(unsafe.Pointer(pExpr)).FiTable = -int32(1) /* Translate the schema name in zDb into a pointer to the corresponding ** schema. If not found, pSchema will remain NULL and nothing will match ** resulting in an appropriate error message toward the end of this routine */ if zDb != 0 { if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_PartIdx)|libc.Int32FromInt32(NC_IsCheck)) != 0 { /* Silently ignore database qualifiers inside CHECK constraints and ** partial indices. Do not raise errors because that might break ** legacy and because it does not hurt anything to just ignore the ** database name. */ zDb = uintptr(0) } else { i = 0 for { if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { break } if _sqlite3StrICmp(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FzDbSName, zDb) == 0 { pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpSchema break } goto _1 _1: ; i = i + 1 } if i == (*Tsqlite3)(unsafe.Pointer(db)).FnDb && _sqlite3StrICmp(tls, __ccgo_ts+6844, zDb) == 0 { /* This branch is taken when the main database has been renamed ** using SQLITE_DBCONFIG_MAINDBNAME. */ pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FzDbSName } } } /* Start at the inner-most context and move outward until a match is found */ for cond := true; cond; cond = pNC != 0 { pSrcList = (*TNameContext)(unsafe.Pointer(pNC)).FpSrcList if pSrcList != 0 { i = 0 pItem = pSrcList + 8 for { if !(i < (*TSrcList)(unsafe.Pointer(pSrcList)).FnSrc) { break } pTab = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4000>>14) != 0 { /* In this case, pItem is a subquery that has been formed from a ** parenthesized subset of the FROM clause terms. Example: ** .... FROM t1 LEFT JOIN (t2 RIGHT JOIN t3 USING(x)) USING(y) ... ** \_________________________/ ** This pItem -------------^ */ hit = 0 pSel = (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pItem + 72)))).FpSelect pEList = (*TSelect)(unsafe.Pointer(pSel)).FpEList j = 0 for { if !(j < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { break } **(**int32)(__ccgo_up(bp + 8)) = 0 /* True if possible rowid match */ if !(_sqlite3MatchEName(tls, pEList+8+uintptr(j)*32, zCol, zTab, zDb, bp+8) != 0) { goto _3 } if **(**int32)(__ccgo_up(bp + 8)) == 0 { if cnt > 0 { if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x800>>11) == 0 || _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pItem + 64)), zCol) < 0 || pMatch == pItem { /* Two or more tables have the same column name which is ** not joined by USING. Or, a single table has two columns ** that match a USING term (if pMatch==pItem). These are both ** "ambiguous column name" errors. Signal as much by clearing ** pFJMatch and letting cnt go above 1. */ _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) **(**uintptr)(__ccgo_up(bp)) = uintptr(0) } else { if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_RIGHT) == 0 { /* An INNER or LEFT JOIN. Use the left-most table */ goto _3 } else { if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LEFT) == 0 { /* A RIGHT JOIN. Use the right-most table */ cnt = 0 _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) **(**uintptr)(__ccgo_up(bp)) = uintptr(0) } else { /* For a FULL JOIN, we must construct a coalesce() func */ _extendFJMatch(tls, pParse, bp, pMatch, (*TExpr)(unsafe.Pointer(pExpr)).FiColumn) } } } } cnt = cnt + 1 hit = int32(1) } else { if cnt > 0 { /* This is a potential rowid match, but there has already been ** a real match found. So this can be ignored. */ goto _3 } } cntTab = cntTab + 1 pMatch = pItem (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(j) libc.SetBitFieldPtr16Uint32(pEList+8+uintptr(j)*32+16+4, libc.Uint32FromInt32(1), 6, 0x40) /* rowid cannot be part of a USING clause - assert() this. */ if int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(j)*32 + 16 + 4))&0x80>>7)) != 0 { break } goto _3 _3: ; j = j + 1 } if hit != 0 || zTab == uintptr(0) { goto _2 } } if zTab != 0 { if zDb != 0 { if (*TTable)(unsafe.Pointer(pTab)).FpSchema != pSchema { goto _2 } if pSchema == uintptr(0) && libc.Xstrcmp(tls, zDb, __ccgo_ts+6849) != 0 { goto _2 } } if (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != uintptr(0) { if _sqlite3StrICmp(tls, zTab, (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias) != 0 { goto _2 } } else { if _sqlite3StrICmp(tls, zTab, (*TTable)(unsafe.Pointer(pTab)).FzName) != 0 { if (*TTable)(unsafe.Pointer(pTab)).Ftnum != uint32(1) { goto _2 } if !(_isValidSchemaTableName(tls, zTab, pTab, zDb) != 0) { goto _2 } } } if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && (*TSrcItem)(unsafe.Pointer(pItem)).FzAlias != 0 { _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr+64) } } j = _sqlite3ColumnIndex(tls, pTab, zCol) if j >= 0 { if cnt > 0 { if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x800>>11) == 0 || _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pItem + 64)), zCol) < 0 { /* Two or more tables have the same column name which is ** not joined by USING. This is an error. Signal as much ** by clearing pFJMatch and letting cnt go above 1. */ _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) **(**uintptr)(__ccgo_up(bp)) = uintptr(0) } else { if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_RIGHT) == 0 { /* An INNER or LEFT JOIN. Use the left-most table */ goto _2 } else { if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LEFT) == 0 { /* A RIGHT JOIN. Use the right-most table */ cnt = 0 _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) **(**uintptr)(__ccgo_up(bp)) = uintptr(0) } else { /* For a FULL JOIN, we must construct a coalesce() func */ _extendFJMatch(tls, pParse, bp, pMatch, (*TExpr)(unsafe.Pointer(pExpr)).FiColumn) } } } } cnt = cnt + 1 pMatch = pItem /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */ if j == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { v4 = -int32(1) } else { v4 = int32(int16(j)) } (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(v4) if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x4000>>14) != 0 { _sqlite3SrcItemColumnUsed(tls, pItem, j) } } if 0 == cnt && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_NoVisibleRowid) == uint32(0) { /* pTab is a potential ROWID match. Keep track of it and match ** the ROWID later if that seems appropriate. (Search for "cntTab" ** to find related code.) Only allow a ROWID match if there is ** a single ROWID match candidate. */ /* The (much more common) non-SQLITE_ALLOW_ROWID_IN_VIEW case is ** simpler since we require exactly one candidate, which will ** always be a non-VIEW */ cntTab = cntTab + 1 pMatch = pItem } goto _2 _2: ; i = i + 1 pItem += 80 } if pMatch != 0 { (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TSrcItem)(unsafe.Pointer(pMatch)).FiCursor *(*uintptr)(unsafe.Pointer(pExpr + 64)) = (*TSrcItem)(unsafe.Pointer(pMatch)).FpSTab if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pMatch)).Ffg.Fjointype)&(libc.Int32FromInt32(JT_LEFT)|libc.Int32FromInt32(JT_LTORJ)) != 0 { **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) } pSchema = (*TTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FpSchema } } /* if( pSrcList ) */ /* If we have not already resolved the name, then maybe ** it is a new.* or old.* trigger argument reference. Or ** maybe it is an excluded.* from an upsert. Or maybe it is ** a reference in the RETURNING clause to a table being modified. */ if cnt == 0 && zDb == uintptr(0) { pTab = uintptr(0) if (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab != uintptr(0) { op = libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeTriggerOp) if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x8>>3)) != 0 { if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_UBaseReg) != 0 && (zTab == uintptr(0) || _sqlite3StrICmp(tls, zTab, (*TTable)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).FpTriggerTab)).FzName) == 0 || _isValidSchemaTableName(tls, zTab, (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab, uintptr(0)) != 0) { (*TExpr)(unsafe.Pointer(pExpr)).FiTable = libc.BoolInt32(op != int32(TK_DELETE)) pTab = (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab } } else { if op != int32(TK_DELETE) && zTab != 0 && _sqlite3StrICmp(tls, __ccgo_ts+6851, zTab) == 0 { (*TExpr)(unsafe.Pointer(pExpr)).FiTable = int32(1) pTab = (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab } else { if op != int32(TK_INSERT) && zTab != 0 && _sqlite3StrICmp(tls, __ccgo_ts+6855, zTab) == 0 { (*TExpr)(unsafe.Pointer(pExpr)).FiTable = 0 pTab = (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab } } } } if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_UUpsert) != 0 && zTab != uintptr(0) { pUpsert = *(*uintptr)(unsafe.Pointer(pNC + 16)) if pUpsert != 0 && _sqlite3StrICmp(tls, __ccgo_ts+6859, zTab) == 0 { pTab = (*(*TSrcItem)(unsafe.Pointer((*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc + 8))).FpSTab (*TExpr)(unsafe.Pointer(pExpr)).FiTable = int32(EXCLUDED_TABLE_NUMBER) } } if pTab != 0 { pSchema = (*TTable)(unsafe.Pointer(pTab)).FpSchema cntTab = cntTab + 1 iCol = _sqlite3ColumnIndex(tls, pTab, zCol) if iCol >= 0 { if int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) == iCol { iCol = -int32(1) } } else { if _sqlite3IsRowid(tls, zCol) != 0 && (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_NoVisibleRowid) == uint32(0) { iCol = -int32(1) } else { iCol = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) } } if iCol < int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { cnt = cnt + 1 pMatch = uintptr(0) if (*TExpr)(unsafe.Pointer(pExpr)).FiTable == int32(EXCLUDED_TABLE_NUMBER) { if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(iCol) *(*uintptr)(unsafe.Pointer(pExpr + 64)) = pTab eNewExprOp = int32(TK_COLUMN) } else { (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TUpsert)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNC + 16)))).FregData + int32(_sqlite3TableColumnToStorage(tls, pTab, int16(iCol))) eNewExprOp = int32(TK_REGISTER) } } else { *(*uintptr)(unsafe.Pointer(pExpr + 64)) = pTab if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x8>>3)) != 0 { eNewExprOp = int32(TK_REGISTER) (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = uint8(TK_COLUMN) (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(iCol) (*TExpr)(unsafe.Pointer(pExpr)).FiTable = *(*int32)(unsafe.Pointer(&(*TNameContext)(unsafe.Pointer(pNC)).FuNC)) + (int32((*TTable)(unsafe.Pointer(pTab)).FnCol)+int32(1))*(*TExpr)(unsafe.Pointer(pExpr)).FiTable + int32(_sqlite3TableColumnToStorage(tls, pTab, int16(iCol))) + int32(1) } else { (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(iCol) eNewExprOp = int32(TK_TRIGGER) if iCol < 0 { (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = uint8(SQLITE_AFF_INTEGER) } else { if (*TExpr)(unsafe.Pointer(pExpr)).FiTable == 0 { if iCol >= int32(32) { v5 = uint32(0xffffffff) } else { v5 = libc.Uint32FromInt32(1) << iCol } **(**Tu32)(__ccgo_up(pParse + 248)) |= v5 } else { if iCol >= int32(32) { v5 = uint32(0xffffffff) } else { v5 = libc.Uint32FromInt32(1) << iCol } **(**Tu32)(__ccgo_up(pParse + 252)) |= v5 } } } } } } } /* ** Perhaps the name is a reference to the ROWID */ if cnt == 0 && cntTab >= int32(1) && pMatch != 0 && (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_IdxExpr)|libc.Int32FromInt32(NC_GenCol)) == 0 && _sqlite3IsRowid(tls, zCol) != 0 && ((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pMatch)).FpSTab)).FtabFlags&uint32(TF_NoVisibleRowid) == uint32(0) || int32(*(*uint32)(unsafe.Pointer(pMatch + 24 + 4))&0x4000>>14) != 0) { cnt = cntTab if int32(*(*uint32)(unsafe.Pointer(pMatch + 24 + 4))&0x4000>>14) == 0 { (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = int16(-int32(1)) } (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = uint8(SQLITE_AFF_INTEGER) } /* ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z ** might refer to an result-set alias. This happens, for example, when ** we are resolving names in the WHERE clause of the following command: ** ** SELECT a+b AS x FROM table WHERE x<10; ** ** In cases like this, replace pExpr with a copy of the expression that ** forms the result set entry ("a+b" in the example) and return immediately. ** Note that the expression in the result set should have already been ** resolved by the time the WHERE clause is resolved. ** ** The ability to use an output result-set column in the WHERE, GROUP BY, ** or HAVING clauses, or as part of a larger expression in the ORDER BY ** clause is not standard SQL. This is a (goofy) SQLite extension, that ** is supported for backwards compatibility only. Hence, we issue a warning ** on sqlite3_log() whenever the capability is used. */ if cnt == 0 && (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_UEList) != 0 && zTab == uintptr(0) { pEList = *(*uintptr)(unsafe.Pointer(pNC + 16)) j = 0 for { if !(j < (*TExprList)(unsafe.Pointer(pEList)).FnExpr) { break } zAs = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(j)*32))).FzEName if int32(uint32(*(*uint16)(unsafe.Pointer(pEList + 8 + uintptr(j)*32 + 16 + 4))&0x3>>0)) == ENAME_NAME && Xsqlite3_stricmp(tls, zAs, zCol) == 0 { pOrig = (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(j)*32))).FpExpr if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_AllowAgg) == 0 && (*TExpr)(unsafe.Pointer(pOrig)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Agg)) != uint32(0) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6868, libc.VaList(bp+24, zAs)) return int32(WRC_Abort) } if (*TExpr)(unsafe.Pointer(pOrig)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Win)) != uint32(0) && ((*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_AllowWin) == 0 || pNC != pTopNC) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6899, libc.VaList(bp+24, zAs)) return int32(WRC_Abort) } if _sqlite3ExprVectorSize(tls, pOrig) != int32(1) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6936, 0) return int32(WRC_Abort) } _resolveAlias(tls, pParse, pEList, j, pExpr, nSubquery) cnt = int32(1) pMatch = uintptr(0) if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), pExpr) } goto lookupname_end } goto _7 _7: ; j = j + 1 } } /* Advance to the next name context. The loop will exit when either ** we have a match (cnt>0) or when we run out of name contexts. */ if cnt != 0 { break } pNC = (*TNameContext)(unsafe.Pointer(pNC)).FpNext nSubquery = nSubquery + 1 } /* ** If X and Y are NULL (in other words if only the column name Z is ** supplied) and the value of Z is enclosed in double-quotes, then ** Z is a string literal if it doesn't match any column names. In that ** case, we need to return right away and not make any changes to ** pExpr. ** ** Because no reference was made to outer contexts, the pNC->nRef ** fields are not changed in any context. */ if cnt == 0 && zTab == uintptr(0) { if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_DblQuoted)) != uint32(0) && _areDoubleQuotedStringsEnabled(tls, db, pTopNC) != 0 { /* If a double-quoted identifier does not match any known column name, ** then treat it as a string. ** ** This hack was added in the early days of SQLite in a misguided attempt ** to be compatible with MySQL 3.x, which used double-quotes for strings. ** I now sorely regret putting in this hack. The effect of this hack is ** that misspelled identifier names are silently converted into strings ** rather than causing an error, to the frustration of countless ** programmers. To all those frustrated programmers, my apologies. ** ** Someday, I hope to get rid of this hack. Unfortunately there is ** a huge amount of legacy SQL that uses it. So for now, we just ** issue a warning. */ Xsqlite3_log(tls, int32(SQLITE_WARNING), __ccgo_ts+6954, libc.VaList(bp+24, zCol)) (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_STRING) libc.Xmemset(tls, pExpr+64, 0, uint64(8)) return int32(WRC_Prune) } if _sqlite3ExprIdToTrueFalse(tls, pExpr) != 0 { return int32(WRC_Prune) } } /* ** cnt==0 means there was not match. ** cnt>1 means there were two or more matches. ** ** cnt==0 is always an error. cnt>1 is often an error, but might ** be multiple matches for a NATURAL LEFT JOIN or a LEFT JOIN USING. */ if cnt != int32(1) { if **(**uintptr)(__ccgo_up(bp)) != 0 { if (*TExprList)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnExpr == cnt-int32(1) { if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) != uint32(0) { **(**Tu32)(__ccgo_up(pExpr + 4)) &= ^libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) } else { _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = uintptr(0) _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) (*TExpr)(unsafe.Pointer(pExpr)).FpRight = uintptr(0) } _extendFJMatch(tls, pParse, bp, pMatch, (*TExpr)(unsafe.Pointer(pExpr)).FiColumn) (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_FUNCTION) *(*uintptr)(unsafe.Pointer(pExpr + 8)) = __ccgo_ts + 6989 *(*uintptr)(unsafe.Pointer(pExpr + 32)) = **(**uintptr)(__ccgo_up(bp)) (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = uint8(SQLITE_AFF_DEFER) cnt = int32(1) goto lookupname_end } else { _sqlite3ExprListDelete(tls, db, **(**uintptr)(__ccgo_up(bp))) **(**uintptr)(__ccgo_up(bp)) = uintptr(0) } } if cnt == 0 { v8 = __ccgo_ts + 6998 } else { v8 = __ccgo_ts + 7013 } zErr = v8 if zDb != 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7035, libc.VaList(bp+24, zErr, zDb, zTab, zCol)) } else { if zTab != 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7048, libc.VaList(bp+24, zErr, zTab, zCol)) } else { if cnt == 0 && (*TExpr)(unsafe.Pointer(pRight)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_DblQuoted)) != uint32(0) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7058, libc.VaList(bp+24, zErr, zCol)) } else { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7119, libc.VaList(bp+24, zErr, zCol)) } } } _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 8, 0x100) (*TNameContext)(unsafe.Pointer(pTopNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pTopNC)).FnNcErr + 1 eNewExprOp = int32(TK_NULL) } /* Remove all substructure from pExpr */ if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_TokenOnly)|libc.Int32FromInt32(EP_Leaf)) != libc.Uint32FromInt32(0)) { _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = uintptr(0) _sqlite3ExprDelete(tls, db, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) (*TExpr)(unsafe.Pointer(pExpr)).FpRight = uintptr(0) **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) } /* If a column from a table in pSrcList is referenced, then record ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes ** bit 0 to be set. Column 1 sets bit 1. And so forth. Bit 63 is ** set if the 63rd or any subsequent column is used. ** ** The colUsed mask is an optimization used to help determine if an ** index is a covering index. The correct answer is still obtained ** if the mask contains extra set bits. However, it is important to ** avoid setting bits beyond the maximum column number of the table. ** (See ticket [b92e5e8ec2cdbaa1]). ** ** If a generated column is referenced, set bits for every column ** of the table. */ if pMatch != 0 { if int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) >= 0 { **(**TBitmask)(__ccgo_up(pMatch + 40)) |= _sqlite3ExprColUsed(tls, pExpr) } else { libc.SetBitFieldPtr32Uint32(pMatch+24+4, libc.Uint32FromInt32(1), 15, 0x8000) } } (*TExpr)(unsafe.Pointer(pExpr)).Fop = libc.Uint8FromInt32(eNewExprOp) goto lookupname_end lookupname_end: ; if cnt == int32(1) { if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FxAuth != 0 && (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLUMN) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_TRIGGER)) { _sqlite3AuthRead(tls, pParse, pExpr, pSchema, (*TNameContext)(unsafe.Pointer(pNC)).FpSrcList) } /* Increment the nRef value on all name contexts from TopNC up to ** the point where the name matched. */ for { (*TNameContext)(unsafe.Pointer(pTopNC)).FnRef = (*TNameContext)(unsafe.Pointer(pTopNC)).FnRef + 1 if pTopNC == pNC { break } pTopNC = (*TNameContext)(unsafe.Pointer(pTopNC)).FpNext goto _9 _9: } return int32(WRC_Prune) } else { return int32(WRC_Abort) } return r } // C documentation // // /* // ** Process a modifier to a date-time stamp. The modifiers are // ** as follows: // ** // ** NNN days // ** NNN hours // ** NNN minutes // ** NNN.NNNN seconds // ** NNN months // ** NNN years // ** +/-YYYY-MM-DD HH:MM:SS.SSS // ** ceiling // ** floor // ** start of month // ** start of year // ** start of week // ** start of day // ** weekday N // ** unixepoch // ** auto // ** localtime // ** utc // ** subsec // ** subsecond // ** // ** Return 0 on success and 1 if there is any kind of error. If the error // ** is in a system call (i.e. localtime()), then an error message is written // ** to context pCtx. If the error is an unrecognized modifier, no error is // ** written to pCtx. // */ func _parseModifier(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, p uintptr, idx int32) (r int32) { bp := tls.Alloc(160) defer tls.Free(160) var Z, day Tsqlite3_int64 var cnt, i, rc, rx, x, y, v1 int32 var db, z2, zCopy uintptr var iErr, iGuess, iOrigJD, v2 Ti64 var rRounder, v11 float64 var z0 uint8 var v4 bool var _ /* D at bp+64 */ int32 var _ /* M at bp+60 */ int32 var _ /* Y at bp+56 */ int32 var _ /* h at bp+68 */ int32 var _ /* m at bp+72 */ int32 var _ /* new at bp+8 */ TDateTime var _ /* r at bp+0 */ float64 var _ /* tx at bp+80 */ TDateTime _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = Z, cnt, day, db, i, iErr, iGuess, iOrigJD, rRounder, rc, rx, x, y, z0, z2, zCopy, v1, v11, v2, v4 rc = int32(1) switch libc.Int32FromUint8(_sqlite3UpperToLower[uint8(**(**uint8)(__ccgo_up(z)))]) { case int32('a'): /* ** auto ** ** If rawS is available, then interpret as a julian day number, or ** a unix timestamp, depending on its magnitude. */ if Xsqlite3_stricmp(tls, z, __ccgo_ts+1272) == 0 { if idx > int32(1) { return int32(1) } /* IMP: R-33611-57934 */ _autoAdjustDate(tls, p) rc = 0 } case int32('c'): /* ** ceiling ** ** Resolve day-of-month overflow by rolling forward into the next ** month. As this is the default action, this modifier is really ** a no-op that is only included for symmetry. See "floor". */ if Xsqlite3_stricmp(tls, z, __ccgo_ts+1277) == 0 { _computeJD(tls, p) _clearYMD_HMS_TZ(tls, p) rc = 0 (*TDateTime)(unsafe.Pointer(p)).FnFloor = uint8(0) } case int32('f'): /* ** floor ** ** Resolve day-of-month overflow by rolling back to the end of the ** previous month. */ if Xsqlite3_stricmp(tls, z, __ccgo_ts+1285) == 0 { _computeJD(tls, p) **(**Tsqlite3_int64)(__ccgo_up(p)) -= int64(libc.Int32FromUint8((*TDateTime)(unsafe.Pointer(p)).FnFloor) * int32(86400000)) _clearYMD_HMS_TZ(tls, p) rc = 0 } case int32('j'): /* ** julianday ** ** Always interpret the prior number as a julian-day value. If this ** is not the first modifier, or if the prior argument is not a numeric ** value in the allowed range of julian day numbers understood by ** SQLite (0..5373484.5) then the result will be NULL. */ if Xsqlite3_stricmp(tls, z, __ccgo_ts+1291) == 0 { if idx > int32(1) { return int32(1) } /* IMP: R-31176-64601 */ if (*TDateTime)(unsafe.Pointer(p)).FvalidJD != 0 && int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x1>>0)) != 0 { rc = 0 libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) } } case int32('l'): /* localtime ** ** Assuming the current time value is UTC (a.k.a. GMT), shift it to ** show local time. */ if Xsqlite3_stricmp(tls, z, __ccgo_ts+1301) == 0 && _sqlite3NotPureFunc(tls, pCtx) != 0 { if int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x10>>4)) != 0 { v1 = SQLITE_OK } else { v1 = _toLocaltime(tls, p, pCtx) } rc = v1 libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 3, 0x8) libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 4, 0x10) } case int32('u'): /* ** unixepoch ** ** Treat the current value of p->s as the number of ** seconds since 1970. Convert to a real julian day number. */ if Xsqlite3_stricmp(tls, z, __ccgo_ts+1311) == 0 && int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x1>>0)) != 0 { if idx > int32(1) { return int32(1) } /* IMP: R-49255-55373 */ **(**float64)(__ccgo_up(bp)) = float64((*TDateTime)(unsafe.Pointer(p)).Fs*float64(1000)) + float64(2.1086676e+14) if **(**float64)(__ccgo_up(bp)) >= float64(0) && **(**float64)(__ccgo_up(bp)) < float64(4.642690608e+14) { _clearYMD_HMS_TZ(tls, p) (*TDateTime)(unsafe.Pointer(p)).FiJD = int64(**(**float64)(__ccgo_up(bp)) + libc.Float64FromFloat64(0.5)) (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(1) libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) rc = 0 } } else { if Xsqlite3_stricmp(tls, z, __ccgo_ts+1321) == 0 && _sqlite3NotPureFunc(tls, pCtx) != 0 { if int32(uint32(*(*uint8)(unsafe.Pointer(p + 44))&0x8>>3)) == 0 { /* Guess at the corresponding utc time */ cnt = 0 /* Guess is off by this much */ _computeJD(tls, p) v2 = (*TDateTime)(unsafe.Pointer(p)).FiJD iOrigJD = v2 iGuess = v2 iErr = 0 for { libc.Xmemset(tls, bp+8, 0, uint64(48)) iGuess = iGuess - iErr (**(**TDateTime)(__ccgo_up(bp + 8))).FiJD = iGuess (**(**TDateTime)(__ccgo_up(bp + 8))).FvalidJD = uint8(1) rc = _toLocaltime(tls, bp+8, pCtx) if rc != 0 { return rc } _computeJD(tls, bp+8) iErr = (**(**TDateTime)(__ccgo_up(bp + 8))).FiJD - iOrigJD goto _5 _5: ; if v4 = iErr != 0; v4 { v1 = cnt cnt = cnt + 1 } if !(v4 && v1 < int32(3)) { break } } libc.Xmemset(tls, p, 0, uint64(48)) (*TDateTime)(unsafe.Pointer(p)).FiJD = iGuess (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(1) libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8) libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10) } rc = SQLITE_OK } } case int32('w'): /* ** weekday N ** ** Move the date to the same time on the next occurrence of ** weekday N where 0==Sunday, 1==Monday, and so forth. If the ** date is already on the appropriate weekday, this is a no-op. */ if v4 = Xsqlite3_strnicmp(tls, z, __ccgo_ts+1325, int32(8)) == 0 && _sqlite3AtoF(tls, z+8, bp) > 0 && **(**float64)(__ccgo_up(bp)) >= float64(0) && **(**float64)(__ccgo_up(bp)) < float64(7); v4 { v1 = int32(**(**float64)(__ccgo_up(bp))) n = v1 } if v4 && float64(v1) == **(**float64)(__ccgo_up(bp)) { _computeYMD_HMS(tls, p) (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0) _computeJD(tls, p) Z = ((*TDateTime)(unsafe.Pointer(p)).FiJD + int64(129600000)) / int64(86400000) % int64(7) if Z > int64(n) { Z = Z - int64(7) } **(**Tsqlite3_int64)(__ccgo_up(p)) += (int64(n) - Z) * int64(86400000) _clearYMD_HMS_TZ(tls, p) rc = 0 } case int32('s'): /* ** start of TTTTT ** ** Move the date backwards to the beginning of the current day, ** or month or year. ** ** subsecond ** subsec ** ** Show subsecond precision in the output of datetime() and ** unixepoch() and strftime('%s'). */ if Xsqlite3_strnicmp(tls, z, __ccgo_ts+1334, int32(9)) != 0 { if Xsqlite3_stricmp(tls, z, __ccgo_ts+1232) == 0 || Xsqlite3_stricmp(tls, z, __ccgo_ts+1239) == 0 { libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 2, 0x4) rc = 0 } break } if !((*TDateTime)(unsafe.Pointer(p)).FvalidJD != 0) && !((*TDateTime)(unsafe.Pointer(p)).FvalidYMD != 0) && !((*TDateTime)(unsafe.Pointer(p)).FvalidHMS != 0) { break } z = z + uintptr(9) _computeYMD(tls, p) (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(1) v1 = libc.Int32FromInt32(0) (*TDateTime)(unsafe.Pointer(p)).Fm = v1 (*TDateTime)(unsafe.Pointer(p)).Fh = v1 (*TDateTime)(unsafe.Pointer(p)).Fs = float64(0) libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0) if Xsqlite3_stricmp(tls, z, __ccgo_ts+1344) == 0 { (*TDateTime)(unsafe.Pointer(p)).FD = int32(1) rc = 0 } else { if Xsqlite3_stricmp(tls, z, __ccgo_ts+1350) == 0 { (*TDateTime)(unsafe.Pointer(p)).FM = int32(1) (*TDateTime)(unsafe.Pointer(p)).FD = int32(1) rc = 0 } else { if Xsqlite3_stricmp(tls, z, __ccgo_ts+1355) == 0 { rc = 0 } } } case int32('+'): fallthrough case int32('-'): fallthrough case int32('0'): fallthrough case int32('1'): fallthrough case int32('2'): fallthrough case int32('3'): fallthrough case int32('4'): fallthrough case int32('5'): fallthrough case int32('6'): fallthrough case int32('7'): fallthrough case int32('8'): fallthrough case int32('9'): z2 = z db = Xsqlite3_context_db_handle(tls, pCtx) z0 = **(**uint8)(__ccgo_up(z)) n = int32(1) for { if !(**(**uint8)(__ccgo_up(z + uintptr(n))) != 0) { break } if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(n)))) == int32(':') { break } if libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + uintptr(n))))])&int32(0x01) != 0 { break } if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(n)))) == int32('-') { if n == int32(5) && _getDigits(tls, z+1, __ccgo_ts+1359, libc.VaList(bp+136, bp+56)) == int32(1) { break } if n == int32(6) && _getDigits(tls, z+1, __ccgo_ts+1363, libc.VaList(bp+136, bp+56)) == int32(1) { break } } goto _9 _9: ; n = n + 1 } zCopy = _sqlite3DbStrNDup(tls, db, z, libc.Uint64FromInt32(n)) if zCopy == uintptr(0) { break } rx = libc.BoolInt32(_sqlite3AtoF(tls, zCopy, bp) <= 0) _sqlite3DbFree(tls, db, zCopy) if rx != 0 { break } if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + uintptr(n)))) == int32('-') { /* A modifier of the form (+|-)YYYY-MM-DD adds or subtracts the ** specified number of years, months, and days. MM is limited to ** the range 0-11 and DD is limited to 0-30. */ if libc.Int32FromUint8(z0) != int32('+') && libc.Int32FromUint8(z0) != int32('-') { break } /* Must start with +/- */ if n == int32(5) { if _getDigits(tls, z+1, __ccgo_ts+1367, libc.VaList(bp+136, bp+56, bp+60, bp+64)) != int32(3) { break } } else { if _getDigits(tls, z+1, __ccgo_ts+1379, libc.VaList(bp+136, bp+56, bp+60, bp+64)) != int32(3) { break } z = z + 1 } if **(**int32)(__ccgo_up(bp + 60)) >= int32(12) { break } /* M range 0..11 */ if **(**int32)(__ccgo_up(bp + 64)) >= int32(31) { break } /* D range 0..30 */ _computeYMD_HMS(tls, p) (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0) if libc.Int32FromUint8(z0) == int32('-') { **(**int32)(__ccgo_up(p + 8)) -= **(**int32)(__ccgo_up(bp + 56)) **(**int32)(__ccgo_up(p + 12)) -= **(**int32)(__ccgo_up(bp + 60)) **(**int32)(__ccgo_up(bp + 64)) = -**(**int32)(__ccgo_up(bp + 64)) } else { **(**int32)(__ccgo_up(p + 8)) += **(**int32)(__ccgo_up(bp + 56)) **(**int32)(__ccgo_up(p + 12)) += **(**int32)(__ccgo_up(bp + 60)) } if (*TDateTime)(unsafe.Pointer(p)).FM > 0 { v1 = ((*TDateTime)(unsafe.Pointer(p)).FM - int32(1)) / int32(12) } else { v1 = ((*TDateTime)(unsafe.Pointer(p)).FM - int32(12)) / int32(12) } x = v1 **(**int32)(__ccgo_up(p + 8)) += x **(**int32)(__ccgo_up(p + 12)) -= x * int32(12) _computeFloor(tls, p) _computeJD(tls, p) (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(0) (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = uint8(0) **(**Tsqlite3_int64)(__ccgo_up(p)) += int64(**(**int32)(__ccgo_up(bp + 64))) * int64(86400000) if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z + 11))) == 0 { rc = 0 break } if libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z + 11)))])&int32(0x01) != 0 && _getDigits(tls, z+12, __ccgo_ts+1204, libc.VaList(bp+136, bp+68, bp+72)) == int32(2) { z2 = z + 12 n = int32(2) } else { break } } if libc.Int32FromUint8(**(**uint8)(__ccgo_up(z2 + uintptr(n)))) == int32(':') { if !(libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z2)))])&libc.Int32FromInt32(0x04) != 0) { z2 = z2 + 1 } libc.Xmemset(tls, bp+80, 0, uint64(48)) if _parseHhMmSs(tls, z2, bp+80) != 0 { break } _computeJD(tls, bp+80) (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD -= int64(43200000) day = (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD / int64(86400000) (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD -= day * int64(86400000) if libc.Int32FromUint8(z0) == int32('-') { (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD = -(**(**TDateTime)(__ccgo_up(bp + 80))).FiJD } _computeJD(tls, p) _clearYMD_HMS_TZ(tls, p) **(**Tsqlite3_int64)(__ccgo_up(p)) += (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD rc = 0 break } /* If control reaches this point, it means the transformation is ** one of the forms like "+NNN days". */ z = z + uintptr(n) for libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(z)))])&int32(0x01) != 0 { z = z + 1 } n = _sqlite3Strlen30(tls, z) if n < int32(3) || n > int32(10) { break } if libc.Int32FromUint8(_sqlite3UpperToLower[uint8(**(**uint8)(__ccgo_up(z + uintptr(n-int32(1)))))]) == int32('s') { n = n - 1 } _computeJD(tls, p) if **(**float64)(__ccgo_up(bp)) < libc.Float64FromInt32(0) { v11 = -libc.Float64FromFloat64(0.5) } else { v11 = +libc.Float64FromFloat64(0.5) } rRounder = v11 (*TDateTime)(unsafe.Pointer(p)).FnFloor = uint8(0) i = 0 for { if !(i < libc.Int32FromUint64(libc.Uint64FromInt64(96)/libc.Uint64FromInt64(16))) { break } if libc.Int32FromUint8(_aXformType[i].FnName) == n && Xsqlite3_strnicmp(tls, uintptr(unsafe.Pointer(&_aXformType))+uintptr(i)*16+1, z, n) == 0 && **(**float64)(__ccgo_up(bp)) > float64(-_aXformType[i].FrLimit) && **(**float64)(__ccgo_up(bp)) < float64(_aXformType[i].FrLimit) { switch i { case int32(4): /* Special processing to add months */ _computeYMD_HMS(tls, p) **(**int32)(__ccgo_up(p + 12)) += int32(**(**float64)(__ccgo_up(bp))) if (*TDateTime)(unsafe.Pointer(p)).FM > 0 { v1 = ((*TDateTime)(unsafe.Pointer(p)).FM - int32(1)) / int32(12) } else { v1 = ((*TDateTime)(unsafe.Pointer(p)).FM - int32(12)) / int32(12) } x = v1 **(**int32)(__ccgo_up(p + 8)) += x **(**int32)(__ccgo_up(p + 12)) -= x * int32(12) _computeFloor(tls, p) (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0) **(**float64)(__ccgo_up(bp)) = **(**float64)(__ccgo_up(bp)) - float64(int32(**(**float64)(__ccgo_up(bp)))) case int32(5): /* Special processing to add years */ y = int32(**(**float64)(__ccgo_up(bp))) _computeYMD_HMS(tls, p) **(**int32)(__ccgo_up(p + 8)) += y _computeFloor(tls, p) (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0) **(**float64)(__ccgo_up(bp)) = **(**float64)(__ccgo_up(bp)) - float64(int32(**(**float64)(__ccgo_up(bp)))) break } _computeJD(tls, p) **(**Tsqlite3_int64)(__ccgo_up(p)) += int64(float64(float64(**(**float64)(__ccgo_up(bp))*libc.Float64FromFloat64(1000))*float64(_aXformType[i].FrXform)) + rRounder) rc = 0 break } goto _12 _12: ; i = i + 1 } _clearYMD_HMS_TZ(tls, p) default: break } return rc } // C documentation // // /* // ** This routine is callback for sqlite3WalkExpr(). // ** // ** Resolve symbolic names into TK_COLUMN operators for the current // ** node in the expression tree. Return 0 to continue the search down // ** the tree or 2 to abort the tree walk. // ** // ** This routine also does error checking and name resolution for // ** function names. The operator for aggregate functions is changed // ** to TK_AGG_FUNCTION. // */ func _resolveExprStep(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) var anRef [8]int32 var auth, i, is_agg, n, nLeft, nRef, nRight, no_such_func, rc, savedAllowFlags, wrong_num_args, v5 int32 var enc Tu8 var p, pDef, pItem, pLeft, pList, pNC, pNC2, pParse, pRight, pRight1, pSel, pSrcList, pWin, zDb, zId, zTable, zType, v4 uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = anRef, auth, enc, i, is_agg, n, nLeft, nRef, nRight, no_such_func, p, pDef, pItem, pLeft, pList, pNC, pNC2, pParse, pRight, pRight1, pSel, pSrcList, pWin, rc, savedAllowFlags, wrong_num_args, zDb, zId, zTable, zType, v4, v5 pNC = *(*uintptr)(unsafe.Pointer(pWalker + 40)) pParse = (*TNameContext)(unsafe.Pointer(pNC)).FpParse switch libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) { /* The special operator TK_ROW means use the rowid for the first ** column in the FROM clause. This is used by the LIMIT and ORDER BY ** clause processing on UPDATE and DELETE statements, and by ** UPDATE ... FROM statement processing. */ case int32(TK_ROW): pSrcList = (*TNameContext)(unsafe.Pointer(pNC)).FpSrcList pItem = pSrcList + 8 (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_COLUMN) *(*uintptr)(unsafe.Pointer(pExpr + 64)) = (*TSrcItem)(unsafe.Pointer(pItem)).FpSTab (*TExpr)(unsafe.Pointer(pExpr)).FiTable = (*TSrcItem)(unsafe.Pointer(pItem)).FiCursor (*TExpr)(unsafe.Pointer(pExpr)).FiColumn = (*TExpr)(unsafe.Pointer(pExpr)).FiColumn - 1 (*TExpr)(unsafe.Pointer(pExpr)).FaffExpr = uint8(SQLITE_AFF_INTEGER) break /* An optimization: Attempt to convert ** ** "expr IS NOT NULL" --> "TRUE" ** "expr IS NULL" --> "FALSE" ** ** if we can prove that "expr" is never NULL. Call this the ** "NOT NULL strength reduction optimization". ** ** If this optimization occurs, also restore the NameContext ref-counts ** to the state they where in before the "column" LHS expression was ** resolved. This prevents "column" from being counted as having been ** referenced, which might prevent a SELECT from being erroneously ** marked as correlated. ** ** 2024-03-28: Beware of aggregates. A bare column of aggregated table ** can still evaluate to NULL even though it is marked as NOT NULL. ** Example: ** ** CREATE TABLE t1(a INT NOT NULL); ** SELECT a, a IS NULL, a IS NOT NULL, count(*) FROM t1; ** ** The "a IS NULL" and "a IS NOT NULL" expressions cannot be optimized ** here because at the time this case is hit, we do not yet know whether ** or not t1 is being aggregated. We have to assume the worst and omit ** the optimization. The only time it is safe to apply this optimization ** is within the WHERE clause. */ fallthrough case int32(TK_NOTNULL): fallthrough case int32(TK_ISNULL): i = 0 p = pNC for { if !(p != 0 && i < libc.Int32FromUint64(libc.Uint64FromInt64(32)/libc.Uint64FromInt64(4))) { break } anRef[i] = (*TNameContext)(unsafe.Pointer(p)).FnRef goto _1 _1: ; p = (*TNameContext)(unsafe.Pointer(p)).FpNext i = i + 1 } _sqlite3WalkExpr(tls, pWalker, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { return int32(WRC_Prune) } if _sqlite3ExprCanBeNull(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) != 0 { /* The expression can be NULL. So the optimization does not apply */ return int32(WRC_Prune) } i = 0 p = pNC for { if !(p != 0) { break } if (*TNameContext)(unsafe.Pointer(p)).FncFlags&int32(NC_Where) == 0 { return int32(WRC_Prune) /* Not in a WHERE clause. Unsafe to optimize. */ } goto _2 _2: ; p = (*TNameContext)(unsafe.Pointer(p)).FpNext i = i + 1 } *(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pExpr)).Fu)) = libc.BoolInt32(libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_NOTNULL)) **(**Tu32)(__ccgo_up(pExpr + 4)) |= uint32(EP_IntValue) (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_INTEGER) i = 0 p = pNC for { if !(p != 0 && i < libc.Int32FromUint64(libc.Uint64FromInt64(32)/libc.Uint64FromInt64(4))) { break } (*TNameContext)(unsafe.Pointer(p)).FnRef = anRef[i] goto _3 _3: ; p = (*TNameContext)(unsafe.Pointer(p)).FpNext i = i + 1 } _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) (*TExpr)(unsafe.Pointer(pExpr)).FpLeft = uintptr(0) return int32(WRC_Prune) /* A column name: ID ** Or table name and column name: ID.ID ** Or a database, table and column: ID.ID.ID ** ** The TK_ID and TK_OUT cases are combined so that there will only ** be one call to lookupName(). Then the compiler will in-line ** lookupName() for a size reduction and performance increase. */ fallthrough case int32(TK_ID): fallthrough case int32(TK_DOT): if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_ID) { zDb = uintptr(0) zTable = uintptr(0) pRight = pExpr } else { pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_IdxExpr)|libc.Int32FromInt32(NC_GenCol)) != 0 { _notValidImpl(tls, pParse, pNC, __ccgo_ts+7228, uintptr(0), pExpr) } pRight = (*TExpr)(unsafe.Pointer(pExpr)).FpRight if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight)).Fop) == int32(TK_ID) { zDb = uintptr(0) } else { zDb = *(*uintptr)(unsafe.Pointer(pLeft + 8)) pLeft = (*TExpr)(unsafe.Pointer(pRight)).FpLeft pRight = (*TExpr)(unsafe.Pointer(pRight)).FpRight } zTable = *(*uintptr)(unsafe.Pointer(pLeft + 8)) if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { _sqlite3RenameTokenRemap(tls, pParse, pExpr, pRight) _sqlite3RenameTokenRemap(tls, pParse, pExpr+64, pLeft) } } return _lookupName(tls, pParse, zDb, zTable, pRight, pNC, pExpr) /* Resolve function names */ fallthrough case int32(TK_FUNCTION): /* Number of arguments */ no_such_func = 0 /* True if no such function exists */ wrong_num_args = 0 /* True if wrong number of arguments */ is_agg = 0 /* Information about the function */ enc = (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fenc /* The database encoding */ savedAllowFlags = (*TNameContext)(unsafe.Pointer(pNC)).FncFlags & (libc.Int32FromInt32(NC_AllowAgg) | libc.Int32FromInt32(NC_AllowWin)) if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) && libc.Int32FromUint8((*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FeFrmType) != int32(TK_FILTER) { v4 = *(*uintptr)(unsafe.Pointer(pExpr + 64)) } else { v4 = uintptr(0) } pWin = v4 pList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) if pList != 0 { v5 = (*TExprList)(unsafe.Pointer(pList)).FnExpr } else { v5 = 0 } n = v5 zId = *(*uintptr)(unsafe.Pointer(pExpr + 8)) pDef = _sqlite3FindFunction(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zId, n, enc, uint8(0)) if pDef == uintptr(0) { pDef = _sqlite3FindFunction(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zId, -int32(2), enc, uint8(0)) if pDef == uintptr(0) { no_such_func = int32(1) } else { wrong_num_args = int32(1) } } else { is_agg = libc.BoolInt32((*TFuncDef)(unsafe.Pointer(pDef)).FxFinalize != uintptr(0)) if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_UNLIKELY) != 0 { **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_Unlikely)) if n == int32(2) { (*TExpr)(unsafe.Pointer(pExpr)).FiTable = _exprProbability(tls, (*(*TExprList_item)(unsafe.Pointer(pList + 8 + 1*32))).FpExpr) if (*TExpr)(unsafe.Pointer(pExpr)).FiTable < 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7245, libc.VaList(bp+8, pExpr)) (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 } } else { /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is ** equivalent to likelihood(X, 0.0625). ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is ** short-hand for likelihood(X,0.0625). ** EVIDENCE-OF: R-36850-34127 The likely(X) function is short-hand ** for likelihood(X,0.9375). ** EVIDENCE-OF: R-53436-40973 The likely(X) function is equivalent ** to likelihood(X,0.9375). */ /* TUNING: unlikely() probability is 0.0625. likely() is 0.9375 */ if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TFuncDef)(unsafe.Pointer(pDef)).FzName))) == int32('u') { v5 = int32(8388608) } else { v5 = int32(125829120) } (*TExpr)(unsafe.Pointer(pExpr)).FiTable = v5 } } auth = _sqlite3AuthCheck(tls, pParse, int32(SQLITE_FUNCTION), uintptr(0), (*TFuncDef)(unsafe.Pointer(pDef)).FzName, uintptr(0)) if auth != SQLITE_OK { if auth == int32(SQLITE_DENY) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7309, libc.VaList(bp+8, pExpr)) (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 } (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_NULL) return int32(WRC_Prune) } /* If the function may call sqlite3_value_subtype(), then set the ** EP_SubtArg flag on all of its argument expressions. This prevents ** where.c from replacing the expression with a value read from an ** index on the same expression, which will not have the correct ** subtype. Also set the flag if the function expression itself is ** an EP_SubtArg expression. In this case subtypes are required as ** the function may return a value with a subtype back to its ** caller using sqlite3_result_value(). */ if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_SUBTYPE) != 0 || (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromUint32(EP_SubtArg) != uint32(0) { _resolveSetExprSubtypeArg(tls, pList) } if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)|libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG)) != 0 { /* For the purposes of the EP_ConstFunc flag, date and time ** functions and other functions that change slowly are considered ** constant because they are constant for the duration of one query. ** This allows them to be factored out of inner loops. */ **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_ConstFunc)) } if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_CONSTANT) == uint32(0) { /* Clearly non-deterministic functions like random(), but also ** date/time functions that use 'now', and other functions like ** sqlite_version() that might change over time cannot be used ** in an index or generated column. Curiously, they can be used ** in a CHECK constraint. SQLServer, MySQL, and PostgreSQL all ** allow this. */ if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_IdxExpr)|libc.Int32FromInt32(NC_PartIdx)|libc.Int32FromInt32(NC_GenCol)) != 0 { _notValidImpl(tls, pParse, pNC, __ccgo_ts+7345, uintptr(0), pExpr) } } else { /* Must fit in 8 bits */ (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = libc.Uint8FromInt32((*TNameContext)(unsafe.Pointer(pNC)).FncFlags & int32(NC_SelfRef)) } if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_INTERNAL) != uint32(0) && libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 && (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags&uint32(DBFLAG_InternalFunc) == uint32(0) { /* Internal-use-only functions are disallowed unless the ** SQL is being compiled using sqlite3NestedParse() or ** the SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test-control has be ** used to activate internal functions for testing purposes */ no_such_func = int32(1) pDef = uintptr(0) } else { if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_DIRECT)|libc.Int32FromInt32(SQLITE_FUNC_UNSAFE)) != uint32(0) && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_FromDDL) != 0 { **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_FromDDL)) } _sqlite3ExprFunctionUsable(tls, pParse, pExpr, pDef) } } } if 0 == libc.BoolInt32(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME)) { if pDef != 0 && (*TFuncDef)(unsafe.Pointer(pDef)).FxValue == uintptr(0) && pWin != 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7373, libc.VaList(bp+8, pExpr)) (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 } else { if is_agg != 0 && (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_AllowAgg) == 0 || is_agg != 0 && (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_WINDOW) != 0 && !(pWin != 0) || is_agg != 0 && pWin != 0 && (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_AllowWin) == 0 { if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_WINDOW) != 0 || pWin != 0 { zType = __ccgo_ts + 7416 } else { zType = __ccgo_ts + 7423 } _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7433, libc.VaList(bp+8, zType, pExpr)) (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 is_agg = 0 } else { if no_such_func != 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Finit1.Fbusy) == 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7461, libc.VaList(bp+8, pExpr)) (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 } else { if wrong_num_args != 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7483, libc.VaList(bp+8, pExpr)) (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 } else { if is_agg == 0 && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7527, libc.VaList(bp+8, pExpr)) (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 } else { if is_agg == 0 && (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 { _sqlite3ExprOrderByAggregateError(tls, pParse, pExpr) (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr = (*TNameContext)(unsafe.Pointer(pNC)).FnNcErr + 1 } } } } } } if is_agg != 0 { /* Window functions may not be arguments of aggregate functions. ** Or arguments of other window functions. But aggregate functions ** may be arguments for window functions. */ if !(pWin != 0) { v5 = int32(NC_AllowAgg) } else { v5 = 0 } **(**int32)(__ccgo_up(pNC + 40)) &= ^(libc.Int32FromInt32(NC_AllowWin) | v5) } } else { if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) || (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 { is_agg = int32(1) } } _sqlite3WalkExprList(tls, pWalker, pList) if is_agg != 0 { if (*TExpr)(unsafe.Pointer(pExpr)).FpLeft != 0 { _sqlite3WalkExprList(tls, pWalker, *(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpLeft + 32))) } if pWin != 0 && (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { pSel = (*TNameContext)(unsafe.Pointer(pNC)).FpWinSelect if libc.BoolInt32(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME)) == 0 { if pSel != 0 { v4 = (*TSelect)(unsafe.Pointer(pSel)).FpWinDefn } else { v4 = uintptr(0) } _sqlite3WindowUpdate(tls, pParse, v4, pWin, pDef) if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { break } } _sqlite3WalkExprList(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpPartition) _sqlite3WalkExprList(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy) _sqlite3WalkExpr(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpFilter) _sqlite3WindowLink(tls, pSel, pWin) **(**int32)(__ccgo_up(pNC + 40)) |= int32(NC_HasWin) } else { /* For looping up thru outer contexts */ (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_AGG_FUNCTION) (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = uint8(0) if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { _sqlite3WalkExpr(tls, pWalker, (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FpFilter) } pNC2 = pNC for pNC2 != 0 && _sqlite3ReferencesSrcList(tls, pParse, pExpr, (*TNameContext)(unsafe.Pointer(pNC2)).FpSrcList) == 0 { v4 = pExpr + 2 *(*Tu8)(unsafe.Pointer(v4)) = Tu8(uint32(*(*Tu8)(unsafe.Pointer(v4))) + (libc.Uint32FromInt32(1) + (*TNameContext)(unsafe.Pointer(pNC2)).FnNestedSelect)) pNC2 = (*TNameContext)(unsafe.Pointer(pNC2)).FpNext } if pNC2 != 0 && pDef != 0 { v4 = pExpr + 2 *(*Tu8)(unsafe.Pointer(v4)) = Tu8(uint32(*(*Tu8)(unsafe.Pointer(v4))) + (*TNameContext)(unsafe.Pointer(pNC2)).FnNestedSelect) v4 = pNC2 + 40 *(*int32)(unsafe.Pointer(v4)) = int32(uint32(*(*int32)(unsafe.Pointer(v4))) | (libc.Uint32FromInt32(NC_HasAgg) | ((*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags^libc.Uint32FromInt32(SQLITE_FUNC_ANYORDER))&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_MINMAX)|libc.Int32FromInt32(SQLITE_FUNC_ANYORDER)))) } } **(**int32)(__ccgo_up(pNC + 40)) |= savedAllowFlags } /* FIX ME: Compute pExpr->affinity based on the expected return ** type of the function */ return int32(WRC_Prune) case int32(TK_EXISTS): fallthrough case int32(TK_SELECT): fallthrough case int32(TK_IN): if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0) { nRef = (*TNameContext)(unsafe.Pointer(pNC)).FnRef if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_EXISTS) { libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 4, 0x10) } if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_SelfRef) != 0 { _notValidImpl(tls, pParse, pNC, __ccgo_ts+7575, pExpr, pExpr) } else { _sqlite3WalkSelect(tls, pWalker, *(*uintptr)(unsafe.Pointer(pExpr + 32))) } if nRef != (*TNameContext)(unsafe.Pointer(pNC)).FnRef { **(**Tu32)(__ccgo_up(pExpr + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_VarSelect)) **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 4)) |= uint32(SF_Correlated) } **(**int32)(__ccgo_up(pNC + 40)) |= int32(NC_Subquery) } case int32(TK_VARIABLE): if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&(libc.Int32FromInt32(NC_IsCheck)|libc.Int32FromInt32(NC_PartIdx)|libc.Int32FromInt32(NC_IdxExpr)|libc.Int32FromInt32(NC_GenCol)) != 0 { _notValidImpl(tls, pParse, pNC, __ccgo_ts+7586, pExpr, pExpr) } case int32(TK_IS): fallthrough case int32(TK_ISNOT): pRight1 = _sqlite3ExprSkipCollateAndLikely(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) /* Handle special cases of "x IS TRUE", "x IS FALSE", "x IS NOT TRUE", ** and "x IS NOT FALSE". */ if pRight1 != 0 && (libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight1)).Fop) == int32(TK_ID) || libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight1)).Fop) == int32(TK_TRUEFALSE)) { rc = _resolveExprStep(tls, pWalker, pRight1) if rc == int32(WRC_Abort) { return int32(WRC_Abort) } if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRight1)).Fop) == int32(TK_TRUEFALSE) { (*TExpr)(unsafe.Pointer(pExpr)).Fop2 = (*TExpr)(unsafe.Pointer(pExpr)).Fop (*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_TRUTH) return WRC_Continue } } fallthrough case int32(TK_BETWEEN): fallthrough case int32(TK_EQ): fallthrough case int32(TK_NE): fallthrough case int32(TK_LT): fallthrough case int32(TK_LE): fallthrough case int32(TK_GT): fallthrough case int32(TK_GE): if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { break } nLeft = _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft) if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_BETWEEN) { nRight = _sqlite3ExprVectorSize(tls, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8))).FpExpr) if nRight == nLeft { nRight = _sqlite3ExprVectorSize(tls, (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)) + 8 + 1*32))).FpExpr) } } else { nRight = _sqlite3ExprVectorSize(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) } if nLeft != nRight { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6936, 0) _sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pExpr) } break } if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { v5 = int32(WRC_Abort) } else { v5 = WRC_Continue } return v5 } // C documentation // // /* // ** Add a new column to the table currently being constructed. // ** // ** The parser calls this routine once for each column declaration // ** in a CREATE TABLE statement. sqlite3StartTable() gets called // ** first to get things going. Then this routine is called for each // ** column. // */ func _sqlite3AddColumn(tls *libc.TLS, pParse uintptr, _sName TToken, _sType TToken) { bp := tls.Alloc(48) defer tls.Free(48) *(*TToken)(unsafe.Pointer(bp)) = _sName *(*TToken)(unsafe.Pointer(bp + 16)) = _sType var aNew, db, p, pCol, z, zType, v1 uintptr var affinity uint8 var eType, h, szEst Tu8 var i int32 _, _, _, _, _, _, _, _, _, _, _, _ = aNew, affinity, db, eType, h, i, p, pCol, szEst, z, zType, v1 db = (*TParse)(unsafe.Pointer(pParse)).Fdb eType = uint8(COLTYPE_CUSTOM) szEst = uint8(1) affinity = uint8(SQLITE_AFF_BLOB) v1 = (*TParse)(unsafe.Pointer(pParse)).FpNewTable p = v1 if v1 == uintptr(0) { return } if int32((*TTable)(unsafe.Pointer(p)).FnCol)+int32(1) > **(**int32)(__ccgo_up(db + 136 + 2*4)) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13984, libc.VaList(bp+40, (*TTable)(unsafe.Pointer(p)).FzName)) return } if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { _sqlite3DequoteToken(tls, bp) } /* Because keywords GENERATE ALWAYS can be converted into identifiers ** by the parser, we can sometimes end up with a typename that ends ** with "generated always". Check for this case and omit the surplus ** text. */ if (**(**TToken)(__ccgo_up(bp + 16))).Fn >= uint32(16) && Xsqlite3_strnicmp(tls, (**(**TToken)(__ccgo_up(bp + 16))).Fz+uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn-libc.Uint32FromInt32(6)), __ccgo_ts+14007, int32(6)) == 0 { (**(**TToken)(__ccgo_up(bp + 16))).Fn -= uint32(6) for (**(**TToken)(__ccgo_up(bp + 16))).Fn > uint32(0) && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up((**(**TToken)(__ccgo_up(bp + 16))).Fz + uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn-uint32(1)))))])&int32(0x01) != 0 { (**(**TToken)(__ccgo_up(bp + 16))).Fn = (**(**TToken)(__ccgo_up(bp + 16))).Fn - 1 } if (**(**TToken)(__ccgo_up(bp + 16))).Fn >= uint32(9) && Xsqlite3_strnicmp(tls, (**(**TToken)(__ccgo_up(bp + 16))).Fz+uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn-libc.Uint32FromInt32(9)), __ccgo_ts+14014, int32(9)) == 0 { (**(**TToken)(__ccgo_up(bp + 16))).Fn -= uint32(9) for (**(**TToken)(__ccgo_up(bp + 16))).Fn > uint32(0) && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up((**(**TToken)(__ccgo_up(bp + 16))).Fz + uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn-uint32(1)))))])&int32(0x01) != 0 { (**(**TToken)(__ccgo_up(bp + 16))).Fn = (**(**TToken)(__ccgo_up(bp + 16))).Fn - 1 } } } /* Check for standard typenames. For standard typenames we will ** set the Column.eType field rather than storing the typename after ** the column name, in order to save space. */ if (**(**TToken)(__ccgo_up(bp + 16))).Fn >= uint32(3) { _sqlite3DequoteToken(tls, bp+16) i = 0 for { if !(i < int32(SQLITE_N_STDTYPE)) { break } if (**(**TToken)(__ccgo_up(bp + 16))).Fn == uint32(_sqlite3StdTypeLen[i]) && Xsqlite3_strnicmp(tls, (**(**TToken)(__ccgo_up(bp + 16))).Fz, _sqlite3StdType[i], libc.Int32FromUint32((**(**TToken)(__ccgo_up(bp + 16))).Fn)) == 0 { (**(**TToken)(__ccgo_up(bp + 16))).Fn = uint32(0) eType = libc.Uint8FromInt32(i + int32(1)) affinity = _sqlite3StdTypeAffinity[i] if libc.Int32FromUint8(affinity) <= int32(SQLITE_AFF_TEXT) { szEst = uint8(5) } break } goto _2 _2: ; i = i + 1 } } z = _sqlite3DbMallocRaw(tls, db, libc.Uint64FromInt64(libc.Int64FromUint32((**(**TToken)(__ccgo_up(bp))).Fn)+int64(1)+libc.Int64FromUint32((**(**TToken)(__ccgo_up(bp + 16))).Fn)+libc.BoolInt64((**(**TToken)(__ccgo_up(bp + 16))).Fn > libc.Uint32FromInt32(0)))) if z == uintptr(0) { return } if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { _sqlite3RenameTokenMap(tls, pParse, z, bp) } libc.Xmemcpy(tls, z, (**(**TToken)(__ccgo_up(bp))).Fz, uint64((**(**TToken)(__ccgo_up(bp))).Fn)) **(**uint8)(__ccgo_up(z + uintptr((**(**TToken)(__ccgo_up(bp))).Fn))) = uint8(0) _sqlite3Dequote(tls, z) if (*TTable)(unsafe.Pointer(p)).FnCol != 0 && _sqlite3ColumnIndex(tls, p, z) >= 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14024, libc.VaList(bp+40, z)) _sqlite3DbFree(tls, db, z) return } aNew = _sqlite3DbRealloc(tls, db, (*TTable)(unsafe.Pointer(p)).FaCol, libc.Uint64FromInt64(int64((*TTable)(unsafe.Pointer(p)).FnCol)+libc.Int64FromInt32(1))*uint64(16)) if aNew == uintptr(0) { _sqlite3DbFree(tls, db, z) return } (*TTable)(unsafe.Pointer(p)).FaCol = aNew pCol = (*TTable)(unsafe.Pointer(p)).FaCol + uintptr((*TTable)(unsafe.Pointer(p)).FnCol)*16 libc.Xmemset(tls, pCol, 0, uint64(16)) (*TColumn)(unsafe.Pointer(pCol)).FzCnName = z (*TColumn)(unsafe.Pointer(pCol)).FhName = _sqlite3StrIHash(tls, z) if (**(**TToken)(__ccgo_up(bp + 16))).Fn == uint32(0) { /* If there is no type specified, columns have the default affinity ** 'BLOB' with a default size of 4 bytes. */ (*TColumn)(unsafe.Pointer(pCol)).Faffinity = affinity libc.SetBitFieldPtr8Uint32(pCol+8, uint32(eType), 4, 0xf0) (*TColumn)(unsafe.Pointer(pCol)).FszEst = szEst } else { zType = z + uintptr(_sqlite3Strlen30(tls, z)) + uintptr(1) libc.Xmemcpy(tls, zType, (**(**TToken)(__ccgo_up(bp + 16))).Fz, uint64((**(**TToken)(__ccgo_up(bp + 16))).Fn)) **(**uint8)(__ccgo_up(zType + uintptr((**(**TToken)(__ccgo_up(bp + 16))).Fn))) = uint8(0) _sqlite3Dequote(tls, zType) (*TColumn)(unsafe.Pointer(pCol)).Faffinity = _sqlite3AffinityType(tls, zType, pCol) v1 = pCol + 14 *(*Tu16)(unsafe.Pointer(v1)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v1))) | libc.Int32FromInt32(COLFLAG_HASTYPE)) } if int32((*TTable)(unsafe.Pointer(p)).FnCol) <= int32(0xff) { h = uint8(uint64((*TColumn)(unsafe.Pointer(pCol)).FhName) % uint64(16)) **(**Tu8)(__ccgo_up(p + 104 + uintptr(h))) = libc.Uint8FromInt16((*TTable)(unsafe.Pointer(p)).FnCol) } (*TTable)(unsafe.Pointer(p)).FnCol = (*TTable)(unsafe.Pointer(p)).FnCol + 1 (*TTable)(unsafe.Pointer(p)).FnNVCol = (*TTable)(unsafe.Pointer(p)).FnNVCol + 1 (*(*struct { FaddrCrTab int32 FregRowid int32 FregRoot int32 FconstraintName TToken })(unsafe.Pointer(pParse + 256))).FconstraintName.Fn = uint32(0) } // C documentation // // /* // ** This function is called after an "ALTER TABLE ... ADD" statement // ** has been parsed. Argument pColDef contains the text of the new // ** column definition. // ** // ** The Table structure pParse->pNewTable was extended to include // ** the new column during parsing. // */ func _sqlite3AlterFinishAddColumn(tls *libc.TLS, pParse uintptr, pColDef uintptr) { bp := tls.Alloc(64) defer tls.Free(64) var db, pCol, pDflt, pNew, pTab, v, zCol, zDb, zEnd, zTab, v1 uintptr var iDb, r1, rc int32 var _ /* pVal at bp+0 */ uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, iDb, pCol, pDflt, pNew, pTab, r1, rc, v, zCol, zDb, zEnd, zTab, v1 /* Temporary registers */ db = (*TParse)(unsafe.Pointer(pParse)).Fdb if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { return } pNew = (*TParse)(unsafe.Pointer(pParse)).FpNewTable iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pNew)).FpSchema) zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName zTab = (*TTable)(unsafe.Pointer(pNew)).FzName + 16 /* Skip the "sqlite_altertab_" prefix on the name */ pCol = (*TTable)(unsafe.Pointer(pNew)).FaCol + uintptr(int32((*TTable)(unsafe.Pointer(pNew)).FnCol)-int32(1))*16 pDflt = _sqlite3ColumnExpr(tls, pNew, pCol) pTab = _sqlite3FindTable(tls, db, zTab, zDb) /* Invoke the authorization callback. */ if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_ALTER_TABLE), zDb, (*TTable)(unsafe.Pointer(pTab)).FzName, uintptr(0)) != 0 { return } /* Check that the new column is not specified as PRIMARY KEY or UNIQUE. ** If there is a NOT NULL constraint, then the default value for the ** column must not be NULL. */ if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+10317, 0) return } if (*TTable)(unsafe.Pointer(pNew)).FpIndex != 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+10349, 0) return } if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_GENERATED) == 0 { /* If the default value for the new column was specified with a ** literal NULL, then set pDflt to 0. This simplifies checking ** for an SQL NULL default below. */ if pDflt != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pDflt)).FpLeft)).Fop) == int32(TK_NULL) { pDflt = uintptr(0) } if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_ForeignKeys) != 0 && (*(*struct { FaddColOffset int32 FpFKey uintptr FpDfltList uintptr })(unsafe.Pointer(pNew + 64))).FpFKey != 0 && pDflt != 0 { _sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, __ccgo_ts+10376) } if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) != 0 && !(pDflt != 0) { _sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, __ccgo_ts+10435) } /* Ensure the default expression is something that sqlite3ValueFromExpr() ** can handle (i.e. not CURRENT_TIME etc.) */ if pDflt != 0 { **(**uintptr)(__ccgo_up(bp)) = uintptr(0) rc = _sqlite3ValueFromExpr(tls, db, pDflt, uint8(SQLITE_UTF8), uint8(SQLITE_AFF_BLOB), bp) if rc != SQLITE_OK { return } if !(**(**uintptr)(__ccgo_up(bp)) != 0) { _sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, __ccgo_ts+10488) } _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp))) } } else { if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_STORED) != 0 { _sqlite3ErrorIfNotEmpty(tls, pParse, zDb, zTab, __ccgo_ts+10534) } } /* Modify the CREATE TABLE statement. */ zCol = _sqlite3DbStrNDup(tls, db, (*TToken)(unsafe.Pointer(pColDef)).Fz, uint64((*TToken)(unsafe.Pointer(pColDef)).Fn)) if zCol != 0 { zEnd = zCol + uintptr((*TToken)(unsafe.Pointer(pColDef)).Fn-uint32(1)) for zEnd > zCol && (libc.Int32FromUint8(**(**uint8)(__ccgo_up(zEnd))) == int32(';') || libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zEnd)))])&int32(0x01) != 0) { v1 = zEnd zEnd = zEnd - 1 **(**uint8)(__ccgo_up(v1)) = uint8('\000') } /* substr() operations on characters, but addColOffset is in bytes. So we ** have to use printf() to translate between these units: */ _sqlite3NestedParse(tls, pParse, __ccgo_ts+10561, libc.VaList(bp+16, zDb, (*(*struct { FaddColOffset int32 FpFKey uintptr FpDfltList uintptr })(unsafe.Pointer(pNew + 64))).FaddColOffset, zCol, (*(*struct { FaddColOffset int32 FpFKey uintptr FpDfltList uintptr })(unsafe.Pointer(pNew + 64))).FaddColOffset, zTab)) _sqlite3DbFree(tls, db, zCol) } v = _sqlite3GetVdbe(tls, pParse) if v != 0 { /* Make sure the schema version is at least 3. But do not upgrade ** from less than 3 to 4, as that will corrupt any preexisting DESC ** index. */ r1 = _sqlite3GetTempReg(tls, pParse) _sqlite3VdbeAddOp3(tls, v, int32(OP_ReadCookie), iDb, r1, int32(BTREE_FILE_FORMAT)) _sqlite3VdbeUsesBtree(tls, v, iDb) _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), r1, -int32(2)) _sqlite3VdbeAddOp2(tls, v, int32(OP_IfPos), r1, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) _sqlite3VdbeAddOp3(tls, v, int32(OP_SetCookie), iDb, int32(BTREE_FILE_FORMAT), int32(3)) _sqlite3ReleaseTempReg(tls, pParse, r1) /* Reload the table definition */ _renameReloadSchema(tls, pParse, iDb, uint16(INITFLAG_AlterAdd)) /* Verify that constraints are still satisfied */ if (*TTable)(unsafe.Pointer(pNew)).FpCheck != uintptr(0) || int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) != 0 && libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 || (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Strict) != uint32(0) { _sqlite3NestedParse(tls, pParse, __ccgo_ts+10707, libc.VaList(bp+16, zTab, zDb)) } } } // C documentation // // /* // ** Given an expression list (which is really the list of expressions // ** that form the result set of a SELECT statement) compute appropriate // ** column names for a table that would hold the expression list. // ** // ** All column names will be unique. // ** // ** Only the column names are computed. Column.zType, Column.zColl, // ** and other fields of Column are zeroed. // ** // ** Return SQLITE_OK on success. If a memory allocation error occurs, // ** store NULL in *paCol and 0 in *pnCol and return SQLITE_NOMEM. // ** // ** The only guarantee that SQLite makes about column names is that if the // ** column has an AS clause assigning it a name, that will be the name used. // ** That is the only documented guarantee. However, countless applications // ** developed over the years have made baseless assumptions about column names // ** and will break if those assumptions changes. Hence, use extreme caution // ** when modifying this routine to avoid breaking legacy. // ** // ** See Also: sqlite3GenerateColumnNames() // */ func _sqlite3ColumnsFromExprList(tls *libc.TLS, pParse uintptr, pEList uintptr, pnCol uintptr, paCol uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) var aCol, db, pCol, pColExpr, pCollide, pTab, pX, zName, v2, v3 uintptr var i, iCol, j, nCol, nName int32 var v5 bool var v8 Tu32 var _ /* cnt at bp+0 */ Tu32 var _ /* ht at bp+8 */ THash _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aCol, db, i, iCol, j, nCol, nName, pCol, pColExpr, pCollide, pTab, pX, zName, v2, v3, v5, v8 db = (*TParse)(unsafe.Pointer(pParse)).Fdb _sqlite3HashInit(tls, bp+8) if pEList != 0 { nCol = (*TExprList)(unsafe.Pointer(pEList)).FnExpr aCol = _sqlite3DbMallocZero(tls, db, uint64(uint64(16)*libc.Uint64FromInt32(nCol))) if nCol > int32(32767) { nCol = int32(32767) } } else { nCol = 0 aCol = uintptr(0) } **(**Ti16)(__ccgo_up(pnCol)) = int16(nCol) **(**uintptr)(__ccgo_up(paCol)) = aCol i = 0 pCol = aCol for { if !(i < nCol && !((*TParse)(unsafe.Pointer(pParse)).FnErr != 0)) { break } pX = pEList + 8 + uintptr(i)*32 /* Get an appropriate name for the column */ v2 = (*TExprList_item)(unsafe.Pointer(pX)).FzEName zName = v2 if v2 != uintptr(0) && int32(uint32(*(*uint16)(unsafe.Pointer(pX + 16 + 4))&0x3>>0)) == ENAME_NAME { /* If the column contains an "AS " phrase, use as the name */ } else { pColExpr = _sqlite3ExprSkipCollateAndLikely(tls, (*TExprList_item)(unsafe.Pointer(pX)).FpExpr) for pColExpr != uintptr(0) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pColExpr)).Fop) == int32(TK_DOT) { pColExpr = (*TExpr)(unsafe.Pointer(pColExpr)).FpRight } if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pColExpr)).Fop) == int32(TK_COLUMN) && (*TExpr)(unsafe.Pointer(pColExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)|libc.Int32FromInt32(EP_Subrtn)) == uint32(0) && *(*uintptr)(unsafe.Pointer(pColExpr + 64)) != uintptr(0) { /* For columns use the column name name */ iCol = int32((*TExpr)(unsafe.Pointer(pColExpr)).FiColumn) pTab = *(*uintptr)(unsafe.Pointer(pColExpr + 64)) if iCol < 0 { iCol = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) } if iCol >= 0 { v2 = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(iCol)*16))).FzCnName } else { v2 = __ccgo_ts + 17991 } zName = v2 } else { if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pColExpr)).Fop) == int32(TK_ID) { zName = *(*uintptr)(unsafe.Pointer(pColExpr + 8)) } else { /* Use the original text of the column expression as its name */ /* pointer comparison intended */ } } } if zName != 0 && !(_sqlite3IsTrueOrFalse(tls, zName) != 0) { zName = _sqlite3DbStrDup(tls, db, zName) } else { zName = _sqlite3MPrintf(tls, db, __ccgo_ts+20660, libc.VaList(bp+40, i+int32(1))) } /* Make sure the column name is unique. If the name is not unique, ** append an integer to the name so that it becomes unique. */ **(**Tu32)(__ccgo_up(bp)) = uint32(0) for { if v5 = zName != 0; v5 { v2 = _sqlite3HashFind(tls, bp+8, zName) pCollide = v2 } if !(v5 && v2 != uintptr(0)) { break } if int32(uint32(*(*uint16)(unsafe.Pointer(pCollide + 16 + 4))&0x80>>7)) != 0 { v3 = pCol + 14 *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromInt32(COLFLAG_NOEXPAND)) } nName = _sqlite3Strlen30(tls, zName) if nName > 0 { j = nName - int32(1) for { if !(j > 0 && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(zName + uintptr(j))))])&int32(0x04) != 0) { break } goto _7 _7: ; j = j - 1 } if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zName + uintptr(j)))) == int32(':') { nName = j } } **(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp)) + 1 v8 = **(**Tu32)(__ccgo_up(bp)) zName = _sqlite3MPrintf(tls, db, __ccgo_ts+20669, libc.VaList(bp+40, nName, zName, v8)) _sqlite3ProgressCheck(tls, pParse) if **(**Tu32)(__ccgo_up(bp)) > uint32(3) { Xsqlite3_randomness(tls, int32(4), bp) } } (*TColumn)(unsafe.Pointer(pCol)).FzCnName = zName (*TColumn)(unsafe.Pointer(pCol)).FhName = _sqlite3StrIHash(tls, zName) if int32(uint32(*(*uint16)(unsafe.Pointer(pX + 16 + 4))&0x100>>8)) != 0 { v2 = pCol + 14 *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(COLFLAG_NOEXPAND)) } if zName != 0 && _sqlite3HashInsert(tls, bp+8, zName, pX) == pX { _sqlite3OomFault(tls, db) } goto _1 _1: ; i = i + 1 pCol += 16 } _sqlite3HashClear(tls, bp+8) if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { j = 0 for { if !(j < i) { break } _sqlite3DbFree(tls, db, (**(**TColumn)(__ccgo_up(aCol + uintptr(j)*16))).FzCnName) goto _10 _10: ; j = j + 1 } _sqlite3DbFree(tls, db, aCol) **(**uintptr)(__ccgo_up(paCol)) = uintptr(0) **(**Ti16)(__ccgo_up(pnCol)) = 0 return (*TParse)(unsafe.Pointer(pParse)).Frc } return SQLITE_OK } // C documentation // // /* // ** Create a new index for an SQL table. pName1.pName2 is the name of the index // ** and pTblList is the name of the table that is to be indexed. Both will // ** be NULL for a primary key or an index that is created to satisfy a // ** UNIQUE constraint. If pTable and pIndex are NULL, use pParse->pNewTable // ** as the table to be indexed. pParse->pNewTable is a table that is // ** currently being constructed by a CREATE TABLE statement. // ** // ** pList is a list of columns to be indexed. pList will be NULL if this // ** is a primary key or unique-constraint on the most recent column added // ** to the table currently under construction. // */ func _sqlite3CreateIndex(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, pTblName uintptr, pList uintptr, onError int32, pStart uintptr, pPIWhere uintptr, sortOrder int32, ifNotExist int32, idxType Tu8) { bp := tls.Alloc(176) defer tls.Free(176) var db, p, pCExpr, pCol, pDb, pExpr, pIdx, pIndex, pListItem, pLoop, pNext, pPk, pTab, pThis, ppFrom, v, z1, z2, zColl, zDb, zName, zStmt, v2 uintptr var i, iDb, iMem, j, k, n, n1, nColl, nExtra, nExtraCol, nName, requestedSortOrder, sortOrderMask, x, v5 int32 var _ /* pName at bp+96 */ uintptr var _ /* prevCol at bp+112 */ TToken var _ /* sFix at bp+0 */ TDbFixer var _ /* zExtra at bp+104 */ uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, i, iDb, iMem, j, k, n, n1, nColl, nExtra, nExtraCol, nName, p, pCExpr, pCol, pDb, pExpr, pIdx, pIndex, pListItem, pLoop, pNext, pPk, pTab, pThis, ppFrom, requestedSortOrder, sortOrderMask, v, x, z1, z2, zColl, zDb, zName, zStmt, v2, v5 pTab = uintptr(0) /* Table to be indexed */ pIndex = uintptr(0) /* The index to be created */ zName = uintptr(0) /* 1 to honor DESC in index. 0 to ignore. */ db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* Index of the database that is being written */ **(**uintptr)(__ccgo_up(bp + 96)) = uintptr(0) /* For looping over pList */ nExtra = 0 /* Number of extra columns needed */ **(**uintptr)(__ccgo_up(bp + 104)) = uintptr(0) /* Extra space after the Index object */ pPk = uintptr(0) /* PRIMARY KEY index for WITHOUT ROWID tables */ if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { goto exit_create_index } if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) == int32(PARSE_MODE_DECLARE_VTAB) && libc.Int32FromUint8(idxType) != int32(SQLITE_IDXTYPE_PRIMARYKEY) { goto exit_create_index } if SQLITE_OK != _sqlite3ReadSchema(tls, pParse) { goto exit_create_index } if _sqlite3HasExplicitNulls(tls, pParse, pList) != 0 { goto exit_create_index } /* ** Find the table that is to be indexed. Return early if not found. */ if pTblName != uintptr(0) { /* Use the two-part index name to determine the database ** to search for the table. 'Fix' the table name to this db ** before looking up the table. */ iDb = _sqlite3TwoPartName(tls, pParse, pName1, pName2, bp+96) if iDb < 0 { goto exit_create_index } /* If the index name was unqualified, check if the table ** is a temp table. If so, set the database to 1. Do not do this ** if initializing a database schema. */ if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { pTab = _sqlite3SrcListLookup(tls, pParse, pTblName) if (*TToken)(unsafe.Pointer(pName2)).Fn == uint32(0) && pTab != 0 && (*TTable)(unsafe.Pointer(pTab)).FpSchema == (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + 1*32))).FpSchema { iDb = int32(1) } } _sqlite3FixInit(tls, bp, pParse, iDb, __ccgo_ts+15441, **(**uintptr)(__ccgo_up(bp + 96))) if _sqlite3FixSrcList(tls, bp, pTblName) != 0 { /* Because the parser constructs pTblName from a single identifier, ** sqlite3FixSrcList can never fail. */ } pTab = _sqlite3LocateTableItem(tls, pParse, uint32(0), pTblName+8) if pTab == uintptr(0) { goto exit_create_index } if iDb == int32(1) && (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema != (*TTable)(unsafe.Pointer(pTab)).FpSchema { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15447, libc.VaList(bp+136, (*TTable)(unsafe.Pointer(pTab)).FzName)) goto exit_create_index } if !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { pPk = _sqlite3PrimaryKeyIndex(tls, pTab) } } else { pTab = (*TParse)(unsafe.Pointer(pParse)).FpNewTable if !(pTab != 0) { goto exit_create_index } iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab)).FpSchema) } pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName, __ccgo_ts+6784, int32(7)) == 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0 && pTblName != uintptr(0) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15497, libc.VaList(bp+136, (*TTable)(unsafe.Pointer(pTab)).FzName)) goto exit_create_index } if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15525, 0) goto exit_create_index } if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15550, 0) goto exit_create_index } /* ** Find the name of the index. Make sure there is not already another ** index or table with the same name. ** ** Exception: If we are reading the names of permanent indices from the ** sqlite_schema table (because some other process changed the schema) and ** one of the index names collides with the name of a temporary table or ** index, then we will continue to process this index. ** ** If pName==0 it means that we are ** dealing with a primary key or UNIQUE constraint. We have to invent our ** own name. */ if **(**uintptr)(__ccgo_up(bp + 96)) != 0 { zName = _sqlite3NameFromToken(tls, db, **(**uintptr)(__ccgo_up(bp + 96))) if zName == uintptr(0) { goto exit_create_index } if SQLITE_OK != _sqlite3CheckObjectName(tls, pParse, zName, __ccgo_ts+15441, (*TTable)(unsafe.Pointer(pTab)).FzName) { goto exit_create_index } if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { if _sqlite3FindTable(tls, db, zName, (*TDb)(unsafe.Pointer(pDb)).FzDbSName) != uintptr(0) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15584, libc.VaList(bp+136, zName)) goto exit_create_index } } if _sqlite3FindIndex(tls, db, zName, (*TDb)(unsafe.Pointer(pDb)).FzDbSName) != uintptr(0) { if !(ifNotExist != 0) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15618, libc.VaList(bp+136, zName)) } else { _sqlite3CodeVerifySchema(tls, pParse, iDb) _sqlite3ForceNotReadOnly(tls, pParse) } goto exit_create_index } } } else { pLoop = (*TTable)(unsafe.Pointer(pTab)).FpIndex n = libc.Int32FromInt32(1) for { if !(pLoop != 0) { break } goto _1 _1: ; pLoop = (*TIndex)(unsafe.Pointer(pLoop)).FpNext n = n + 1 } zName = _sqlite3MPrintf(tls, db, __ccgo_ts+15642, libc.VaList(bp+136, (*TTable)(unsafe.Pointer(pTab)).FzName, n)) if zName == uintptr(0) { goto exit_create_index } /* Automatic index names generated from within sqlite3_declare_vtab() ** must have names that are distinct from normal automatic index names. ** The following statement converts "sqlite3_autoindex..." into ** "sqlite3_butoindex..." in order to make the names distinct. ** The "vtab_err.test" test demonstrates the need of this statement. */ if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL { **(**uint8)(__ccgo_up(zName + 7)) = **(**uint8)(__ccgo_up(zName + 7)) + 1 } } /* Check for authorization to create an index. */ if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { zDb = (*TDb)(unsafe.Pointer(pDb)).FzDbSName if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { v2 = __ccgo_ts + 6792 } else { v2 = __ccgo_ts + 6312 } if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_INSERT), v2, uintptr(0), zDb) != 0 { goto exit_create_index } i = int32(SQLITE_CREATE_INDEX) if libc.Bool(!(libc.Int32FromInt32(OMIT_TEMPDB) != 0)) && iDb == int32(1) { i = int32(SQLITE_CREATE_TEMP_INDEX) } if _sqlite3AuthCheck(tls, pParse, i, zName, (*TTable)(unsafe.Pointer(pTab)).FzName, zDb) != 0 { goto exit_create_index } } /* If pList==0, it means this routine was called to make a primary ** key out of the last column added to the table under construction. ** So create a fake list to simulate this. */ if pList == uintptr(0) { pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(int32((*TTable)(unsafe.Pointer(pTab)).FnCol)-int32(1))*16 v2 = pCol + 14 *(*Tu16)(unsafe.Pointer(v2)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v2))) | libc.Int32FromInt32(COLFLAG_UNIQUE)) _sqlite3TokenInit(tls, bp+112, (*TColumn)(unsafe.Pointer(pCol)).FzCnName) pList = _sqlite3ExprListAppend(tls, pParse, uintptr(0), _sqlite3ExprAlloc(tls, db, int32(TK_ID), bp+112, 0)) if pList == uintptr(0) { goto exit_create_index } _sqlite3ExprListSetSortOrder(tls, pList, sortOrder, -int32(1)) } else { _sqlite3ExprListCheckLength(tls, pParse, pList, __ccgo_ts+15441) if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { goto exit_create_index } } /* Figure out how many bytes of space are required to store explicitly ** specified collation sequence names. */ i = 0 for { if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { break } pExpr = (*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_COLLATE) { nExtra = nExtra + (int32(1) + _sqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)))) } goto _4 _4: ; i = i + 1 } /* ** Allocate the index structure. */ nName = _sqlite3Strlen30(tls, zName) if pPk != 0 { v5 = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol) } else { v5 = int32(1) } nExtraCol = v5 pIndex = _sqlite3AllocateIndexObject(tls, db, (*TExprList)(unsafe.Pointer(pList)).FnExpr+nExtraCol, nName+nExtra+int32(1), bp+104) if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { goto exit_create_index } (*TIndex)(unsafe.Pointer(pIndex)).FzName = **(**uintptr)(__ccgo_up(bp + 104)) **(**uintptr)(__ccgo_up(bp + 104)) = **(**uintptr)(__ccgo_up(bp + 104)) + uintptr(nName+int32(1)) libc.Xmemcpy(tls, (*TIndex)(unsafe.Pointer(pIndex)).FzName, zName, libc.Uint64FromInt32(nName+int32(1))) (*TIndex)(unsafe.Pointer(pIndex)).FpTable = pTab (*TIndex)(unsafe.Pointer(pIndex)).FonError = libc.Uint8FromInt32(onError) libc.SetBitFieldPtr16Uint32(pIndex+100, libc.BoolUint32(onError != libc.Int32FromInt32(OE_None)), 3, 0x8) libc.SetBitFieldPtr16Uint32(pIndex+100, uint32(idxType), 0, 0x3) (*TIndex)(unsafe.Pointer(pIndex)).FpSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema (*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol = libc.Uint16FromInt32((*TExprList)(unsafe.Pointer(pList)).FnExpr) if pPIWhere != 0 { _sqlite3ResolveSelfReference(tls, pParse, pTab, int32(NC_PartIdx), pPIWhere, uintptr(0)) (*TIndex)(unsafe.Pointer(pIndex)).FpPartIdxWhere = pPIWhere pPIWhere = uintptr(0) } /* Check to see if we should honor DESC requests on index columns */ if libc.Int32FromUint8((*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Ffile_format) >= int32(4) { sortOrderMask = -int32(1) /* Honor DESC */ } else { sortOrderMask = 0 /* Ignore DESC */ } /* Analyze the list of expressions that form the terms of the index and ** report any errors. In the common case where the expression is exactly ** a table column, store that column in aiColumn[]. For general expressions, ** populate pIndex->aColExpr and store XN_EXPR (-2) in aiColumn[]. ** ** TODO: Issue a warning if two or more columns of the index are identical. ** TODO: Issue a warning if the table primary key is used as part of the ** index key. */ pListItem = pList + 8 if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { (*TIndex)(unsafe.Pointer(pIndex)).FaColExpr = pList pList = uintptr(0) } i = 0 for { if !(i < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol)) { break } /* Collation sequence name */ _sqlite3StringToId(tls, (*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr) _sqlite3ResolveSelfReference(tls, pParse, pTab, int32(NC_IdxExpr), (*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr, uintptr(0)) if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { goto exit_create_index } pCExpr = _sqlite3ExprSkipCollate(tls, (*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr) if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pCExpr)).Fop) != int32(TK_COLUMN) { if pTab == (*TParse)(unsafe.Pointer(pParse)).FpNewTable { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15665, 0) goto exit_create_index } if (*TIndex)(unsafe.Pointer(pIndex)).FaColExpr == uintptr(0) { (*TIndex)(unsafe.Pointer(pIndex)).FaColExpr = pList pList = uintptr(0) } j = -int32(2) **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(-libc.Int32FromInt32(2)) libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 3, 0x8) libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 11, 0x800) } else { j = int32((*TExpr)(unsafe.Pointer(pCExpr)).FiColumn) if j < 0 { j = int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) } else { if int32(uint32(*(*uint8)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16 + 8))&0xf>>0)) == 0 { libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 3, 0x8) } if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr(j)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 10, 0x400) libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 11, 0x800) } } **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(j) } zColl = uintptr(0) if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr)).Fop) == int32(TK_COLLATE) { zColl = *(*uintptr)(unsafe.Pointer((*TExprList_item)(unsafe.Pointer(pListItem)).FpExpr + 8)) nColl = _sqlite3Strlen30(tls, zColl) + int32(1) libc.Xmemcpy(tls, **(**uintptr)(__ccgo_up(bp + 104)), zColl, libc.Uint64FromInt32(nColl)) zColl = **(**uintptr)(__ccgo_up(bp + 104)) **(**uintptr)(__ccgo_up(bp + 104)) = **(**uintptr)(__ccgo_up(bp + 104)) + uintptr(nColl) nExtra = nExtra - nColl } else { if j >= 0 { zColl = _sqlite3ColumnColl(tls, (*TTable)(unsafe.Pointer(pTab)).FaCol+uintptr(j)*16) } } if !(zColl != 0) { zColl = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) } if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) && !(_sqlite3LocateCollSeq(tls, pParse, zColl) != 0) { goto exit_create_index } **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*8)) = zColl requestedSortOrder = libc.Int32FromUint8((*TExprList_item)(unsafe.Pointer(pListItem)).Ffg.FsortFlags) & sortOrderMask **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaSortOrder + uintptr(i))) = libc.Uint8FromInt32(requestedSortOrder) goto _6 _6: ; i = i + 1 pListItem += 32 } /* Append the table key to the end of the index. For WITHOUT ROWID ** tables (when pPk!=0) this will be the declared PRIMARY KEY. For ** normal tables (when pPk==0) this will be the rowid. */ if pPk != 0 { j = 0 for { if !(j < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk)).FnKeyCol)) { break } x = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(j)*2))) if _isDupColumn(tls, pIndex, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol), pPk, j) != 0 { (*TIndex)(unsafe.Pointer(pIndex)).FnColumn = (*TIndex)(unsafe.Pointer(pIndex)).FnColumn - 1 } else { **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(x) **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*8)) = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FazColl + uintptr(j)*8)) **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaSortOrder + uintptr(i))) = **(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaSortOrder + uintptr(j))) i = i + 1 } goto _7 _7: ; j = j + 1 } } else { **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(i)*2)) = int16(-libc.Int32FromInt32(1)) **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(i)*8)) = uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) } _sqlite3DefaultRowEst(tls, pIndex) if (*TParse)(unsafe.Pointer(pParse)).FpNewTable == uintptr(0) { _estimateIndexWidth(tls, pIndex) } /* If this index contains every column of its table, then mark ** it as a covering index */ _recomputeColumnsNotIndexed(tls, pIndex) if pTblName != uintptr(0) && libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnColumn) >= int32((*TTable)(unsafe.Pointer(pTab)).FnCol) { libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(1), 5, 0x20) j = 0 for { if !(j < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { break } if j == int32((*TTable)(unsafe.Pointer(pTab)).FiPKey) { goto _8 } if _sqlite3TableColumnToIndex(tls, pIndex, j) >= 0 { goto _8 } libc.SetBitFieldPtr16Uint32(pIndex+100, libc.Uint32FromInt32(0), 5, 0x20) break goto _8 _8: ; j = j + 1 } } if pTab == (*TParse)(unsafe.Pointer(pParse)).FpNewTable { pIdx = (*TTable)(unsafe.Pointer(pTab)).FpIndex for { if !(pIdx != 0) { break } if libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) != libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIndex)).FnKeyCol) { goto _9 } k = 0 for { if !(k < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)) { break } if int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(k)*2))) != int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FaiColumn + uintptr(k)*2))) { break } z1 = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(k)*8)) z2 = **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIndex)).FazColl + uintptr(k)*8)) if _sqlite3StrICmp(tls, z1, z2) != 0 { break } goto _10 _10: ; k = k + 1 } if k == libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) { if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) != libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIndex)).FonError) { /* This constraint creates the same index as a previous ** constraint specified somewhere in the CREATE TABLE statement. ** However the ON CONFLICT clauses are different. If both this ** constraint and the previous equivalent constraint have explicit ** ON CONFLICT clauses this is an error. Otherwise, use the ** explicitly specified behavior for the index. */ if !(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) == int32(OE_Default) || libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIndex)).FonError) == int32(OE_Default)) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15726, libc.VaList(bp+136, 0)) } if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx)).FonError) == int32(OE_Default) { (*TIndex)(unsafe.Pointer(pIdx)).FonError = (*TIndex)(unsafe.Pointer(pIndex)).FonError } } if libc.Int32FromUint8(idxType) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { libc.SetBitFieldPtr16Uint32(pIdx+100, uint32(idxType), 0, 0x3) } if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { (*TIndex)(unsafe.Pointer(pIndex)).FpNext = (*TParse)(unsafe.Pointer(pParse)).FpNewIndex (*TParse)(unsafe.Pointer(pParse)).FpNewIndex = pIndex pIndex = uintptr(0) } goto exit_create_index } goto _9 _9: ; pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext } } if !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= libc.Int32FromInt32(PARSE_MODE_RENAME)) { /* Link the new Index structure to its table and to the other ** in-memory database structures. */ if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { if pTblName != uintptr(0) { (*TIndex)(unsafe.Pointer(pIndex)).Ftnum = (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum if _sqlite3IndexHasDuplicateRootPage(tls, pIndex) != 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+15768, 0) (*TParse)(unsafe.Pointer(pParse)).Frc = _sqlite3CorruptError(tls, int32(131088)) goto exit_create_index } } p = _sqlite3HashInsert(tls, (*TIndex)(unsafe.Pointer(pIndex)).FpSchema+32, (*TIndex)(unsafe.Pointer(pIndex)).FzName, pIndex) if p != 0 { /* Malloc must have failed */ _sqlite3OomFault(tls, db) goto exit_create_index } **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) } else { if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) || pTblName != uintptr(0) { v2 = pParse + 60 *(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1 v5 = *(*int32)(unsafe.Pointer(v2)) iMem = v5 v = _sqlite3GetVdbe(tls, pParse) if v == uintptr(0) { goto exit_create_index } _sqlite3BeginWriteOperation(tls, pParse, int32(1), iDb) /* Create the rootpage for the index using CreateIndex. But before ** doing so, code a Noop instruction and store its address in ** Index.tnum. This is required in case this index is actually a ** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In ** that case the convertToWithoutRowidTable() routine will replace ** the Noop with a Goto to jump over the VDBE code generated below. */ (*TIndex)(unsafe.Pointer(pIndex)).Ftnum = libc.Uint32FromInt32(_sqlite3VdbeAddOp0(tls, v, int32(OP_Noop))) _sqlite3VdbeAddOp3(tls, v, int32(OP_CreateBtree), iDb, iMem, int32(BTREE_BLOBKEY)) /* Gather the complete text of the CREATE INDEX statement into ** the zStmt variable */ if pStart != 0 { n1 = libc.Int32FromUint32(libc.Uint32FromInt32(int32(int64((*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fz)-int64((*TToken)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 96)))).Fz))) + (*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fn) if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TToken)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 96)))).Fz + uintptr(n1-int32(1))))) == int32(';') { n1 = n1 - 1 } /* A named index with an explicit CREATE INDEX statement */ if onError == OE_None { v2 = __ccgo_ts + 1704 } else { v2 = __ccgo_ts + 15785 } zStmt = _sqlite3MPrintf(tls, db, __ccgo_ts+15793, libc.VaList(bp+136, v2, n1, (*TToken)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 96)))).Fz)) } else { /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */ /* zStmt = sqlite3MPrintf(""); */ zStmt = uintptr(0) } /* Add an entry in sqlite_schema for this index */ _sqlite3NestedParse(tls, pParse, __ccgo_ts+15813, libc.VaList(bp+136, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TIndex)(unsafe.Pointer(pIndex)).FzName, (*TTable)(unsafe.Pointer(pTab)).FzName, iMem, zStmt)) _sqlite3DbFree(tls, db, zStmt) /* Fill the index with data and reparse the schema. Code an OP_Expire ** to invalidate all pre-compiled statements. */ if pTblName != 0 { _sqlite3RefillIndex(tls, pParse, pIndex, iMem) _sqlite3ChangeCookie(tls, pParse, iDb) _sqlite3VdbeAddParseSchemaOp(tls, v, iDb, _sqlite3MPrintf(tls, db, __ccgo_ts+15872, libc.VaList(bp+136, (*TIndex)(unsafe.Pointer(pIndex)).FzName)), uint16(0)) _sqlite3VdbeAddOp2(tls, v, int32(OP_Expire), 0, int32(1)) } _sqlite3VdbeJumpHere(tls, v, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIndex)).Ftnum)) } } } if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 || pTblName == uintptr(0) { (*TIndex)(unsafe.Pointer(pIndex)).FpNext = (*TTable)(unsafe.Pointer(pTab)).FpIndex (*TTable)(unsafe.Pointer(pTab)).FpIndex = pIndex pIndex = uintptr(0) } else { if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { (*TParse)(unsafe.Pointer(pParse)).FpNewIndex = pIndex pIndex = uintptr(0) } } /* Clean up before exiting */ goto exit_create_index exit_create_index: ; if pIndex != 0 { _sqlite3FreeIndex(tls, db, pIndex) } if pTab != 0 { ppFrom = pTab + 16 for { v2 = **(**uintptr)(__ccgo_up(ppFrom)) pThis = v2 if !(v2 != uintptr(0)) { break } if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pThis)).FonError) != int32(OE_Replace) { goto _14 } for { v2 = (*TIndex)(unsafe.Pointer(pThis)).FpNext pNext = v2 if !(v2 != uintptr(0) && libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pNext)).FonError) != int32(OE_Replace)) { break } **(**uintptr)(__ccgo_up(ppFrom)) = pNext (*TIndex)(unsafe.Pointer(pThis)).FpNext = (*TIndex)(unsafe.Pointer(pNext)).FpNext (*TIndex)(unsafe.Pointer(pNext)).FpNext = pThis ppFrom = pNext + 40 } break goto _14 _14: ; ppFrom = pThis + 40 } } _sqlite3ExprDelete(tls, db, pPIWhere) _sqlite3ExprListDelete(tls, db, pList) _sqlite3SrcListDelete(tls, db, pTblName) _sqlite3DbFree(tls, db, zName) } // C documentation // // /* // ** This routine is called to report the final ")" that terminates // ** a CREATE TABLE statement. // ** // ** The table structure that other action routines have been building // ** is added to the internal hash tables, assuming no errors have // ** occurred. // ** // ** An entry for the table is made in the schema table on disk, unless // ** this is a temporary table or db->init.busy==1. When db->init.busy==1 // ** it means we are reading the sqlite_schema table because we just // ** connected to the database or because the sqlite_schema table has // ** recently changed, so the entry for this table already exists in // ** the sqlite_schema table. We do not want to create it again. // ** // ** If the pSelect argument is not NULL, it means that this routine // ** was called to create a table generated from a // ** "CREATE TABLE ... AS SELECT ..." statement. The column names of // ** the new table will match the result set of the SELECT. // */ func _sqlite3EndTable(tls *libc.TLS, pParse uintptr, pCons uintptr, pEnd uintptr, tabOpts Tu32, pSelect uintptr) { bp := tls.Alloc(112) defer tls.Free(112) var addrInsLoop, addrTop, iCsr, iDb, ii, ii1, n, nNG, regRec, regRowid, regYield, v4 int32 var colFlags Tu32 var db, p, pCol, pDb, pEnd2, pIdx, pOld, pSchema, pSelTab, pX, v, zStmt, zType, zType2, v5 uintptr var v12 Ti16 var _ /* dest at bp+0 */ TSelectDest _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = addrInsLoop, addrTop, colFlags, db, iCsr, iDb, ii, ii1, n, nNG, p, pCol, pDb, pEnd2, pIdx, pOld, pSchema, pSelTab, pX, regRec, regRowid, regYield, v, zStmt, zType, zType2, v12, v4, v5 /* The new table */ db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* An implied index of the table */ if pEnd == uintptr(0) && pSelect == uintptr(0) { return } p = (*TParse)(unsafe.Pointer(pParse)).FpNewTable if p == uintptr(0) { return } if pSelect == uintptr(0) && _sqlite3ShadowTableName(tls, db, (*TTable)(unsafe.Pointer(p)).FzName) != 0 { **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_Shadow) } /* If the db->init.busy is 1 it means we are reading the SQL off the ** "sqlite_schema" or "sqlite_temp_schema" table on the disk. ** So do not write to the disk again. Extract the root page number ** for the table from the db->init.newTnum field. (The page number ** should have been put there by the sqliteOpenCb routine.) ** ** If the root page number is 1, that means this is the sqlite_schema ** table itself. So mark it read-only. */ if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { if pSelect != 0 || !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(p)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) && (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum != 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+1704, 0) return } (*TTable)(unsafe.Pointer(p)).Ftnum = (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FnewTnum if (*TTable)(unsafe.Pointer(p)).Ftnum == uint32(1) { **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_Readonly) } } /* Special processing for tables that include the STRICT keyword: ** ** * Do not allow custom column datatypes. Every column must have ** a datatype that is one of INT, INTEGER, REAL, TEXT, or BLOB. ** ** * If a PRIMARY KEY is defined, other than the INTEGER PRIMARY KEY, ** then all columns of the PRIMARY KEY must have a NOT NULL ** constraint. */ if tabOpts&uint32(TF_Strict) != 0 { **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_Strict) ii = 0 for { if !(ii < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { break } pCol = (*TTable)(unsafe.Pointer(p)).FaCol + uintptr(ii)*16 if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf0>>4)) == COLTYPE_CUSTOM { if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_HASTYPE) != 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14424, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(p)).FzName, (*TColumn)(unsafe.Pointer(pCol)).FzCnName, _sqlite3ColumnType(tls, pCol, __ccgo_ts+1704))) } else { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14457, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(p)).FzName, (*TColumn)(unsafe.Pointer(pCol)).FzCnName)) } return } else { if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf0>>4)) == int32(COLTYPE_ANY) { (*TColumn)(unsafe.Pointer(pCol)).Faffinity = uint8(SQLITE_AFF_BLOB) } } if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) != 0 && int32((*TTable)(unsafe.Pointer(p)).FiPKey) != ii && int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) == OE_None { libc.SetBitFieldPtr8Uint32(pCol+8, libc.Uint32FromInt32(OE_Abort), 0, 0xf) **(**Tu32)(__ccgo_up(p + 48)) |= uint32(TF_HasNotNull) } goto _1 _1: ; ii = ii + 1 } } /* Special processing for WITHOUT ROWID Tables */ if tabOpts&uint32(TF_WithoutRowid) != 0 { if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_Autoincrement) != 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14484, 0) return } if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_HasPrimaryKey) == uint32(0) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14534, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(p)).FzName)) return } **(**Tu32)(__ccgo_up(p + 48)) |= libc.Uint32FromInt32(libc.Int32FromInt32(TF_WithoutRowid) | libc.Int32FromInt32(TF_NoVisibleRowid)) _convertToWithoutRowidTable(tls, pParse, p) } iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(p)).FpSchema) /* Resolve names in all CHECK constraint expressions. */ if (*TTable)(unsafe.Pointer(p)).FpCheck != 0 { _sqlite3ResolveSelfReference(tls, pParse, p, int32(NC_IsCheck), uintptr(0), (*TTable)(unsafe.Pointer(p)).FpCheck) if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { /* If errors are seen, delete the CHECK constraints now, else they might ** actually be used if PRAGMA writable_schema=ON is set. */ _sqlite3ExprListDelete(tls, db, (*TTable)(unsafe.Pointer(p)).FpCheck) (*TTable)(unsafe.Pointer(p)).FpCheck = uintptr(0) } else { } } if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_HasGenerated) != 0 { nNG = 0 ii1 = 0 for { if !(ii1 < int32((*TTable)(unsafe.Pointer(p)).FnCol)) { break } colFlags = uint32((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(p)).FaCol + uintptr(ii1)*16))).FcolFlags) if colFlags&uint32(COLFLAG_GENERATED) != uint32(0) { pX = _sqlite3ColumnExpr(tls, p, (*TTable)(unsafe.Pointer(p)).FaCol+uintptr(ii1)*16) if _sqlite3ResolveSelfReference(tls, pParse, p, int32(NC_GenCol), pX, uintptr(0)) != 0 { /* If there are errors in resolving the expression, change the ** expression to a NULL. This prevents code generators that operate ** on the expression from inserting extra parts into the expression ** tree that have been allocated from lookaside memory, which is ** illegal in a schema and will lead to errors or heap corruption ** when the database connection closes. */ _sqlite3ColumnSetExpr(tls, pParse, p, (*TTable)(unsafe.Pointer(p)).FaCol+uintptr(ii1)*16, _sqlite3ExprAlloc(tls, db, int32(TK_NULL), uintptr(0), 0)) } } else { nNG = nNG + 1 } goto _2 _2: ; ii1 = ii1 + 1 } if nNG == 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+14566, 0) return } } /* Estimate the average row size for the table and for all implied indices */ _estimateTableWidth(tls, p) pIdx = (*TTable)(unsafe.Pointer(p)).FpIndex for { if !(pIdx != 0) { break } _estimateIndexWidth(tls, pIdx) goto _3 _3: ; pIdx = (*TIndex)(unsafe.Pointer(pIdx)).FpNext } /* If not initializing, then create a record for the new table ** in the schema table of the database. ** ** If this is a TEMPORARY table, write the entry into the auxiliary ** file instead of into the main database file. */ if !((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0) { /* Text of the CREATE TABLE or CREATE VIEW statement */ v = _sqlite3GetVdbe(tls, pParse) if v == uintptr(0) { return } _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), 0) /* ** Initialize zType for the new view or table. */ if libc.Int32FromUint8((*TTable)(unsafe.Pointer(p)).FeTabType) == TABTYP_NORM { /* A regular table */ zType = __ccgo_ts + 9405 zType2 = __ccgo_ts + 14610 } else { /* A view */ zType = __ccgo_ts + 11143 zType2 = __ccgo_ts + 14616 } /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT ** statement to populate the new table. The root-page number for the ** new table is in register pParse->u1.cr.regRoot. ** ** Once the SELECT has been coded by sqlite3Select(), it is in a ** suitable state to query for the column names and types to be used ** by the new table. ** ** A shared-cache write-lock is not required to write to the new table, ** as a schema-lock must have already been obtained to create it. Since ** a schema-lock excludes all other database users, the write-lock would ** be redundant. */ if pSelect != 0 { /* Write cursor on the new table */ if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL { (*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_ERROR) (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 return } v5 = pParse + 56 v4 = *(*int32)(unsafe.Pointer(v5)) *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 iCsr = v4 v5 = pParse + 60 *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 v4 = *(*int32)(unsafe.Pointer(v5)) regYield = v4 v5 = pParse + 60 *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 v4 = *(*int32)(unsafe.Pointer(v5)) regRec = v4 v5 = pParse + 60 *(*int32)(unsafe.Pointer(v5)) = *(*int32)(unsafe.Pointer(v5)) + 1 v4 = *(*int32)(unsafe.Pointer(v5)) regRowid = v4 _sqlite3MayAbort(tls, pParse) _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenWrite), iCsr, (*(*struct { FaddrCrTab int32 FregRowid int32 FregRoot int32 FconstraintName TToken })(unsafe.Pointer(pParse + 256))).FregRoot, iDb) _sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_P2ISREG)) addrTop = _sqlite3VdbeCurrentAddr(tls, v) + int32(1) _sqlite3VdbeAddOp3(tls, v, int32(OP_InitCoroutine), regYield, 0, addrTop) if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { return } pSelTab = _sqlite3ResultSetOfSelect(tls, pParse, pSelect, uint8(SQLITE_AFF_BLOB)) if pSelTab == uintptr(0) { return } v12 = (*TTable)(unsafe.Pointer(pSelTab)).FnCol (*TTable)(unsafe.Pointer(p)).FnNVCol = v12 (*TTable)(unsafe.Pointer(p)).FnCol = v12 (*TTable)(unsafe.Pointer(p)).FaCol = (*TTable)(unsafe.Pointer(pSelTab)).FaCol (*TTable)(unsafe.Pointer(pSelTab)).FnCol = 0 (*TTable)(unsafe.Pointer(pSelTab)).FaCol = uintptr(0) _sqlite3DeleteTable(tls, db, pSelTab) _sqlite3SelectDestInit(tls, bp, int32(SRT_Coroutine), regYield) _sqlite3Select(tls, pParse, pSelect, bp) if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { return } _sqlite3VdbeEndCoroutine(tls, v, regYield) _sqlite3VdbeJumpHere(tls, v, addrTop-int32(1)) addrInsLoop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Yield), (**(**TSelectDest)(__ccgo_up(bp))).FiSDParm) _sqlite3VdbeAddOp3(tls, v, int32(OP_MakeRecord), (**(**TSelectDest)(__ccgo_up(bp))).FiSdst, (**(**TSelectDest)(__ccgo_up(bp))).FnSdst, regRec) _sqlite3TableAffinity(tls, v, p, 0) _sqlite3VdbeAddOp2(tls, v, int32(OP_NewRowid), iCsr, regRowid) _sqlite3VdbeAddOp3(tls, v, int32(OP_Insert), iCsr, regRec, regRowid) _sqlite3VdbeGoto(tls, v, addrInsLoop) _sqlite3VdbeJumpHere(tls, v, addrInsLoop) _sqlite3VdbeAddOp1(tls, v, int32(OP_Close), iCsr) } /* Compute the complete text of the CREATE statement */ if pSelect != 0 { zStmt = _createTableStmt(tls, db, p) } else { if tabOpts != 0 { v5 = pParse + 288 } else { v5 = pEnd } pEnd2 = v5 n = int32(int64((*TToken)(unsafe.Pointer(pEnd2)).Fz) - int64((*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fz)) if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TToken)(unsafe.Pointer(pEnd2)).Fz))) != int32(';') { n = libc.Int32FromUint32(uint32(n) + (*TToken)(unsafe.Pointer(pEnd2)).Fn) } zStmt = _sqlite3MPrintf(tls, db, __ccgo_ts+14621, libc.VaList(bp+48, zType2, n, (*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fz)) } /* A slot for the record has already been allocated in the ** schema table. We just need to update that slot with all ** the information we've collected. */ _sqlite3NestedParse(tls, pParse, __ccgo_ts+14636, libc.VaList(bp+48, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, zType, (*TTable)(unsafe.Pointer(p)).FzName, (*TTable)(unsafe.Pointer(p)).FzName, (*(*struct { FaddrCrTab int32 FregRowid int32 FregRoot int32 FconstraintName TToken })(unsafe.Pointer(pParse + 256))).FregRoot, zStmt, (*(*struct { FaddrCrTab int32 FregRowid int32 FregRoot int32 FconstraintName TToken })(unsafe.Pointer(pParse + 256))).FregRowid)) _sqlite3DbFree(tls, db, zStmt) _sqlite3ChangeCookie(tls, pParse, iDb) /* Check to see if we need to create an sqlite_sequence table for ** keeping track of autoincrement keys. */ if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_Autoincrement) != uint32(0) && !(libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != libc.Int32FromInt32(PARSE_MODE_NORMAL)) { pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 if (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).FpSeqTab == uintptr(0) { _sqlite3NestedParse(tls, pParse, __ccgo_ts+14734, libc.VaList(bp+48, (*TDb)(unsafe.Pointer(pDb)).FzDbSName)) } } /* Reparse everything to update our internal data structures */ _sqlite3VdbeAddParseSchemaOp(tls, v, iDb, _sqlite3MPrintf(tls, db, __ccgo_ts+14776, libc.VaList(bp+48, (*TTable)(unsafe.Pointer(p)).FzName)), uint16(0)) /* Test for cycles in generated columns and illegal expressions ** in CHECK constraints and in DEFAULT clauses. */ if (*TTable)(unsafe.Pointer(p)).FtabFlags&uint32(TF_HasGenerated) != 0 { _sqlite3VdbeAddOp4(tls, v, int32(OP_SqlExec), int32(0x0001), 0, 0, _sqlite3MPrintf(tls, db, __ccgo_ts+14810, libc.VaList(bp+48, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TTable)(unsafe.Pointer(p)).FzName)), -int32(7)) } } /* Add the table to the in-memory representation of the database. */ if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 { pSchema = (*TTable)(unsafe.Pointer(p)).FpSchema pOld = _sqlite3HashInsert(tls, pSchema+8, (*TTable)(unsafe.Pointer(p)).FzName, p) if pOld != 0 { /* Malloc must have failed inside HashInsert() */ _sqlite3OomFault(tls, db) return } (*TParse)(unsafe.Pointer(pParse)).FpNewTable = uintptr(0) **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) /* If this is the magic sqlite_sequence table used by autoincrement, ** then record a pointer to this table in the main database structure ** so that INSERT can find the table easily. */ if libc.Xstrcmp(tls, (*TTable)(unsafe.Pointer(p)).FzName, __ccgo_ts+9927) == 0 { (*TSchema)(unsafe.Pointer((*TTable)(unsafe.Pointer(p)).FpSchema)).FpSeqTab = p } } if !(pSelect != 0) && libc.Int32FromUint8((*TTable)(unsafe.Pointer(p)).FeTabType) == TABTYP_NORM { if (*TToken)(unsafe.Pointer(pCons)).Fz == uintptr(0) { pCons = pEnd } (*(*struct { FaddColOffset int32 FpFKey uintptr FpDfltList uintptr })(unsafe.Pointer(p + 64))).FaddColOffset = int32(13) + int32(int64((*TToken)(unsafe.Pointer(pCons)).Fz)-int64((*TParse)(unsafe.Pointer(pParse)).FsNameToken.Fz)) } } // C documentation // // /* // ** Generate code into the current Vdbe to evaluate the given // ** expression. Attempt to store the results in register "target". // ** Return the register where results are stored. // ** // ** With this routine, there is no guarantee that results will // ** be stored in target. The result might be stored in some other // ** register if it is convenient to do so. The calling function // ** must check the return code and move the results to the desired // ** register. // */ func _sqlite3ExprCodeTarget(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32) (r int32) { bp := tls.Alloc(192) defer tls.Free(192) var aListelem, db, db1, pAggInfo, pAggInfo1, pCol, pCol1, pColl, pDef, pDel, pEList, pFarg, pInfo, pLeft, pLeft1, pLeft2, pTab, pTab1, pTab2, pTest, pX, v, z, zBlob, zId, v3 uintptr var addr, addrINR, addrIsNull, addrIsNull1, aff, bNormal, destIfFalse, destIfNull, endLabel, i, i1, iCol, iCol1, iReg, iSrc, iTab, inReg, isTrue, n, n1, nCol, nExpr, nFarg, nextCase, op, p1, p5, v1 int32 var constMask Tu32 var enc, exprOp, okConstFactor Tu8 var v2 bool var _ /* opCompare at bp+88 */ TExpr var _ /* r1 at bp+8 */ int32 var _ /* r2 at bp+12 */ int32 var _ /* regFree1 at bp+0 */ int32 var _ /* regFree2 at bp+4 */ int32 var _ /* tempX at bp+16 */ TExpr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aListelem, addr, addrINR, addrIsNull, addrIsNull1, aff, bNormal, constMask, db, db1, destIfFalse, destIfNull, enc, endLabel, exprOp, i, i1, iCol, iCol1, iReg, iSrc, iTab, inReg, isTrue, n, n1, nCol, nExpr, nFarg, nextCase, okConstFactor, op, p1, p5, pAggInfo, pAggInfo1, pCol, pCol1, pColl, pDef, pDel, pEList, pFarg, pInfo, pLeft, pLeft1, pLeft2, pTab, pTab1, pTab2, pTest, pX, v, z, zBlob, zId, v1, v2, v3 v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe /* The opcode being coded */ inReg = target /* Results stored in register inReg */ **(**int32)(__ccgo_up(bp)) = 0 /* If non-zero free this temporary register */ **(**int32)(__ccgo_up(bp + 4)) = 0 /* Temporary expression node */ p5 = 0 goto expr_code_doover expr_code_doover: ; if pExpr == uintptr(0) { op = int32(TK_NULL) } else { if v2 = (*TParse)(unsafe.Pointer(pParse)).FpIdxEpr != uintptr(0) && !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Leaf)) != libc.Uint32FromInt32(0)); v2 { v1 = _sqlite3IndexedExprLookup(tls, pParse, pExpr, target) **(**int32)(__ccgo_up(bp + 8)) = v1 } if v2 && v1 >= 0 { return **(**int32)(__ccgo_up(bp + 8)) } else { op = libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) } } switch op { case int32(TK_AGG_COLUMN): pAggInfo = (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo if int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) >= (*TAggInfo)(unsafe.Pointer(pAggInfo)).FnColumn { /* Happens when the left table of a RIGHT JOIN is null and ** is using an expression index */ _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) break } pCol = (*TAggInfo)(unsafe.Pointer(pAggInfo)).FaCol + uintptr((*TExpr)(unsafe.Pointer(pExpr)).FiAgg)*32 if !((*TAggInfo)(unsafe.Pointer(pAggInfo)).FdirectMode != 0) { return (*TAggInfo)(unsafe.Pointer(pAggInfo)).FiFirstReg + int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) } else { if (*TAggInfo)(unsafe.Pointer(pAggInfo)).FuseSortingIdx != 0 { pTab = (*TAggInfo_col)(unsafe.Pointer(pCol)).FpTab _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TAggInfo)(unsafe.Pointer(pAggInfo)).FsortingIdxPTab, (*TAggInfo_col)(unsafe.Pointer(pCol)).FiSorterColumn, target) if pTab == uintptr(0) { /* No comment added */ } else { if (*TAggInfo_col)(unsafe.Pointer(pCol)).FiColumn < 0 { } else { if libc.Int32FromUint8((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab)).FaCol + uintptr((*TAggInfo_col)(unsafe.Pointer(pCol)).FiColumn)*16))).Faffinity) == int32(SQLITE_AFF_REAL) { _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), target) } } } return target } else { if *(*uintptr)(unsafe.Pointer(pExpr + 64)) == uintptr(0) { /* This case happens when the argument to an aggregate function ** is rewritten by aggregateConvertIndexedExprRefToColumn() */ _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TExpr)(unsafe.Pointer(pExpr)).FiTable, int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn), target) return target } } } /* Otherwise, fall thru into the TK_COLUMN case */ fallthrough case int32(TK_COLUMN): iTab = (*TExpr)(unsafe.Pointer(pExpr)).FiTable if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FixedCol)) != uint32(0) { iReg = _sqlite3ExprCodeTarget(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) aff = libc.Int32FromUint8(_sqlite3TableColumnAffinity(tls, *(*uintptr)(unsafe.Pointer(pExpr + 64)), int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn))) if aff > int32(SQLITE_AFF_BLOB) { _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), iReg, int32(1), 0, uintptr(unsafe.Pointer(&_zAff))+uintptr((aff-int32('B'))*int32(2)), -int32(1)) } return iReg } if iTab < 0 { if (*TParse)(unsafe.Pointer(pParse)).FiSelfTab < 0 { iCol = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) pTab1 = *(*uintptr)(unsafe.Pointer(pExpr + 64)) if iCol < 0 { return -int32(1) - (*TParse)(unsafe.Pointer(pParse)).FiSelfTab } pCol1 = (*TTable)(unsafe.Pointer(pTab1)).FaCol + uintptr(iCol)*16 iSrc = int32(_sqlite3TableColumnToStorage(tls, pTab1, int16(iCol))) - (*TParse)(unsafe.Pointer(pParse)).FiSelfTab if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol1)).FcolFlags)&int32(COLFLAG_GENERATED) != 0 { if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol1)).FcolFlags)&int32(COLFLAG_BUSY) != 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8480, libc.VaList(bp+168, (*TColumn)(unsafe.Pointer(pCol1)).FzCnName)) return 0 } v3 = pCol1 + 14 *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) | libc.Int32FromInt32(COLFLAG_BUSY)) if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol1)).FcolFlags)&int32(COLFLAG_NOTAVAIL) != 0 { _sqlite3ExprCodeGeneratedColumn(tls, pParse, pTab1, pCol1, iSrc) } v3 = pCol1 + 14 *(*Tu16)(unsafe.Pointer(v3)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v3))) & ^(libc.Int32FromInt32(COLFLAG_BUSY) | libc.Int32FromInt32(COLFLAG_NOTAVAIL))) return iSrc } else { if libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol1)).Faffinity) == int32(SQLITE_AFF_REAL) { _sqlite3VdbeAddOp2(tls, v, int32(OP_SCopy), iSrc, target) _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), target) return target } else { return iSrc } } } else { /* Coding an expression that is part of an index where column names ** in the index refer to the table to which the index belongs */ iTab = (*TParse)(unsafe.Pointer(pParse)).FiSelfTab - int32(1) } } else { if v2 = (*TParse)(unsafe.Pointer(pParse)).FpIdxPartExpr != 0; v2 { v1 = _exprPartidxExprLookup(tls, pParse, pExpr, target) **(**int32)(__ccgo_up(bp + 8)) = v1 } if v2 && 0 != v1 { return **(**int32)(__ccgo_up(bp + 8)) } } iReg = _sqlite3ExprCodeGetColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(pExpr + 64)), int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn), iTab, target, (*TExpr)(unsafe.Pointer(pExpr)).Fop2) return iReg case int32(TK_INTEGER): _codeInteger(tls, pParse, pExpr, 0, target) return target case int32(TK_TRUEFALSE): _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), _sqlite3ExprTruthValue(tls, pExpr), target) return target case int32(TK_FLOAT): _codeReal(tls, v, *(*uintptr)(unsafe.Pointer(pExpr + 8)), 0, target) return target case int32(TK_STRING): _sqlite3VdbeLoadString(tls, v, target, *(*uintptr)(unsafe.Pointer(pExpr + 8))) return target case int32(TK_NULLS): /* Set a range of registers to NULL. pExpr->y.nReg registers starting ** with target */ _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, target, target+*(*int32)(unsafe.Pointer(&(*TExpr)(unsafe.Pointer(pExpr)).Fy))-int32(1)) return target default: /* Make NULL the default case so that if a bug causes an illegal ** Expr node to be passed into this function, it will be handled ** sanely and not crash. But keep the assert() to bring the problem ** to the attention of the developers. */ _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) return target case int32(TK_BLOB): z = *(*uintptr)(unsafe.Pointer(pExpr + 8)) + 2 n = _sqlite3Strlen30(tls, z) - int32(1) zBlob = _sqlite3HexToBlob(tls, _sqlite3VdbeDb(tls, v), z, n) _sqlite3VdbeAddOp4(tls, v, int32(OP_Blob), n/int32(2), target, 0, zBlob, -int32(7)) return target case int32(TK_VARIABLE): _sqlite3VdbeAddOp2(tls, v, int32(OP_Variable), int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn), target) return target case int32(TK_REGISTER): return (*TExpr)(unsafe.Pointer(pExpr)).FiTable case int32(TK_CAST): /* Expressions of the form: CAST(pLeft AS token) */ _sqlite3ExprCode(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) _sqlite3VdbeAddOp2(tls, v, int32(OP_Cast), target, libc.Int32FromUint8(_sqlite3AffinityType(tls, *(*uintptr)(unsafe.Pointer(pExpr + 8)), uintptr(0)))) return inReg case int32(TK_IS): fallthrough case int32(TK_ISNOT): if op == int32(TK_IS) { v1 = int32(TK_EQ) } else { v1 = int32(TK_NE) } op = v1 p5 = int32(SQLITE_NULLEQ) fallthrough case int32(TK_LT): fallthrough case int32(TK_LE): fallthrough case int32(TK_GT): fallthrough case int32(TK_GE): fallthrough case int32(TK_NE): fallthrough case int32(TK_EQ): pLeft = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft addrIsNull = 0 if _sqlite3ExprIsVector(tls, pLeft) != 0 { _codeVectorCompare(tls, pParse, pExpr, target, libc.Uint8FromInt32(op), libc.Uint8FromInt32(p5)) } else { if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) && p5 != int32(SQLITE_NULLEQ) { addrIsNull = _exprComputeOperands(tls, pParse, pExpr, bp+8, bp+12, bp, bp+4) } else { **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) **(**int32)(__ccgo_up(bp + 12)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, bp+4) } _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), inReg) _codeCompare(tls, pParse, pLeft, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, op, **(**int32)(__ccgo_up(bp + 8)), **(**int32)(__ccgo_up(bp + 12)), _sqlite3VdbeCurrentAddr(tls, v)+int32(2), p5, libc.BoolInt32((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Commuted)) != uint32(0))) if p5 == int32(SQLITE_NULLEQ) { _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, inReg) } else { _sqlite3VdbeAddOp3(tls, v, int32(OP_ZeroOrNull), **(**int32)(__ccgo_up(bp + 8)), inReg, **(**int32)(__ccgo_up(bp + 12))) if addrIsNull != 0 { _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) _sqlite3VdbeJumpHere(tls, v, addrIsNull) _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, inReg) } } } case int32(TK_AND): fallthrough case int32(TK_OR): inReg = _exprCodeTargetAndOr(tls, pParse, pExpr, target, bp) case int32(TK_PLUS): fallthrough case int32(TK_STAR): fallthrough case int32(TK_MINUS): fallthrough case int32(TK_REM): fallthrough case int32(TK_BITAND): fallthrough case int32(TK_BITOR): fallthrough case int32(TK_SLASH): fallthrough case int32(TK_LSHIFT): fallthrough case int32(TK_RSHIFT): fallthrough case int32(TK_CONCAT): if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Subquery)) != uint32(0) { addrIsNull1 = _exprComputeOperands(tls, pParse, pExpr, bp+8, bp+12, bp, bp+4) } else { **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) **(**int32)(__ccgo_up(bp + 12)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpRight, bp+4) addrIsNull1 = 0 } _sqlite3VdbeAddOp3(tls, v, op, **(**int32)(__ccgo_up(bp + 12)), **(**int32)(__ccgo_up(bp + 8)), target) if addrIsNull1 != 0 { _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, _sqlite3VdbeCurrentAddr(tls, v)+int32(2)) _sqlite3VdbeJumpHere(tls, v, addrIsNull1) _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) } case int32(TK_UMINUS): pLeft1 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft1)).Fop) == int32(TK_INTEGER) { _codeInteger(tls, pParse, pLeft1, int32(1), target) return target } else { if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft1)).Fop) == int32(TK_FLOAT) { _codeReal(tls, v, *(*uintptr)(unsafe.Pointer(pLeft1 + 8)), int32(1), target) return target } else { (**(**TExpr)(__ccgo_up(bp + 16))).Fop = uint8(TK_INTEGER) (**(**TExpr)(__ccgo_up(bp + 16))).Fflags = libc.Uint32FromInt32(libc.Int32FromInt32(EP_IntValue) | libc.Int32FromInt32(EP_TokenOnly)) *(*int32)(unsafe.Pointer(bp + 16 + 8)) = 0 **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, bp+16, bp) **(**int32)(__ccgo_up(bp + 12)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp+4) _sqlite3VdbeAddOp3(tls, v, int32(OP_Subtract), **(**int32)(__ccgo_up(bp + 12)), **(**int32)(__ccgo_up(bp + 8)), target) } } case int32(TK_BITNOT): fallthrough case int32(TK_NOT): **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) _sqlite3VdbeAddOp2(tls, v, op, **(**int32)(__ccgo_up(bp + 8)), inReg) case int32(TK_TRUTH): /* IS TRUE or IS FALSE */ **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) isTrue = _sqlite3ExprTruthValue(tls, (*TExpr)(unsafe.Pointer(pExpr)).FpRight) bNormal = libc.BoolInt32(libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2) == int32(TK_IS)) _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsTrue), **(**int32)(__ccgo_up(bp + 8)), inReg, libc.BoolInt32(!(isTrue != 0)), isTrue^bNormal) case int32(TK_ISNULL): fallthrough case int32(TK_NOTNULL): _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), target) **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) addr = _sqlite3VdbeAddOp1(tls, v, op, **(**int32)(__ccgo_up(bp + 8))) _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, target) _sqlite3VdbeJumpHere(tls, v, addr) case int32(TK_AGG_FUNCTION): pInfo = (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo if pInfo == uintptr(0) || int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) < 0 || int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) >= (*TAggInfo)(unsafe.Pointer(pInfo)).FnFunc { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8541, libc.VaList(bp+168, pExpr)) } else { return (*TAggInfo)(unsafe.Pointer(pInfo)).FiFirstReg + (*TAggInfo)(unsafe.Pointer(pInfo)).FnColumn + int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) } case int32(TK_FUNCTION): /* The function name */ constMask = uint32(0) /* Loop counter */ db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* The database connection */ enc = (*Tsqlite3)(unsafe.Pointer(db)).Fenc /* The text encoding used by this database */ pColl = uintptr(0) /* A collating sequence */ if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_WinFunc)) != uint32(0) { return (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 64)))).FregResult } if int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40))&0x80>>7)) != 0 && _sqlite3ExprIsConstantNotJoin(tls, pParse, pExpr) != 0 { /* SQL functions can be expensive. So try to avoid running them ** multiple times if we know they always give the same result */ return _sqlite3ExprCodeRunJustOnce(tls, pParse, pExpr, -int32(1)) } pFarg = *(*uintptr)(unsafe.Pointer(pExpr + 32)) if pFarg != 0 { v1 = (*TExprList)(unsafe.Pointer(pFarg)).FnExpr } else { v1 = 0 } nFarg = v1 zId = *(*uintptr)(unsafe.Pointer(pExpr + 8)) pDef = _sqlite3FindFunction(tls, db, zId, nFarg, enc, uint8(0)) if pDef == uintptr(0) || (*TFuncDef)(unsafe.Pointer(pDef)).FxFinalize != uintptr(0) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8568, libc.VaList(bp+168, pExpr)) break } if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_INLINE) != uint32(0) && pFarg != uintptr(0) { return _exprCodeInlineFunction(tls, pParse, pFarg, int32(int64((*TFuncDef)(unsafe.Pointer(pDef)).FpUserData)), target) } else { if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_DIRECT)|libc.Int32FromInt32(SQLITE_FUNC_UNSAFE)) != 0 { _sqlite3ExprFunctionUsable(tls, pParse, pExpr, pDef) } } i = 0 for { if !(i < nFarg) { break } if i < int32(32) && _sqlite3ExprIsConstant(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + uintptr(i)*32))).FpExpr) != 0 { constMask = constMask | libc.Uint32FromInt32(1)<= int32(2) && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_InfixFunc)) != uint32(0) { pDef = _sqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8 + 1*32))).FpExpr) } else { if nFarg > 0 { pDef = _sqlite3VtabOverloadFunction(tls, db, pDef, nFarg, (*(*TExprList_item)(unsafe.Pointer(pFarg + 8))).FpExpr) } } if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_NEEDCOLL) != 0 { if !(pColl != 0) { pColl = (*Tsqlite3)(unsafe.Pointer(db)).FpDfltColl } _sqlite3VdbeAddOp4(tls, v, int32(OP_CollSeq), 0, 0, 0, pColl, -int32(2)) } _sqlite3VdbeAddFunctionCall(tls, pParse, libc.Int32FromUint32(constMask), **(**int32)(__ccgo_up(bp + 8)), target, nFarg, pDef, libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop2)) if nFarg != 0 { if constMask == uint32(0) { _sqlite3ReleaseTempRange(tls, pParse, **(**int32)(__ccgo_up(bp + 8)), nFarg) } else { } } return target case int32(TK_EXISTS): fallthrough case int32(TK_SELECT): if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 { return 0 } else { if v2 = op == int32(TK_SELECT) && (*TExpr)(unsafe.Pointer(pExpr)).Fflags&uint32(EP_xIsSelect) != uint32(0); v2 { v1 = (*TExprList)(unsafe.Pointer((*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pExpr + 32)))).FpEList)).FnExpr nCol = v1 } if v2 && v1 != int32(1) { _sqlite3SubselectError(tls, pParse, nCol, int32(1)) } else { return _sqlite3CodeSubselect(tls, pParse, pExpr) } } case int32(TK_SELECT_COLUMN): pLeft2 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft if (*TExpr)(unsafe.Pointer(pLeft2)).FiTable == 0 || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn) > libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pLeft2)).Fop2) { (*TExpr)(unsafe.Pointer(pLeft2)).FiTable = _sqlite3CodeSubselect(tls, pParse, pLeft2) (*TExpr)(unsafe.Pointer(pLeft2)).Fop2 = (*TParse)(unsafe.Pointer(pParse)).FwithinRJSubrtn } n1 = _sqlite3ExprVectorSize(tls, pLeft2) if (*TExpr)(unsafe.Pointer(pExpr)).FiTable != n1 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8153, libc.VaList(bp+168, (*TExpr)(unsafe.Pointer(pExpr)).FiTable, n1)) } return (*TExpr)(unsafe.Pointer(pLeft2)).FiTable + int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) case int32(TK_IN): destIfFalse = _sqlite3VdbeMakeLabel(tls, pParse) destIfNull = _sqlite3VdbeMakeLabel(tls, pParse) _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) _sqlite3ExprCodeIN(tls, pParse, pExpr, destIfFalse, destIfNull) _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), int32(1), target) _sqlite3VdbeResolveLabel(tls, v, destIfFalse) _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), target, 0) _sqlite3VdbeResolveLabel(tls, v, destIfNull) return target /* ** x BETWEEN y AND z ** ** This is equivalent to ** ** x>=y AND x<=z ** ** X is stored in pExpr->pLeft. ** Y is stored in pExpr->pList->a[0].pExpr. ** Z is stored in pExpr->pList->a[1].pExpr. */ fallthrough case int32(TK_BETWEEN): _exprCodeBetween(tls, pParse, pExpr, target, uintptr(0), 0) return target case int32(TK_COLLATE): if !((*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)) != libc.Uint32FromInt32(0)) { /* A TK_COLLATE Expr node without the EP_Collate tag is a so-called ** "SOFT-COLLATE" that is added to constraints that are pushed down ** from outer queries into sub-queries by the WHERE-clause push-down ** optimization. Clear subtypes as subtypes may not cross a subquery ** boundary. */ _sqlite3ExprCode(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) _sqlite3VdbeAddOp1(tls, v, int32(OP_ClrSubtype), target) return target } else { pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft goto expr_code_doover /* 2018-04-28: Prevent deep recursion. */ } fallthrough case int32(TK_SPAN): fallthrough case int32(TK_UPLUS): pExpr = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft goto expr_code_doover /* 2018-04-28: Prevent deep recursion. OSSFuzz. */ case int32(TK_TRIGGER): pTab2 = *(*uintptr)(unsafe.Pointer(pExpr + 64)) iCol1 = int32((*TExpr)(unsafe.Pointer(pExpr)).FiColumn) p1 = (*TExpr)(unsafe.Pointer(pExpr)).FiTable*(int32((*TTable)(unsafe.Pointer(pTab2)).FnCol)+int32(1)) + int32(1) + int32(_sqlite3TableColumnToStorage(tls, pTab2, int16(iCol1))) _sqlite3VdbeAddOp2(tls, v, int32(OP_Param), p1, target) /* If the column has REAL affinity, it may currently be stored as an ** integer. Use OP_RealAffinity to make sure it is really real. ** ** EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to ** floating point when extracting it from the record. */ if iCol1 >= 0 && libc.Int32FromUint8((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab2)).FaCol + uintptr(iCol1)*16))).Faffinity) == int32(SQLITE_AFF_REAL) { _sqlite3VdbeAddOp1(tls, v, int32(OP_RealAffinity), target) } case int32(TK_VECTOR): _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+6936, 0) break /* TK_IF_NULL_ROW Expr nodes are inserted ahead of expressions ** that derive from the right-hand table of a LEFT JOIN. The ** Expr.iTable value is the table number for the right-hand table. ** The expression is only evaluated if that table is not currently ** on a LEFT JOIN NULL row. */ fallthrough case int32(TK_IF_NULL_ROW): okConstFactor = libc.Uint8FromInt32(int32(Tbft(*(*uint16)(unsafe.Pointer(pParse + 40)) & 0x80 >> 7))) pAggInfo1 = (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo if pAggInfo1 != 0 { if !((*TAggInfo)(unsafe.Pointer(pAggInfo1)).FdirectMode != 0) { inReg = (*TAggInfo)(unsafe.Pointer(pAggInfo1)).FiFirstReg + int32((*TExpr)(unsafe.Pointer(pExpr)).FiAgg) break } if (*TAggInfo)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo)).FuseSortingIdx != 0 { _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), (*TAggInfo)(unsafe.Pointer(pAggInfo1)).FsortingIdxPTab, (**(**TAggInfo_col)(__ccgo_up((*TAggInfo)(unsafe.Pointer(pAggInfo1)).FaCol + uintptr((*TExpr)(unsafe.Pointer(pExpr)).FiAgg)*32))).FiSorterColumn, target) inReg = target break } } addrINR = _sqlite3VdbeAddOp3(tls, v, int32(OP_IfNullRow), (*TExpr)(unsafe.Pointer(pExpr)).FiTable, 0, target) /* The OP_IfNullRow opcode above can overwrite the result register with ** NULL. So we have to ensure that the result register is not a value ** that is suppose to be a constant. Two defenses are needed: ** (1) Temporarily disable factoring of constant expressions ** (2) Make sure the computed value really is stored in register ** "target" and not someplace else. */ libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(0), 7, 0x80) /* note (1) above */ _sqlite3ExprCode(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, target) libc.SetBitFieldPtr16Uint32(pParse+40, uint32(okConstFactor), 7, 0x80) _sqlite3VdbeJumpHere(tls, v, addrINR) break /* ** Form A: ** CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END ** ** Form B: ** CASE WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END ** ** Form A is can be transformed into the equivalent form B as follows: ** CASE WHEN x=e1 THEN r1 WHEN x=e2 THEN r2 ... ** WHEN x=eN THEN rN ELSE y END ** ** X (if it exists) is in pExpr->pLeft. ** Y is in the last element of pExpr->x.pList if pExpr->x.pList->nExpr is ** odd. The Y is also optional. If the number of elements in x.pList ** is even, then Y is omitted and the "otherwise" result is NULL. ** Ei is in pExpr->pList->a[i*2] and Ri is pExpr->pList->a[i*2+1]. ** ** The result of the expression is the Ri for the first matching Ei, ** or if there is no matching Ei, the ELSE term Y, or if there is ** no ELSE term, NULL. */ fallthrough case int32(TK_CASE): /* The X expression */ pTest = uintptr(0) /* X==Ei (form A) or just Ei (form B) */ pDel = uintptr(0) db1 = (*TParse)(unsafe.Pointer(pParse)).Fdb pEList = *(*uintptr)(unsafe.Pointer(pExpr + 32)) aListelem = pEList + 8 nExpr = (*TExprList)(unsafe.Pointer(pEList)).FnExpr endLabel = _sqlite3VdbeMakeLabel(tls, pParse) v3 = (*TExpr)(unsafe.Pointer(pExpr)).FpLeft pX = v3 if v3 != uintptr(0) { pDel = _sqlite3ExprDup(tls, db1, pX, 0) if (*Tsqlite3)(unsafe.Pointer(db1)).FmallocFailed != 0 { _sqlite3ExprDelete(tls, db1, pDel) break } _sqlite3ExprToRegister(tls, pDel, _exprCodeVector(tls, pParse, pDel, bp)) libc.Xmemset(tls, bp+88, 0, uint64(72)) (**(**TExpr)(__ccgo_up(bp + 88))).Fop = uint8(TK_EQ) (**(**TExpr)(__ccgo_up(bp + 88))).FpLeft = pDel pTest = bp + 88 /* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001: ** The value in regFree1 might get SCopy-ed into the file result. ** So make sure that the regFree1 register is not reused for other ** purposes and possibly overwritten. */ **(**int32)(__ccgo_up(bp)) = 0 } i1 = 0 for { if !(i1 < nExpr-int32(1)) { break } if pX != 0 { (**(**TExpr)(__ccgo_up(bp + 88))).FpRight = (**(**TExprList_item)(__ccgo_up(aListelem + uintptr(i1)*32))).FpExpr } else { pTest = (**(**TExprList_item)(__ccgo_up(aListelem + uintptr(i1)*32))).FpExpr } nextCase = _sqlite3VdbeMakeLabel(tls, pParse) _sqlite3ExprIfFalse(tls, pParse, pTest, nextCase, int32(SQLITE_JUMPIFNULL)) _sqlite3ExprCode(tls, pParse, (**(**TExprList_item)(__ccgo_up(aListelem + uintptr(i1+int32(1))*32))).FpExpr, target) _sqlite3VdbeGoto(tls, v, endLabel) _sqlite3VdbeResolveLabel(tls, v, nextCase) goto _13 _13: ; i1 = i1 + int32(2) } if nExpr&int32(1) != 0 { _sqlite3ExprCode(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(nExpr-int32(1))*32))).FpExpr, target) } else { _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, target) } _sqlite3ExprDelete(tls, db1, pDel) _setDoNotMergeFlagOnCopy(tls, v) _sqlite3VdbeResolveLabel(tls, v, endLabel) case int32(TK_RAISE): if !((*TParse)(unsafe.Pointer(pParse)).FpTriggerTab != 0) && !((*TParse)(unsafe.Pointer(pParse)).Fnested != 0) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8592, 0) return 0 } if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).FaffExpr) == int32(OE_Abort) { _sqlite3MayAbort(tls, pParse) } if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).FaffExpr) == int32(OE_Ignore) { _sqlite3VdbeAddOp2(tls, v, int32(OP_Halt), SQLITE_OK, int32(OE_Ignore)) } else { **(**int32)(__ccgo_up(bp + 8)) = _sqlite3ExprCodeTemp(tls, pParse, (*TExpr)(unsafe.Pointer(pExpr)).FpLeft, bp) if (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab != 0 { v1 = libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(7)< (*TInitData)(unsafe.Pointer(pData)).FmxPage && (*TInitData)(unsafe.Pointer(pData)).FmxPage > uint32(0) { if _sqlite3Config.FbExtraSchemaChecks != 0 { _corruptSchema(tls, pData, argv, __ccgo_ts+15768) } } libc.SetBitFieldPtr8Uint32(db+192+8, libc.Uint32FromInt32(0), 0, 0x1) (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FazInit = argv **(**uintptr)(__ccgo_up(bp)) = uintptr(0) _sqlite3Prepare(tls, db, **(**uintptr)(__ccgo_up(argv + 4*8)), -int32(1), uint32(0), uintptr(0), bp, uintptr(0)) rc = (*Tsqlite3)(unsafe.Pointer(db)).FerrCode (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb = saved_iDb /* assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 ); */ if SQLITE_OK != rc { if int32(uint32(*(*uint8)(unsafe.Pointer(db + 192 + 8))&0x1>>0)) != 0 { } else { if rc > (*TInitData)(unsafe.Pointer(pData)).Frc { (*TInitData)(unsafe.Pointer(pData)).Frc = rc } if rc == int32(SQLITE_NOMEM) { _sqlite3OomFault(tls, db) } else { if rc != int32(SQLITE_INTERRUPT) && rc&int32(0xFF) != int32(SQLITE_LOCKED) { _corruptSchema(tls, pData, argv, Xsqlite3_errmsg(tls, db)) } } } } (*Tsqlite3)(unsafe.Pointer(db)).Finit1.FazInit = uintptr(unsafe.Pointer(&_sqlite3StdType)) /* Any array of string ptrs will do */ Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp))) } else { if **(**uintptr)(__ccgo_up(argv + 1*8)) == uintptr(0) || **(**uintptr)(__ccgo_up(argv + 4*8)) != uintptr(0) && libc.Int32FromUint8(**(**uint8)(__ccgo_up(**(**uintptr)(__ccgo_up(argv + 4*8))))) != 0 { _corruptSchema(tls, pData, argv, uintptr(0)) } else { pIndex = _sqlite3FindIndex(tls, db, **(**uintptr)(__ccgo_up(argv + 1*8)), (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName) if pIndex == uintptr(0) { _corruptSchema(tls, pData, argv, __ccgo_ts+20118) } else { if _sqlite3GetUInt32(tls, **(**uintptr)(__ccgo_up(argv + 3*8)), pIndex+88) == 0 || (*TIndex)(unsafe.Pointer(pIndex)).Ftnum < uint32(2) || (*TIndex)(unsafe.Pointer(pIndex)).Ftnum > (*TInitData)(unsafe.Pointer(pData)).FmxPage || _sqlite3IndexHasDuplicateRootPage(tls, pIndex) != 0 { if _sqlite3Config.FbExtraSchemaChecks != 0 { _corruptSchema(tls, pData, argv, __ccgo_ts+15768) } } } } } } return 0 } // C documentation // // /* // ** Process a pragma statement. // ** // ** Pragmas are of this form: // ** // ** PRAGMA [schema.]id [= value] // ** // ** The identifier might also be a string. The value is a string, and // ** identifier, or a number. If minusFlag is true, then the value is // ** a number that was preceded by a minus sign. // ** // ** If the left side is "database.id" then pId1 is the database name // ** and pId2 is the id. If the left side is just "id" then pId1 is the // ** id and pId2 is any empty string. // */ func _sqlite3Pragma(tls *libc.TLS, pParse uintptr, pId1 uintptr, pId2 uintptr, pValue uintptr, minusFlag int32) { bp := tls.Alloc(240) defer tls.Free(240) var a1, a11, addr, addr1, addrCkFault, addrCkOk, addrOk, addrTop, b, bStrict, ckUniq, cnt, doTypeCheck, eAuto, eMode, eMode1, eMode2, i, i1, i10, i2, i3, i4, i5, i6, i7, i8, i9, iAddr, iAddr1, iBt, iCol, iCol1, iCookie, iDb, iDbLast, iEnd, iIdxDb, iLevel, iReg, iTab, iTabCur, iTabDb, iTabDb1, ii, ii1, ii2, ii3, ii4, initNCol, isHidden, isQuick, j2, j3, j4, jmp, jmp2, jmp21, jmp3, jmp4, jmp5, jmp6, jmp61, jmp7, k, k3, kk, label6, labelError, labelOk, loopTop, mx, mxCol, n, nBtree, nCheck, nHidden, nIdx, nIndex, nLimit, p11, p3, p4, r1, r11, r2, rc, regResult, regRow, showInternFunc, size, size1, size2, uniqOk, x1, v2 int32 var aOp, aOp1, aOp2, aOp3, aOp4, aOp5, aRoot, db, j, j1, k1, k2, k4, p, p1, pBt, pBt1, pBt2, pCheck, pCol, pCol1, pColExpr, pColl, pDb, pEnc, pFK, pFK1, pHash, pIdx, pIdx1, pIdx3, pIdx4, pIdx5, pIdx6, pIdx7, pMod, pObjTab, pPager, pPager1, pParent, pPk, pPk1, pPragma, pPrior, pSchema, pTab, pTab1, pTab10, pTab11, pTab12, pTab2, pTab3, pTab4, pTab5, pTab6, pTab7, pTab8, pTab9, pTbls, pVTab, v, x2, zDb, zErr, zErr1, zErr2, zLeft, zMod, zMode, zOpt, zRet, zRight, zSql, zSubSql, zType, v1, v5 uintptr var azOrigin [3]uintptr var cnum Ti16 var enc Tu8 var iPrior Tsqlite3_int64 var iRange, szThreshold TLogEst var mask Tu64 var opMask Tu32 var _ /* N at bp+136 */ Tsqlite3_int64 var _ /* N at bp+144 */ Tsqlite3_int64 var _ /* N at bp+152 */ Tsqlite3_int64 var _ /* N at bp+160 */ Tsqlite3_int64 var _ /* aFcntl at bp+8 */ [4]uintptr var _ /* aiCols at bp+96 */ uintptr var _ /* iDataCur at bp+108 */ int32 var _ /* iIdxCur at bp+112 */ int32 var _ /* iLimit at bp+48 */ Ti64 var _ /* iLimit at bp+56 */ int32 var _ /* jmp3 at bp+128 */ int32 var _ /* mxErr at bp+104 */ int32 var _ /* pDfltValue at bp+120 */ uintptr var _ /* pDummy at bp+80 */ uintptr var _ /* pId at bp+0 */ uintptr var _ /* pIdx at bp+88 */ uintptr var _ /* res at bp+72 */ int32 var _ /* size at bp+60 */ int32 var _ /* sz at bp+64 */ Tsqlite3_int64 var _ /* x at bp+40 */ Ti64 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a1, a11, aOp, aOp1, aOp2, aOp3, aOp4, aOp5, aRoot, addr, addr1, addrCkFault, addrCkOk, addrOk, addrTop, azOrigin, b, bStrict, ckUniq, cnt, cnum, db, doTypeCheck, eAuto, eMode, eMode1, eMode2, enc, i, i1, i10, i2, i3, i4, i5, i6, i7, i8, i9, iAddr, iAddr1, iBt, iCol, iCol1, iCookie, iDb, iDbLast, iEnd, iIdxDb, iLevel, iPrior, iRange, iReg, iTab, iTabCur, iTabDb, iTabDb1, ii, ii1, ii2, ii3, ii4, initNCol, isHidden, isQuick, j, j1, j2, j3, j4, jmp, jmp2, jmp21, jmp3, jmp4, jmp5, jmp6, jmp61, jmp7, k, k1, k2, k3, k4, kk, label6, labelError, labelOk, loopTop, mask, mx, mxCol, n, nBtree, nCheck, nHidden, nIdx, nIndex, nLimit, opMask, p, p1, p11, p3, p4, pBt, pBt1, pBt2, pCheck, pCol, pCol1, pColExpr, pColl, pDb, pEnc, pFK, pFK1, pHash, pIdx, pIdx1, pIdx3, pIdx4, pIdx5, pIdx6, pIdx7, pMod, pObjTab, pPager, pPager1, pParent, pPk, pPk1, pPragma, pPrior, pSchema, pTab, pTab1, pTab10, pTab11, pTab12, pTab2, pTab3, pTab4, pTab5, pTab6, pTab7, pTab8, pTab9, pTbls, pVTab, r1, r11, r2, rc, regResult, regRow, showInternFunc, size, size1, size2, szThreshold, uniqOk, v, x1, x2, zDb, zErr, zErr1, zErr2, zLeft, zMod, zMode, zOpt, zRet, zRight, zSql, zSubSql, zType, v1, v2, v5 zLeft = uintptr(0) /* Nul-terminated UTF-8 string */ zRight = uintptr(0) /* Nul-terminated UTF-8 string , or NULL */ zDb = uintptr(0) /* return value form SQLITE_FCNTL_PRAGMA */ db = (*TParse)(unsafe.Pointer(pParse)).Fdb /* The specific database being pragmaed */ v = _sqlite3GetVdbe(tls, pParse) /* The pragma */ if v == uintptr(0) { return } _sqlite3VdbeRunOnlyOnce(tls, v) (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(2) /* Interpret the [schema.] part of the pragma statement. iDb is the ** index of the database this pragma is being applied to in db.aDb[]. */ iDb = _sqlite3TwoPartName(tls, pParse, pId1, pId2, bp) if iDb < 0 { return } pDb = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32 /* If the temp database has been explicitly named as part of the ** pragma, make sure it is open. */ if iDb == int32(1) && _sqlite3OpenTempDatabase(tls, pParse) != 0 { return } zLeft = _sqlite3NameFromToken(tls, db, **(**uintptr)(__ccgo_up(bp))) if !(zLeft != 0) { return } if minusFlag != 0 { zRight = _sqlite3MPrintf(tls, db, __ccgo_ts+19242, libc.VaList(bp+176, pValue)) } else { zRight = _sqlite3NameFromToken(tls, db, pValue) } if (*TToken)(unsafe.Pointer(pId2)).Fn > uint32(0) { v1 = (*TDb)(unsafe.Pointer(pDb)).FzDbSName } else { v1 = uintptr(0) } zDb = v1 if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_PRAGMA), zLeft, zRight, zDb) != 0 { goto pragma_out } /* Send an SQLITE_FCNTL_PRAGMA file-control to the underlying VFS ** connection. If it returns SQLITE_OK, then assume that the VFS ** handled the pragma and generate a no-op prepared statement. ** ** IMPLEMENTATION-OF: R-12238-55120 Whenever a PRAGMA statement is parsed, ** an SQLITE_FCNTL_PRAGMA file control is sent to the open sqlite3_file ** object corresponding to the database file to which the pragma ** statement refers. ** ** IMPLEMENTATION-OF: R-29875-31678 The argument to the SQLITE_FCNTL_PRAGMA ** file control is an array of pointers to strings (char**) in which the ** second element of the array is the name of the pragma and the third ** element is the argument to the pragma or NULL if the pragma has no ** argument. */ (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0] = uintptr(0) (**(**[4]uintptr)(__ccgo_up(bp + 8)))[int32(1)] = zLeft (**(**[4]uintptr)(__ccgo_up(bp + 8)))[int32(2)] = zRight (**(**[4]uintptr)(__ccgo_up(bp + 8)))[int32(3)] = uintptr(0) (*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0 rc = Xsqlite3_file_control(tls, db, zDb, int32(SQLITE_FCNTL_PRAGMA), bp+8) if rc == SQLITE_OK { _sqlite3VdbeSetNumCols(tls, v, int32(1)) _sqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0], uintptr(-libc.Int32FromInt32(1))) _returnSingleText(tls, v, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0]) Xsqlite3_free(tls, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0]) goto pragma_out } if rc != int32(SQLITE_NOTFOUND) { if (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0] != 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+3968, libc.VaList(bp+176, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0])) Xsqlite3_free(tls, (**(**[4]uintptr)(__ccgo_up(bp + 8)))[0]) } (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 (*TParse)(unsafe.Pointer(pParse)).Frc = rc goto pragma_out } /* Locate the pragma in the lookup table */ pPragma = _pragmaLocate(tls, zLeft) if pPragma == uintptr(0) { /* IMP: R-43042-22504 No error messages are generated if an ** unknown pragma is issued. */ goto pragma_out } /* Make sure the database schema is loaded if the pragma requires that */ if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_NeedSchema) != 0 { if _sqlite3ReadSchema(tls, pParse) != 0 { goto pragma_out } } /* Register the result column names for pragmas that return results */ if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_NoColumns) == 0 && (libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_NoColumns1) == 0 || zRight == uintptr(0)) { _setPragmaResultColumnNames(tls, v, pPragma) } /* Jump to the appropriate pragma handler */ switch libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FePragTyp) { /* ** PRAGMA [schema.]default_cache_size ** PRAGMA [schema.]default_cache_size=N ** ** The first form reports the current persistent setting for the ** page cache size. The value returned is the maximum number of ** pages in the page cache. The second form sets both the current ** page cache size value and the persistent page cache size value ** stored in the database file. ** ** Older versions of SQLite would set the default cache size to a ** negative number to indicate synchronous=OFF. These days, synchronous ** is always on by default regardless of the sign of the default cache ** size. But continue to take the absolute value of the default cache ** size of historical compatibility. */ case int32(PragTyp_DEFAULT_CACHE_SIZE): _sqlite3VdbeUsesBtree(tls, v, iDb) if !(zRight != 0) { **(**int32)(__ccgo_up(pParse + 60)) += int32(2) aOp = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(36)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_getCacheSize)), _iLn3) if 0 != 0 { break } (**(**TVdbeOp)(__ccgo_up(aOp))).Fp1 = iDb (**(**TVdbeOp)(__ccgo_up(aOp + 1*24))).Fp1 = iDb (**(**TVdbeOp)(__ccgo_up(aOp + 6*24))).Fp1 = -int32(2000) } else { size = _sqlite3AbsInt32(tls, _sqlite3Atoi(tls, zRight)) _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) _sqlite3VdbeAddOp3(tls, v, int32(OP_SetCookie), iDb, int32(BTREE_DEFAULT_CACHE_SIZE), size) (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size = size _sqlite3BtreeSetCacheSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size) } break /* ** PRAGMA [schema.]page_size ** PRAGMA [schema.]page_size=N ** ** The first form reports the current setting for the ** database page size in bytes. The second form sets the ** database page size value. The value can only be set if ** the database has not yet been created. */ fallthrough case int32(PragTyp_PAGE_SIZE): pBt = (*TDb)(unsafe.Pointer(pDb)).FpBt if !(zRight != 0) { if pBt != 0 { v2 = _sqlite3BtreeGetPageSize(tls, pBt) } else { v2 = 0 } size1 = v2 _returnSingleInt(tls, v, int64(size1)) } else { /* Malloc may fail when setting the page-size, as there is an internal ** buffer that the pager module resizes using sqlite3_realloc(). */ (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize = _sqlite3Atoi(tls, zRight) if int32(SQLITE_NOMEM) == _sqlite3BtreeSetPageSize(tls, pBt, (*Tsqlite3)(unsafe.Pointer(db)).FnextPagesize, 0, 0) { _sqlite3OomFault(tls, db) } } break /* ** PRAGMA [schema.]secure_delete ** PRAGMA [schema.]secure_delete=ON/OFF/FAST ** ** The first form reports the current setting for the ** secure_delete flag. The second form changes the secure_delete ** flag setting and reports the new value. */ fallthrough case int32(PragTyp_SECURE_DELETE): pBt1 = (*TDb)(unsafe.Pointer(pDb)).FpBt b = -int32(1) if zRight != 0 { if Xsqlite3_stricmp(tls, zRight, __ccgo_ts+19246) == 0 { b = int32(2) } else { b = libc.Int32FromUint8(_sqlite3GetBoolean(tls, zRight, uint8(0))) } } if (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) && b >= 0 { ii = 0 for { if !(ii < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { break } _sqlite3BtreeSecureDelete(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii)*32))).FpBt, b) goto _3 _3: ; ii = ii + 1 } } b = _sqlite3BtreeSecureDelete(tls, pBt1, b) _returnSingleInt(tls, v, int64(b)) break /* ** PRAGMA [schema.]max_page_count ** PRAGMA [schema.]max_page_count=N ** ** The first form reports the current setting for the ** maximum number of pages in the database file. The ** second form attempts to change this setting. Both ** forms return the current setting. ** ** The absolute value of N is used. This is undocumented and might ** change. The only purpose is to provide an easy way to test ** the sqlite3AbsInt32() function. ** ** PRAGMA [schema.]page_count ** ** Return the number of pages in the specified database. */ fallthrough case int32(PragTyp_PAGE_COUNT): **(**Ti64)(__ccgo_up(bp + 40)) = 0 _sqlite3CodeVerifySchema(tls, pParse, iDb) v1 = pParse + 60 *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 v2 = *(*int32)(unsafe.Pointer(v1)) iReg = v2 if libc.Int32FromUint8(_sqlite3UpperToLower[uint8(**(**uint8)(__ccgo_up(zLeft)))]) == int32('p') { _sqlite3VdbeAddOp2(tls, v, int32(OP_Pagecount), iDb, iReg) } else { if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+40) == 0 { if **(**Ti64)(__ccgo_up(bp + 40)) < 0 { **(**Ti64)(__ccgo_up(bp + 40)) = 0 } else { if **(**Ti64)(__ccgo_up(bp + 40)) > libc.Int64FromUint32(0xfffffffe) { **(**Ti64)(__ccgo_up(bp + 40)) = libc.Int64FromUint32(0xfffffffe) } } } else { **(**Ti64)(__ccgo_up(bp + 40)) = 0 } _sqlite3VdbeAddOp3(tls, v, int32(OP_MaxPgcnt), iDb, iReg, int32(**(**Ti64)(__ccgo_up(bp + 40)))) } _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), iReg, int32(1)) break /* ** PRAGMA [schema.]locking_mode ** PRAGMA [schema.]locking_mode = (normal|exclusive) */ fallthrough case int32(PragTyp_LOCKING_MODE): zRet = __ccgo_ts + 19037 eMode = _getLockingMode(tls, zRight) if (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) && eMode == -int32(1) { /* Simple "PRAGMA locking_mode;" statement. This is a query for ** the current default locking mode (which may be different to ** the locking-mode of the main database). */ eMode = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FdfltLockMode) } else { if (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) { ii1 = int32(2) for { if !(ii1 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { break } pPager = _sqlite3BtreePager(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii1)*32))).FpBt) _sqlite3PagerLockingMode(tls, pPager, eMode) goto _6 _6: ; ii1 = ii1 + 1 } (*Tsqlite3)(unsafe.Pointer(db)).FdfltLockMode = libc.Uint8FromInt32(eMode) } pPager = _sqlite3BtreePager(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) eMode = _sqlite3PagerLockingMode(tls, pPager, eMode) } if eMode == int32(PAGER_LOCKINGMODE_EXCLUSIVE) { zRet = __ccgo_ts + 19027 } _returnSingleText(tls, v, zRet) break /* ** PRAGMA [schema.]journal_mode ** PRAGMA [schema.]journal_mode = ** (delete|persist|off|truncate|memory|wal|off) */ fallthrough case int32(PragTyp_JOURNAL_MODE): /* Loop counter */ if zRight == uintptr(0) { /* If there is no "=MODE" part of the pragma, do a query for the ** current mode */ eMode1 = -int32(1) } else { n = _sqlite3Strlen30(tls, zRight) eMode1 = 0 for { v1 = _sqlite3JournalModename(tls, eMode1) zMode = v1 if !(v1 != uintptr(0)) { break } if Xsqlite3_strnicmp(tls, zRight, zMode, n) == 0 { break } goto _7 _7: ; eMode1 = eMode1 + 1 } if !(zMode != 0) { /* If the "=MODE" part does not match any known journal mode, ** then do a query */ eMode1 = -int32(1) } if eMode1 == int32(PAGER_JOURNALMODE_OFF) && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) != uint64(0) { /* Do not allow journal-mode "OFF" in defensive since the database ** can become corrupted using ordinary SQL when the journal is off */ eMode1 = -int32(1) } } if eMode1 == -int32(1) && (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) { /* Convert "PRAGMA journal_mode" into "PRAGMA main.journal_mode" */ iDb = 0 (*TToken)(unsafe.Pointer(pId2)).Fn = uint32(1) } ii2 = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) for { if !(ii2 >= 0) { break } if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii2)*32))).FpBt != 0 && (ii2 == iDb || (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0)) { _sqlite3VdbeUsesBtree(tls, v, ii2) _sqlite3VdbeAddOp3(tls, v, int32(OP_JournalMode), ii2, int32(1), eMode1) } goto _9 _9: ; ii2 = ii2 - 1 } _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), int32(1)) break /* ** PRAGMA [schema.]journal_size_limit ** PRAGMA [schema.]journal_size_limit=N ** ** Get or set the size limit on rollback journal files. */ fallthrough case int32(PragTyp_JOURNAL_SIZE_LIMIT): pPager1 = _sqlite3BtreePager(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt) **(**Ti64)(__ccgo_up(bp + 48)) = int64(-int32(2)) if zRight != 0 { _sqlite3DecOrHexToI64(tls, zRight, bp+48) if **(**Ti64)(__ccgo_up(bp + 48)) < int64(-int32(1)) { **(**Ti64)(__ccgo_up(bp + 48)) = int64(-int32(1)) } } **(**Ti64)(__ccgo_up(bp + 48)) = _sqlite3PagerJournalSizeLimit(tls, pPager1, **(**Ti64)(__ccgo_up(bp + 48))) _returnSingleInt(tls, v, **(**Ti64)(__ccgo_up(bp + 48))) break /* ** PRAGMA [schema.]auto_vacuum ** PRAGMA [schema.]auto_vacuum=N ** ** Get or set the value of the database 'auto-vacuum' parameter. ** The value is one of: 0 NONE 1 FULL 2 INCREMENTAL */ fallthrough case int32(PragTyp_AUTO_VACUUM): pBt2 = (*TDb)(unsafe.Pointer(pDb)).FpBt if !(zRight != 0) { _returnSingleInt(tls, v, int64(_sqlite3BtreeGetAutoVacuum(tls, pBt2))) } else { eAuto = _getAutoVacuum(tls, zRight) (*Tsqlite3)(unsafe.Pointer(db)).FnextAutovac = libc.Int8FromUint8(libc.Uint8FromInt32(eAuto)) /* Call SetAutoVacuum() to set initialize the internal auto and ** incr-vacuum flags. This is required in case this connection ** creates the database file. It is important that it is created ** as an auto-vacuum capable db. */ rc = _sqlite3BtreeSetAutoVacuum(tls, pBt2, eAuto) if rc == SQLITE_OK && (eAuto == int32(1) || eAuto == int32(2)) { iAddr = _sqlite3VdbeCurrentAddr(tls, v) aOp1 = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(20)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_setMeta6)), _iLn11) if 0 != 0 { break } (**(**TVdbeOp)(__ccgo_up(aOp1))).Fp1 = iDb (**(**TVdbeOp)(__ccgo_up(aOp1 + 1*24))).Fp1 = iDb (**(**TVdbeOp)(__ccgo_up(aOp1 + 2*24))).Fp2 = iAddr + int32(4) (**(**TVdbeOp)(__ccgo_up(aOp1 + 4*24))).Fp1 = iDb (**(**TVdbeOp)(__ccgo_up(aOp1 + 4*24))).Fp3 = eAuto - int32(1) _sqlite3VdbeUsesBtree(tls, v, iDb) } } break /* ** PRAGMA [schema.]incremental_vacuum(N) ** ** Do N steps of incremental vacuuming on a database. */ fallthrough case int32(PragTyp_INCREMENTAL_VACUUM): **(**int32)(__ccgo_up(bp + 56)) = 0 if zRight == uintptr(0) || !(_sqlite3GetInt32(tls, zRight, bp+56) != 0) || **(**int32)(__ccgo_up(bp + 56)) <= 0 { **(**int32)(__ccgo_up(bp + 56)) = int32(0x7fffffff) } _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), **(**int32)(__ccgo_up(bp + 56)), int32(1)) addr = _sqlite3VdbeAddOp1(tls, v, int32(OP_IncrVacuum), iDb) _sqlite3VdbeAddOp1(tls, v, int32(OP_ResultRow), int32(1)) _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), int32(1), -int32(1)) _sqlite3VdbeAddOp2(tls, v, int32(OP_IfPos), int32(1), addr) _sqlite3VdbeJumpHere(tls, v, addr) break /* ** PRAGMA [schema.]cache_size ** PRAGMA [schema.]cache_size=N ** ** The first form reports the current local setting for the ** page cache size. The second form sets the local ** page cache size value. If N is positive then that is the ** number of pages in the cache. If N is negative, then the ** number of pages is adjusted so that the cache uses -N kibibytes ** of memory. */ fallthrough case int32(PragTyp_CACHE_SIZE): if !(zRight != 0) { _returnSingleInt(tls, v, int64((*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size)) } else { size2 = _sqlite3Atoi(tls, zRight) (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size = size2 _sqlite3BtreeSetCacheSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).Fcache_size) } break /* ** PRAGMA [schema.]cache_spill ** PRAGMA cache_spill=BOOLEAN ** PRAGMA [schema.]cache_spill=N ** ** The first form reports the current local setting for the ** page cache spill size. The second form turns cache spill on ** or off. When turning cache spill on, the size is set to the ** current cache_size. The third form sets a spill size that ** may be different form the cache size. ** If N is positive then that is the ** number of pages in the cache. If N is negative, then the ** number of pages is adjusted so that the cache uses -N kibibytes ** of memory. ** ** If the number of cache_spill pages is less then the number of ** cache_size pages, no spilling occurs until the page count exceeds ** the number of cache_size pages. ** ** The cache_spill=BOOLEAN setting applies to all attached schemas, ** not just the schema specified. */ fallthrough case int32(PragTyp_CACHE_SPILL): if !(zRight != 0) { if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_CacheSpill) == uint64(0) { v2 = 0 } else { v2 = _sqlite3BtreeSetSpillSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, 0) } _returnSingleInt(tls, v, int64(v2)) } else { **(**int32)(__ccgo_up(bp + 60)) = int32(1) if _sqlite3GetInt32(tls, zRight, bp+60) != 0 { _sqlite3BtreeSetSpillSize(tls, (*TDb)(unsafe.Pointer(pDb)).FpBt, **(**int32)(__ccgo_up(bp + 60))) } if _sqlite3GetBoolean(tls, zRight, libc.BoolUint8(**(**int32)(__ccgo_up(bp + 60)) != 0)) != 0 { **(**Tu64)(__ccgo_up(db + 48)) |= uint64(SQLITE_CacheSpill) } else { **(**Tu64)(__ccgo_up(db + 48)) &= ^libc.Uint64FromInt32(SQLITE_CacheSpill) } _setAllPagerFlags(tls, db) } break /* ** PRAGMA [schema.]mmap_size(N) ** ** Used to set mapping size limit. The mapping size limit is ** used to limit the aggregate size of all memory mapped regions of the ** database file. If this parameter is set to zero, then memory mapping ** is not used at all. If N is negative, then the default memory map ** limit determined by sqlite3_config(SQLITE_CONFIG_MMAP_SIZE) is set. ** The parameter N is measured in bytes. ** ** This value is advisory. The underlying VFS is free to memory map ** as little or as much as it wants. Except, if N is set to 0 then the ** upper layers will never invoke the xFetch interfaces to the VFS. */ fallthrough case int32(PragTyp_MMAP_SIZE): if zRight != 0 { _sqlite3DecOrHexToI64(tls, zRight, bp+64) if **(**Tsqlite3_int64)(__ccgo_up(bp + 64)) < 0 { **(**Tsqlite3_int64)(__ccgo_up(bp + 64)) = _sqlite3Config.FszMmap } if (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0) { (*Tsqlite3)(unsafe.Pointer(db)).FszMmap = **(**Tsqlite3_int64)(__ccgo_up(bp + 64)) } ii3 = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) for { if !(ii3 >= 0) { break } if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii3)*32))).FpBt != 0 && (ii3 == iDb || (*TToken)(unsafe.Pointer(pId2)).Fn == uint32(0)) { _sqlite3BtreeSetMmapLimit(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii3)*32))).FpBt, **(**Tsqlite3_int64)(__ccgo_up(bp + 64))) } goto _11 _11: ; ii3 = ii3 - 1 } } **(**Tsqlite3_int64)(__ccgo_up(bp + 64)) = int64(-int32(1)) rc = Xsqlite3_file_control(tls, db, zDb, int32(SQLITE_FCNTL_MMAP_SIZE), bp+64) if rc == SQLITE_OK { _returnSingleInt(tls, v, **(**Tsqlite3_int64)(__ccgo_up(bp + 64))) } else { if rc != int32(SQLITE_NOTFOUND) { (*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1 (*TParse)(unsafe.Pointer(pParse)).Frc = rc } } break /* ** PRAGMA temp_store ** PRAGMA temp_store = "default"|"memory"|"file" ** ** Return or set the local value of the temp_store flag. Changing ** the local value does not make changes to the disk file and the default ** value will be restored the next time the database is opened. ** ** Note that it is possible for the library compile-time options to ** override this setting */ fallthrough case int32(PragTyp_TEMP_STORE): if !(zRight != 0) { _returnSingleInt(tls, v, libc.Int64FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Ftemp_store)) } else { _changeTempStorage(tls, pParse, zRight) } break /* ** PRAGMA temp_store_directory ** PRAGMA temp_store_directory = ""|"directory_name" ** ** Return or set the local value of the temp_store_directory flag. Changing ** the value sets a specific directory to be used for temporary files. ** Setting to a null string reverts to the default temporary directory search. ** If temporary directory is changed, then invalidateTempStorage. ** */ fallthrough case int32(PragTyp_TEMP_STORE_DIRECTORY): Xsqlite3_mutex_enter(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) if !(zRight != 0) { _returnSingleText(tls, v, Xsqlite3_temp_directory) } else { if **(**uint8)(__ccgo_up(zRight)) != 0 { rc = _sqlite3OsAccess(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpVfs, zRight, int32(SQLITE_ACCESS_READWRITE), bp+72) if rc != SQLITE_OK || **(**int32)(__ccgo_up(bp + 72)) == 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+19251, 0) Xsqlite3_mutex_leave(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) goto pragma_out } } if libc.Bool(false) || libc.Bool(true) && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Ftemp_store) <= int32(1) || libc.Bool(libc.Bool(false) && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Ftemp_store) == int32(1)) { _invalidateTempStorage(tls, pParse) } Xsqlite3_free(tls, Xsqlite3_temp_directory) if **(**uint8)(__ccgo_up(zRight)) != 0 { Xsqlite3_temp_directory = Xsqlite3_mprintf(tls, __ccgo_ts+3968, libc.VaList(bp+176, zRight)) } else { Xsqlite3_temp_directory = uintptr(0) } } Xsqlite3_mutex_leave(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1))) break /* ** PRAGMA [schema.]synchronous ** PRAGMA [schema.]synchronous=OFF|ON|NORMAL|FULL|EXTRA ** ** Return or set the local value of the synchronous flag. Changing ** the local value does not make changes to the disk file and the ** default value will be restored the next time the database is ** opened. */ fallthrough case int32(PragTyp_SYNCHRONOUS): if !(zRight != 0) { _returnSingleInt(tls, v, int64(libc.Int32FromUint8((*TDb)(unsafe.Pointer(pDb)).Fsafety_level)-int32(1))) } else { if !((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+19276, 0) } else { if iDb != int32(1) { iLevel = (libc.Int32FromUint8(_getSafetyLevel(tls, zRight, 0, uint8(1))) + int32(1)) & int32(PAGER_SYNCHRONOUS_MASK) if iLevel == 0 { iLevel = int32(1) } (*TDb)(unsafe.Pointer(pDb)).Fsafety_level = libc.Uint8FromInt32(iLevel) (*TDb)(unsafe.Pointer(pDb)).FbSyncSet = uint8(1) _setAllPagerFlags(tls, db) } } } case int32(PragTyp_FLAG): if zRight == uintptr(0) { _setPragmaResultColumnNames(tls, v, pPragma) _returnSingleInt(tls, v, libc.BoolInt64((*Tsqlite3)(unsafe.Pointer(db)).Fflags&(*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != uint64(0))) } else { mask = (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg /* Mask of bits to set or clear. */ if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit) == 0 { /* Foreign key support may not be enabled or disabled while not ** in auto-commit mode. */ mask = mask & libc.Uint64FromInt32(^libc.Int32FromInt32(SQLITE_ForeignKeys)) } if _sqlite3GetBoolean(tls, zRight, uint8(0)) != 0 { if mask&uint64(SQLITE_WriteSchema) == uint64(0) || (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) == uint64(0) { **(**Tu64)(__ccgo_up(db + 48)) |= mask } } else { **(**Tu64)(__ccgo_up(db + 48)) &= ^mask if mask == uint64(SQLITE_DeferFKs) { (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons = 0 (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons = 0 } if mask&uint64(SQLITE_WriteSchema) != uint64(0) && Xsqlite3_stricmp(tls, zRight, __ccgo_ts+19329) == 0 { /* IMP: R-60817-01178 If the argument is "RESET" then schema ** writing is disabled (as with "PRAGMA writable_schema=OFF") and, ** in addition, the schema is reloaded. */ _sqlite3ResetAllSchemasOfConnection(tls, db) } } /* Many of the flag-pragmas modify the code generated by the SQL ** compiler (eg. count_changes). So add an opcode to expire all ** compiled SQL statements after modifying a pragma value. */ _sqlite3VdbeAddOp0(tls, v, int32(OP_Expire)) _setAllPagerFlags(tls, db) } break /* ** PRAGMA table_info() ** ** Return a single row for each column of the named table. The columns of ** the returned data set are: ** ** cid: Column id (numbered from left to right, starting at 0) ** name: Column name ** type: Column declaration type. ** notnull: True if 'NOT NULL' is part of column declaration ** dflt_value: The default value for the column, if any. ** pk: Non-zero for PK fields. */ fallthrough case int32(PragTyp_TABLE_INFO): if zRight != 0 { _sqlite3CodeVerifyNamedSchema(tls, pParse, zDb) pTab = _sqlite3LocateTable(tls, pParse, uint32(LOCATE_NOERR), zRight, zDb) if pTab != 0 { nHidden = 0 pPk = _sqlite3PrimaryKeyIndex(tls, pTab) (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(7) _sqlite3ViewGetColumnNames(tls, pParse, pTab) i = 0 pCol = (*TTable)(unsafe.Pointer(pTab)).FaCol for { if !(i < int32((*TTable)(unsafe.Pointer(pTab)).FnCol)) { break } isHidden = 0 if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_NOINSERT) != 0 { if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg == uint64(0) { nHidden = nHidden + 1 goto _12 } if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { isHidden = int32(2) /* GENERATED ALWAYS AS ... VIRTUAL */ } else { if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_STORED) != 0 { isHidden = int32(3) /* GENERATED ALWAYS AS ... STORED */ } else { isHidden = int32(1) /* HIDDEN */ } } } if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol)).FcolFlags)&int32(COLFLAG_PRIMKEY) == 0 { k = 0 } else { if pPk == uintptr(0) { k = int32(1) } else { k = int32(1) for { if !(k <= int32((*TTable)(unsafe.Pointer(pTab)).FnCol) && int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pPk)).FaiColumn + uintptr(k-int32(1))*2))) != i) { break } goto _13 _13: ; k = k + 1 } } } pColExpr = _sqlite3ColumnExpr(tls, pTab, pCol) if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != 0 { v1 = __ccgo_ts + 19335 } else { v1 = __ccgo_ts + 19343 } if int32(uint32(*(*uint8)(unsafe.Pointer(pCol + 8))&0xf>>0)) != 0 { v2 = int32(1) } else { v2 = 0 } if isHidden >= int32(2) || pColExpr == uintptr(0) { v5 = uintptr(0) } else { v5 = *(*uintptr)(unsafe.Pointer(pColExpr + 8)) } _sqlite3VdbeMultiLoad(tls, v, int32(1), v1, libc.VaList(bp+176, i-nHidden, (*TColumn)(unsafe.Pointer(pCol)).FzCnName, _sqlite3ColumnType(tls, pCol, __ccgo_ts+1704), v2, v5, k, isHidden)) goto _12 _12: ; i = i + 1 pCol += 16 } } } break /* ** PRAGMA table_list ** ** Return a single row for each table, virtual table, or view in the ** entire schema. ** ** schema: Name of attached database hold this table ** name: Name of the table itself ** type: "table", "view", "virtual", "shadow" ** ncol: Number of columns ** wr: True for a WITHOUT ROWID table ** strict: True for a STRICT table */ fallthrough case int32(PragTyp_TABLE_LIST): (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(6) _sqlite3CodeVerifyNamedSchema(tls, pParse, zDb) ii4 = 0 for { if !(ii4 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { break } if zDb != 0 && Xsqlite3_stricmp(tls, zDb, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii4)*32))).FzDbSName) != 0 { goto _17 } /* Ensure that the Table.nCol field is initialized for all views ** and virtual tables. Each time we initialize a Table.nCol value ** for a table, that can potentially disrupt the hash table, so restart ** the initialization scan. */ pHash = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii4)*32))).FpSchema + 8 initNCol = libc.Int32FromUint32((*THash)(unsafe.Pointer(pHash)).Fcount) for { v2 = initNCol initNCol = initNCol - 1 if !(v2 != 0) { break } k1 = (*THash)(unsafe.Pointer(pHash)).Ffirst for { if !(int32(1) != 0) { break } if k1 == uintptr(0) { initNCol = 0 break } pTab1 = (*THashElem)(unsafe.Pointer(k1)).Fdata if int32((*TTable)(unsafe.Pointer(pTab1)).FnCol) == 0 { zSql = _sqlite3MPrintf(tls, db, __ccgo_ts+19350, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab1)).FzName)) if zSql != 0 { **(**uintptr)(__ccgo_up(bp + 80)) = uintptr(0) Xsqlite3_prepare_v3(tls, db, zSql, -int32(1), uint32(SQLITE_PREPARE_DONT_LOG), bp+80, uintptr(0)) Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp + 80))) _sqlite3DbFree(tls, db, zSql) } if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { _sqlite3ErrorMsg(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpParse, __ccgo_ts+1674, 0) (*TParse)(unsafe.Pointer((*Tsqlite3)(unsafe.Pointer(db)).FpParse)).Frc = int32(SQLITE_NOMEM) } pHash = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii4)*32))).FpSchema + 8 break } goto _19 _19: ; k1 = (*THashElem)(unsafe.Pointer(k1)).Fnext } } k1 = (*THash)(unsafe.Pointer(pHash)).Ffirst for { if !(k1 != 0) { break } pTab2 = (*THashElem)(unsafe.Pointer(k1)).Fdata if zRight != 0 && Xsqlite3_stricmp(tls, zRight, (*TTable)(unsafe.Pointer(pTab2)).FzName) != 0 { goto _20 } if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab2)).FeTabType) == int32(TABTYP_VIEW) { zType = __ccgo_ts + 11143 } else { if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab2)).FeTabType) == int32(TABTYP_VTAB) { zType = __ccgo_ts + 14328 } else { if (*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_Shadow) != 0 { zType = __ccgo_ts + 19366 } else { zType = __ccgo_ts + 9405 } } } _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19373, libc.VaList(bp+176, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii4)*32))).FzDbSName, _sqlite3PreferredTableName(tls, (*TTable)(unsafe.Pointer(pTab2)).FzName), zType, int32((*TTable)(unsafe.Pointer(pTab2)).FnCol), libc.BoolInt32((*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_WithoutRowid) != uint32(0)), libc.BoolInt32((*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_Strict) != uint32(0)))) goto _20 _20: ; k1 = (*THashElem)(unsafe.Pointer(k1)).Fnext } goto _17 _17: ; ii4 = ii4 + 1 } case int32(PragTyp_INDEX_INFO): if zRight != 0 { pIdx = _sqlite3FindIndex(tls, db, zRight, zDb) if pIdx == uintptr(0) { /* If there is no index named zRight, check to see if there is a ** WITHOUT ROWID table named zRight, and if there is, show the ** structure of the PRIMARY KEY index for that table. */ pTab3 = _sqlite3LocateTable(tls, pParse, uint32(LOCATE_NOERR), zRight, zDb) if pTab3 != 0 && !((*TTable)(unsafe.Pointer(pTab3)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { pIdx = _sqlite3PrimaryKeyIndex(tls, pTab3) } } if pIdx != 0 { iIdxDb = _sqlite3SchemaToIndex(tls, db, (*TIndex)(unsafe.Pointer(pIdx)).FpSchema) if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != 0 { /* PRAGMA index_xinfo (newer version with more rows and columns) */ mx = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnColumn) (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(6) } else { /* PRAGMA index_info (legacy version) */ mx = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol) (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(3) } pTab3 = (*TIndex)(unsafe.Pointer(pIdx)).FpTable _sqlite3CodeVerifySchema(tls, pParse, iIdxDb) i1 = 0 for { if !(i1 < mx) { break } cnum = **(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaiColumn + uintptr(i1)*2)) if int32(cnum) < 0 { v1 = uintptr(0) } else { v1 = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab3)).FaCol + uintptr(cnum)*16))).FzCnName } _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19380, libc.VaList(bp+176, i1, int32(cnum), v1)) if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != 0 { _sqlite3VdbeMultiLoad(tls, v, int32(4), __ccgo_ts+19385, libc.VaList(bp+176, libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FaSortOrder + uintptr(i1)))), **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx)).FazColl + uintptr(i1)*8)), libc.BoolInt32(i1 < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx)).FnKeyCol)))) } _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), (*TParse)(unsafe.Pointer(pParse)).FnMem) goto _21 _21: ; i1 = i1 + 1 } } } case int32(PragTyp_INDEX_LIST): if zRight != 0 { pTab4 = _sqlite3FindTable(tls, db, zRight, zDb) if pTab4 != 0 { iTabDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab4)).FpSchema) (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(5) _sqlite3CodeVerifySchema(tls, pParse, iTabDb) pIdx1 = (*TTable)(unsafe.Pointer(pTab4)).FpIndex i2 = libc.Int32FromInt32(0) for { if !(pIdx1 != 0) { break } azOrigin = [3]uintptr{ 0: __ccgo_ts + 19390, 1: __ccgo_ts + 19392, 2: __ccgo_ts + 17879, } _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19394, libc.VaList(bp+176, i2, (*TIndex)(unsafe.Pointer(pIdx1)).FzName, libc.BoolInt32(libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx1)).FonError) != OE_None), azOrigin[int32(uint32(*(*uint16)(unsafe.Pointer(pIdx1 + 100))&0x3>>0))], libc.BoolInt32((*TIndex)(unsafe.Pointer(pIdx1)).FpPartIdxWhere != uintptr(0)))) goto _23 _23: ; pIdx1 = (*TIndex)(unsafe.Pointer(pIdx1)).FpNext i2 = i2 + 1 } } } case int32(PragTyp_DATABASE_LIST): (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(3) i3 = 0 for { if !(i3 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { break } if (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i3)*32))).FpBt == uintptr(0) { goto _24 } _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19400, libc.VaList(bp+176, i3, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i3)*32))).FzDbSName, _sqlite3BtreeGetFilename(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i3)*32))).FpBt))) goto _24 _24: ; i3 = i3 + 1 } case int32(PragTyp_COLLATION_LIST): i4 = 0 (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(2) p = (*THash)(unsafe.Pointer(db + 648)).Ffirst for { if !(p != 0) { break } pColl = (*THashElem)(unsafe.Pointer(p)).Fdata v2 = i4 i4 = i4 + 1 _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19404, libc.VaList(bp+176, v2, (*TCollSeq)(unsafe.Pointer(pColl)).FzName)) goto _25 _25: ; p = (*THashElem)(unsafe.Pointer(p)).Fnext } case int32(PragTyp_FUNCTION_LIST): showInternFunc = libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_InternalFunc) != uint32(0)) (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(6) i5 = 0 for { if !(i5 < int32(SQLITE_FUNC_HASH_SZ)) { break } p1 = **(**uintptr)(__ccgo_up(uintptr(unsafe.Pointer(&_sqlite3BuiltinFunctions)) + uintptr(i5)*8)) for { if !(p1 != 0) { break } _pragmaFunclistLine(tls, v, p1, int32(1), showInternFunc) goto _28 _28: ; p1 = *(*uintptr)(unsafe.Pointer(p1 + 64)) } goto _27 _27: ; i5 = i5 + 1 } j = (*THash)(unsafe.Pointer(db + 624)).Ffirst for { if !(j != 0) { break } p1 = (*THashElem)(unsafe.Pointer(j)).Fdata _pragmaFunclistLine(tls, v, p1, 0, showInternFunc) goto _29 _29: ; j = (*THashElem)(unsafe.Pointer(j)).Fnext } case int32(PragTyp_MODULE_LIST): (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(1) j1 = (*THash)(unsafe.Pointer(db + 576)).Ffirst for { if !(j1 != 0) { break } pMod = (*THashElem)(unsafe.Pointer(j1)).Fdata _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+7937, libc.VaList(bp+176, (*TModule)(unsafe.Pointer(pMod)).FzName)) goto _30 _30: ; j1 = (*THashElem)(unsafe.Pointer(j1)).Fnext } case int32(PragTyp_PRAGMA_LIST): i6 = 0 for { if !(i6 < libc.Int32FromUint64(libc.Uint64FromInt64(1584)/libc.Uint64FromInt64(24))) { break } _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+7937, libc.VaList(bp+176, _aPragmaName[i6].FzName)) goto _31 _31: ; i6 = i6 + 1 } case int32(PragTyp_FOREIGN_KEY_LIST): if zRight != 0 { pTab5 = _sqlite3FindTable(tls, db, zRight, zDb) if pTab5 != 0 && libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab5)).FeTabType) == TABTYP_NORM { pFK = (*(*struct { FaddColOffset int32 FpFKey uintptr FpDfltList uintptr })(unsafe.Pointer(pTab5 + 64))).FpFKey if pFK != 0 { iTabDb1 = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab5)).FpSchema) i7 = 0 (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(8) _sqlite3CodeVerifySchema(tls, pParse, iTabDb1) for pFK != 0 { j2 = 0 for { if !(j2 < (*TFKey)(unsafe.Pointer(pFK)).FnCol) { break } _sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19407, libc.VaList(bp+176, i7, j2, (*TFKey)(unsafe.Pointer(pFK)).FzTo, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab5)).FaCol + uintptr((*(*TsColMap)(unsafe.Pointer(pFK + 64 + uintptr(j2)*16))).FiFrom)*16))).FzCnName, (*(*TsColMap)(unsafe.Pointer(pFK + 64 + uintptr(j2)*16))).FzCol, _actionName(tls, **(**Tu8)(__ccgo_up(pFK + 45 + 1))), _actionName(tls, **(**Tu8)(__ccgo_up(pFK + 45))), __ccgo_ts+19416)) goto _32 _32: ; j2 = j2 + 1 } i7 = i7 + 1 pFK = (*TFKey)(unsafe.Pointer(pFK)).FpNextFrom } } } } case int32(PragTyp_FOREIGN_KEY_CHECK): /* child to parent column mapping */ regResult = (*TParse)(unsafe.Pointer(pParse)).FnMem + int32(1) **(**int32)(__ccgo_up(pParse + 60)) += int32(4) v1 = pParse + 60 *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 v2 = *(*int32)(unsafe.Pointer(v1)) regRow = v2 k2 = (*THash)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema + 8)).Ffirst for k2 != 0 { if zRight != 0 { pTab6 = _sqlite3LocateTable(tls, pParse, uint32(0), zRight, zDb) k2 = uintptr(0) } else { pTab6 = (*THashElem)(unsafe.Pointer(k2)).Fdata k2 = (*THashElem)(unsafe.Pointer(k2)).Fnext } if pTab6 == uintptr(0) || !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab6)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) || (*(*struct { FaddColOffset int32 FpFKey uintptr FpDfltList uintptr })(unsafe.Pointer(pTab6 + 64))).FpFKey == uintptr(0) { continue } iDb = _sqlite3SchemaToIndex(tls, db, (*TTable)(unsafe.Pointer(pTab6)).FpSchema) zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName _sqlite3CodeVerifySchema(tls, pParse, iDb) _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pTab6)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pTab6)).FzName) _sqlite3TouchRegister(tls, pParse, int32((*TTable)(unsafe.Pointer(pTab6)).FnCol)+regRow) _sqlite3OpenTable(tls, pParse, 0, iDb, pTab6, int32(OP_OpenRead)) _sqlite3VdbeLoadString(tls, v, regResult, (*TTable)(unsafe.Pointer(pTab6)).FzName) i8 = int32(1) pFK1 = (*(*struct { FaddColOffset int32 FpFKey uintptr FpDfltList uintptr })(unsafe.Pointer(pTab6 + 64))).FpFKey for { if !(pFK1 != 0) { break } pParent = _sqlite3FindTable(tls, db, (*TFKey)(unsafe.Pointer(pFK1)).FzTo, zDb) if pParent == uintptr(0) { goto _35 } **(**uintptr)(__ccgo_up(bp + 88)) = uintptr(0) _sqlite3TableLock(tls, pParse, iDb, (*TTable)(unsafe.Pointer(pParent)).Ftnum, uint8(0), (*TTable)(unsafe.Pointer(pParent)).FzName) x1 = _sqlite3FkLocateIndex(tls, pParse, pParent, pFK1, bp+88, uintptr(0)) if x1 == 0 { if **(**uintptr)(__ccgo_up(bp + 88)) == uintptr(0) { _sqlite3OpenTable(tls, pParse, i8, iDb, pParent, int32(OP_OpenRead)) } else { _sqlite3VdbeAddOp3(tls, v, int32(OP_OpenRead), i8, libc.Int32FromUint32((*TIndex)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp + 88)))).Ftnum), iDb) _sqlite3VdbeSetP4KeyInfo(tls, pParse, **(**uintptr)(__ccgo_up(bp + 88))) } } else { k2 = uintptr(0) break } goto _35 _35: ; i8 = i8 + 1 pFK1 = (*TFKey)(unsafe.Pointer(pFK1)).FpNextFrom } if pFK1 != 0 { break } if (*TParse)(unsafe.Pointer(pParse)).FnTab < i8 { (*TParse)(unsafe.Pointer(pParse)).FnTab = i8 } addrTop = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), 0) i8 = int32(1) pFK1 = (*(*struct { FaddColOffset int32 FpFKey uintptr FpDfltList uintptr })(unsafe.Pointer(pTab6 + 64))).FpFKey for { if !(pFK1 != 0) { break } pParent = _sqlite3FindTable(tls, db, (*TFKey)(unsafe.Pointer(pFK1)).FzTo, zDb) **(**uintptr)(__ccgo_up(bp + 88)) = uintptr(0) **(**uintptr)(__ccgo_up(bp + 96)) = uintptr(0) if pParent != 0 { x1 = _sqlite3FkLocateIndex(tls, pParse, pParent, pFK1, bp+88, bp+96) } addrOk = _sqlite3VdbeMakeLabel(tls, pParse) /* Generate code to read the child key values into registers ** regRow..regRow+n. If any of the child key values are NULL, this ** row cannot cause an FK violation. Jump directly to addrOk in ** this case. */ _sqlite3TouchRegister(tls, pParse, regRow+(*TFKey)(unsafe.Pointer(pFK1)).FnCol) j3 = 0 for { if !(j3 < (*TFKey)(unsafe.Pointer(pFK1)).FnCol) { break } if **(**uintptr)(__ccgo_up(bp + 96)) != 0 { v2 = **(**int32)(__ccgo_up(**(**uintptr)(__ccgo_up(bp + 96)) + uintptr(j3)*4)) } else { v2 = (*(*TsColMap)(unsafe.Pointer(pFK1 + 64 + uintptr(j3)*16))).FiFrom } iCol = v2 _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab6, 0, iCol, regRow+j3) _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), regRow+j3, addrOk) goto _37 _37: ; j3 = j3 + 1 } /* Generate code to query the parent index for a matching parent ** key. If a match is found, jump to addrOk. */ if **(**uintptr)(__ccgo_up(bp + 88)) != 0 { _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), regRow, (*TFKey)(unsafe.Pointer(pFK1)).FnCol, 0, _sqlite3IndexAffinityStr(tls, db, **(**uintptr)(__ccgo_up(bp + 88))), (*TFKey)(unsafe.Pointer(pFK1)).FnCol) _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), i8, addrOk, regRow, (*TFKey)(unsafe.Pointer(pFK1)).FnCol) } else { if pParent != 0 { jmp = _sqlite3VdbeCurrentAddr(tls, v) + int32(2) _sqlite3VdbeAddOp3(tls, v, int32(OP_SeekRowid), i8, jmp, regRow) _sqlite3VdbeGoto(tls, v, addrOk) } } /* Generate code to report an FK violation to the caller. */ if (*TTable)(unsafe.Pointer(pTab6)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { _sqlite3VdbeAddOp2(tls, v, int32(OP_Rowid), 0, regResult+int32(1)) } else { _sqlite3VdbeAddOp2(tls, v, int32(OP_Null), 0, regResult+int32(1)) } _sqlite3VdbeMultiLoad(tls, v, regResult+int32(2), __ccgo_ts+19421, libc.VaList(bp+176, (*TFKey)(unsafe.Pointer(pFK1)).FzTo, i8-int32(1))) _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), regResult, int32(4)) _sqlite3VdbeResolveLabel(tls, v, addrOk) _sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp + 96))) goto _36 _36: ; i8 = i8 + 1 pFK1 = (*TFKey)(unsafe.Pointer(pFK1)).FpNextFrom } _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), 0, addrTop+int32(1)) _sqlite3VdbeJumpHere(tls, v, addrTop) } break /* Reinstall the LIKE and GLOB functions. The variant of LIKE ** used will be case sensitive or not depending on the RHS. */ fallthrough case int32(PragTyp_CASE_SENSITIVE_LIKE): if zRight != 0 { _sqlite3RegisterLikeFunctions(tls, db, libc.Int32FromUint8(_sqlite3GetBoolean(tls, zRight, uint8(0)))) } break /* PRAGMA integrity_check ** PRAGMA integrity_check(N) ** PRAGMA quick_check ** PRAGMA quick_check(N) ** ** Verify the integrity of the database. ** ** The "quick_check" is reduced version of ** integrity_check designed to detect most database corruption ** without the overhead of cross-checking indexes. Quick_check ** is linear time whereas integrity_check is O(NlogN). ** ** The maximum number of errors is 100 by default. A different default ** can be specified using a numeric parameter N. ** ** Or, the parameter N can be the name of a table. In that case, only ** the one table named is verified. The freelist is only verified if ** the named table is "sqlite_schema" (or one of its aliases). ** ** All schemas are checked by default. To check just a single ** schema, use the form: ** ** PRAGMA schema.integrity_check; */ fallthrough case int32(PragTyp_INTEGRITY_CHECK): pObjTab = uintptr(0) /* Check only this one table, if not NULL */ isQuick = libc.BoolInt32(libc.Int32FromUint8(_sqlite3UpperToLower[uint8(**(**uint8)(__ccgo_up(zLeft)))]) == int32('q')) /* If the PRAGMA command was of the form "PRAGMA .integrity_check", ** then iDb is set to the index of the database identified by . ** In this case, the integrity of database iDb only is verified by ** the VDBE created below. ** ** Otherwise, if the command was simply "PRAGMA integrity_check" (or ** "PRAGMA quick_check"), then iDb is set to 0. In this case, set iDb ** to -1 here, to indicate that the VDBE should verify the integrity ** of all attached databases. */ if (*TToken)(unsafe.Pointer(pId2)).Fz == uintptr(0) { iDb = -int32(1) } /* Initialize the VDBE program */ (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(6) /* Set the maximum error count */ **(**int32)(__ccgo_up(bp + 104)) = int32(SQLITE_INTEGRITY_CHECK_ERROR_MAX) if zRight != 0 { if _sqlite3GetInt32(tls, (*TToken)(unsafe.Pointer(pValue)).Fz, bp+104) != 0 { if **(**int32)(__ccgo_up(bp + 104)) <= 0 { **(**int32)(__ccgo_up(bp + 104)) = int32(SQLITE_INTEGRITY_CHECK_ERROR_MAX) } } else { if iDb >= 0 { v1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName } else { v1 = uintptr(0) } pObjTab = _sqlite3LocateTable(tls, pParse, uint32(0), zRight, v1) } } _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), **(**int32)(__ccgo_up(bp + 104))-int32(1), int32(1)) /* reg[1] holds errors left */ /* Do an integrity check on each database file */ i9 = 0 for { if !(i9 < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { break } /* Array of root page numbers of all btrees */ cnt = 0 /* Number of entries in aRoot[] */ if libc.Bool(OMIT_TEMPDB != 0) && i9 == int32(1) { goto _40 } if iDb >= 0 && i9 != iDb { goto _40 } _sqlite3CodeVerifySchema(tls, pParse, i9) libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(0), 7, 0x80) /* tag-20230327-1 */ /* Do an integrity check of the B-Tree ** ** Begin by finding the root pages numbers ** for all tables and indices in the database. */ pTbls = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i9)*32))).FpSchema + 8 cnt = 0 x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst for { if !(x2 != 0) { break } pTab7 = (*THashElem)(unsafe.Pointer(x2)).Fdata /* Number of indexes on pTab */ if _tableSkipIntegrityCheck(tls, pTab7, pObjTab) != 0 { goto _41 } if (*TTable)(unsafe.Pointer(pTab7)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { cnt = cnt + 1 } nIdx = 0 pIdx3 = (*TTable)(unsafe.Pointer(pTab7)).FpIndex for { if !(pIdx3 != 0) { break } cnt = cnt + 1 goto _42 _42: ; pIdx3 = (*TIndex)(unsafe.Pointer(pIdx3)).FpNext nIdx = nIdx + 1 } goto _41 _41: ; x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext } if cnt == 0 { goto _40 } if pObjTab != 0 { cnt = cnt + 1 } aRoot = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(4)*libc.Uint64FromInt32(cnt+libc.Int32FromInt32(1)))) if aRoot == uintptr(0) { break } cnt = 0 if pObjTab != 0 { cnt = cnt + 1 v2 = cnt **(**int32)(__ccgo_up(aRoot + uintptr(v2)*4)) = 0 } x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst for { if !(x2 != 0) { break } pTab8 = (*THashElem)(unsafe.Pointer(x2)).Fdata if _tableSkipIntegrityCheck(tls, pTab8, pObjTab) != 0 { goto _44 } if (*TTable)(unsafe.Pointer(pTab8)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { cnt = cnt + 1 v2 = cnt **(**int32)(__ccgo_up(aRoot + uintptr(v2)*4)) = libc.Int32FromUint32((*TTable)(unsafe.Pointer(pTab8)).Ftnum) } pIdx4 = (*TTable)(unsafe.Pointer(pTab8)).FpIndex for { if !(pIdx4 != 0) { break } cnt = cnt + 1 v2 = cnt **(**int32)(__ccgo_up(aRoot + uintptr(v2)*4)) = libc.Int32FromUint32((*TIndex)(unsafe.Pointer(pIdx4)).Ftnum) goto _46 _46: ; pIdx4 = (*TIndex)(unsafe.Pointer(pIdx4)).FpNext } goto _44 _44: ; x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext } **(**int32)(__ccgo_up(aRoot)) = cnt /* Make sure sufficient number of registers have been allocated */ _sqlite3TouchRegister(tls, pParse, int32(8)+cnt) _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), 0, int32(8), int32(8)+cnt) _sqlite3ClearTempRegCache(tls, pParse) /* Do the b-tree integrity checks */ _sqlite3VdbeAddOp4(tls, v, int32(OP_IntegrityCk), int32(1), cnt, int32(8), aRoot, -int32(15)) _sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(i9)) addr1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), int32(2)) _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, _sqlite3MPrintf(tls, db, __ccgo_ts+19425, libc.VaList(bp+176, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i9)*32))).FzDbSName)), -int32(7)) _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(2), int32(3), int32(3)) _integrityCheckResultRow(tls, v) _sqlite3VdbeJumpHere(tls, v, addr1) /* Check that the indexes all have the right number of rows */ if pObjTab != 0 { v2 = int32(1) } else { v2 = 0 } cnt = v2 _sqlite3VdbeLoadString(tls, v, int32(2), __ccgo_ts+19449) x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst for { if !(x2 != 0) { break } iTab = 0 pTab9 = (*THashElem)(unsafe.Pointer(x2)).Fdata if _tableSkipIntegrityCheck(tls, pTab9, pObjTab) != 0 { goto _49 } if (*TTable)(unsafe.Pointer(pTab9)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { v2 = cnt cnt = cnt + 1 iTab = v2 } else { iTab = cnt pIdx5 = (*TTable)(unsafe.Pointer(pTab9)).FpIndex for { if !(pIdx5 != 0) { break } if int32(uint32(*(*uint16)(unsafe.Pointer(pIdx5 + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { break } iTab = iTab + 1 goto _51 _51: ; pIdx5 = (*TIndex)(unsafe.Pointer(pIdx5)).FpNext } } pIdx5 = (*TTable)(unsafe.Pointer(pTab9)).FpIndex for { if !(pIdx5 != 0) { break } if (*TIndex)(unsafe.Pointer(pIdx5)).FpPartIdxWhere == uintptr(0) { addr1 = _sqlite3VdbeAddOp3(tls, v, int32(OP_Eq), int32(8)+cnt, 0, int32(8)+iTab) _sqlite3VdbeLoadString(tls, v, int32(4), (*TIndex)(unsafe.Pointer(pIdx5)).FzName) _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(4), int32(2), int32(3)) _integrityCheckResultRow(tls, v) _sqlite3VdbeJumpHere(tls, v, addr1) } cnt = cnt + 1 goto _52 _52: ; pIdx5 = (*TIndex)(unsafe.Pointer(pIdx5)).FpNext } goto _49 _49: ; x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext } /* Make sure all the indices are constructed correctly. */ x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst for { if !(x2 != 0) { break } pTab10 = (*THashElem)(unsafe.Pointer(x2)).Fdata pPrior = uintptr(0) r1 = -int32(1) /* Maximum non-virtual column number */ if _tableSkipIntegrityCheck(tls, pTab10, pObjTab) != 0 { goto _53 } if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab10)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { goto _53 } if isQuick != 0 || (*TTable)(unsafe.Pointer(pTab10)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { pPk1 = uintptr(0) r2 = 0 } else { pPk1 = _sqlite3PrimaryKeyIndex(tls, pTab10) r2 = _sqlite3GetTempRange(tls, pParse, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) _sqlite3VdbeAddOp3(tls, v, int32(OP_Null), int32(1), r2, r2+libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)-int32(1)) } _sqlite3OpenTableAndIndices(tls, pParse, pTab10, int32(OP_OpenRead), uint8(0), int32(1), uintptr(0), bp+108, bp+112) /* reg[7] counts the number of entries in the table. ** reg[8+i] counts the number of entries in the i-th index */ _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, int32(7)) j4 = 0 pIdx6 = (*TTable)(unsafe.Pointer(pTab10)).FpIndex for { if !(pIdx6 != 0) { break } _sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, int32(8)+j4) /* index entries counter */ goto _54 _54: ; pIdx6 = (*TIndex)(unsafe.Pointer(pIdx6)).FpNext j4 = j4 + 1 } _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), **(**int32)(__ccgo_up(bp + 108)), 0) loopTop = _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), int32(7), int32(1)) /* Fetch the right-most column from the table. This will cause ** the entire record header to be parsed and sanity checked. It ** will also prepopulate the cursor column cache that is used ** by the OP_IsType code, so it is a required step. */ if (*TTable)(unsafe.Pointer(pTab10)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { mxCol = -int32(1) j4 = 0 for { if !(j4 < int32((*TTable)(unsafe.Pointer(pTab10)).FnCol)) { break } if libc.Int32FromUint16((**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) == 0 { mxCol = mxCol + 1 } goto _55 _55: ; j4 = j4 + 1 } if mxCol == int32((*TTable)(unsafe.Pointer(pTab10)).FiPKey) { mxCol = mxCol - 1 } } else { /* COLFLAG_VIRTUAL columns are not included in the WITHOUT ROWID ** PK index column-count, so there is no need to account for them ** in this case. */ mxCol = libc.Int32FromUint16((*TIndex)(unsafe.Pointer(_sqlite3PrimaryKeyIndex(tls, pTab10))).FnColumn) - int32(1) } if mxCol >= 0 { _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), **(**int32)(__ccgo_up(bp + 108)), mxCol, int32(3)) _sqlite3VdbeTypeofColumn(tls, v, int32(3)) } if !(isQuick != 0) { if pPk1 != 0 { a1 = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxGT), **(**int32)(__ccgo_up(bp + 108)), 0, r2, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), r2) zErr = _sqlite3MPrintf(tls, db, __ccgo_ts+19478, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab10)).FzName)) _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr, -int32(7)) _integrityCheckResultRow(tls, v) _sqlite3VdbeJumpHere(tls, v, a1) _sqlite3VdbeJumpHere(tls, v, a1+int32(1)) j4 = 0 for { if !(j4 < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) { break } _sqlite3ExprCodeLoadIndexColumn(tls, pParse, pPk1, **(**int32)(__ccgo_up(bp + 108)), j4, r2+j4) goto _56 _56: ; j4 = j4 + 1 } } } /* Verify datatypes for all columns: ** ** (1) NOT NULL columns may not contain a NULL ** (2) Datatype must be exact for non-ANY columns in STRICT tables ** (3) Datatype for TEXT columns in non-STRICT tables must be ** NULL, TEXT, or BLOB. ** (4) Datatype for numeric columns in non-STRICT tables must not ** be a TEXT value that can be losslessly converted to numeric. */ bStrict = libc.BoolInt32((*TTable)(unsafe.Pointer(pTab10)).FtabFlags&uint32(TF_Strict) != uint32(0)) j4 = 0 for { if !(j4 < int32((*TTable)(unsafe.Pointer(pTab10)).FnCol)) { break } pCol1 = (*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16 /* Check datatypes (besides NOT NULL) */ if j4 == int32((*TTable)(unsafe.Pointer(pTab10)).FiPKey) { goto _57 } if bStrict != 0 { doTypeCheck = libc.BoolInt32(int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf0>>4)) > int32(COLTYPE_ANY)) } else { doTypeCheck = libc.BoolInt32(libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol1)).Faffinity) > int32(SQLITE_AFF_BLOB)) } if int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf>>0)) == 0 && !(doTypeCheck != 0) { goto _57 } /* Compute the operands that will be needed for OP_IsType */ p4 = int32(SQLITE_NULL) if libc.Int32FromUint16((*TColumn)(unsafe.Pointer(pCol1)).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab10, **(**int32)(__ccgo_up(bp + 108)), j4, int32(3)) p11 = -int32(1) p3 = int32(3) } else { if (*TColumn)(unsafe.Pointer(pCol1)).FiDflt != 0 { **(**uintptr)(__ccgo_up(bp + 120)) = uintptr(0) _sqlite3ValueFromExpr(tls, db, _sqlite3ColumnExpr(tls, pTab10, pCol1), (*Tsqlite3)(unsafe.Pointer(db)).Fenc, (*TColumn)(unsafe.Pointer(pCol1)).Faffinity, bp+120) if **(**uintptr)(__ccgo_up(bp + 120)) != 0 { p4 = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(bp + 120))) _sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp + 120))) } } p11 = **(**int32)(__ccgo_up(bp + 108)) if !((*TTable)(unsafe.Pointer(pTab10)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) { p3 = _sqlite3TableColumnToIndex(tls, _sqlite3PrimaryKeyIndex(tls, pTab10), j4) } else { p3 = int32(_sqlite3TableColumnToStorage(tls, pTab10, int16(j4))) } } labelError = _sqlite3VdbeMakeLabel(tls, pParse) labelOk = _sqlite3VdbeMakeLabel(tls, pParse) if int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf>>0)) != 0 { jmp2 = _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), p11, labelOk, p3, p4) if p11 < 0 { _sqlite3VdbeChangeP5(tls, v, uint16(0x0f)) /* INT, REAL, TEXT, or BLOB */ jmp3 = jmp2 } else { _sqlite3VdbeChangeP5(tls, v, uint16(0x0d)) /* INT, TEXT, or BLOB */ /* OP_IsType does not detect NaN values in the database file ** which should be treated as a NULL. So if the header type ** is REAL, we have to load the actual data using OP_Column ** to reliably determine if the value is a NULL. */ _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), p11, p3, int32(3)) _sqlite3ColumnDefault(tls, v, pTab10, j4, int32(3)) jmp3 = _sqlite3VdbeAddOp2(tls, v, int32(OP_NotNull), int32(3), labelOk) } zErr1 = _sqlite3MPrintf(tls, db, __ccgo_ts+19514, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab10)).FzName, (*TColumn)(unsafe.Pointer(pCol1)).FzCnName)) _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr1, -int32(7)) if doTypeCheck != 0 { _sqlite3VdbeGoto(tls, v, labelError) _sqlite3VdbeJumpHere(tls, v, jmp2) _sqlite3VdbeJumpHere(tls, v, jmp3) } else { /* VDBE byte code will fall thru */ } } if bStrict != 0 && doTypeCheck != 0 { _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), p11, labelOk, p3, p4) _sqlite3VdbeChangeP5(tls, v, uint16(_aStdTypeMask[int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf0>>4))-int32(1)])) zErr1 = _sqlite3MPrintf(tls, db, __ccgo_ts+19534, libc.VaList(bp+176, _sqlite3StdType[int32(uint32(*(*uint8)(unsafe.Pointer(pCol1 + 8))&0xf0>>4))-int32(1)], (*TTable)(unsafe.Pointer(pTab10)).FzName, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16))).FzCnName)) _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr1, -int32(7)) } else { if !(bStrict != 0) && libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol1)).Faffinity) == int32(SQLITE_AFF_TEXT) { /* (3) Datatype for TEXT columns in non-STRICT tables must be ** NULL, TEXT, or BLOB. */ _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), p11, labelOk, p3, p4) _sqlite3VdbeChangeP5(tls, v, uint16(0x1c)) /* NULL, TEXT, or BLOB */ zErr1 = _sqlite3MPrintf(tls, db, __ccgo_ts+19556, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab10)).FzName, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16))).FzCnName)) _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr1, -int32(7)) } else { if !(bStrict != 0) && libc.Int32FromUint8((*TColumn)(unsafe.Pointer(pCol1)).Faffinity) >= int32(SQLITE_AFF_NUMERIC) { /* (4) Datatype for numeric columns in non-STRICT tables must not ** be a TEXT value that can be converted to numeric. */ _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), p11, labelOk, p3, p4) _sqlite3VdbeChangeP5(tls, v, uint16(0x1b)) /* NULL, INT, FLOAT, or BLOB */ if p11 >= 0 { _sqlite3ExprCodeGetColumnOfTable(tls, v, pTab10, **(**int32)(__ccgo_up(bp + 108)), j4, int32(3)) } _sqlite3VdbeAddOp4(tls, v, int32(OP_Affinity), int32(3), int32(1), 0, __ccgo_ts+19579, -int32(1)) _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IsType), -int32(1), labelOk, int32(3), p4) _sqlite3VdbeChangeP5(tls, v, uint16(0x1c)) /* NULL, TEXT, or BLOB */ zErr1 = _sqlite3MPrintf(tls, db, __ccgo_ts+19581, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab10)).FzName, (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(j4)*16))).FzCnName)) _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr1, -int32(7)) } } } _sqlite3VdbeResolveLabel(tls, v, labelError) _integrityCheckResultRow(tls, v) _sqlite3VdbeResolveLabel(tls, v, labelOk) goto _57 _57: ; j4 = j4 + 1 } /* Verify CHECK constraints */ if (*TTable)(unsafe.Pointer(pTab10)).FpCheck != 0 && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_IgnoreChecks) == uint64(0) { pCheck = _sqlite3ExprListDup(tls, db, (*TTable)(unsafe.Pointer(pTab10)).FpCheck, 0) if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed) == 0 { addrCkFault = _sqlite3VdbeMakeLabel(tls, pParse) addrCkOk = _sqlite3VdbeMakeLabel(tls, pParse) (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = **(**int32)(__ccgo_up(bp + 108)) + int32(1) k3 = (*TExprList)(unsafe.Pointer(pCheck)).FnExpr - int32(1) for { if !(k3 > 0) { break } _sqlite3ExprIfFalse(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pCheck + 8 + uintptr(k3)*32))).FpExpr, addrCkFault, 0) goto _58 _58: ; k3 = k3 - 1 } _sqlite3ExprIfTrue(tls, pParse, (*(*TExprList_item)(unsafe.Pointer(pCheck + 8))).FpExpr, addrCkOk, int32(SQLITE_JUMPIFNULL)) _sqlite3VdbeResolveLabel(tls, v, addrCkFault) (*TParse)(unsafe.Pointer(pParse)).FiSelfTab = 0 zErr2 = _sqlite3MPrintf(tls, db, __ccgo_ts+19601, libc.VaList(bp+176, (*TTable)(unsafe.Pointer(pTab10)).FzName)) _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, zErr2, -int32(7)) _integrityCheckResultRow(tls, v) _sqlite3VdbeResolveLabel(tls, v, addrCkOk) } _sqlite3ExprListDelete(tls, db, pCheck) } if !(isQuick != 0) { /* Omit the remaining tests for quick_check */ /* Validate index entries for the current row */ j4 = 0 pIdx6 = (*TTable)(unsafe.Pointer(pTab10)).FpIndex for { if !(pIdx6 != 0) { break } ckUniq = _sqlite3VdbeMakeLabel(tls, pParse) if pPk1 == pIdx6 { goto _59 } r1 = _sqlite3GenerateIndexKey(tls, pParse, pIdx6, **(**int32)(__ccgo_up(bp + 108)), 0, 0, bp+128, pPrior, r1) pPrior = pIdx6 _sqlite3VdbeAddOp2(tls, v, int32(OP_AddImm), int32(8)+j4, int32(1)) /* increment entry count */ /* Verify that an index entry exists for the current table row */ _sqlite3VdbeAddOp4Int(tls, v, int32(OP_Found), **(**int32)(__ccgo_up(bp + 112))+j4, ckUniq, r1, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnColumn)) jmp21 = _sqlite3VdbeAddOp3(tls, v, int32(OP_IFindKey), **(**int32)(__ccgo_up(bp + 112))+j4, ckUniq, r1) _sqlite3VdbeChangeP4(tls, v, -int32(1), pIdx6, -int32(6)) _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, int32(3), 0, _sqlite3MPrintf(tls, db, __ccgo_ts+19631, libc.VaList(bp+176, (*TIndex)(unsafe.Pointer(pIdx6)).FzName)), -int32(7)) _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3)) _integrityCheckResultRow(tls, v) _sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, ckUniq) _sqlite3VdbeJumpHere(tls, v, jmp21) _sqlite3VdbeLoadString(tls, v, int32(3), __ccgo_ts+19690) _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3)) _sqlite3VdbeLoadString(tls, v, int32(4), __ccgo_ts+19695) _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(4), int32(3), int32(3)) jmp5 = _sqlite3VdbeLoadString(tls, v, int32(4), (*TIndex)(unsafe.Pointer(pIdx6)).FzName) _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(4), int32(3), int32(3)) jmp4 = _integrityCheckResultRow(tls, v) _sqlite3VdbeResolveLabel(tls, v, ckUniq) /* The OP_IdxRowid opcode is an optimized version of OP_Column ** that extracts the rowid off the end of the index record. ** But it only works correctly if index record does not have ** any extra bytes at the end. Verify that this is the case. */ if (*TTable)(unsafe.Pointer(pTab10)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { _sqlite3VdbeAddOp2(tls, v, int32(OP_IdxRowid), **(**int32)(__ccgo_up(bp + 112))+j4, int32(3)) jmp7 = _sqlite3VdbeAddOp3(tls, v, int32(OP_Eq), int32(3), 0, r1+libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnColumn)-int32(1)) _sqlite3VdbeLoadString(tls, v, int32(3), __ccgo_ts+19716) _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3)) _sqlite3VdbeLoadString(tls, v, int32(4), __ccgo_ts+19752) _sqlite3VdbeGoto(tls, v, jmp5-int32(1)) _sqlite3VdbeJumpHere(tls, v, jmp7) } /* Any indexed columns with non-BINARY collations must still hold ** the exact same text value as the table. */ label6 = 0 kk = 0 for { if !(kk < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnKeyCol)) { break } if **(**uintptr)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx6)).FazColl + uintptr(kk)*8)) == uintptr(unsafe.Pointer(&_sqlite3StrBINARY)) { goto _60 } if label6 == 0 { label6 = _sqlite3VdbeMakeLabel(tls, pParse) } _sqlite3VdbeAddOp3(tls, v, int32(OP_Column), **(**int32)(__ccgo_up(bp + 112))+j4, kk, int32(3)) _sqlite3VdbeAddOp3(tls, v, int32(OP_Ne), int32(3), label6, r1+kk) goto _60 _60: ; kk = kk + 1 } if label6 != 0 { jmp6 = _sqlite3VdbeAddOp0(tls, v, int32(OP_Goto)) _sqlite3VdbeResolveLabel(tls, v, label6) _sqlite3VdbeLoadString(tls, v, int32(3), __ccgo_ts+19690) _sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3)) _sqlite3VdbeLoadString(tls, v, int32(4), __ccgo_ts+19763) _sqlite3VdbeGoto(tls, v, jmp5-int32(1)) _sqlite3VdbeJumpHere(tls, v, jmp6) } /* For UNIQUE indexes, verify that only one entry exists with the ** current key. The entry is unique if (1) any column is NULL ** or (2) the next entry has a different key */ if libc.Int32FromUint8((*TIndex)(unsafe.Pointer(pIdx6)).FonError) != OE_None { uniqOk = _sqlite3VdbeMakeLabel(tls, pParse) kk = 0 for { if !(kk < libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnKeyCol)) { break } iCol1 = int32(**(**Ti16)(__ccgo_up((*TIndex)(unsafe.Pointer(pIdx6)).FaiColumn + uintptr(kk)*2))) if iCol1 >= 0 && int32(uint32(*(*uint8)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab10)).FaCol + uintptr(iCol1)*16 + 8))&0xf>>0)) != 0 { goto _61 } _sqlite3VdbeAddOp2(tls, v, int32(OP_IsNull), r1+kk, uniqOk) goto _61 _61: ; kk = kk + 1 } jmp61 = _sqlite3VdbeAddOp1(tls, v, int32(OP_Next), **(**int32)(__ccgo_up(bp + 112))+j4) _sqlite3VdbeGoto(tls, v, uniqOk) _sqlite3VdbeJumpHere(tls, v, jmp61) _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IdxGT), **(**int32)(__ccgo_up(bp + 112))+j4, uniqOk, r1, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pIdx6)).FnKeyCol)) _sqlite3VdbeLoadString(tls, v, int32(3), __ccgo_ts+19790) _sqlite3VdbeGoto(tls, v, jmp5) _sqlite3VdbeResolveLabel(tls, v, uniqOk) } _sqlite3VdbeJumpHere(tls, v, jmp4) _sqlite3ResolvePartIdxLabel(tls, pParse, **(**int32)(__ccgo_up(bp + 128))) goto _59 _59: ; pIdx6 = (*TIndex)(unsafe.Pointer(pIdx6)).FpNext j4 = j4 + 1 } } _sqlite3VdbeAddOp2(tls, v, int32(OP_Next), **(**int32)(__ccgo_up(bp + 108)), loopTop) _sqlite3VdbeJumpHere(tls, v, loopTop-int32(1)) if pPk1 != 0 { _sqlite3ReleaseTempRange(tls, pParse, r2, libc.Int32FromUint16((*TIndex)(unsafe.Pointer(pPk1)).FnKeyCol)) } goto _53 _53: ; x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext } /* Second pass to invoke the xIntegrity method on all virtual ** tables. */ x2 = (*THash)(unsafe.Pointer(pTbls)).Ffirst for { if !(x2 != 0) { break } pTab11 = (*THashElem)(unsafe.Pointer(x2)).Fdata if _tableSkipIntegrityCheck(tls, pTab11, pObjTab) != 0 { goto _62 } if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab11)).FeTabType) == TABTYP_NORM { goto _62 } if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab11)).FeTabType) == libc.Int32FromInt32(TABTYP_VTAB)) { goto _62 } if int32((*TTable)(unsafe.Pointer(pTab11)).FnCol) <= 0 { zMod = **(**uintptr)(__ccgo_up((*(*struct { FnArg int32 FazArg uintptr Fp uintptr })(unsafe.Pointer(pTab11 + 64))).FazArg)) if _sqlite3HashFind(tls, db+576, zMod) == uintptr(0) { goto _62 } } _sqlite3ViewGetColumnNames(tls, pParse, pTab11) if (*(*struct { FnArg int32 FazArg uintptr Fp uintptr })(unsafe.Pointer(pTab11 + 64))).Fp == uintptr(0) { goto _62 } pVTab = (*TVTable)(unsafe.Pointer((*(*struct { FnArg int32 FazArg uintptr Fp uintptr })(unsafe.Pointer(pTab11 + 64))).Fp)).FpVtab if pVTab == uintptr(0) { goto _62 } if (*Tsqlite3_vtab)(unsafe.Pointer(pVTab)).FpModule == uintptr(0) { goto _62 } if (*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer(pVTab)).FpModule)).FiVersion < int32(4) { goto _62 } if (*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer(pVTab)).FpModule)).FxIntegrity == uintptr(0) { goto _62 } _sqlite3VdbeAddOp3(tls, v, int32(OP_VCheck), i9, int32(3), isQuick) (*TTable)(unsafe.Pointer(pTab11)).FnTabRef = (*TTable)(unsafe.Pointer(pTab11)).FnTabRef + 1 _sqlite3VdbeAppendP4(tls, v, pTab11, -int32(17)) a11 = _sqlite3VdbeAddOp1(tls, v, int32(OP_IsNull), int32(3)) _integrityCheckResultRow(tls, v) _sqlite3VdbeJumpHere(tls, v, a11) goto _62 goto _62 _62: ; x2 = (*THashElem)(unsafe.Pointer(x2)).Fnext } goto _40 _40: ; i9 = i9 + 1 } aOp2 = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(28)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_endCode)), _iLn21) if aOp2 != 0 { (**(**TVdbeOp)(__ccgo_up(aOp2))).Fp2 = int32(1) - **(**int32)(__ccgo_up(bp + 104)) (**(**TVdbeOp)(__ccgo_up(aOp2 + 2*24))).Fp4type = int8(-libc.Int32FromInt32(1)) *(*uintptr)(unsafe.Pointer(aOp2 + 2*24 + 16)) = __ccgo_ts + 19817 (**(**TVdbeOp)(__ccgo_up(aOp2 + 5*24))).Fp4type = int8(-libc.Int32FromInt32(1)) *(*uintptr)(unsafe.Pointer(aOp2 + 5*24 + 16)) = _sqlite3ErrStr(tls, int32(SQLITE_CORRUPT)) } _sqlite3VdbeChangeP3(tls, v, 0, _sqlite3VdbeCurrentAddr(tls, v)-int32(2)) break /* ** PRAGMA encoding ** PRAGMA encoding = "utf-8"|"utf-16"|"utf-16le"|"utf-16be" ** ** In its first form, this pragma returns the encoding of the main ** database. If the database is not initialized, it is initialized now. ** ** The second form of this pragma is a no-op if the main database file ** has not already been initialized. In this case it sets the default ** encoding that will be used for the main database file if a new file ** is created. If an existing main database file is opened, then the ** default text encoding for the existing database is used. ** ** In all cases new databases created using the ATTACH command are ** created to use the same default text encoding as the main database. If ** the main database has not been initialized and/or created when ATTACH ** is executed, this is done before the ATTACH operation. ** ** In the second form this pragma sets the text encoding to be used in ** new database files created using this database handle. It is only ** useful if invoked immediately after the main database i */ fallthrough case int32(PragTyp_ENCODING): if !(zRight != 0) { /* "PRAGMA encoding" */ if _sqlite3ReadSchema(tls, pParse) != 0 { goto pragma_out } _returnSingleText(tls, v, _encnames1[(*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fenc].FzName) } else { /* "PRAGMA encoding = XXX" */ /* Only change the value of sqlite.enc if the database handle is not ** initialized. If the main database exists, the new sqlite.enc value ** will be overwritten when the schema is next loaded. If it does not ** already exists, it will be created to use the new encoding value. */ if (*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_EncodingFixed) == uint32(0) { pEnc = uintptr(unsafe.Pointer(&_encnames1)) for { if !((*struct { FzName uintptr Fenc Tu8 })(unsafe.Pointer(pEnc)).FzName != 0) { break } if 0 == _sqlite3StrICmp(tls, zRight, (*struct { FzName uintptr Fenc Tu8 })(unsafe.Pointer(pEnc)).FzName) { if (*struct { FzName uintptr Fenc Tu8 })(unsafe.Pointer(pEnc)).Fenc != 0 { v2 = libc.Int32FromUint8((*struct { FzName uintptr Fenc Tu8 })(unsafe.Pointer(pEnc)).Fenc) } else { v2 = int32(SQLITE_UTF16LE) } enc = libc.Uint8FromInt32(v2) (*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb))).FpSchema)).Fenc = enc _sqlite3SetTextEncoding(tls, db, enc) break } goto _63 _63: ; pEnc += 16 } if !((*struct { FzName uintptr Fenc Tu8 })(unsafe.Pointer(pEnc)).FzName != 0) { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+19878, libc.VaList(bp+176, zRight)) } } } break /* ** PRAGMA [schema.]schema_version ** PRAGMA [schema.]schema_version = ** ** PRAGMA [schema.]user_version ** PRAGMA [schema.]user_version = ** ** PRAGMA [schema.]freelist_count ** ** PRAGMA [schema.]data_version ** ** PRAGMA [schema.]application_id ** PRAGMA [schema.]application_id = ** ** The pragma's schema_version and user_version are used to set or get ** the value of the schema-version and user-version, respectively. Both ** the schema-version and the user-version are 32-bit signed integers ** stored in the database header. ** ** The schema-cookie is usually only manipulated internally by SQLite. It ** is incremented by SQLite whenever the database schema is modified (by ** creating or dropping a table or index). The schema version is used by ** SQLite each time a query is executed to ensure that the internal cache ** of the schema used when compiling the SQL query matches the schema of ** the database against which the compiled query is actually executed. ** Subverting this mechanism by using "PRAGMA schema_version" to modify ** the schema-version is potentially dangerous and may lead to program ** crashes or database corruption. Use with caution! ** ** The user-version is not used internally by SQLite. It may be used by ** applications for any purpose. */ fallthrough case int32(PragTyp_HEADER_VALUE): iCookie = libc.Int32FromUint64((*TPragmaName)(unsafe.Pointer(pPragma)).FiArg) /* Which cookie to read or write */ _sqlite3VdbeUsesBtree(tls, v, iDb) if zRight != 0 && libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_ReadOnly) == 0 { aOp3 = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(8)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_setCookie)), 0) if 0 != 0 { break } (**(**TVdbeOp)(__ccgo_up(aOp3))).Fp1 = iDb (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fp1 = iDb (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fp2 = iCookie (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fp3 = _sqlite3Atoi(tls, zRight) (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fp5 = uint16(1) if iCookie == int32(BTREE_SCHEMA_VERSION) && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) != uint64(0) { /* Do not allow the use of PRAGMA schema_version=VALUE in defensive ** mode. Change the OP_SetCookie opcode into a no-op. */ (**(**TVdbeOp)(__ccgo_up(aOp3 + 1*24))).Fopcode = uint8(OP_Noop) } } else { aOp4 = _sqlite3VdbeAddOpList(tls, v, libc.Int32FromUint64(libc.Uint64FromInt64(12)/libc.Uint64FromInt64(4)), uintptr(unsafe.Pointer(&_readCookie)), 0) if 0 != 0 { break } (**(**TVdbeOp)(__ccgo_up(aOp4))).Fp1 = iDb (**(**TVdbeOp)(__ccgo_up(aOp4 + 1*24))).Fp1 = iDb (**(**TVdbeOp)(__ccgo_up(aOp4 + 1*24))).Fp3 = iCookie _sqlite3VdbeReusable(tls, v) } break /* ** PRAGMA compile_options ** ** Return the names of all compile-time options used in this build, ** one option per row. */ fallthrough case int32(PragTyp_COMPILE_OPTIONS): i10 = 0 (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(1) for { v2 = i10 i10 = i10 + 1 v1 = Xsqlite3_compileoption_get(tls, v2) zOpt = v1 if !(v1 != uintptr(0)) { break } _sqlite3VdbeLoadString(tls, v, int32(1), zOpt) _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), int32(1)) } _sqlite3VdbeReusable(tls, v) break /* ** PRAGMA [schema.]wal_checkpoint = passive|full|restart|truncate ** ** Checkpoint the database. */ fallthrough case int32(PragTyp_WAL_CHECKPOINT): if (*TToken)(unsafe.Pointer(pId2)).Fz != 0 { v2 = iDb } else { v2 = libc.Int32FromInt32(SQLITE_MAX_ATTACHED) + libc.Int32FromInt32(2) } iBt = v2 eMode2 = SQLITE_CHECKPOINT_PASSIVE if zRight != 0 { if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19044) == 0 { eMode2 = int32(SQLITE_CHECKPOINT_FULL) } else { if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19903) == 0 { eMode2 = int32(SQLITE_CHECKPOINT_RESTART) } else { if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19197) == 0 { eMode2 = int32(SQLITE_CHECKPOINT_TRUNCATE) } else { if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19911) == 0 { eMode2 = -int32(1) } } } } } (*TParse)(unsafe.Pointer(pParse)).FnMem = int32(3) _sqlite3VdbeAddOp3(tls, v, int32(OP_Checkpoint), iBt, eMode2, int32(1)) _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), int32(3)) break /* ** PRAGMA wal_autocheckpoint ** PRAGMA wal_autocheckpoint = N ** ** Configure a database connection to automatically checkpoint a database ** after accumulating N frames in the log. Or query for the current value ** of N. */ fallthrough case int32(PragTyp_WAL_AUTOCHECKPOINT): if zRight != 0 { Xsqlite3_wal_autocheckpoint(tls, db, _sqlite3Atoi(tls, zRight)) } if (*Tsqlite3)(unsafe.Pointer(db)).FxWalCallback == __ccgo_fp(_sqlite3WalDefaultHook) { v2 = int32(int64((*Tsqlite3)(unsafe.Pointer(db)).FpWalArg)) } else { v2 = 0 } _returnSingleInt(tls, v, int64(v2)) break /* ** PRAGMA shrink_memory ** ** IMPLEMENTATION-OF: R-23445-46109 This pragma causes the database ** connection on which it is invoked to free up as much memory as it ** can, by calling sqlite3_db_release_memory(). */ fallthrough case int32(PragTyp_SHRINK_MEMORY): Xsqlite3_db_release_memory(tls, db) break /* ** PRAGMA optimize ** PRAGMA optimize(MASK) ** PRAGMA schema.optimize ** PRAGMA schema.optimize(MASK) ** ** Attempt to optimize the database. All schemas are optimized in the first ** two forms, and only the specified schema is optimized in the latter two. ** ** The details of optimizations performed by this pragma are expected ** to change and improve over time. Applications should anticipate that ** this pragma will perform new optimizations in future releases. ** ** The optional argument is a bitmask of optimizations to perform: ** ** 0x00001 Debugging mode. Do not actually perform any optimizations ** but instead return one line of text for each optimization ** that would have been done. Off by default. ** ** 0x00002 Run ANALYZE on tables that might benefit. On by default. ** See below for additional information. ** ** 0x00010 Run all ANALYZE operations using an analysis_limit that ** is the lessor of the current analysis_limit and the ** SQLITE_DEFAULT_OPTIMIZE_LIMIT compile-time option. ** The default value of SQLITE_DEFAULT_OPTIMIZE_LIMIT is ** currently (2024-02-19) set to 2000, which is such that ** the worst case run-time for PRAGMA optimize on a 100MB ** database will usually be less than 100 milliseconds on ** a RaspberryPI-4 class machine. On by default. ** ** 0x10000 Look at tables to see if they need to be reanalyzed ** due to growth or shrinkage even if they have not been ** queried during the current connection. Off by default. ** ** The default MASK is and always shall be 0x0fffe. In the current ** implementation, the default mask only covers the 0x00002 optimization, ** though additional optimizations that are covered by 0x0fffe might be ** added in the future. Optimizations that are off by default and must ** be explicitly requested have masks of 0x10000 or greater. ** ** DETERMINATION OF WHEN TO RUN ANALYZE ** ** In the current implementation, a table is analyzed if only if all of ** the following are true: ** ** (1) MASK bit 0x00002 is set. ** ** (2) The table is an ordinary table, not a virtual table or view. ** ** (3) The table name does not begin with "sqlite_". ** ** (4) One or more of the following is true: ** (4a) The 0x10000 MASK bit is set. ** (4b) One or more indexes on the table lacks an entry ** in the sqlite_stat1 table. ** (4c) The query planner used sqlite_stat1-style statistics for one ** or more indexes of the table at some point during the lifetime ** of the current connection. ** ** (5) One or more of the following is true: ** (5a) One or more indexes on the table lacks an entry ** in the sqlite_stat1 table. (Same as 4a) ** (5b) The number of rows in the table has increased or decreased by ** 10-fold. In other words, the current size of the table is ** 10 times larger than the size in sqlite_stat1 or else the ** current size is less than 1/10th the size in sqlite_stat1. ** ** The rules for when tables are analyzed are likely to change in ** future releases. Future versions of SQLite might accept a string ** literal argument to this pragma that contains a mnemonic description ** of the options rather than a bitmap. */ fallthrough case int32(PragTyp_OPTIMIZE): /* Analysis limit to use */ nCheck = 0 /* Number of tables to be optimized */ nBtree = 0 /* Number of indexes on the current table */ if zRight != 0 { opMask = libc.Uint32FromInt32(_sqlite3Atoi(tls, zRight)) if opMask&uint32(0x02) == uint32(0) { break } } else { opMask = uint32(0xfffe) } if opMask&uint32(0x10) == uint32(0) { nLimit = 0 } else { if (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit > 0 && (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit < int32(SQLITE_DEFAULT_OPTIMIZE_LIMIT) { nLimit = 0 } else { nLimit = int32(SQLITE_DEFAULT_OPTIMIZE_LIMIT) } } v1 = pParse + 56 v2 = *(*int32)(unsafe.Pointer(v1)) *(*int32)(unsafe.Pointer(v1)) = *(*int32)(unsafe.Pointer(v1)) + 1 iTabCur = v2 if zDb != 0 { v2 = iDb } else { v2 = (*Tsqlite3)(unsafe.Pointer(db)).FnDb - int32(1) } iDbLast = v2 for { if !(iDb <= iDbLast) { break } if iDb == int32(1) { goto _71 } _sqlite3CodeVerifySchema(tls, pParse, iDb) pSchema = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpSchema k4 = (*THash)(unsafe.Pointer(pSchema + 8)).Ffirst for { if !(k4 != 0) { break } pTab12 = (*THashElem)(unsafe.Pointer(k4)).Fdata /* This only works for ordinary tables */ if !(libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab12)).FeTabType) == libc.Int32FromInt32(TABTYP_NORM)) { goto _73 } /* Do not scan system tables */ if 0 == Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab12)).FzName, __ccgo_ts+6784, int32(7)) { goto _73 } /* Find the size of the table as last recorded in sqlite_stat1. ** If any index is unanalyzed, then the threshold is -1 to ** indicate a new, unanalyzed index */ szThreshold = (*TTable)(unsafe.Pointer(pTab12)).FnRowLogEst nIndex = 0 pIdx7 = (*TTable)(unsafe.Pointer(pTab12)).FpIndex for { if !(pIdx7 != 0) { break } nIndex = nIndex + 1 if !(int32(uint32(*(*uint16)(unsafe.Pointer(pIdx7 + 100))&0x80>>7)) != 0) { szThreshold = int16(-int32(1)) /* Always analyze if any index lacks statistics */ } goto _74 _74: ; pIdx7 = (*TIndex)(unsafe.Pointer(pIdx7)).FpNext } /* If table pTab has not been used in a way that would benefit from ** having analysis statistics during the current session, then skip it, ** unless the 0x10000 MASK bit is set. */ if (*TTable)(unsafe.Pointer(pTab12)).FtabFlags&uint32(TF_MaybeReanalyze) != uint32(0) { /* Check for size change if stat1 has been used for a query */ } else { if opMask&uint32(0x10000) != 0 { /* Check for size change if 0x10000 is set */ } else { if (*TTable)(unsafe.Pointer(pTab12)).FpIndex != uintptr(0) && int32(szThreshold) < 0 { /* Do analysis if unanalyzed indexes exists */ } else { /* Otherwise, we can skip this table */ goto _73 } } } nCheck = nCheck + 1 if nCheck == int32(2) { /* If ANALYZE might be invoked two or more times, hold a write ** transaction for efficiency */ _sqlite3BeginWriteOperation(tls, pParse, 0, iDb) } nBtree = nBtree + (nIndex + int32(1)) /* Reanalyze if the table is 10 times larger or smaller than ** the last analysis. Unconditional reanalysis if there are ** unanalyzed indexes. */ _sqlite3OpenTable(tls, pParse, iTabCur, iDb, pTab12, int32(OP_OpenRead)) if int32(szThreshold) >= 0 { iRange = int16(33) /* 10x size change */ if int32(szThreshold) >= int32(iRange) { v2 = int32(szThreshold) - int32(iRange) } else { v2 = -int32(1) } _sqlite3VdbeAddOp4Int(tls, v, int32(OP_IfSizeBetween), iTabCur, libc.Int32FromUint32(libc.Uint32FromInt32(_sqlite3VdbeCurrentAddr(tls, v)+int32(2))+opMask&uint32(1)), v2, int32(szThreshold)+int32(iRange)) } else { _sqlite3VdbeAddOp2(tls, v, int32(OP_Rewind), iTabCur, libc.Int32FromUint32(libc.Uint32FromInt32(_sqlite3VdbeCurrentAddr(tls, v)+int32(2))+opMask&uint32(1))) } zSubSql = _sqlite3MPrintf(tls, db, __ccgo_ts+19916, libc.VaList(bp+176, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FzDbSName, (*TTable)(unsafe.Pointer(pTab12)).FzName)) if opMask&uint32(0x01) != 0 { r11 = _sqlite3GetTempReg(tls, pParse) _sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, r11, 0, zSubSql, -int32(7)) _sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), r11, int32(1)) } else { if nLimit != 0 { v2 = int32(0x02) } else { v2 = 00 } _sqlite3VdbeAddOp4(tls, v, int32(OP_SqlExec), v2, nLimit, 0, zSubSql, -int32(7)) } goto _73 _73: ; k4 = (*THashElem)(unsafe.Pointer(k4)).Fnext } goto _71 _71: ; iDb = iDb + 1 } _sqlite3VdbeAddOp0(tls, v, int32(OP_Expire)) /* In a schema with a large number of tables and indexes, scale back ** the analysis_limit to avoid excess run-time in the worst case. */ if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) && nLimit > 0 && nBtree > int32(100) { nLimit = int32(100) * nLimit / nBtree if nLimit < int32(100) { nLimit = int32(100) } aOp5 = _sqlite3VdbeGetOp(tls, v, 0) iEnd = _sqlite3VdbeCurrentAddr(tls, v) iAddr1 = 0 for { if !(iAddr1 < iEnd) { break } if libc.Int32FromUint8((**(**TVdbeOp)(__ccgo_up(aOp5 + uintptr(iAddr1)*24))).Fopcode) == int32(OP_SqlExec) { (**(**TVdbeOp)(__ccgo_up(aOp5 + uintptr(iAddr1)*24))).Fp2 = nLimit } goto _77 _77: ; iAddr1 = iAddr1 + 1 } } break /* ** PRAGMA busy_timeout ** PRAGMA busy_timeout = N ** ** Call sqlite3_busy_timeout(db, N). Return the current timeout value ** if one is set. If no busy handler or a different busy handler is set ** then 0 is returned. Setting the busy_timeout to 0 or negative ** disables the timeout. */ /*case PragTyp_BUSY_TIMEOUT*/ fallthrough default: if zRight != 0 { Xsqlite3_busy_timeout(tls, db, _sqlite3Atoi(tls, zRight)) } _returnSingleInt(tls, v, int64((*Tsqlite3)(unsafe.Pointer(db)).FbusyTimeout)) break /* ** PRAGMA soft_heap_limit ** PRAGMA soft_heap_limit = N ** ** IMPLEMENTATION-OF: R-26343-45930 This pragma invokes the ** sqlite3_soft_heap_limit64() interface with the argument N, if N is ** specified and is a non-negative integer. ** IMPLEMENTATION-OF: R-64451-07163 The soft_heap_limit pragma always ** returns the same integer that would be returned by the ** sqlite3_soft_heap_limit64(-1) C-language function. */ fallthrough case int32(PragTyp_SOFT_HEAP_LIMIT): if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+136) == SQLITE_OK { Xsqlite3_soft_heap_limit64(tls, **(**Tsqlite3_int64)(__ccgo_up(bp + 136))) } _returnSingleInt(tls, v, Xsqlite3_soft_heap_limit64(tls, int64(-int32(1)))) break /* ** PRAGMA hard_heap_limit ** PRAGMA hard_heap_limit = N ** ** Invoke sqlite3_hard_heap_limit64() to query or set the hard heap ** limit. The hard heap limit can be activated or lowered by this ** pragma, but not raised or deactivated. Only the ** sqlite3_hard_heap_limit64() C-language API can raise or deactivate ** the hard heap limit. This allows an application to set a heap limit ** constraint that cannot be relaxed by an untrusted SQL script. */ fallthrough case int32(PragTyp_HARD_HEAP_LIMIT): if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+144) == SQLITE_OK { iPrior = Xsqlite3_hard_heap_limit64(tls, int64(-int32(1))) if **(**Tsqlite3_int64)(__ccgo_up(bp + 144)) > 0 && (iPrior == 0 || iPrior > **(**Tsqlite3_int64)(__ccgo_up(bp + 144))) { Xsqlite3_hard_heap_limit64(tls, **(**Tsqlite3_int64)(__ccgo_up(bp + 144))) } } _returnSingleInt(tls, v, Xsqlite3_hard_heap_limit64(tls, int64(-int32(1)))) break /* ** PRAGMA threads ** PRAGMA threads = N ** ** Configure the maximum number of worker threads. Return the new ** maximum, which might be less than requested. */ fallthrough case int32(PragTyp_THREADS): if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+152) == SQLITE_OK && **(**Tsqlite3_int64)(__ccgo_up(bp + 152)) >= 0 { Xsqlite3_limit(tls, db, int32(SQLITE_LIMIT_WORKER_THREADS), int32(**(**Tsqlite3_int64)(__ccgo_up(bp + 152))&libc.Int64FromInt32(0x7fffffff))) } _returnSingleInt(tls, v, int64(Xsqlite3_limit(tls, db, int32(SQLITE_LIMIT_WORKER_THREADS), -int32(1)))) break /* ** PRAGMA analysis_limit ** PRAGMA analysis_limit = N ** ** Configure the maximum number of rows that ANALYZE will examine ** in each index that it looks at. Return the new limit. */ fallthrough case int32(PragTyp_ANALYSIS_LIMIT): if zRight != 0 && _sqlite3DecOrHexToI64(tls, zRight, bp+160) == SQLITE_OK && **(**Tsqlite3_int64)(__ccgo_up(bp + 160)) >= 0 { (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit = int32(**(**Tsqlite3_int64)(__ccgo_up(bp + 160)) & libc.Int64FromInt32(0x7fffffff)) } _returnSingleInt(tls, v, int64((*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit)) /* IMP: R-57594-65522 */ break } /* End of the PRAGMA switch */ /* The following block is a no-op unless SQLITE_DEBUG is defined. Its only ** purpose is to execute assert() statements to verify that if the ** PragFlg_NoColumns1 flag is set and the caller specified an argument ** to the PRAGMA, the implementation has not added any OP_ResultRow ** instructions to the VM. */ if libc.Int32FromUint8((*TPragmaName)(unsafe.Pointer(pPragma)).FmPragFlg)&int32(PragFlg_NoColumns1) != 0 && zRight != 0 { } goto pragma_out pragma_out: ; _sqlite3DbFree(tls, db, zLeft) _sqlite3DbFree(tls, db, zRight) } // C documentation // // /* // ** Compile the UTF-8 encoded SQL statement zSql into a statement handle. // */ func _sqlite3Prepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags Tu32, pReprepare uintptr, ppStmt uintptr, pzTail uintptr) (r int32) { bp := tls.Alloc(448) defer tls.Free(448) var i, mxLen, rc, v1 int32 var pBt, pT, zDb, zSqlCopy uintptr var _ /* sParse at bp+0 */ TParse _, _, _, _, _, _, _, _ = i, mxLen, pBt, pT, rc, zDb, zSqlCopy, v1 rc = SQLITE_OK /* Parsing context */ /* sqlite3ParseObjectInit(&sParse, db); // inlined for performance */ libc.Xmemset(tls, bp+uintptr(uint64(libc.UintptrFromInt32(0)+8)), 0, uint64(libc.UintptrFromInt32(0)+192)-uint64(libc.UintptrFromInt32(0)+8)) libc.Xmemset(tls, bp+uintptr(uint64(libc.UintptrFromInt32(0)+288)), 0, libc.Uint64FromInt64(424)-uint64(libc.UintptrFromInt32(0)+288)) (**(**TParse)(__ccgo_up(bp))).FpOuterParse = (*Tsqlite3)(unsafe.Pointer(db)).FpParse (*Tsqlite3)(unsafe.Pointer(db)).FpParse = bp (**(**TParse)(__ccgo_up(bp))).Fdb = db if pReprepare != 0 { (**(**TParse)(__ccgo_up(bp))).FpReprepare = pReprepare (**(**TParse)(__ccgo_up(bp))).Fexplain = libc.Uint8FromInt32(Xsqlite3_stmt_isexplain(tls, pReprepare)) } else { } if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { _sqlite3ErrorMsg(tls, bp, __ccgo_ts+1674, 0) v1 = libc.Int32FromInt32(SQLITE_NOMEM) rc = v1 (*Tsqlite3)(unsafe.Pointer(db)).FerrCode = v1 goto end_prepare } /* For a long-term use prepared statement avoid the use of ** lookaside memory. */ if prepFlags&uint32(SQLITE_PREPARE_PERSISTENT) != 0 { (**(**TParse)(__ccgo_up(bp))).FdisableLookaside = (**(**TParse)(__ccgo_up(bp))).FdisableLookaside + 1 (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable = (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.FbDisable + 1 (*Tsqlite3)(unsafe.Pointer(db)).Flookaside.Fsz = uint16(0) } (**(**TParse)(__ccgo_up(bp))).FprepFlags = uint8(prepFlags & uint32(0xff)) /* Check to verify that it is possible to get a read lock on all ** database schemas. The inability to get a read lock indicates that ** some other database connection is holding a write-lock, which in ** turn means that the other connection has made uncommitted changes ** to the schema. ** ** Were we to proceed and prepare the statement against the uncommitted ** schema changes and if those schema changes are subsequently rolled ** back and different changes are made in their place, then when this ** prepared statement goes to run the schema cookie would fail to detect ** the schema change. Disaster would follow. ** ** This thread is currently holding mutexes on all Btrees (because ** of the sqlite3BtreeEnterAll() in sqlite3LockAndPrepare()) so it ** is not possible for another thread to start a new schema change ** while this routine is running. Hence, we do not need to hold ** locks on the schema, we just need to make sure nobody else is ** holding them. ** ** Note that setting READ_UNCOMMITTED overrides most lock detection, ** but it does *not* override schema lock detection, so this all still ** works even if READ_UNCOMMITTED is set. */ if !((*Tsqlite3)(unsafe.Pointer(db)).FnoSharedCache != 0) { i = 0 for { if !(i < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { break } pBt = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FpBt if pBt != 0 { rc = _sqlite3BtreeSchemaLocked(tls, pBt) if rc != 0 { zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(i)*32))).FzDbSName _sqlite3ErrorWithMsg(tls, db, rc, __ccgo_ts+20263, libc.VaList(bp+432, zDb)) goto end_prepare } } goto _2 _2: ; i = i + 1 } } if (*Tsqlite3)(unsafe.Pointer(db)).FpDisconnect != 0 { _sqlite3VtabUnlockList(tls, db) } if nBytes >= 0 && (nBytes == 0 || libc.Int32FromUint8(**(**uint8)(__ccgo_up(zSql + uintptr(nBytes-int32(1))))) != 0) { mxLen = **(**int32)(__ccgo_up(db + 136 + 1*4)) if nBytes > mxLen { _sqlite3ErrorWithMsg(tls, db, int32(SQLITE_TOOBIG), __ccgo_ts+20293, 0) rc = _sqlite3ApiExit(tls, db, int32(SQLITE_TOOBIG)) goto end_prepare } zSqlCopy = _sqlite3DbStrNDup(tls, db, zSql, libc.Uint64FromInt32(nBytes)) if zSqlCopy != 0 { _sqlite3RunParser(tls, bp, zSqlCopy) (**(**TParse)(__ccgo_up(bp))).FzTail = zSql + uintptr(int64((**(**TParse)(__ccgo_up(bp))).FzTail)-int64(zSqlCopy)) _sqlite3DbFree(tls, db, zSqlCopy) } else { (**(**TParse)(__ccgo_up(bp))).FzTail = zSql + uintptr(nBytes) } } else { _sqlite3RunParser(tls, bp, zSql) } if pzTail != 0 { **(**uintptr)(__ccgo_up(pzTail)) = (**(**TParse)(__ccgo_up(bp))).FzTail } if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0 { _sqlite3VdbeSetSql(tls, (**(**TParse)(__ccgo_up(bp))).FpVdbe, zSql, int32(int64((**(**TParse)(__ccgo_up(bp))).FzTail)-int64(zSql)), uint8(prepFlags)) } if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { (**(**TParse)(__ccgo_up(bp))).Frc = int32(SQLITE_NOMEM) libc.SetBitFieldPtr16Uint32(bp+40, libc.Uint32FromInt32(0), 8, 0x100) } if (**(**TParse)(__ccgo_up(bp))).Frc != SQLITE_OK && (**(**TParse)(__ccgo_up(bp))).Frc != int32(SQLITE_DONE) { if int32(Tbft(*(*uint16)(unsafe.Pointer(bp + 40))&0x100>>8)) != 0 && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy) == 0 { _schemaIsValid(tls, bp) } if (**(**TParse)(__ccgo_up(bp))).FpVdbe != 0 { _sqlite3VdbeFinalize(tls, (**(**TParse)(__ccgo_up(bp))).FpVdbe) } rc = (**(**TParse)(__ccgo_up(bp))).Frc if (**(**TParse)(__ccgo_up(bp))).FzErrMsg != 0 { _sqlite3ErrorWithMsg(tls, db, rc, __ccgo_ts+3968, libc.VaList(bp+432, (**(**TParse)(__ccgo_up(bp))).FzErrMsg)) _sqlite3DbFree(tls, db, (**(**TParse)(__ccgo_up(bp))).FzErrMsg) } else { _sqlite3Error(tls, db, rc) } } else { **(**uintptr)(__ccgo_up(ppStmt)) = (**(**TParse)(__ccgo_up(bp))).FpVdbe rc = SQLITE_OK _sqlite3ErrorClear(tls, db) } /* Delete any TriggerPrg structures allocated while parsing this statement. */ for (**(**TParse)(__ccgo_up(bp))).FpTriggerPrg != 0 { pT = (**(**TParse)(__ccgo_up(bp))).FpTriggerPrg (**(**TParse)(__ccgo_up(bp))).FpTriggerPrg = (*TTriggerPrg)(unsafe.Pointer(pT)).FpNext _sqlite3DbFree(tls, db, pT) } goto end_prepare end_prepare: ; _sqlite3ParseObjectReset(tls, bp) return rc } // C documentation // // /* // ** This routine processes the join information for a SELECT statement. // ** // ** * A NATURAL join is converted into a USING join. After that, we // ** do not need to be concerned with NATURAL joins and we only have // ** think about USING joins. // ** // ** * ON and USING clauses result in extra terms being added to the // ** WHERE clause to enforce the specified constraints. The extra // ** WHERE clause terms will be tagged with EP_OuterON or // ** EP_InnerON so that we know that they originated in ON/USING. // ** // ** The terms of a FROM clause are contained in the Select.pSrc structure. // ** The left most table is the first entry in Select.pSrc. The right-most // ** table is the last entry. The join operator is held in the entry to // ** the right. Thus entry 1 contains the join operator for the join between // ** entries 0 and 1. Any ON or USING clauses associated with the join are // ** also attached to the right entry. // ** // ** This routine returns the number of errors encountered. // */ func _sqlite3ProcessJoin(tls *libc.TLS, pParse uintptr, p uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) var db, pE1, pE2, pEq, pFuncArgs, pLeft, pList, pRight, pRightTab, pSrc, pUsing, zName, zName1 uintptr var i, iRightCol, j, v2 int32 var joinType Tu32 var _ /* iLeft at bp+0 */ int32 var _ /* iLeftCol at bp+4 */ int32 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = db, i, iRightCol, j, joinType, pE1, pE2, pEq, pFuncArgs, pLeft, pList, pRight, pRightTab, pSrc, pUsing, zName, zName1, v2 /* Right table being joined */ pSrc = (*TSelect)(unsafe.Pointer(p)).FpSrc pLeft = pSrc + 8 pRight = pLeft + 1*80 i = 0 for { if !(i < (*TSrcList)(unsafe.Pointer(pSrc)).FnSrc-int32(1)) { break } pRightTab = (*TSrcItem)(unsafe.Pointer(pRight)).FpSTab if (*TSrcItem)(unsafe.Pointer(pLeft)).FpSTab == uintptr(0) || pRightTab == uintptr(0) { goto _1 } if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pRight)).Ffg.Fjointype)&int32(JT_OUTER) != 0 { v2 = int32(EP_OuterON) } else { v2 = int32(EP_InnerON) } joinType = libc.Uint32FromInt32(v2) /* If this is a NATURAL join, synthesize an appropriate USING clause ** to specify which columns should be joined. */ if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pRight)).Ffg.Fjointype)&int32(JT_NATURAL) != 0 { pUsing = uintptr(0) if int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x800>>11) != 0 || *(*uintptr)(unsafe.Pointer(pRight + 64)) != 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20342, libc.VaList(bp+16, 0)) return int32(1) } j = 0 for { if !(j < int32((*TTable)(unsafe.Pointer(pRightTab)).FnCol)) { break } /* Name of column in the right table */ if libc.Int32FromUint16((*TColumn)(unsafe.Pointer((*TTable)(unsafe.Pointer(pRightTab)).FaCol+uintptr(j)*16)).FcolFlags)&int32(COLFLAG_HIDDEN) != 0 { goto _3 } zName = (**(**TColumn)(__ccgo_up((*TTable)(unsafe.Pointer(pRightTab)).FaCol + uintptr(j)*16))).FzCnName if _tableAndColumnIndex(tls, pSrc, 0, i, zName, uintptr(0), uintptr(0), int32(1)) != 0 { pUsing = _sqlite3IdListAppend(tls, pParse, pUsing, uintptr(0)) if pUsing != 0 { (*(*TIdList_item)(unsafe.Pointer(pUsing + 8 + uintptr((*TIdList)(unsafe.Pointer(pUsing)).FnId-int32(1))*8))).FzName = _sqlite3DbStrDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zName) } } goto _3 _3: ; j = j + 1 } if pUsing != 0 { libc.SetBitFieldPtr32Uint32(pRight+24+4, libc.Uint32FromInt32(1), 11, 0x800) libc.SetBitFieldPtr32Uint32(pRight+24+4, libc.Uint32FromInt32(1), 13, 0x2000) *(*uintptr)(unsafe.Pointer(pRight + 64)) = pUsing } if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { return int32(1) } } /* Create extra terms on the WHERE clause for each column named ** in the USING clause. Example: If the two tables to be joined are ** A and B and the USING clause names X, Y, and Z, then add this ** to the WHERE clause: A.X=B.X AND A.Y=B.Y AND A.Z=B.Z ** Report an error if any column mentioned in the USING clause is ** not contained in both tables to be joined. */ if int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x800>>11) != 0 { pList = *(*uintptr)(unsafe.Pointer(pRight + 64)) db = (*TParse)(unsafe.Pointer(pParse)).Fdb j = 0 for { if !(j < (*TIdList)(unsafe.Pointer(pList)).FnId) { break } /* Equality constraint. pE1 == pE2 */ zName1 = (*(*TIdList_item)(unsafe.Pointer(pList + 8 + uintptr(j)*8))).FzName iRightCol = _sqlite3ColumnIndex(tls, pRightTab, zName1) if iRightCol < 0 || _tableAndColumnIndex(tls, pSrc, 0, i, zName1, bp, bp+4, int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x2000>>13)) == 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20392, libc.VaList(bp+16, zName1)) return int32(1) } pE1 = _sqlite3CreateColumnExpr(tls, db, pSrc, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4))) _sqlite3SrcItemColumnUsed(tls, pSrc+8+uintptr(**(**int32)(__ccgo_up(bp)))*80, **(**int32)(__ccgo_up(bp + 4))) if libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pSrc + 8))).Ffg.Fjointype)&int32(JT_LTORJ) != 0 && (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { /* This branch runs if the query contains one or more RIGHT or FULL ** JOINs. If only a single table on the left side of this join ** contains the zName column, then this branch is a no-op. ** But if there are two or more tables on the left side ** of the join, construct a coalesce() function that gathers all ** such tables. Raise an error if more than one of those references ** to zName is not also within a prior USING clause. ** ** We really ought to raise an error if there are two or more ** non-USING references to zName on the left of an INNER or LEFT ** JOIN. But older versions of SQLite do not do that, so we avoid ** adding a new error so as to not break legacy applications. */ pFuncArgs = uintptr(0) /* Arguments to the coalesce() */ **(**Tu32)(__ccgo_up(pE1 + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) for _tableAndColumnIndex(tls, pSrc, **(**int32)(__ccgo_up(bp))+int32(1), i, zName1, bp, bp+4, int32(*(*uint32)(unsafe.Pointer(pRight + 24 + 4))&0x2000>>13)) != 0 { if int32(*(*uint32)(unsafe.Pointer(pSrc + 8 + uintptr(**(**int32)(__ccgo_up(bp)))*80 + 24 + 4))&0x800>>11) == 0 || _sqlite3IdListIndex(tls, *(*uintptr)(unsafe.Pointer(pSrc + 8 + uintptr(**(**int32)(__ccgo_up(bp)))*80 + 64)), zName1) < 0 { _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20456, libc.VaList(bp+16, zName1)) break } pFuncArgs = _sqlite3ExprListAppend(tls, pParse, pFuncArgs, pE1) pE1 = _sqlite3CreateColumnExpr(tls, db, pSrc, **(**int32)(__ccgo_up(bp)), **(**int32)(__ccgo_up(bp + 4))) _sqlite3SrcItemColumnUsed(tls, pSrc+8+uintptr(**(**int32)(__ccgo_up(bp)))*80, **(**int32)(__ccgo_up(bp + 4))) } if pFuncArgs != 0 { pFuncArgs = _sqlite3ExprListAppend(tls, pParse, pFuncArgs, pE1) pE1 = _sqlite3ExprFunction(tls, pParse, pFuncArgs, uintptr(unsafe.Pointer(&_tkCoalesce)), 0) if pE1 != 0 { (*TExpr)(unsafe.Pointer(pE1)).FaffExpr = uint8(SQLITE_AFF_DEFER) } } } else { if libc.Int32FromUint8((*(*TSrcItem)(unsafe.Pointer(pSrc + 8 + uintptr(i+int32(1))*80))).Ffg.Fjointype)&int32(JT_LEFT) != 0 && (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 { **(**Tu32)(__ccgo_up(pE1 + 4)) |= libc.Uint32FromInt32(libc.Int32FromInt32(EP_CanBeNull)) } } pE2 = _sqlite3CreateColumnExpr(tls, db, pSrc, i+int32(1), iRightCol) _sqlite3SrcItemColumnUsed(tls, pRight, iRightCol) pEq = _sqlite3PExpr(tls, pParse, int32(TK_EQ), pE1, pE2) if pEq != 0 { **(**Tu32)(__ccgo_up(pEq + 4)) |= joinType *(*int32)(unsafe.Pointer(pEq + 52)) = (*TExpr)(unsafe.Pointer(pE2)).FiTable } (*TSelect)(unsafe.Pointer(p)).FpWhere = _sqlite3ExprAnd(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpWhere, pEq) goto _4 _4: ; j = j + 1 } } else { if *(*uintptr)(unsafe.Pointer(pRight + 64)) != 0 { _sqlite3SetJoinExpr(tls, *(*uintptr)(unsafe.Pointer(pRight + 64)), (*TSrcItem)(unsafe.Pointer(pRight)).FiCursor, joinType) (*TSelect)(unsafe.Pointer(p)).FpWhere = _sqlite3ExprAnd(tls, pParse, (*TSelect)(unsafe.Pointer(p)).FpWhere, *(*uintptr)(unsafe.Pointer(pRight + 64))) *(*uintptr)(unsafe.Pointer(pRight + 64)) = uintptr(0) libc.SetBitFieldPtr32Uint32(pRight+24+4, libc.Uint32FromInt32(1), 12, 0x1000) **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_OnToWhere) } } if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pRightTab)).FeTabType) == int32(TABTYP_VTAB) && joinType == uint32(EP_OuterON) && *(*uintptr)(unsafe.Pointer(pRight + 48)) != 0 { **(**Tu32)(__ccgo_up(p + 4)) |= uint32(SF_OnToWhere) } goto _1 _1: ; i = i + 1 pRight += 80 pLeft += 80 } return 0 } // C documentation // // /* // ** Execute as much of a VDBE program as we can. // ** This is the core of sqlite3_step(). // */ func _sqlite3VdbeExec(tls *libc.TLS, p uintptr) (r int32) { bp := tls.Alloc(1024) defer tls.Free(1024) var aCol, aMem, aOffset, aOp, aPermute, aRoot, apArg, apArg1, db, pArgc, pBt, pBt1, pBt2, pBt3, pC, pC1, pC10, pC11, pC12, pC13, pC14, pC15, pC16, pC17, pC18, pC19, pC2, pC20, pC21, pC22, pC23, pC24, pC25, pC26, pC27, pC28, pC29, pC3, pC30, pC31, pC32, pC33, pC34, pC4, pC5, pC6, pC7, pC8, pC9, pCaller, pColl, pCrsr, pCrsr1, pCrsr2, pCrsr3, pCrsr4, pCrsr5, pCrsr6, pCrsr7, pCrsr8, pCtx, pCtx1, pCtx2, pCur, pCur1, pCur2, pCur3, pCur4, pCur5, pCur6, pCx, pCx1, pCx2, pCx3, pData, pData0, pDb, pDb1, pDb2, pDb3, pDest, pDest1, pDest2, pEnd, pFrame, pFrame1, pFrame2, pFrame3, pFrame4, pIdxKey, pIn, pIn1, pIn2, pIn3, pKey, pKeyInfo, pKeyInfo1, pKeyInfo2, pLast, pMem, pMem1, pMem2, pMem3, pMem4, pModule, pModule1, pModule2, pModule3, pModule4, pModule5, pModule6, pName, pNew, pOp, pOrig, pOut, pPager, pProgram, pQuery, pRec, pReg, pRhs, pRt, pSavepoint, pSrc, pTab, pTab1, pTab2, pTab3, pTabCur, pTmp, pVCur1, pVTab, pVar, pVtab, pVtab1, pVtab2, pVtab3, pVtab4, pVtab5, pVtab6, pVtab7, pX, pX1, pnErr, t1, z1, z2, z3, zAffinity, zAffinity1, zData, zDb, zDb1, zEndHdr, zErr, zFilename, zHdr, zHdr1, zName, zPayload, zSchema, zSql, zTab, zTrace, v191, v194 uintptr var affinity uint8 var alreadyExists, bRev, c, c1, c2, cnt, cnt1, desiredAutoCommit, eNew, eOld, eqOnly, exists, i, i1, i2, i4, i5, i6, i7, i8, i9, iCompare, iCookie, iDb, iDb1, iDb2, iDb3, iQuery, iRollback, iSavepoint, iSet, ii, ii1, isLegacy, isSchemaChange, isTransaction, len1, n, n1, n2, n4, nArg, nArg1, nCol, nField, nField1, nField2, nHdr, nKeyCol, nMem, nName, nRoot, nStep, nVarint, oc, opflags, p1, p11, p12, p13, p2, p21, pcDest, pcx, rc, res, res11, res13, res14, res21, savedAnalysisLimit, seekResult, v11, v21, wrFlag, v190, v193 int32 var colCacheCtr, iAddr, iMap, iPrior, idx, len11, n3, p22, p23, serialType, serial_type, v215, v216 Tu32 var encoding, isWriteLock, mTrace, op, p5, resetSchemaOnFault, vtabOnConflict, v227 Tu8 var flags1, flags11, flags2, flags3, flags31, newType, nullFlag, type1, type2, typeMask, v192 Tu16 var h, h1, iKey1, nAlloc, nData, nProgressLimit, nVmStep, offset64, uu Tu64 var i3, iA, iB1, iKey, iKey2, nByte, nByte1, nByte2, nCellKey, nZero, sz, v256 Ti64 var newMax, v213 uint32 var rA, rB float64 var xAuth Tsqlite3_xauth var v206 int64 var v217 bool var _ /* aRes at bp+760 */ [3]int32 var _ /* iA at bp+8 */ Ti64 var _ /* iB at bp+0 */ Ti64 var _ /* iMeta at bp+104 */ int32 var _ /* iMeta at bp+108 */ int32 var _ /* iMoved at bp+608 */ int32 var _ /* initData at bp+640 */ TInitData var _ /* m at bp+552 */ TMem var _ /* nChange at bp+616 */ Ti64 var _ /* nEntry at bp+96 */ Ti64 var _ /* nErr at bp+680 */ int32 var _ /* nullFunc at bp+896 */ TFuncDef var _ /* pVCur at bp+832 */ uintptr var _ /* pgno at bp+624 */ TPgno var _ /* r at bp+120 */ TUnpackedRecord var _ /* r at bp+168 */ TUnpackedRecord var _ /* r at bp+208 */ TUnpackedRecord var _ /* r at bp+464 */ TUnpackedRecord var _ /* r at bp+512 */ TUnpackedRecord var _ /* r at bp+704 */ TUnpackedRecord var _ /* res at bp+112 */ int32 var _ /* res at bp+160 */ int32 var _ /* res at bp+248 */ int32 var _ /* res at bp+320 */ int32 var _ /* res at bp+376 */ int32 var _ /* res at bp+392 */ int32 var _ /* res at bp+396 */ int32 var _ /* res at bp+400 */ int32 var _ /* res at bp+404 */ int32 var _ /* res at bp+456 */ int32 var _ /* res at bp+696 */ int32 var _ /* rowid at bp+504 */ Ti64 var _ /* rowid at bp+968 */ Tsqlite_int64 var _ /* sContext at bp+848 */ Tsqlite3_context var _ /* sMem at bp+24 */ TMem var _ /* sMem at bp+776 */ TMem var _ /* t at bp+80 */ Tu32 var _ /* uA at bp+16 */ Tu64 var _ /* v at bp+312 */ Ti64 var _ /* v at bp+384 */ Ti64 var _ /* v at bp+88 */ Tu64 var _ /* val at bp+744 */ Ti64 var _ /* x at bp+256 */ TMem var _ /* x at bp+328 */ TBtreePayload var _ /* x at bp+408 */ TBtreePayload var _ /* x at bp+752 */ Ti64 var _ /* z at bp+688 */ uintptr var _ /* zErr at bp+632 */ uintptr var _ /* zErr at bp+840 */ uintptr _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = aCol, aMem, aOffset, aOp, aPermute, aRoot, affinity, alreadyExists, apArg, apArg1, bRev, c, c1, c2, cnt, cnt1, colCacheCtr, db, desiredAutoCommit, eNew, eOld, encoding, eqOnly, exists, flags1, flags11, flags2, flags3, flags31, h, h1, i, i1, i2, i3, i4, i5, i6, i7, i8, i9, iA, iAddr, iB1, iCompare, iCookie, iDb, iDb1, iDb2, iDb3, iKey, iKey1, iKey2, iMap, iPrior, iQuery, iRollback, iSavepoint, iSet, idx, ii, ii1, isLegacy, isSchemaChange, isTransaction, isWriteLock, len1, len11, mTrace, n, n1, n2, n3, n4, nAlloc, nArg, nArg1, nByte, nByte1, nByte2, nCellKey, nCol, nData, nField, nField1, nField2, nHdr, nKeyCol, nMem, nName, nProgressLimit, nRoot, nStep, nVarint, nVmStep, nZero, newMax, newType, nullFlag, oc, offset64, op, opflags, p1, p11, p12, p13, p2, p21, p22, p23, p5, pArgc, pBt, pBt1, pBt2, pBt3, pC, pC1, pC10, pC11, pC12, pC13, pC14, pC15, pC16, pC17, pC18, pC19, pC2, pC20, pC21, pC22, pC23, pC24, pC25, pC26, pC27, pC28, pC29, pC3, pC30, pC31, pC32, pC33, pC34, pC4, pC5, pC6, pC7, pC8, pC9, pCaller, pColl, pCrsr, pCrsr1, pCrsr2, pCrsr3, pCrsr4, pCrsr5, pCrsr6, pCrsr7, pCrsr8, pCtx, pCtx1, pCtx2, pCur, pCur1, pCur2, pCur3, pCur4, pCur5, pCur6, pCx, pCx1, pCx2, pCx3, pData, pData0, pDb, pDb1, pDb2, pDb3, pDest, pDest1, pDest2, pEnd, pFrame, pFrame1, pFrame2, pFrame3, pFrame4, pIdxKey, pIn, pIn1, pIn2, pIn3, pKey, pKeyInfo, pKeyInfo1, pKeyInfo2, pLast, pMem, pMem1, pMem2, pMem3, pMem4, pModule, pModule1, pModule2, pModule3, pModule4, pModule5, pModule6, pName, pNew, pOp, pOrig, pOut, pPager, pProgram, pQuery, pRec, pReg, pRhs, pRt, pSavepoint, pSrc, pTab, pTab1, pTab2, pTab3, pTabCur, pTmp, pVCur1, pVTab, pVar, pVtab, pVtab1, pVtab2, pVtab3, pVtab4, pVtab5, pVtab6, pVtab7, pX, pX1, pcDest, pcx, pnErr, rA, rB, rc, res, res11, res13, res14, res21, resetSchemaOnFault, savedAnalysisLimit, seekResult, serialType, serial_type, sz, t1, type1, type2, typeMask, uu, v11, v21, vtabOnConflict, wrFlag, xAuth, z1, z2, z3, zAffinity, zAffinity1, zData, zDb, zDb1, zEndHdr, zErr, zFilename, zHdr, zHdr1, zName, zPayload, zSchema, zSql, zTab, zTrace, v190, v191, v192, v193, v194, v206, v213, v215, v216, v217, v227, v256 aOp = (*TVdbe)(unsafe.Pointer(p)).FaOp /* Copy of p->aOp */ pOp = aOp /* Current operation */ rc = SQLITE_OK /* Value to return */ db = (*TVdbe)(unsafe.Pointer(p)).Fdb /* The database */ resetSchemaOnFault = uint8(0) /* Reset schema after an error if positive */ encoding = (*Tsqlite3)(unsafe.Pointer(db)).Fenc /* The database encoding */ iCompare = 0 /* Result of last comparison */ nVmStep = uint64(0) /* Invoke xProgress() when nVmStep reaches this */ aMem = (*TVdbe)(unsafe.Pointer(p)).FaMem /* Copy of p->aMem */ pIn1 = uintptr(0) /* 1st input operand */ pIn2 = uintptr(0) /* 2nd input operand */ pIn3 = uintptr(0) /* 3rd input operand */ pOut = uintptr(0) /* Output operand */ colCacheCtr = uint32(0) /* Column cache counter */ /*** INSERT STACK UNION HERE ***/ /* sqlite3_step() verifies this */ if (*TVdbe)(unsafe.Pointer(p)).FlockMask != uint32(0) { _sqlite3VdbeEnter(tls, p) } if (*Tsqlite3)(unsafe.Pointer(db)).FxProgress != 0 { iPrior = **(**Tu32)(__ccgo_up(p + 212 + 4*4)) nProgressLimit = uint64((*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps - iPrior%(*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps) } else { nProgressLimit = libc.Uint64FromUint32(0xffffffff) | libc.Uint64FromUint32(0xffffffff)<= nProgressLimit && (*Tsqlite3)(unsafe.Pointer(db)).FxProgress != uintptr(0) { nProgressLimit = nProgressLimit + uint64((*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps) if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxProgress})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpProgressArg) != 0 { nProgressLimit = libc.Uint64FromUint32(0xffffffff) | libc.Uint64FromUint32(0xffffffff)< 0 && int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == P4_NOTUSED { zErr = _sqlite3ValueText(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56, uint8(SQLITE_UTF8)) _sqlite3VdbeError(tls, p, __ccgo_ts+3968, libc.VaList(bp+984, zErr)) } else { if (*TOp)(unsafe.Pointer(pOp)).Fp5 != 0 { _sqlite3VdbeError(tls, p, __ccgo_ts+5884, libc.VaList(bp+984, _azType[libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)-int32(1)])) if *(*uintptr)(unsafe.Pointer(pOp + 16)) != 0 { (*TVdbe)(unsafe.Pointer(p)).FzErrMsg = _sqlite3MPrintf(tls, db, __ccgo_ts+5905, libc.VaList(bp+984, (*TVdbe)(unsafe.Pointer(p)).FzErrMsg, *(*uintptr)(unsafe.Pointer(pOp + 16)))) } } else { _sqlite3VdbeError(tls, p, __ccgo_ts+3968, libc.VaList(bp+984, *(*uintptr)(unsafe.Pointer(pOp + 16)))) } } _sqlite3VdbeLogAbort(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, pOp, aOp) } rc = _sqlite3VdbeHalt(tls, p) if rc == int32(SQLITE_BUSY) { (*TVdbe)(unsafe.Pointer(p)).Frc = int32(SQLITE_BUSY) } else { if (*TVdbe)(unsafe.Pointer(p)).Frc != 0 { v190 = int32(SQLITE_ERROR) } else { v190 = int32(SQLITE_DONE) } rc = v190 } goto vdbe_return /* Opcode: Integer P1 P2 * * * ** Synopsis: r[P2]=P1 ** ** The 32-bit integer value P1 is written into register P2. */ _10: ; /* out2 */ pOut = _out2Prerelease(tls, p, pOp) *(*Ti64)(unsafe.Pointer(pOut)) = int64((*TOp)(unsafe.Pointer(pOp)).Fp1) goto _189 /* Opcode: Int64 * P2 * P4 * ** Synopsis: r[P2]=P4 ** ** P4 is a pointer to a 64-bit integer value. ** Write that value into register P2. */ _11: ; /* out2 */ pOut = _out2Prerelease(tls, p, pOp) *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pOp + 16)))) goto _189 /* Opcode: Real * P2 * P4 * ** Synopsis: r[P2]=P4 ** ** P4 is a pointer to a 64-bit floating point value. ** Write that value into register P2. */ _12: ; /* same as TK_FLOAT, out2 */ pOut = _out2Prerelease(tls, p, pOp) (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Real) *(*float64)(unsafe.Pointer(pOut)) = **(**float64)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pOp + 16)))) goto _189 /* Opcode: String8 * P2 * P4 * ** Synopsis: r[P2]='P4' ** ** P4 points to a nul terminated UTF-8 string. This opcode is transformed ** into a String opcode before it is executed for the first time. During ** this transformation, the length of string P4 is computed and stored ** as the P1 parameter. */ _13: ; /* same as TK_STRING, out2 */ pOut = _out2Prerelease(tls, p, pOp) (*TOp)(unsafe.Pointer(pOp)).Fp1 = _sqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(pOp + 16))) if libc.Int32FromUint8(encoding) != int32(SQLITE_UTF8) { rc = _sqlite3VdbeMemSetStr(tls, pOut, *(*uintptr)(unsafe.Pointer(pOp + 16)), int64(-int32(1)), uint8(SQLITE_UTF8), libc.UintptrFromInt32(0)) if rc != 0 { goto too_big } if SQLITE_OK != _sqlite3VdbeChangeEncoding(tls, pOut, libc.Int32FromUint8(encoding)) { goto no_mem } (*TMem)(unsafe.Pointer(pOut)).FszMalloc = 0 v191 = pOut + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Static)) if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == -int32(7) { _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pOp + 16))) } (*TOp)(unsafe.Pointer(pOp)).Fp4type = int8(-libc.Int32FromInt32(7)) *(*uintptr)(unsafe.Pointer(pOp + 16)) = (*TMem)(unsafe.Pointer(pOut)).Fz (*TOp)(unsafe.Pointer(pOp)).Fp1 = (*TMem)(unsafe.Pointer(pOut)).Fn } if (*TOp)(unsafe.Pointer(pOp)).Fp1 > **(**int32)(__ccgo_up(db + 136)) { goto too_big } (*TOp)(unsafe.Pointer(pOp)).Fopcode = uint8(OP_String) /* Fall through to the next case, OP_String */ /* Opcode: String P1 P2 P3 P4 P5 ** Synopsis: r[P2]='P4' (len=P1) ** ** The string value P4 of length P1 (bytes) is stored in register P2. ** ** If P3 is not zero and the content of register P3 is equal to P5, then ** the datatype of the register P2 is converted to BLOB. The content is ** the same sequence of bytes, it is merely interpreted as a BLOB instead ** of a string, as if it had been CAST. In other words: ** ** if( P3!=0 and reg[P3]==P5 ) reg[P2] := CAST(reg[P2] as BLOB) */ _14: ; /* out2 */ pOut = _out2Prerelease(tls, p, pOp) (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Static) | libc.Int32FromInt32(MEM_Term)) (*TMem)(unsafe.Pointer(pOut)).Fz = *(*uintptr)(unsafe.Pointer(pOp + 16)) (*TMem)(unsafe.Pointer(pOut)).Fn = (*TOp)(unsafe.Pointer(pOp)).Fp1 (*TMem)(unsafe.Pointer(pOut)).Fenc = encoding goto _189 /* Opcode: BeginSubrtn * P2 * * * ** Synopsis: r[P2]=NULL ** ** Mark the beginning of a subroutine that can be entered in-line ** or that can be called using OP_Gosub. The subroutine should ** be terminated by an OP_Return instruction that has a P1 operand that ** is the same as the P2 operand to this opcode and that has P3 set to 1. ** If the subroutine is entered in-line, then the OP_Return will simply ** fall through. But if the subroutine is entered using OP_Gosub, then ** the OP_Return will jump back to the first instruction after the OP_Gosub. ** ** This routine works by loading a NULL into the P2 register. When the ** return address register contains a NULL, the OP_Return instruction is ** a no-op that simply falls through to the next instruction (assuming that ** the OP_Return opcode has a P3 value of 1). Thus if the subroutine is ** entered in-line, then the OP_Return will cause in-line execution to ** continue. But if the subroutine is entered via OP_Gosub, then the ** OP_Return will cause a return to the address following the OP_Gosub. ** ** This opcode is identical to OP_Null. It has a different name ** only to make the byte code easier to read and verify. */ /* Opcode: Null P1 P2 P3 * * ** Synopsis: r[P2..P3]=NULL ** ** Write a NULL into registers P2. If P3 greater than P2, then also write ** NULL into register P3 and every register in between P2 and P3. If P3 ** is less than P2 (typically P3 is zero) then only register P2 is ** set to NULL. ** ** If the P1 value is non-zero, then also set the MEM_Cleared flag so that ** NULL values will not compare equal even if SQLITE_NULLEQ is set on ** OP_Ne or OP_Eq. */ _16: ; _15: ; pOut = _out2Prerelease(tls, p, pOp) cnt = (*TOp)(unsafe.Pointer(pOp)).Fp3 - (*TOp)(unsafe.Pointer(pOp)).Fp2 if (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { v190 = libc.Int32FromInt32(MEM_Null) | libc.Int32FromInt32(MEM_Cleared) } else { v190 = int32(MEM_Null) } v192 = libc.Uint16FromInt32(v190) nullFlag = v192 (*TMem)(unsafe.Pointer(pOut)).Fflags = v192 (*TMem)(unsafe.Pointer(pOut)).Fn = 0 for cnt > 0 { pOut += 56 _sqlite3VdbeMemSetNull(tls, pOut) (*TMem)(unsafe.Pointer(pOut)).Fflags = nullFlag (*TMem)(unsafe.Pointer(pOut)).Fn = 0 cnt = cnt - 1 } goto _189 /* Opcode: SoftNull P1 * * * * ** Synopsis: r[P1]=NULL ** ** Set register P1 to have the value NULL as seen by the OP_MakeRecord ** instruction, but do not free any string or blob memory associated with ** the register, so that if the value was a string or blob that was ** previously copied using OP_SCopy, the copies will continue to be valid. */ _17: ; pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_Undefined)|libc.Int32FromInt32(MEM_AffMask)) | int32(MEM_Null)) goto _189 /* Opcode: Blob P1 P2 * P4 * ** Synopsis: r[P2]=P4 (len=P1) ** ** P4 points to a blob of data P1 bytes long. Store this ** blob in register P2. If P4 is a NULL pointer, then construct ** a zero-filled blob that is P1 bytes long in P2. */ _18: ; /* out2 */ pOut = _out2Prerelease(tls, p, pOp) if *(*uintptr)(unsafe.Pointer(pOp + 16)) == uintptr(0) { _sqlite3VdbeMemSetZeroBlob(tls, pOut, (*TOp)(unsafe.Pointer(pOp)).Fp1) if _sqlite3VdbeMemExpandBlob(tls, pOut) != 0 { goto no_mem } } else { _sqlite3VdbeMemSetStr(tls, pOut, *(*uintptr)(unsafe.Pointer(pOp + 16)), int64((*TOp)(unsafe.Pointer(pOp)).Fp1), uint8(0), uintptr(0)) } (*TMem)(unsafe.Pointer(pOut)).Fenc = encoding goto _189 /* Opcode: Variable P1 P2 * * * ** Synopsis: r[P2]=parameter(P1) ** ** Transfer the values of bound parameter P1 into register P2 */ _19: ; /* Value being transferred */ pVar = (*TVdbe)(unsafe.Pointer(p)).FaVar + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1-int32(1))*56 if _sqlite3VdbeMemTooBig(tls, pVar) != 0 { goto too_big } pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&(libc.Int32FromInt32(MEM_Agg)|libc.Int32FromInt32(MEM_Dyn)) != 0 { _sqlite3VdbeMemSetNull(tls, pOut) } libc.Xmemcpy(tls, pOut, pVar, uint64(libc.UintptrFromInt32(0)+24)) v191 = pOut + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^(libc.Int32FromInt32(MEM_Dyn) | libc.Int32FromInt32(MEM_Ephem))) v191 = pOut + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | (libc.Int32FromInt32(MEM_Static) | libc.Int32FromInt32(MEM_FromBind))) goto _189 /* Opcode: Move P1 P2 P3 * * ** Synopsis: r[P2@P3]=r[P1@P3] ** ** Move the P3 values in register P1..P1+P3-1 over into ** registers P2..P2+P3-1. Registers P1..P1+P3-1 are ** left holding a NULL. It is an error for register ranges ** P1..P1+P3-1 and P2..P2+P3-1 to overlap. It is an error ** for P3 to be less than 1. */ _20: ; /* Register to copy to */ n = (*TOp)(unsafe.Pointer(pOp)).Fp3 p1 = (*TOp)(unsafe.Pointer(pOp)).Fp1 p2 = (*TOp)(unsafe.Pointer(pOp)).Fp2 pIn1 = aMem + uintptr(p1)*56 pOut = aMem + uintptr(p2)*56 for { _sqlite3VdbeMemMove(tls, pOut, pIn1) if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Ephem) != 0 && _sqlite3VdbeMemMakeWriteable(tls, pOut) != 0 { goto no_mem } pIn1 += 56 pOut += 56 goto _197 _197: ; n = n - 1 v190 = n if !(v190 != 0) { break } } goto _189 /* Opcode: Copy P1 P2 P3 * P5 ** Synopsis: r[P2@P3+1]=r[P1@P3+1] ** ** Make a copy of registers P1..P1+P3 into registers P2..P2+P3. ** ** If the 0x0002 bit of P5 is set then also clear the MEM_Subtype flag in the ** destination. The 0x0001 bit of P5 indicates that this Copy opcode cannot ** be merged. The 0x0001 bit is used by the query planner and does not ** come into play during query execution. ** ** This instruction makes a deep copy of the value. A duplicate ** is made of any string or blob constant. See also OP_SCopy. */ _21: ; n1 = (*TOp)(unsafe.Pointer(pOp)).Fp3 pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 for int32(1) != 0 { _sqlite3VdbeMemShallowCopy(tls, pOut, pIn1, int32(MEM_Ephem)) if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Ephem) != 0 && _sqlite3VdbeMemMakeWriteable(tls, pOut) != 0 { goto no_mem } if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Subtype) != 0 && libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(0x0002) != 0 { v191 = pOut + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Subtype)) } v190 = n1 n1 = n1 - 1 if v190 == 0 { break } pOut += 56 pIn1 += 56 } goto _189 /* Opcode: SCopy P1 P2 * * * ** Synopsis: r[P2]=r[P1] ** ** Make a shallow copy of register P1 into register P2. ** ** This instruction makes a shallow copy of the value. If the value ** is a string or blob, then the copy is only a pointer to the ** original and hence if the original changes so will the copy. ** Worse, if the original is deallocated, the copy becomes invalid. ** Thus the program must guarantee that the original will not change ** during the lifetime of the copy. Use OP_Copy to make a complete ** copy. */ _22: ; /* out2 */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 _sqlite3VdbeMemShallowCopy(tls, pOut, pIn1, int32(MEM_Ephem)) goto _189 /* Opcode: IntCopy P1 P2 * * * ** Synopsis: r[P2]=r[P1] ** ** Transfer the integer value held in register P1 into register P2. ** ** This is an optimized version of SCopy that works only for integer ** values. */ _23: ; /* out2 */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 _sqlite3VdbeMemSetInt64(tls, pOut, *(*Ti64)(unsafe.Pointer(pIn1))) goto _189 /* Opcode: FkCheck * * * * * ** ** Halt with an SQLITE_CONSTRAINT error if there are any unresolved ** foreign key constraint violations. If there are no foreign key ** constraint violations, this is a no-op. ** ** FK constraint violations are also checked when the prepared statement ** exits. This opcode is used to raise foreign key constraint errors prior ** to returning results such as a row change count or the result of a ** RETURNING clause. */ _24: ; v190 = _sqlite3VdbeCheckFkImmediate(tls, p) rc = v190 if v190 != SQLITE_OK { goto abort_due_to_error } goto _189 /* Opcode: ResultRow P1 P2 * * * ** Synopsis: output=r[P1@P2] ** ** The registers P1 through P1+P2-1 contain a single row of ** results. This opcode causes the sqlite3_step() call to terminate ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt ** structure to provide access to the r(P1)..r(P1+P2-1) values as ** the result row. */ _25: ; (*TVdbe)(unsafe.Pointer(p)).FcacheCtr = (*TVdbe)(unsafe.Pointer(p)).FcacheCtr + uint32(2) | uint32(1) (*TVdbe)(unsafe.Pointer(p)).FpResultRow = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { goto no_mem } if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmTrace)&int32(SQLITE_TRACE_ROW) != 0 { (*(*func(*libc.TLS, Tu32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*Tsqlite3)(unsafe.Pointer(db)).Ftrace))})))(tls, uint32(SQLITE_TRACE_ROW), (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, p, uintptr(0)) } (*TVdbe)(unsafe.Pointer(p)).Fpc = int32((int64(pOp)-int64(aOp))/24) + int32(1) rc = int32(SQLITE_ROW) goto vdbe_return /* Opcode: Concat P1 P2 P3 * * ** Synopsis: r[P3]=r[P2]+r[P1] ** ** Add the text in register P1 onto the end of the text in ** register P2 and store the result in register P3. ** If either the P1 or P2 text are NULL then store NULL in P3. ** ** P3 = P2 || P1 ** ** It is illegal for P1 and P3 to be the same register. Sometimes, ** if P3 is the same register as P2, the implementation is able ** to avoid a memcpy(). */ _26: ; /* Initial flags for P2 */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 flags1 = (*TMem)(unsafe.Pointer(pIn1)).Fflags if (libc.Int32FromUint16(flags1)|libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags))&int32(MEM_Null) != 0 { _sqlite3VdbeMemSetNull(tls, pOut) goto _189 } if libc.Int32FromUint16(flags1)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob)) == 0 { if _sqlite3VdbeMemStringify(tls, pIn1, encoding, uint8(0)) != 0 { goto no_mem } flags1 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32FromInt32(MEM_Str)) } else { if libc.Int32FromUint16(flags1)&int32(MEM_Zero) != 0 { if _sqlite3VdbeMemExpandBlob(tls, pIn1) != 0 { goto no_mem } flags1 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32FromInt32(MEM_Str)) } } flags2 = (*TMem)(unsafe.Pointer(pIn2)).Fflags if libc.Int32FromUint16(flags2)&(libc.Int32FromInt32(MEM_Str)|libc.Int32FromInt32(MEM_Blob)) == 0 { if _sqlite3VdbeMemStringify(tls, pIn2, encoding, uint8(0)) != 0 { goto no_mem } flags2 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags) & ^libc.Int32FromInt32(MEM_Str)) } else { if libc.Int32FromUint16(flags2)&int32(MEM_Zero) != 0 { if _sqlite3VdbeMemExpandBlob(tls, pIn2) != 0 { goto no_mem } flags2 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags) & ^libc.Int32FromInt32(MEM_Str)) } } nByte = int64((*TMem)(unsafe.Pointer(pIn1)).Fn) nByte = nByte + int64((*TMem)(unsafe.Pointer(pIn2)).Fn) if nByte > int64(**(**int32)(__ccgo_up(db + 136))) { goto too_big } if _sqlite3VdbeMemGrow(tls, pOut, int32(nByte)+int32(2), libc.BoolInt32(pOut == pIn2)) != 0 { goto no_mem } (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Str)) if pOut != pIn2 { libc.Xmemcpy(tls, (*TMem)(unsafe.Pointer(pOut)).Fz, (*TMem)(unsafe.Pointer(pIn2)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pIn2)).Fn)) (*TMem)(unsafe.Pointer(pIn2)).Fflags = flags2 } libc.Xmemcpy(tls, (*TMem)(unsafe.Pointer(pOut)).Fz+uintptr((*TMem)(unsafe.Pointer(pIn2)).Fn), (*TMem)(unsafe.Pointer(pIn1)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pIn1)).Fn)) (*TMem)(unsafe.Pointer(pIn1)).Fflags = flags1 if libc.Int32FromUint8(encoding) > int32(SQLITE_UTF8) { nByte = nByte & int64(^libc.Int32FromInt32(1)) } **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pOut)).Fz + uintptr(nByte))) = uint8(0) **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pOut)).Fz + uintptr(nByte+int64(1)))) = uint8(0) v191 = pOut + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Term)) (*TMem)(unsafe.Pointer(pOut)).Fn = int32(nByte) (*TMem)(unsafe.Pointer(pOut)).Fenc = encoding goto _189 /* Opcode: Add P1 P2 P3 * * ** Synopsis: r[P3]=r[P1]+r[P2] ** ** Add the value in register P1 to the value in register P2 ** and store the result in register P3. ** If either input is NULL, the result is NULL. */ /* Opcode: Multiply P1 P2 P3 * * ** Synopsis: r[P3]=r[P1]*r[P2] ** ** ** Multiply the value in register P1 by the value in register P2 ** and store the result in register P3. ** If either input is NULL, the result is NULL. */ /* Opcode: Subtract P1 P2 P3 * * ** Synopsis: r[P3]=r[P2]-r[P1] ** ** Subtract the value in register P1 from the value in register P2 ** and store the result in register P3. ** If either input is NULL, the result is NULL. */ /* Opcode: Divide P1 P2 P3 * * ** Synopsis: r[P3]=r[P2]/r[P1] ** ** Divide the value in register P1 by the value in register P2 ** and store the result in register P3 (P3=P2/P1). If the value in ** register P1 is zero, then the result is NULL. If either input is ** NULL, the result is NULL. */ /* Opcode: Remainder P1 P2 P3 * * ** Synopsis: r[P3]=r[P2]%r[P1] ** ** Compute the remainder after integer register P2 is divided by ** register P1 and store the result in register P3. ** If the value in register P1 is zero the result is NULL. ** If either operand is NULL, the result is NULL. */ _31: ; /* same as TK_PLUS, in1, in2, out3 */ _30: ; /* same as TK_MINUS, in1, in2, out3 */ _29: ; /* same as TK_STAR, in1, in2, out3 */ _28: ; /* same as TK_SLASH, in1, in2, out3 */ _27: ; /* Real value of right operand */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 type1 = (*TMem)(unsafe.Pointer(pIn1)).Fflags pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 type2 = (*TMem)(unsafe.Pointer(pIn2)).Fflags pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 if !(libc.Int32FromUint16(type1)&libc.Int32FromUint16(type2)&int32(MEM_Int) != 0) { goto _202 } goto int_math int_math: ; iA = *(*Ti64)(unsafe.Pointer(pIn1)) **(**Ti64)(__ccgo_up(bp)) = *(*Ti64)(unsafe.Pointer(pIn2)) switch libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) { case int32(OP_Add): if _sqlite3AddInt64(tls, bp, iA) != 0 { goto fp_math } case int32(OP_Subtract): if _sqlite3SubInt64(tls, bp, iA) != 0 { goto fp_math } case int32(OP_Multiply): if _sqlite3MulInt64(tls, bp, iA) != 0 { goto fp_math } case int32(OP_Divide): if iA == 0 { goto arithmetic_result_is_null } if iA == int64(-int32(1)) && **(**Ti64)(__ccgo_up(bp)) == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<>r[P1] ** ** Shift the integer value in register P2 to the right by the ** number of bits specified by the integer in register P1. ** Store the result in register P3. ** If either input is NULL, the result is NULL. */ _36: ; /* same as TK_BITAND, in1, in2, out3 */ _35: ; /* same as TK_BITOR, in1, in2, out3 */ _34: ; /* same as TK_LSHIFT, in1, in2, out3 */ _33: ; pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 if (libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)|libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags))&int32(MEM_Null) != 0 { _sqlite3VdbeMemSetNull(tls, pOut) goto _189 } **(**Ti64)(__ccgo_up(bp + 8)) = _sqlite3VdbeIntValue(tls, pIn2) iB1 = _sqlite3VdbeIntValue(tls, pIn1) op = (*TOp)(unsafe.Pointer(pOp)).Fopcode if libc.Int32FromUint8(op) == int32(OP_BitAnd) { **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) & iB1 } else { if libc.Int32FromUint8(op) == int32(OP_BitOr) { **(**Ti64)(__ccgo_up(bp + 8)) = **(**Ti64)(__ccgo_up(bp + 8)) | iB1 } else { if iB1 != 0 { /* If shifting by a negative amount, shift in the other direction */ if iB1 < 0 { op = libc.Uint8FromInt32(libc.Int32FromInt32(2)*libc.Int32FromInt32(OP_ShiftLeft) + libc.Int32FromInt32(1) - libc.Int32FromUint8(op)) if iB1 > int64(-libc.Int32FromInt32(64)) { v206 = -iB1 } else { v206 = int64(64) } iB1 = v206 } if iB1 >= int64(64) { if **(**Ti64)(__ccgo_up(bp + 8)) >= 0 || libc.Int32FromUint8(op) == int32(OP_ShiftLeft) { v190 = 0 } else { v190 = -int32(1) } **(**Ti64)(__ccgo_up(bp + 8)) = int64(v190) } else { libc.Xmemcpy(tls, bp+16, bp+8, uint64(8)) if libc.Int32FromUint8(op) == int32(OP_ShiftLeft) { **(**Tu64)(__ccgo_up(bp + 16)) = **(**Tu64)(__ccgo_up(bp + 16)) << libc.Uint64FromInt64(iB1) } else { **(**Tu64)(__ccgo_up(bp + 16)) = **(**Tu64)(__ccgo_up(bp + 16)) >> libc.Uint64FromInt64(iB1) /* Sign-extend on a right shift of a negative number */ if **(**Ti64)(__ccgo_up(bp + 8)) < 0 { **(**Tu64)(__ccgo_up(bp + 16)) = **(**Tu64)(__ccgo_up(bp + 16)) | (libc.Uint64FromUint32(0xffffffff)< **
  • P2=='A' → BLOB **
  • P2=='B' → TEXT **
  • P2=='C' → NUMERIC **
  • P2=='D' → INTEGER **
  • P2=='E' → REAL ** ** ** A NULL value is not changed by this routine. It remains NULL. */ _40: ; /* in1 */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Zero) != 0 { v190 = _sqlite3VdbeMemExpandBlob(tls, pIn1) } else { v190 = 0 } rc = v190 if rc != 0 { goto abort_due_to_error } rc = _sqlite3VdbeMemCast(tls, pIn1, libc.Uint8FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2), encoding) if rc != 0 { goto abort_due_to_error } goto _189 /* Opcode: Eq P1 P2 P3 P4 P5 ** Synopsis: IF r[P3]==r[P1] ** ** Compare the values in register P1 and P3. If reg(P3)==reg(P1) then ** jump to address P2. ** ** The SQLITE_AFF_MASK portion of P5 must be an affinity character - ** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made ** to coerce both inputs according to this affinity before the ** comparison is made. If the SQLITE_AFF_MASK is 0x00, then numeric ** affinity is used. Note that the affinity conversions are stored ** back into the input registers P1 and P3. So this opcode can cause ** persistent changes to registers P1 and P3. ** ** Once any conversions have taken place, and neither value is NULL, ** the values are compared. If both values are blobs then memcmp() is ** used to determine the results of the comparison. If both values ** are text, then the appropriate collating function specified in ** P4 is used to do the comparison. If P4 is not specified then ** memcmp() is used to compare text string. If both values are ** numeric, then a numeric comparison is used. If the two values ** are of different types, then numbers are considered less than ** strings and strings are considered less than blobs. ** ** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either ** true or false and is never NULL. If both operands are NULL then the result ** of comparison is true. If either operand is NULL then the result is false. ** If neither operand is NULL the result is the same as it would be if ** the SQLITE_NULLEQ flag were omitted from P5. ** ** This opcode saves the result of comparison for use by the new ** OP_Jump opcode. */ /* Opcode: Ne P1 P2 P3 P4 P5 ** Synopsis: IF r[P3]!=r[P1] ** ** This works just like the Eq opcode except that the jump is taken if ** the operands in registers P1 and P3 are not equal. See the Eq opcode for ** additional information. */ /* Opcode: Lt P1 P2 P3 P4 P5 ** Synopsis: IF r[P3]r[P1] ** ** This works just like the Lt opcode except that the jump is taken if ** the content of register P3 is greater than the content of ** register P1. See the Lt opcode for additional information. */ /* Opcode: Ge P1 P2 P3 P4 P5 ** Synopsis: IF r[P3]>=r[P1] ** ** This works just like the Lt opcode except that the jump is taken if ** the content of register P3 is greater than or equal to the content of ** register P1. See the Lt opcode for additional information. */ _46: ; /* same as TK_EQ, jump, in1, in3 */ _45: ; /* same as TK_NE, jump, in1, in3 */ _44: ; /* same as TK_LT, jump, in1, in3 */ _43: ; /* same as TK_LE, jump, in1, in3 */ _42: ; /* same as TK_GT, jump, in1, in3 */ _41: ; /* Copy of initial value of pIn3->flags */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 flags11 = (*TMem)(unsafe.Pointer(pIn1)).Fflags flags3 = (*TMem)(unsafe.Pointer(pIn3)).Fflags if libc.Int32FromUint16(flags11)&libc.Int32FromUint16(flags3)&int32(MEM_Int) != 0 { /* Common case of comparison of two integers */ if *(*Ti64)(unsafe.Pointer(pIn3)) > *(*Ti64)(unsafe.Pointer(pIn1)) { if **(**uint8)(__ccgo_up(_sqlite3aGTb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode))) != 0 { goto jump_to_p2 } iCompare = +libc.Int32FromInt32(1) } else { if *(*Ti64)(unsafe.Pointer(pIn3)) < *(*Ti64)(unsafe.Pointer(pIn1)) { if **(**uint8)(__ccgo_up(_sqlite3aLTb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode))) != 0 { goto jump_to_p2 } iCompare = -int32(1) } else { if **(**uint8)(__ccgo_up(_sqlite3aEQb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode))) != 0 { goto jump_to_p2 } iCompare = 0 } } goto _189 } if (libc.Int32FromUint16(flags11)|libc.Int32FromUint16(flags3))&int32(MEM_Null) != 0 { /* One or both operands are NULL */ if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(SQLITE_NULLEQ) != 0 { /* If SQLITE_NULLEQ is set (which will only happen if the operator is ** OP_Eq or OP_Ne) then take the jump or not depending on whether ** or not both operands are null. */ if libc.Int32FromUint16(flags11)&libc.Int32FromUint16(flags3)&int32(MEM_Null) != 0 && libc.Int32FromUint16(flags3)&int32(MEM_Cleared) == 0 { res = 0 /* Operands are equal */ } else { if libc.Int32FromUint16(flags3)&int32(MEM_Null) != 0 { v190 = -int32(1) } else { v190 = +libc.Int32FromInt32(1) } res = v190 /* Operands are not equal */ } } else { /* SQLITE_NULLEQ is clear and at least one operand is NULL, ** then the result is always NULL. ** The jump is taken if the SQLITE_JUMPIFNULL bit is set. */ if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(SQLITE_JUMPIFNULL) != 0 { goto jump_to_p2 } iCompare = int32(1) /* Operands are not equal */ goto _189 } } else { /* Neither operand is NULL and we couldn't do the special high-speed ** integer comparison case. So do a general-case comparison. */ affinity = libc.Uint8FromInt32(libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) & int32(SQLITE_AFF_MASK)) if libc.Int32FromUint8(affinity) >= int32(SQLITE_AFF_NUMERIC) { if (libc.Int32FromUint16(flags11)|libc.Int32FromUint16(flags3))&int32(MEM_Str) != 0 { if libc.Int32FromUint16(flags11)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_Str)) == int32(MEM_Str) { _applyNumericAffinity(tls, pIn1, 0) flags3 = (*TMem)(unsafe.Pointer(pIn3)).Fflags } if libc.Int32FromUint16(flags3)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_Str)) == int32(MEM_Str) { _applyNumericAffinity(tls, pIn3, 0) } } } else { if libc.Int32FromUint8(affinity) == int32(SQLITE_AFF_TEXT) && (libc.Int32FromUint16(flags11)|libc.Int32FromUint16(flags3))&int32(MEM_Str) != 0 { if libc.Int32FromUint16(flags11)&int32(MEM_Str) != 0 { v191 = pIn1 + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^(libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_Real) | libc.Int32FromInt32(MEM_IntReal))) } else { if libc.Int32FromUint16(flags11)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)) != 0 { _sqlite3VdbeMemStringify(tls, pIn1, encoding, uint8(1)) flags11 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags) & ^libc.Int32FromInt32(MEM_TypeMask) | libc.Int32FromUint16(flags11)&int32(MEM_TypeMask)) if pIn1 == pIn3 { flags3 = libc.Uint16FromInt32(libc.Int32FromUint16(flags11) | int32(MEM_Str)) } } } if libc.Int32FromUint16(flags3)&int32(MEM_Str) != 0 { v191 = pIn3 + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^(libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_Real) | libc.Int32FromInt32(MEM_IntReal))) } else { if libc.Int32FromUint16(flags3)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)) != 0 { _sqlite3VdbeMemStringify(tls, pIn3, encoding, uint8(1)) flags3 = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn3)).Fflags) & ^libc.Int32FromInt32(MEM_TypeMask) | libc.Int32FromUint16(flags3)&int32(MEM_TypeMask)) } } } } res = _sqlite3MemCompare(tls, pIn3, pIn1, *(*uintptr)(unsafe.Pointer(pOp + 16))) } /* At this point, res is negative, zero, or positive if reg[P1] is ** less than, equal to, or greater than reg[P3], respectively. Compute ** the answer to this operator in res2, depending on what the comparison ** operator actually is. The next block of code depends on the fact ** that the 6 comparison operators are consecutive integers in this ** order: NE, EQ, GT, LE, LT, GE */ if res < 0 { res21 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(_sqlite3aLTb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode)))) } else { if res == 0 { res21 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(_sqlite3aEQb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode)))) } else { res21 = libc.Int32FromUint8(**(**uint8)(__ccgo_up(_sqlite3aGTb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fopcode)))) } } iCompare = res /* Undo any changes made by applyAffinity() to the input registers. */ (*TMem)(unsafe.Pointer(pIn3)).Fflags = flags3 (*TMem)(unsafe.Pointer(pIn1)).Fflags = flags11 if res21 != 0 { goto jump_to_p2 } goto _189 /* Opcode: ElseEq * P2 * * * ** ** This opcode must follow an OP_Lt or OP_Gt comparison operator. There ** can be zero or more OP_ReleaseReg opcodes intervening, but no other ** opcodes are allowed to occur between this instruction and the previous ** OP_Lt or OP_Gt. ** ** If the result of an OP_Eq comparison on the same two operands as ** the prior OP_Lt or OP_Gt would have been true, then jump to P2. If ** the result of an OP_Eq comparison on the two previous operands ** would have been false or NULL, then fall through. */ _47: ; /* same as TK_ESCAPE, jump */ if iCompare == 0 { goto jump_to_p2 } goto _189 /* Opcode: Permutation * * * P4 * ** ** Set the permutation used by the OP_Compare operator in the next ** instruction. The permutation is stored in the P4 operand. ** ** The permutation is only valid for the next opcode which must be ** an OP_Compare that has the OPFLAG_PERMUTE bit set in P5. ** ** The first integer in the P4 integer array is the length of the array ** and does not become part of the permutation. */ _48: ; goto _189 /* Opcode: Compare P1 P2 P3 P4 P5 ** Synopsis: r[P1@P3] <-> r[P2@P3] ** ** Compare two vectors of registers in reg(P1)..reg(P1+P3-1) (call this ** vector "A") and in reg(P2)..reg(P2+P3-1) ("B"). Save the result of ** the comparison for use by the next OP_Jump instruct. ** ** If P5 has the OPFLAG_PERMUTE bit set, then the order of comparison is ** determined by the most recent OP_Permutation operator. If the ** OPFLAG_PERMUTE bit is clear, then register are compared in sequential ** order. ** ** P4 is a KeyInfo structure that defines collating sequences and sort ** orders for the comparison. The permutation applies to registers ** only. The KeyInfo elements are used sequentially. ** ** The comparison is a sort comparison, so NULLs compare equal, ** NULLs are less than numbers, numbers are less than strings, ** and strings are less than blobs. ** ** This opcode must be immediately followed by an OP_Jump opcode. */ _49: ; /* The permutation */ if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_PERMUTE) == 0 { aPermute = uintptr(0) } else { aPermute = *(*uintptr)(unsafe.Pointer(pOp + uintptr(-libc.Int32FromInt32(1))*24 + 16)) + uintptr(1)*4 } n2 = (*TOp)(unsafe.Pointer(pOp)).Fp3 pKeyInfo = *(*uintptr)(unsafe.Pointer(pOp + 16)) p11 = (*TOp)(unsafe.Pointer(pOp)).Fp1 p21 = (*TOp)(unsafe.Pointer(pOp)).Fp2 i = 0 for { if !(i < n2) { break } if aPermute != 0 { v213 = **(**Tu32)(__ccgo_up(aPermute + uintptr(i)*4)) } else { v213 = libc.Uint32FromInt32(i) } idx = v213 pColl = *(*uintptr)(unsafe.Pointer(pKeyInfo + 32 + uintptr(i)*8)) bRev = libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i)))) & int32(KEYINFO_ORDER_DESC) iCompare = _sqlite3MemCompare(tls, aMem+uintptr(libc.Uint32FromInt32(p11)+idx)*56, aMem+uintptr(libc.Uint32FromInt32(p21)+idx)*56, pColl) if iCompare != 0 { if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TKeyInfo)(unsafe.Pointer(pKeyInfo)).FaSortFlags + uintptr(i))))&int32(KEYINFO_ORDER_BIGNULL) != 0 && (libc.Int32FromUint16((**(**TMem)(__ccgo_up(aMem + uintptr(libc.Uint32FromInt32(p11)+idx)*56))).Fflags)&int32(MEM_Null) != 0 || libc.Int32FromUint16((**(**TMem)(__ccgo_up(aMem + uintptr(libc.Uint32FromInt32(p21)+idx)*56))).Fflags)&int32(MEM_Null) != 0) { iCompare = -iCompare } if bRev != 0 { iCompare = -iCompare } break } goto _212 _212: ; i = i + 1 } goto _189 /* Opcode: Jump P1 P2 P3 * * ** ** Jump to the instruction at address P1, P2, or P3 depending on whether ** in the most recent OP_Compare instruction the P1 vector was less than, ** equal to, or greater than the P2 vector, respectively. ** ** This opcode must immediately follow an OP_Compare opcode. */ _50: ; /* jump */ if iCompare < 0 { pOp = aOp + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1-int32(1))*24 } else { if iCompare == 0 { pOp = aOp + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2-int32(1))*24 } else { pOp = aOp + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3-int32(1))*24 } } goto _189 /* Opcode: And P1 P2 P3 * * ** Synopsis: r[P3]=(r[P1] && r[P2]) ** ** Take the logical AND of the values in registers P1 and P2 and ** write the result into register P3. ** ** If either P1 or P2 is 0 (false) then the result is 0 even if ** the other input is NULL. A NULL and true or two NULLs give ** a NULL output. */ /* Opcode: Or P1 P2 P3 * * ** Synopsis: r[P3]=(r[P1] || r[P2]) ** ** Take the logical OR of the values in register P1 and P2 and ** store the answer in register P3. ** ** If either P1 or P2 is nonzero (true) then the result is 1 (true) ** even if the other input is NULL. A NULL and false or two NULLs ** give a NULL output. */ _52: ; /* same as TK_AND, in1, in2, out3 */ _51: ; /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */ v11 = _sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56, int32(2)) v21 = _sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56, int32(2)) if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_And) { v11 = libc.Int32FromUint8(_and_logic[v11*int32(3)+v21]) } else { v11 = libc.Int32FromUint8(_or_logic[v11*int32(3)+v21]) } pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 if v11 == int32(2) { (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Null)) } else { *(*Ti64)(unsafe.Pointer(pOut)) = int64(v11) (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Int)) } goto _189 /* Opcode: IsTrue P1 P2 P3 P4 * ** Synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 ** ** This opcode implements the IS TRUE, IS FALSE, IS NOT TRUE, and ** IS NOT FALSE operators. ** ** Interpret the value in register P1 as a boolean value. Store that ** boolean (a 0 or 1) in register P2. Or if the value in register P1 is ** NULL, then the P3 is stored in register P2. Invert the answer if P4 ** is 1. ** ** The logic is summarized like this: ** **
      **
    • If P3==0 and P4==0 then r[P2] := r[P1] IS TRUE **
    • If P3==1 and P4==1 then r[P2] := r[P1] IS FALSE **
    • If P3==0 and P4==1 then r[P2] := r[P1] IS NOT TRUE **
    • If P3==1 and P4==0 then r[P2] := r[P1] IS NOT FALSE **
    */ _53: ; /* in1, out2 */ _sqlite3VdbeMemSetInt64(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56, int64(_sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56, (*TOp)(unsafe.Pointer(pOp)).Fp3)^(*TOp)(unsafe.Pointer(pOp)).Fp4.Fi)) goto _189 /* Opcode: Not P1 P2 * * * ** Synopsis: r[P2]= !r[P1] ** ** Interpret the value in register P1 as a boolean value. Store the ** boolean complement in register P2. If the value in register P1 is ** NULL, then a NULL is stored in P2. */ _54: ; /* same as TK_NOT, in1, out2 */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) == 0 { _sqlite3VdbeMemSetInt64(tls, pOut, libc.BoolInt64(!(_sqlite3VdbeBooleanValue(tls, pIn1, 0) != 0))) } else { _sqlite3VdbeMemSetNull(tls, pOut) } goto _189 /* Opcode: BitNot P1 P2 * * * ** Synopsis: r[P2]= ~r[P1] ** ** Interpret the content of register P1 as an integer. Store the ** ones-complement of the P1 value into register P2. If P1 holds ** a NULL then store a NULL in P2. */ _55: ; /* same as TK_BITNOT, in1, out2 */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 _sqlite3VdbeMemSetNull(tls, pOut) if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) == 0 { (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Int) *(*Ti64)(unsafe.Pointer(pOut)) = ^_sqlite3VdbeIntValue(tls, pIn1) } goto _189 /* Opcode: Once P1 P2 P3 * * ** ** Fall through to the next instruction the first time this opcode is ** encountered on each invocation of the byte-code program. Jump to P2 ** on the second and all subsequent encounters during the same invocation. ** ** Top-level programs determine first invocation by comparing the P1 ** operand against the P1 operand on the OP_Init opcode at the beginning ** of the program. If the P1 values differ, then fall through and make ** the P1 of this opcode equal to the P1 of OP_Init. If P1 values are ** the same then take the jump. ** ** For subprograms, there is a bitmask in the VdbeFrame that determines ** whether or not the jump should be taken. The bitmask is necessary ** because the self-altering code trick does not work for recursive ** triggers. ** ** The P3 operand is not used directly by this opcode. However P3 is ** used by the code generator as follows: If this opcode is the start ** of a subroutine and that subroutine uses a Bloom filter, then P3 will ** be the register that holds that Bloom filter. See tag-202407032019 ** in the source code for implementation details. */ _56: ; /* Address of this instruction */ if (*TVdbe)(unsafe.Pointer(p)).FpFrame != 0 { iAddr = libc.Uint32FromInt32(int32((int64(pOp) - int64((*TVdbe)(unsafe.Pointer(p)).FaOp)) / 24)) if libc.Int32FromUint8(**(**Tu8)(__ccgo_up((*TVdbeFrame)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).FpFrame)).FaOnce + uintptr(iAddr/uint32(8)))))&(int32(1)<<(iAddr&uint32(7))) != 0 { goto jump_to_p2 } v191 = (*TVdbeFrame)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).FpFrame)).FaOnce + uintptr(iAddr/uint32(8)) *(*Tu8)(unsafe.Pointer(v191)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v191))) | libc.Int32FromInt32(1)<<(iAddr&libc.Uint32FromInt32(7))) } else { if (**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp))).Fp1 == (*TOp)(unsafe.Pointer(pOp)).Fp1 { goto jump_to_p2 } } (*TOp)(unsafe.Pointer(pOp)).Fp1 = (**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp))).Fp1 goto _189 /* Opcode: If P1 P2 P3 * * ** ** Jump to P2 if the value in register P1 is true. The value ** is considered true if it is numeric and non-zero. If the value ** in P1 is NULL then take the jump if and only if P3 is non-zero. */ _57: ; c = _sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56, (*TOp)(unsafe.Pointer(pOp)).Fp3) if c != 0 { goto jump_to_p2 } goto _189 /* Opcode: IfNot P1 P2 P3 * * ** ** Jump to P2 if the value in register P1 is False. The value ** is considered false if it has a numeric value of zero. If the value ** in P1 is NULL then take the jump if and only if P3 is non-zero. */ _58: ; c1 = libc.BoolInt32(!(_sqlite3VdbeBooleanValue(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56, libc.BoolInt32(!((*TOp)(unsafe.Pointer(pOp)).Fp3 != 0))) != 0)) if c1 != 0 { goto jump_to_p2 } goto _189 /* Opcode: IsNull P1 P2 * * * ** Synopsis: if r[P1]==NULL goto P2 ** ** Jump to P2 if the value in register P1 is NULL. */ _59: ; /* same as TK_ISNULL, jump, in1 */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) != 0 { goto jump_to_p2 } goto _189 /* Opcode: IsType P1 P2 P3 P4 P5 ** Synopsis: if typeof(P1.P3) in P5 goto P2 ** ** Jump to P2 if the type of a column in a btree is one of the types specified ** by the P5 bitmask. ** ** P1 is normally a cursor on a btree for which the row decode cache is ** valid through at least column P3. In other words, there should have been ** a prior OP_Column for column P3 or greater. If the cursor is not valid, ** then this opcode might give spurious results. ** The the btree row has fewer than P3 columns, then use P4 as the ** datatype. ** ** If P1 is -1, then P3 is a register number and the datatype is taken ** from the value in that register. ** ** P5 is a bitmask of data types. SQLITE_INTEGER is the least significant ** (0x01) bit. SQLITE_FLOAT is the 0x02 bit. SQLITE_TEXT is 0x04. ** SQLITE_BLOB is 0x08. SQLITE_NULL is 0x10. ** ** WARNING: This opcode does not reliably distinguish between NULL and REAL ** when P1>=0. If the database contains a NaN value, this opcode will think ** that the datatype is REAL when it should be NULL. When P1<0 and the value ** is already stored in register P3, then this opcode does reliably ** distinguish between NULL and REAL. The problem only arises then P1>=0. ** ** Take the jump to address P2 if and only if the datatype of the ** value determined by P1 and P3 corresponds to one of the bits in the ** P5 bitmask. ** */ _60: ; if (*TOp)(unsafe.Pointer(pOp)).Fp1 >= 0 { pC = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) if (*TOp)(unsafe.Pointer(pOp)).Fp3 < libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC)).FnHdrParsed) { serialType = *(*Tu32)(unsafe.Pointer(pC + 120 + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*4)) if serialType >= uint32(12) { if serialType&uint32(1) != 0 { typeMask = uint16(0x04) /* SQLITE_TEXT */ } else { typeMask = uint16(0x08) /* SQLITE_BLOB */ } } else { typeMask = uint16(_aMask[serialType]) } } else { typeMask = libc.Uint16FromInt32(int32(1) << ((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi - int32(1))) } } else { typeMask = libc.Uint16FromInt32(int32(1) << (Xsqlite3_value_type(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56) - int32(1))) } if libc.Int32FromUint16(typeMask)&libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) != 0 { goto jump_to_p2 } goto _189 /* Opcode: ZeroOrNull P1 P2 P3 * * ** Synopsis: r[P2] = 0 OR NULL ** ** If both registers P1 and P3 are NOT NULL, then store a zero in ** register P2. If either registers P1 or P3 are NULL then put ** a NULL in register P2. */ _61: ; /* in1, in2, out2, in3 */ if libc.Int32FromUint16((**(**TMem)(__ccgo_up(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56))).Fflags)&int32(MEM_Null) != 0 || libc.Int32FromUint16((**(**TMem)(__ccgo_up(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56))).Fflags)&int32(MEM_Null) != 0 { _sqlite3VdbeMemSetNull(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56) } else { _sqlite3VdbeMemSetInt64(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56, 0) } goto _189 /* Opcode: NotNull P1 P2 * * * ** Synopsis: if r[P1]!=NULL goto P2 ** ** Jump to P2 if the value in register P1 is not NULL. */ _62: ; /* same as TK_NOTNULL, jump, in1 */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) == 0 { goto jump_to_p2 } goto _189 /* Opcode: IfNullRow P1 P2 P3 * * ** Synopsis: if P1.nullRow then r[P3]=NULL, goto P2 ** ** Check the cursor P1 to see if it is currently pointing at a NULL row. ** If it is, then set register P3 to NULL and jump immediately to P2. ** If P1 is not on a NULL row, then fall through without making any ** changes. ** ** If P1 is not an open cursor, then this opcode is a no-op. */ _63: ; pC1 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) if pC1 != 0 && (*TVdbeCursor)(unsafe.Pointer(pC1)).FnullRow != 0 { _sqlite3VdbeMemSetNull(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56) goto jump_to_p2 } goto _189 /* Opcode: Offset P1 P2 P3 * * ** Synopsis: r[P3] = sqlite_offset(P1) ** ** Store in register r[P3] the byte offset into the database file that is the ** start of the payload for the record at which that cursor P1 is currently ** pointing. ** ** P2 is the column number for the argument to the sqlite_offset() function. ** This opcode does not use P2 itself, but the P2 value is used by the ** code generator. The P1, P2, and P3 operands to this opcode are the ** same as for OP_Column. ** ** This opcode is only available if SQLite is compiled with the ** -DSQLITE_ENABLE_OFFSET_SQL_FUNC option. */ _64: ; /* The VDBE cursor */ pC2 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) pOut = (*TVdbe)(unsafe.Pointer(p)).FaMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 if pC2 == uintptr(0) || libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC2)).FeCurType) != CURTYPE_BTREE { _sqlite3VdbeMemSetNull(tls, pOut) } else { if (*TVdbeCursor)(unsafe.Pointer(pC2)).FdeferredMoveto != 0 { rc = _sqlite3VdbeFinishMoveto(tls, pC2) if rc != 0 { goto abort_due_to_error } } if _sqlite3BtreeEof(tls, *(*uintptr)(unsafe.Pointer(pC2 + 48))) != 0 { _sqlite3VdbeMemSetNull(tls, pOut) } else { _sqlite3VdbeMemSetInt64(tls, pOut, _sqlite3BtreeOffset(tls, *(*uintptr)(unsafe.Pointer(pC2 + 48)))) } } goto _189 /* Opcode: Column P1 P2 P3 P4 P5 ** Synopsis: r[P3]=PX cursor P1 column P2 ** ** Interpret the data that cursor P1 points to as a structure built using ** the MakeRecord instruction. (See the MakeRecord opcode for additional ** information about the format of the data.) Extract the P2-th column ** from this record. If there are less than (P2+1) ** values in the record, extract a NULL. ** ** The value extracted is stored in register P3. ** ** If the record contains fewer than P2 fields, then extract a NULL. Or, ** if the P4 argument is a P4_MEM use the value of the P4 argument as ** the result. ** ** If the OPFLAG_LENGTHARG bit is set in P5 then the result is guaranteed ** to only be used by the length() function or the equivalent. The content ** of large blobs is not loaded, thus saving CPU cycles. If the ** OPFLAG_TYPEOFARG bit is set then the result will only be used by the ** typeof() function or the IS NULL or IS NOT NULL operators or the ** equivalent. In this case, all content loading can be omitted. */ _65: ; /* PseudoTable input register */ pC3 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) p22 = libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2) goto op_column_restart op_column_restart: ; aOffset = (*TVdbeCursor)(unsafe.Pointer(pC3)).FaOffset if (*TVdbeCursor)(unsafe.Pointer(pC3)).FcacheStatus != (*TVdbe)(unsafe.Pointer(p)).FcacheCtr { /*OPTIMIZATION-IF-FALSE*/ if (*TVdbeCursor)(unsafe.Pointer(pC3)).FnullRow != 0 { if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC3)).FeCurType) == int32(CURTYPE_PSEUDO) && (*TVdbeCursor)(unsafe.Pointer(pC3)).FseekResult > 0 { /* For the special case of as pseudo-cursor, the seekResult field ** identifies the register that holds the record */ pReg = aMem + uintptr((*TVdbeCursor)(unsafe.Pointer(pC3)).FseekResult)*56 v215 = libc.Uint32FromInt32((*TMem)(unsafe.Pointer(pReg)).Fn) (*TVdbeCursor)(unsafe.Pointer(pC3)).FszRow = v215 (*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize = v215 (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow = (*TMem)(unsafe.Pointer(pReg)).Fz } else { pDest = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 _sqlite3VdbeMemSetNull(tls, pDest) goto op_column_out } } else { pCrsr = *(*uintptr)(unsafe.Pointer(pC3 + 48)) if (*TVdbeCursor)(unsafe.Pointer(pC3)).FdeferredMoveto != 0 { if v217 = *(*uintptr)(unsafe.Pointer(pC3 + 16)) != 0; v217 { v215 = **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(pC3 + 16)) + uintptr(uint32(1)+p22)*4)) iMap = v215 } if v217 && v215 > uint32(0) { pC3 = (*TVdbeCursor)(unsafe.Pointer(pC3)).FpAltCursor p22 = iMap - uint32(1) goto op_column_restart } rc = _sqlite3VdbeFinishMoveto(tls, pC3) if rc != 0 { goto abort_due_to_error } } else { if _sqlite3BtreeCursorHasMoved(tls, pCrsr) != 0 { rc = _sqlite3VdbeHandleMovedCursor(tls, pC3) if rc != 0 { goto abort_due_to_error } goto op_column_restart } } (*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize = _sqlite3BtreePayloadSize(tls, pCrsr) (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow = _sqlite3BtreePayloadFetch(tls, pCrsr, pC3+108) /* Maximum page size is 64KiB */ } (*TVdbeCursor)(unsafe.Pointer(pC3)).FcacheStatus = (*TVdbe)(unsafe.Pointer(p)).FcacheCtr v215 = uint32(**(**Tu8)(__ccgo_up((*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow))) **(**Tu32)(__ccgo_up(aOffset)) = v215 if v215 < uint32(0x80) { (*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset = uint32(1) } else { (*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset = uint32(_sqlite3GetVarint32(tls, (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow, aOffset)) } (*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed = uint16(0) if (*TVdbeCursor)(unsafe.Pointer(pC3)).FszRow < **(**Tu32)(__ccgo_up(aOffset)) { /*OPTIMIZATION-IF-FALSE*/ /* pC->aRow does not have to hold the entire row, but it does at least ** need to cover the header of the record. If pC->aRow does not contain ** the complete header, then set it to zero, forcing the header to be ** dynamically allocated. */ (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow = uintptr(0) (*TVdbeCursor)(unsafe.Pointer(pC3)).FszRow = uint32(0) /* Make sure a corrupt database has not given us an oversize header. ** Do this now to avoid an oversize memory allocation. ** ** Type entries can be between 1 and 5 bytes each. But 4 and 5 byte ** types use so much data space that there can only be 4096 and 32 of ** them, respectively. So the maximum header length results from a ** 3-byte type for each of the maximum of 32768 columns plus three ** extra bytes for the header length itself. 32768*3 + 3 = 98307. */ if **(**Tu32)(__ccgo_up(aOffset)) > uint32(98307) || **(**Tu32)(__ccgo_up(aOffset)) > (*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize { goto op_column_corrupt } } else { /* This is an optimization. By skipping over the first few tests ** (ex: pC->nHdrParsed<=p2) in the next section, we achieve a ** measurable performance gain. ** ** This branch is taken even if aOffset[0]==0. Such a record is never ** generated by SQLite, and could be considered corruption, but we ** accept it for historical reasons. When aOffset[0]==0, the code this ** branch jumps to reads past the end of the record, but never more ** than a few bytes. Even if the record occurs at the end of the page ** content area, the "page header" comes after the page content and so ** this overread is harmless. Similar overreads can occur for a corrupt ** database file. */ zData = (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow /* Conditional skipped */ goto op_column_read_header } } else { if _sqlite3BtreeCursorHasMoved(tls, *(*uintptr)(unsafe.Pointer(pC3 + 48))) != 0 { rc = _sqlite3VdbeHandleMovedCursor(tls, pC3) if rc != 0 { goto abort_due_to_error } goto op_column_restart } } /* Make sure at least the first p2+1 entries of the header have been ** parsed and valid information is in aOffset[] and pC->aType[]. */ if !(uint32((*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed) <= p22) { goto _219 } /* If there is more header available for parsing in the record, try ** to extract additional fields up through the p2+1-th field */ if !((*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset < **(**Tu32)(__ccgo_up(aOffset))) { goto _221 } /* Make sure zData points to enough of the record to cover the header. */ if (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow == uintptr(0) { libc.Xmemset(tls, bp+24, 0, uint64(56)) rc = _sqlite3VdbeMemFromBtreeZeroOffset(tls, *(*uintptr)(unsafe.Pointer(pC3 + 48)), **(**Tu32)(__ccgo_up(aOffset)), bp+24) if rc != SQLITE_OK { goto abort_due_to_error } zData = (**(**TMem)(__ccgo_up(bp + 24))).Fz } else { zData = (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow } /* Fill in pC->aType[i] and aOffset[i] values through the p2-th field. */ goto op_column_read_header op_column_read_header: ; i1 = libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed) offset64 = uint64(**(**Tu32)(__ccgo_up(aOffset + uintptr(i1)*4))) zHdr = zData + uintptr((*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset) zEndHdr = zData + uintptr(**(**Tu32)(__ccgo_up(aOffset))) for cond := true; cond; cond = libc.Uint32FromInt32(i1) <= p22 && zHdr < zEndHdr { v216 = uint32(**(**Tu8)(__ccgo_up(zHdr))) **(**Tu32)(__ccgo_up(bp + 80)) = v216 v215 = v216 *(*Tu32)(unsafe.Pointer(pC3 + 120 + uintptr(i1)*4)) = v215 if v215 < uint32(0x80) { zHdr = zHdr + 1 offset64 = offset64 + uint64(_sqlite3VdbeOneByteSerialTypeLen(tls, uint8(**(**Tu32)(__ccgo_up(bp + 80))))) } else { zHdr = zHdr + uintptr(_sqlite3GetVarint32(tls, zHdr, bp+80)) *(*Tu32)(unsafe.Pointer(pC3 + 120 + uintptr(i1)*4)) = **(**Tu32)(__ccgo_up(bp + 80)) offset64 = offset64 + uint64(_sqlite3VdbeSerialTypeLen(tls, **(**Tu32)(__ccgo_up(bp + 80)))) } i1 = i1 + 1 v190 = i1 **(**Tu32)(__ccgo_up(aOffset + uintptr(v190)*4)) = uint32(offset64 & libc.Uint64FromUint32(0xffffffff)) } /* The record is corrupt if any of the following are true: ** (1) the bytes of the header extend past the declared header size ** (2) the entire header was used but not all data was used ** (3) the end of the data extends beyond the end of the record. */ if zHdr >= zEndHdr && (zHdr > zEndHdr || offset64 != uint64((*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize)) || offset64 > uint64((*TVdbeCursor)(unsafe.Pointer(pC3)).FpayloadSize) { if **(**Tu32)(__ccgo_up(aOffset)) == uint32(0) { i1 = 0 zHdr = zEndHdr } else { if (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow == uintptr(0) { _sqlite3VdbeMemRelease(tls, bp+24) } goto op_column_corrupt } } (*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed = libc.Uint16FromInt32(i1) (*TVdbeCursor)(unsafe.Pointer(pC3)).FiHdrOffset = libc.Uint32FromInt64(int64(zHdr) - int64(zData)) if (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow == uintptr(0) { _sqlite3VdbeMemRelease(tls, bp+24) } goto _222 _221: ; **(**Tu32)(__ccgo_up(bp + 80)) = uint32(0) _222: ; /* If after trying to extract new entries from the header, nHdrParsed is ** still not up to p2, that means that the record has fewer than p2 ** columns. So the result will be either the default value or a NULL. */ if uint32((*TVdbeCursor)(unsafe.Pointer(pC3)).FnHdrParsed) <= p22 { pDest = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == -int32(11) { _sqlite3VdbeMemShallowCopy(tls, pDest, *(*uintptr)(unsafe.Pointer(pOp + 16)), int32(MEM_Static)) } else { _sqlite3VdbeMemSetNull(tls, pDest) } goto op_column_out } goto _220 _219: ; **(**Tu32)(__ccgo_up(bp + 80)) = *(*Tu32)(unsafe.Pointer(pC3 + 120 + uintptr(p22)*4)) _220: ; /* Extract the content for the p2+1-th column. Control can only ** reach this point if aOffset[p2], aOffset[p2+1], and pC->aType[p2] are ** all valid. */ pDest = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pDest)).Fflags)&(libc.Int32FromInt32(MEM_Agg)|libc.Int32FromInt32(MEM_Dyn)) != 0 { _sqlite3VdbeMemSetNull(tls, pDest) } if (*TVdbeCursor)(unsafe.Pointer(pC3)).FszRow >= **(**Tu32)(__ccgo_up(aOffset + uintptr(p22+uint32(1))*4)) { /* This is the common case where the desired content fits on the original ** page - where the content is not on an overflow page */ zData = (*TVdbeCursor)(unsafe.Pointer(pC3)).FaRow + uintptr(**(**Tu32)(__ccgo_up(aOffset + uintptr(p22)*4))) if **(**Tu32)(__ccgo_up(bp + 80)) < uint32(12) { _sqlite3VdbeSerialGet(tls, zData, **(**Tu32)(__ccgo_up(bp + 80)), pDest) } else { v190 = libc.Int32FromUint32((**(**Tu32)(__ccgo_up(bp + 80)) - libc.Uint32FromInt32(12)) / libc.Uint32FromInt32(2)) len1 = v190 (*TMem)(unsafe.Pointer(pDest)).Fn = v190 (*TMem)(unsafe.Pointer(pDest)).Fenc = encoding if (*TMem)(unsafe.Pointer(pDest)).FszMalloc < len1+int32(2) { if len1 > **(**int32)(__ccgo_up(db + 136)) { goto too_big } (*TMem)(unsafe.Pointer(pDest)).Fflags = uint16(MEM_Null) if _sqlite3VdbeMemGrow(tls, pDest, len1+int32(2), 0) != 0 { goto no_mem } } else { (*TMem)(unsafe.Pointer(pDest)).Fz = (*TMem)(unsafe.Pointer(pDest)).FzMalloc } libc.Xmemcpy(tls, (*TMem)(unsafe.Pointer(pDest)).Fz, zData, libc.Uint64FromInt32(len1)) **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pDest)).Fz + uintptr(len1))) = uint8(0) **(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pDest)).Fz + uintptr(len1+int32(1)))) = uint8(0) (*TMem)(unsafe.Pointer(pDest)).Fflags = _aFlag1[**(**Tu32)(__ccgo_up(bp + 80))&uint32(1)] } } else { (*TMem)(unsafe.Pointer(pDest)).Fenc = encoding /* This branch happens only when content is on overflow pages */ v227 = libc.Uint8FromInt32(libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) & libc.Int32FromInt32(OPFLAG_BYTELENARG)) p5 = v227 if libc.Int32FromUint8(v227) != 0 && (libc.Int32FromUint8(p5) == int32(OPFLAG_TYPEOFARG) || **(**Tu32)(__ccgo_up(bp + 80)) >= uint32(12) && (**(**Tu32)(__ccgo_up(bp + 80))&uint32(1) == uint32(0) || libc.Int32FromUint8(p5) == int32(OPFLAG_BYTELENARG))) || _sqlite3VdbeSerialTypeLen(tls, **(**Tu32)(__ccgo_up(bp + 80))) == uint32(0) { /* Content is irrelevant for ** 1. the typeof() function, ** 2. the length(X) function if X is a blob, and ** 3. if the content length is zero. ** So we might as well use bogus content rather than reading ** content from disk. ** ** Although sqlite3VdbeSerialGet() may read at most 8 bytes from the ** buffer passed to it, debugging function VdbeMemPrettyPrint() may ** read more. Use the global constant sqlite3CtypeMap[] as the array, ** as that array is 256 bytes long (plenty for VdbeMemPrettyPrint()) ** and it begins with a bunch of zeros. */ _sqlite3VdbeSerialGet(tls, uintptr(unsafe.Pointer(&_sqlite3CtypeMap)), **(**Tu32)(__ccgo_up(bp + 80)), pDest) } else { rc = _vdbeColumnFromOverflow(tls, pC3, libc.Int32FromUint32(p22), **(**Tu32)(__ccgo_up(bp + 80)), libc.Int64FromUint32(**(**Tu32)(__ccgo_up(aOffset + uintptr(p22)*4))), (*TVdbe)(unsafe.Pointer(p)).FcacheCtr, colCacheCtr, pDest) if rc != 0 { if rc == int32(SQLITE_NOMEM) { goto no_mem } if rc == int32(SQLITE_TOOBIG) { goto too_big } goto abort_due_to_error } } } goto op_column_out op_column_out: ; goto _189 goto op_column_corrupt op_column_corrupt: ; if (**(**TOp)(__ccgo_up(aOp))).Fp3 > 0 { pOp = aOp + uintptr((**(**TOp)(__ccgo_up(aOp))).Fp3-int32(1))*24 goto _189 } else { rc = _sqlite3CorruptError(tls, int32(100021)) goto abort_due_to_error } /* Opcode: TypeCheck P1 P2 P3 P4 * ** Synopsis: typecheck(r[P1@P2]) ** ** Apply affinities to the range of P2 registers beginning with P1. ** Take the affinities from the Table object in P4. If any value ** cannot be coerced into the correct type, then raise an error. ** ** If P3==0, then omit checking of VIRTUAL columns. ** ** If P3==1, then omit checking of all generated column, both VIRTUAL ** and STORED. ** ** If P3>=2, then only check column number P3-2 in the table (which will ** be a VIRTUAL column) against the value in reg[P1]. In this case, ** P2 will be 1. ** ** This opcode is similar to OP_Affinity except that this opcode ** forces the register type to the Table column type. This is used ** to implement "strict affinity". ** ** GENERATED ALWAYS AS ... STATIC columns are only checked if P3 ** is zero. When P3 is non-zero, no type checking occurs for ** static generated columns. Virtual columns are computed at query time ** and so they are never checked. ** ** Preconditions: ** **
      **
    • P2 should be the number of non-virtual columns in the ** table of P4 unless P3>1, in which case P2 will be 1. **
    • Table P4 is a STRICT table. **
    ** ** If any precondition is false, an assertion fault occurs. */ _66: ; pTab = *(*uintptr)(unsafe.Pointer(pOp + 16)) aCol = (*TTable)(unsafe.Pointer(pTab)).FaCol pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 if (*TOp)(unsafe.Pointer(pOp)).Fp3 < int32(2) { i2 = 0 nCol = int32((*TTable)(unsafe.Pointer(pTab)).FnCol) } else { i2 = (*TOp)(unsafe.Pointer(pOp)).Fp3 - int32(2) nCol = i2 + int32(1) } for { if !(i2 < nCol) { break } if libc.Int32FromUint16((**(**TColumn)(__ccgo_up(aCol + uintptr(i2)*16))).FcolFlags)&int32(COLFLAG_GENERATED) != 0 && (*TOp)(unsafe.Pointer(pOp)).Fp3 < int32(2) { if libc.Int32FromUint16((**(**TColumn)(__ccgo_up(aCol + uintptr(i2)*16))).FcolFlags)&int32(COLFLAG_VIRTUAL) != 0 { goto _228 } if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { pIn1 += 56 goto _228 } } _applyAffinity(tls, pIn1, (**(**TColumn)(__ccgo_up(aCol + uintptr(i2)*16))).Faffinity, encoding) if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) == 0 { switch int32(uint32(*(*uint8)(unsafe.Pointer(aCol + uintptr(i2)*16 + 8)) & 0xf0 >> 4)) { case int32(COLTYPE_BLOB): if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Blob) == 0 { goto vdbe_type_error } case int32(COLTYPE_INTEGER): fallthrough case int32(COLTYPE_INT): if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Int) == 0 { goto vdbe_type_error } case int32(COLTYPE_TEXT): if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Str) == 0 { goto vdbe_type_error } case int32(COLTYPE_REAL): if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Int) != 0 { /* When applying REAL affinity, if the result is still an MEM_Int ** that will fit in 6 bytes, then change the type to MEM_IntReal ** so that we keep the high-resolution integer value but know that ** the type really wants to be REAL. */ if *(*Ti64)(unsafe.Pointer(pIn1)) <= int64(140737488355327) && *(*Ti64)(unsafe.Pointer(pIn1)) >= -int64(140737488355328) { v191 = pIn1 + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_IntReal)) v191 = pIn1 + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Int)) } else { *(*float64)(unsafe.Pointer(pIn1)) = float64(*(*Ti64)(unsafe.Pointer(pIn1))) v191 = pIn1 + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Real)) v191 = pIn1 + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Int)) } } else { if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&(libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)) == 0 { goto vdbe_type_error } } default: /* COLTYPE_ANY. Accept anything. */ break } } pIn1 += 56 goto _228 _228: ; i2 = i2 + 1 } goto _189 goto vdbe_type_error vdbe_type_error: ; _sqlite3VdbeError(tls, p, __ccgo_ts+5912, libc.VaList(bp+984, _vdbeMemTypeName(tls, pIn1), _sqlite3StdType[int32(uint32(*(*uint8)(unsafe.Pointer(aCol + uintptr(i2)*16 + 8))&0xf0>>4))-int32(1)], (*TTable)(unsafe.Pointer(pTab)).FzName, (**(**TColumn)(__ccgo_up(aCol + uintptr(i2)*16))).FzCnName)) rc = libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(12)<= -int64(140737488355328) { v191 = pIn1 + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_IntReal)) v191 = pIn1 + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Int)) } else { *(*float64)(unsafe.Pointer(pIn1)) = float64(*(*Ti64)(unsafe.Pointer(pIn1))) v191 = pIn1 + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Real)) v191 = pIn1 + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^(libc.Int32FromInt32(MEM_Int) | libc.Int32FromInt32(MEM_Str))) } } zAffinity = zAffinity + 1 if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zAffinity))) == 0 { break } pIn1 += 56 } goto _189 /* Opcode: MakeRecord P1 P2 P3 P4 * ** Synopsis: r[P3]=mkrec(r[P1@P2]) ** ** Convert P2 registers beginning with P1 into the [record format] ** use as a data record in a database table or as a key ** in an index. The OP_Column opcode can decode the record later. ** ** P4 may be a string that is P2 characters long. The N-th character of the ** string indicates the column affinity that should be used for the N-th ** field of the index key. ** ** The mapping from character to affinity is given by the SQLITE_AFF_ ** macros defined in sqliteInt.h. ** ** If P4 is NULL then all index fields have the affinity BLOB. ** ** The meaning of P5 depends on whether or not the SQLITE_ENABLE_NULL_TRIM ** compile-time option is enabled: ** ** * If SQLITE_ENABLE_NULL_TRIM is enabled, then the P5 is the index ** of the right-most table that can be null-trimmed. ** ** * If SQLITE_ENABLE_NULL_TRIM is omitted, then P5 has the value ** OPFLAG_NOCHNG_MAGIC if the OP_MakeRecord opcode is allowed to ** accept no-change records with serial_type 10. This value is ** only used inside an assert() and does not affect the end result. */ _68: ; /* Where to write next byte of the payload */ /* Assuming the record contains N fields, the record format looks ** like this: ** ** ------------------------------------------------------------------------ ** | hdr-size | type 0 | type 1 | ... | type N-1 | data0 | ... | data N-1 | ** ------------------------------------------------------------------------ ** ** Data(0) is taken from register P1. Data(1) comes from register P1+1 ** and so forth. ** ** Each type field is a varint representing the serial type of the ** corresponding data element (see sqlite3VdbeSerialType()). The ** hdr-size field is also a varint which is the offset from the beginning ** of the record to data0. */ nData = uint64(0) /* Number of bytes of data space */ nHdr = 0 /* Number of bytes of header space */ nZero = 0 /* Number of zero bytes at the end of the record */ nField = (*TOp)(unsafe.Pointer(pOp)).Fp1 zAffinity1 = *(*uintptr)(unsafe.Pointer(pOp + 16)) pData0 = aMem + uintptr(nField)*56 nField = (*TOp)(unsafe.Pointer(pOp)).Fp2 pLast = pData0 + uintptr(nField-int32(1))*56 /* Identify the output register */ pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 /* Apply the requested affinity to all inputs */ if zAffinity1 != 0 { pRec = pData0 for cond := true; cond; cond = **(**uint8)(__ccgo_up(zAffinity1)) != 0 { _applyAffinity(tls, pRec, **(**uint8)(__ccgo_up(zAffinity1)), encoding) if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zAffinity1))) == int32(SQLITE_AFF_REAL) && libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Int) != 0 { v191 = pRec + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_IntReal)) v191 = pRec + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Int)) } zAffinity1 = zAffinity1 + 1 pRec += 56 } } /* Loop through the elements that will make up the record to figure ** out how much space is required for the new record. After this loop, ** the Mem.uTemp field of each term should hold the serial-type that will ** be used for that term in the generated record: ** ** Mem.uTemp value type ** --------------- --------------- ** 0 NULL ** 1 1-byte signed integer ** 2 2-byte signed integer ** 3 3-byte signed integer ** 4 4-byte signed integer ** 5 6-byte signed integer ** 6 8-byte signed integer ** 7 IEEE float ** 8 Integer constant 0 ** 9 Integer constant 1 ** 10,11 reserved for expansion ** N>=12 and even BLOB ** N>=13 and odd text ** ** The following additional values are computed: ** nHdr Number of bytes needed for the record header ** nData Number of bytes of data space needed for the record ** nZero Zero bytes at the end of the record */ pRec = pLast for cond := true; cond; cond = int32(1) != 0 { if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Null) != 0 { if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Zero) != 0 { /* Values with MEM_Null and MEM_Zero are created by xColumn virtual ** table methods that never invoke sqlite3_result_xxxxx() while ** computing an unchanging column value in an UPDATE statement. ** Give such values a special internal-use-only serial-type of 10 ** so that they can be passed through to xUpdate and have ** a true sqlite3_value_nochange(). */ (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(10) } else { (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(0) } nHdr = nHdr + 1 } else { if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) != 0 { /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */ i3 = *(*Ti64)(unsafe.Pointer(pRec)) if i3 < 0 { uu = libc.Uint64FromInt64(^i3) } else { uu = libc.Uint64FromInt64(i3) } nHdr = nHdr + 1 if uu <= uint64(127) { if i3&int64(1) == i3 && libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FminWriteFileFormat) >= int32(4) { (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(8) + uint32(uu) } else { nData = nData + 1 (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(1) } } else { if uu <= uint64(32767) { nData = nData + uint64(2) (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(2) } else { if uu <= uint64(8388607) { nData = nData + uint64(3) (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(3) } else { if uu <= uint64(2147483647) { nData = nData + uint64(4) (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(4) } else { if uu <= uint64(140737488355327) { nData = nData + uint64(6) (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(5) } else { nData = nData + uint64(8) if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_IntReal) != 0 { /* If the value is IntReal and is going to take up 8 bytes to store ** as an integer, then we might as well make it an 8-byte floating ** point value */ *(*float64)(unsafe.Pointer(pRec)) = float64(*(*Ti64)(unsafe.Pointer(pRec))) v191 = pRec + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_IntReal)) v191 = pRec + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Real)) (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(7) } else { (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(6) } } } } } } } else { if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Real) != 0 { nHdr = nHdr + 1 nData = nData + uint64(8) (*TMem)(unsafe.Pointer(pRec)).FuTemp = uint32(7) } else { len11 = libc.Uint32FromInt32((*TMem)(unsafe.Pointer(pRec)).Fn) serial_type = len11*uint32(2) + uint32(12) + libc.BoolUint32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&libc.Int32FromInt32(MEM_Str) != libc.Int32FromInt32(0)) if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRec)).Fflags)&int32(MEM_Zero) != 0 { serial_type = serial_type + libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pRec)).Fu)))*uint32(2) if nData != 0 { if _sqlite3VdbeMemExpandBlob(tls, pRec) != 0 { goto no_mem } len11 = len11 + libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pRec)).Fu))) } else { nZero = nZero + int64(*(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pRec)).Fu))) } } nData = nData + uint64(len11) nHdr = nHdr + _sqlite3VarintLen(tls, uint64(serial_type)) (*TMem)(unsafe.Pointer(pRec)).FuTemp = serial_type } } } if pRec == pData0 { break } pRec -= 56 } /* EVIDENCE-OF: R-22564-11647 The header begins with a single varint ** which determines the total number of bytes in the header. The varint ** value is the size of the header in bytes including the size varint ** itself. */ if nHdr <= int32(126) { /* The common case */ nHdr = nHdr + int32(1) } else { /* Rare case of a really large header */ nVarint = _sqlite3VarintLen(tls, libc.Uint64FromInt32(nHdr)) nHdr = nHdr + nVarint if nVarint < _sqlite3VarintLen(tls, libc.Uint64FromInt32(nHdr)) { nHdr = nHdr + 1 } } nByte1 = libc.Int64FromUint64(libc.Uint64FromInt32(nHdr) + nData) /* Make sure the output register has a buffer large enough to store ** the new record. The output register (pOp->p3) is not allowed to ** be one of the input registers (because the following call to ** sqlite3VdbeMemClearAndResize() could clobber the value before it is used). */ if nByte1+nZero <= int64((*TMem)(unsafe.Pointer(pOut)).FszMalloc) { /* The output register is already large enough to hold the record. ** No error checks or buffer enlargement is required */ (*TMem)(unsafe.Pointer(pOut)).Fz = (*TMem)(unsafe.Pointer(pOut)).FzMalloc } else { /* Need to make sure that the output is not too big and then enlarge ** the output register to hold the full result */ if nByte1+nZero > int64(**(**int32)(__ccgo_up(db + 136))) { goto too_big } if _sqlite3VdbeMemClearAndResize(tls, pOut, int32(nByte1)) != 0 { goto no_mem } } (*TMem)(unsafe.Pointer(pOut)).Fn = int32(nByte1) (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Blob) if nZero != 0 { *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pOut)).Fu)) = int32(nZero) v191 = pOut + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Zero)) } zHdr1 = (*TMem)(unsafe.Pointer(pOut)).Fz zPayload = zHdr1 + uintptr(nHdr) /* Write the record */ if nHdr < int32(0x80) { v191 = zHdr1 zHdr1 = zHdr1 + 1 **(**Tu8)(__ccgo_up(v191)) = libc.Uint8FromInt32(nHdr) } else { zHdr1 = zHdr1 + uintptr(_sqlite3PutVarint(tls, zHdr1, libc.Uint64FromInt32(nHdr))) } pRec = pData0 for int32(1) != 0 { serial_type = (*TMem)(unsafe.Pointer(pRec)).FuTemp /* EVIDENCE-OF: R-06529-47362 Following the size varint are one or more ** additional varints, one per column. ** EVIDENCE-OF: R-64536-51728 The values for each column in the record ** immediately follow the header. */ if serial_type <= uint32(7) { v191 = zHdr1 zHdr1 = zHdr1 + 1 **(**Tu8)(__ccgo_up(v191)) = uint8(serial_type) if serial_type == uint32(0) { /* NULL value. No change in zPayload */ } else { if serial_type == uint32(7) { libc.Xmemcpy(tls, bp+88, pRec, uint64(8)) } else { **(**Tu64)(__ccgo_up(bp + 88)) = libc.Uint64FromInt64(*(*Ti64)(unsafe.Pointer(pRec))) } len11 = uint32(_sqlite3SmallTypeSizes[serial_type]) switch len11 { default: **(**Tu8)(__ccgo_up(zPayload + 7)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) **(**Tu8)(__ccgo_up(zPayload + 6)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) fallthrough case uint32(6): **(**Tu8)(__ccgo_up(zPayload + 5)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) **(**Tu8)(__ccgo_up(zPayload + 4)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) fallthrough case uint32(4): **(**Tu8)(__ccgo_up(zPayload + 3)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) fallthrough case uint32(3): **(**Tu8)(__ccgo_up(zPayload + 2)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) fallthrough case uint32(2): **(**Tu8)(__ccgo_up(zPayload + 1)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) **(**Tu64)(__ccgo_up(bp + 88)) = **(**Tu64)(__ccgo_up(bp + 88)) >> uint64(8) fallthrough case uint32(1): **(**Tu8)(__ccgo_up(zPayload)) = uint8(**(**Tu64)(__ccgo_up(bp + 88)) & libc.Uint64FromInt32(0xff)) } zPayload = zPayload + uintptr(len11) } } else { if serial_type < uint32(0x80) { v191 = zHdr1 zHdr1 = zHdr1 + 1 **(**Tu8)(__ccgo_up(v191)) = uint8(serial_type) if serial_type >= uint32(14) && (*TMem)(unsafe.Pointer(pRec)).Fn > 0 { libc.Xmemcpy(tls, zPayload, (*TMem)(unsafe.Pointer(pRec)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pRec)).Fn)) zPayload = zPayload + uintptr((*TMem)(unsafe.Pointer(pRec)).Fn) } } else { zHdr1 = zHdr1 + uintptr(_sqlite3PutVarint(tls, zHdr1, uint64(serial_type))) if (*TMem)(unsafe.Pointer(pRec)).Fn != 0 { libc.Xmemcpy(tls, zPayload, (*TMem)(unsafe.Pointer(pRec)).Fz, libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pRec)).Fn)) zPayload = zPayload + uintptr((*TMem)(unsafe.Pointer(pRec)).Fn) } } } if pRec == pLast { break } pRec += 56 } goto _189 /* Opcode: Count P1 P2 P3 * * ** Synopsis: r[P2]=count() ** ** Store the number of entries (an integer value) in the table or index ** opened by cursor P1 in register P2. ** ** If P3==0, then an exact count is obtained, which involves visiting ** every btree page of the table. But if P3 is non-zero, an estimate ** is returned based on the current cursor position. */ _69: ; pCrsr1 = *(*uintptr)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + 48)) if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { **(**Ti64)(__ccgo_up(bp + 96)) = _sqlite3BtreeRowCountEst(tls, pCrsr1) } else { **(**Ti64)(__ccgo_up(bp + 96)) = 0 /* Not needed. Only used to silence a warning. */ rc = _sqlite3BtreeCount(tls, db, pCrsr1, bp+96) if rc != 0 { goto abort_due_to_error } } pOut = _out2Prerelease(tls, p, pOp) *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(bp + 96)) goto check_for_interrupt /* Opcode: Savepoint P1 * * P4 * ** ** Open, release or rollback the savepoint named by parameter P4, depending ** on the value of P1. To open a new savepoint set P1==0 (SAVEPOINT_BEGIN). ** To release (commit) an existing savepoint set P1==1 (SAVEPOINT_RELEASE). ** To rollback an existing savepoint set P1==2 (SAVEPOINT_ROLLBACK). */ _70: ; p12 = (*TOp)(unsafe.Pointer(pOp)).Fp1 zName = *(*uintptr)(unsafe.Pointer(pOp + 16)) /* Assert that the p1 parameter is valid. Also that if there is no open ** transaction, then there cannot be any savepoints. */ if p12 == SAVEPOINT_BEGIN { if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0 { /* A new savepoint cannot be created if there are active write ** statements (i.e. open read/write incremental blob handles). */ _sqlite3VdbeError(tls, p, __ccgo_ts+5953, 0) rc = int32(SQLITE_BUSY) } else { nName = _sqlite3Strlen30(tls, zName) /* This call is Ok even if this savepoint is actually a transaction ** savepoint (and therefore should not prompt xSavepoint()) callbacks. ** If this is a transaction savepoint being opened, it is guaranteed ** that the db->aVTrans[] array is empty. */ rc = _sqlite3VtabSavepoint(tls, db, SAVEPOINT_BEGIN, (*Tsqlite3)(unsafe.Pointer(db)).FnStatement+(*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint) if rc != SQLITE_OK { goto abort_due_to_error } /* Create a new savepoint structure. */ pNew = _sqlite3DbMallocRawNN(tls, db, uint64(uint64(32)+libc.Uint64FromInt32(nName)+uint64(1))) if pNew != 0 { (*TSavepoint)(unsafe.Pointer(pNew)).FzName = pNew + 1*32 libc.Xmemcpy(tls, (*TSavepoint)(unsafe.Pointer(pNew)).FzName, zName, libc.Uint64FromInt32(nName+int32(1))) /* If there is no open transaction, then mark this as a special ** "transaction savepoint". */ if (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0 { (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(0) (*Tsqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint = uint8(1) } else { (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint = (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint + 1 } /* Link the new savepoint into the database handle's list. */ (*TSavepoint)(unsafe.Pointer(pNew)).FpNext = (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint = pNew (*TSavepoint)(unsafe.Pointer(pNew)).FnDeferredCons = (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons (*TSavepoint)(unsafe.Pointer(pNew)).FnDeferredImmCons = (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons } } } else { iSavepoint = 0 /* Find the named savepoint. If there is no such savepoint, then an ** an error is returned to the user. */ pSavepoint = (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint for { if !(pSavepoint != 0 && _sqlite3StrICmp(tls, (*TSavepoint)(unsafe.Pointer(pSavepoint)).FzName, zName) != 0) { break } iSavepoint = iSavepoint + 1 goto _245 _245: ; pSavepoint = (*TSavepoint)(unsafe.Pointer(pSavepoint)).FpNext } if !(pSavepoint != 0) { _sqlite3VdbeError(tls, p, __ccgo_ts+6004, libc.VaList(bp+984, zName)) rc = int32(SQLITE_ERROR) } else { if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeWrite > 0 && p12 == int32(SAVEPOINT_RELEASE) { /* It is not possible to release (commit) a savepoint if there are ** active write statements. */ _sqlite3VdbeError(tls, p, __ccgo_ts+6026, 0) rc = int32(SQLITE_BUSY) } else { /* Determine whether or not this is a transaction savepoint. If so, ** and this is a RELEASE command, then the current transaction ** is committed. */ isTransaction = libc.BoolInt32((*TSavepoint)(unsafe.Pointer(pSavepoint)).FpNext == uintptr(0) && (*Tsqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint != 0) if isTransaction != 0 && p12 == int32(SAVEPOINT_RELEASE) { v190 = _sqlite3VdbeCheckFkDeferred(tls, p) rc = v190 if v190 != SQLITE_OK { goto vdbe_return } (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(1) if _sqlite3VdbeHalt(tls, p) == int32(SQLITE_BUSY) { (*TVdbe)(unsafe.Pointer(p)).Fpc = int32((int64(pOp) - int64(aOp)) / 24) (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(0) v190 = libc.Int32FromInt32(SQLITE_BUSY) rc = v190 (*TVdbe)(unsafe.Pointer(p)).Frc = v190 goto vdbe_return } rc = (*TVdbe)(unsafe.Pointer(p)).Frc if rc != 0 { (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = uint8(0) } else { (*Tsqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint = uint8(0) } } else { iSavepoint = (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint - iSavepoint - int32(1) if p12 == int32(SAVEPOINT_ROLLBACK) { isSchemaChange = libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).FmDbFlags&uint32(DBFLAG_SchemaChange) != uint32(0)) ii = 0 for { if !(ii < (*Tsqlite3)(unsafe.Pointer(db)).FnDb) { break } rc = _sqlite3BtreeTripAllCursors(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(ii)*32))).FpBt, libc.Int32FromInt32(SQLITE_ABORT)|libc.Int32FromInt32(2)< 0 { /* If this instruction implements a COMMIT and other VMs are writing ** return an error indicating that the other VMs must complete first. */ _sqlite3VdbeError(tls, p, __ccgo_ts+6080, 0) rc = int32(SQLITE_BUSY) goto abort_due_to_error } else { v190 = _sqlite3VdbeCheckFkDeferred(tls, p) rc = v190 if v190 != SQLITE_OK { goto vdbe_return } else { (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = libc.Uint8FromInt32(desiredAutoCommit) } } } if _sqlite3VdbeHalt(tls, p) == int32(SQLITE_BUSY) { (*TVdbe)(unsafe.Pointer(p)).Fpc = int32((int64(pOp) - int64(aOp)) / 24) (*Tsqlite3)(unsafe.Pointer(db)).FautoCommit = libc.Uint8FromInt32(libc.Int32FromInt32(1) - desiredAutoCommit) v190 = libc.Int32FromInt32(SQLITE_BUSY) rc = v190 (*TVdbe)(unsafe.Pointer(p)).Frc = v190 goto vdbe_return } _sqlite3CloseSavepoints(tls, db) if (*TVdbe)(unsafe.Pointer(p)).Frc == SQLITE_OK { rc = int32(SQLITE_DONE) } else { rc = int32(SQLITE_ERROR) } goto vdbe_return } else { if !(desiredAutoCommit != 0) { v191 = __ccgo_ts + 6135 } else { if iRollback != 0 { v194 = __ccgo_ts + 6183 } else { v194 = __ccgo_ts + 6226 } v191 = v194 } _sqlite3VdbeError(tls, p, v191, 0) rc = int32(SQLITE_ERROR) goto abort_due_to_error } /* Opcode: Transaction P1 P2 P3 P4 P5 ** ** Begin a transaction on database P1 if a transaction is not already ** active. ** If P2 is non-zero, then a write-transaction is started, or if a ** read-transaction is already active, it is upgraded to a write-transaction. ** If P2 is zero, then a read-transaction is started. If P2 is 2 or more ** then an exclusive transaction is started. ** ** P1 is the index of the database file on which the transaction is ** started. Index 0 is the main database file and index 1 is the ** file used for temporary tables. Indices of 2 or more are used for ** attached databases. ** ** If a write-transaction is started and the Vdbe.usesStmtJournal flag is ** true (this flag is set if the Vdbe may modify more than one row and may ** throw an ABORT exception), a statement transaction may also be opened. ** More specifically, a statement transaction is opened iff the database ** connection is currently not in autocommit mode, or if there are other ** active statements. A statement transaction allows the changes made by this ** VDBE to be rolled back after an error without having to roll back the ** entire transaction. If no error is encountered, the statement transaction ** will automatically commit when the VDBE halts. ** ** If P5!=0 then this opcode also checks the schema cookie against P3 ** and the schema generation counter against P4. ** The cookie changes its value whenever the database schema changes. ** This operation is used to detect when that the cookie has changed ** and that the current process needs to reread the schema. If the schema ** cookie in P3 differs from the schema cookie in the database header or ** if the schema generation counter in P4 differs from the current ** generation counter, then an SQLITE_SCHEMA error is raised and execution ** halts. The sqlite3_step() wrapper function might then reprepare the ** statement and rerun it from the beginning. */ _72: ; **(**int32)(__ccgo_up(bp + 104)) = 0 if (*TOp)(unsafe.Pointer(pOp)).Fp2 != 0 && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(SQLITE_QueryOnly)|libc.Uint64FromInt32(libc.Int32FromInt32(0x00002))<>5)) != 0 && (*TOp)(unsafe.Pointer(pOp)).Fp2 != 0 && (libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit) == 0 || (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead > int32(1)) { if (*TVdbe)(unsafe.Pointer(p)).FiStatement == 0 { (*Tsqlite3)(unsafe.Pointer(db)).FnStatement = (*Tsqlite3)(unsafe.Pointer(db)).FnStatement + 1 (*TVdbe)(unsafe.Pointer(p)).FiStatement = (*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint + (*Tsqlite3)(unsafe.Pointer(db)).FnStatement } rc = _sqlite3VtabSavepoint(tls, db, SAVEPOINT_BEGIN, (*TVdbe)(unsafe.Pointer(p)).FiStatement-int32(1)) if rc == SQLITE_OK { rc = _sqlite3BtreeBeginStmt(tls, pBt, (*TVdbe)(unsafe.Pointer(p)).FiStatement) } /* Store the current value of the database handles deferred constraint ** counter. If the statement transaction needs to be rolled back, ** the value of this counter needs to be restored too. */ (*TVdbe)(unsafe.Pointer(p)).FnStmtDefCons = (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons (*TVdbe)(unsafe.Pointer(p)).FnStmtDefImmCons = (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons } } if rc == SQLITE_OK && (*TOp)(unsafe.Pointer(pOp)).Fp5 != 0 && (**(**int32)(__ccgo_up(bp + 104)) != (*TOp)(unsafe.Pointer(pOp)).Fp3 || (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb)).FpSchema)).FiGeneration != (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi) { /* ** IMPLEMENTATION-OF: R-03189-51135 As each SQL statement runs, the schema ** version is checked to ensure that the schema has not changed since the ** SQL statement was prepared. */ _sqlite3DbFree(tls, db, (*TVdbe)(unsafe.Pointer(p)).FzErrMsg) (*TVdbe)(unsafe.Pointer(p)).FzErrMsg = _sqlite3DbStrDup(tls, db, __ccgo_ts+6267) /* If the schema-cookie from the database file matches the cookie ** stored with the in-memory representation of the schema, do ** not reload the schema from the database file. ** ** If virtual-tables are in use, this is not just an optimization. ** Often, v-tables store their data in other SQLite tables, which ** are queried from within xNext() and other v-table methods using ** prepared queries. If such a query is out-of-date, we do not want to ** discard the database schema, as the user code implementing the ** v-table would have to be ready for the sqlite3_vtab structure itself ** to be invalidated whenever sqlite3_step() is called from within ** a v-table method. */ if (*TSchema)(unsafe.Pointer((**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpSchema)).Fschema_cookie != **(**int32)(__ccgo_up(bp + 104)) { _sqlite3ResetOneSchema(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1) } libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(1), 0, 0x3) rc = int32(SQLITE_SCHEMA) /* Set changeCntOn to 0 to prevent the value returned by sqlite3_changes() ** from being modified in sqlite3VdbeHalt(). If this statement is ** reprepared, changeCntOn will be set again. */ libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 4, 0x10) } if rc != 0 { goto abort_due_to_error } goto _189 /* Opcode: ReadCookie P1 P2 P3 * * ** ** Read cookie number P3 from database P1 and write it into register P2. ** P3==1 is the schema version. P3==2 is the database format. ** P3==3 is the recommended pager cache size, and so forth. P1==0 is ** the main database file and P1==1 is the database file used to store ** temporary tables. ** ** There must be a read-lock on the database (either a transaction ** must be started or there must be an open cursor) before ** executing this instruction. */ _73: ; iDb = (*TOp)(unsafe.Pointer(pOp)).Fp1 iCookie = (*TOp)(unsafe.Pointer(pOp)).Fp3 _sqlite3BtreeGetMeta(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32))).FpBt, iCookie, bp+108) pOut = _out2Prerelease(tls, p, pOp) *(*Ti64)(unsafe.Pointer(pOut)) = int64(**(**int32)(__ccgo_up(bp + 108))) goto _189 /* Opcode: SetCookie P1 P2 P3 * P5 ** ** Write the integer value P3 into cookie number P2 of database P1. ** P2==1 is the schema version. P2==2 is the database format. ** P2==3 is the recommended pager cache ** size, and so forth. P1==0 is the main database file and P1==1 is the ** database file used to store temporary tables. ** ** A transaction must be started before executing this opcode. ** ** If P2 is the SCHEMA_VERSION cookie (cookie number 1) then the internal ** schema version is set to P3-P5. The "PRAGMA schema_version=N" statement ** has P5 set to 1, so that the internal schema version will be different ** from the database schema version, resulting in a schema reset. */ _74: ; pDb1 = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32 /* See note about index shifting on OP_ReadCookie */ rc = _sqlite3BtreeUpdateMeta(tls, (*TDb)(unsafe.Pointer(pDb1)).FpBt, (*TOp)(unsafe.Pointer(pOp)).Fp2, libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3)) if (*TOp)(unsafe.Pointer(pOp)).Fp2 == int32(BTREE_SCHEMA_VERSION) { /* When the schema cookie changes, record the new cookie internally */ **(**Tu32)(__ccgo_up((*TDb)(unsafe.Pointer(pDb1)).FpSchema)) = **(**Tu32)(__ccgo_up(pOp + 12)) - uint32((*TOp)(unsafe.Pointer(pOp)).Fp5) **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) _sqlite3FkClearTriggerCache(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1) } else { if (*TOp)(unsafe.Pointer(pOp)).Fp2 == int32(BTREE_FILE_FORMAT) { /* Record changes in the file format */ (*TSchema)(unsafe.Pointer((*TDb)(unsafe.Pointer(pDb1)).FpSchema)).Ffile_format = libc.Uint8FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) } } if (*TOp)(unsafe.Pointer(pOp)).Fp1 == int32(1) { /* Invalidate all prepared statements whenever the TEMP database ** schema is changed. Ticket #1644 */ _sqlite3ExpirePreparedStatements(tls, db, 0) libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 0, 0x3) } if rc != 0 { goto abort_due_to_error } goto _189 /* Opcode: OpenRead P1 P2 P3 P4 P5 ** Synopsis: root=P2 iDb=P3 ** ** Open a read-only cursor for the database table whose root page is ** P2 in a database file. The database file is determined by P3. ** P3==0 means the main database, P3==1 means the database used for ** temporary tables, and P3>1 means used the corresponding attached ** database. Give the new cursor an identifier of P1. The P1 ** values need not be contiguous but all P1 values should be small integers. ** It is an error for P1 to be negative. ** ** Allowed P5 bits: **
      **
    • 0x02 OPFLAG_SEEKEQ: This cursor will only be used for ** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT ** of OP_SeekLE/OP_IdxLT) **
    ** ** The P4 value may be either an integer (P4_INT32) or a pointer to ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo ** object, then table being opened must be an [index b-tree] where the ** KeyInfo object defines the content and collating ** sequence of that index b-tree. Otherwise, if P4 is an integer ** value, then the table being opened must be a [table b-tree] with a ** number of columns no less than the value of P4. ** ** See also: OpenWrite, ReopenIdx */ /* Opcode: ReopenIdx P1 P2 P3 P4 P5 ** Synopsis: root=P2 iDb=P3 ** ** The ReopenIdx opcode works like OP_OpenRead except that it first ** checks to see if the cursor on P1 is already open on the same ** b-tree and if it is this opcode becomes a no-op. In other words, ** if the cursor is already open, do not reopen it. ** ** The ReopenIdx opcode may only be used with P5==0 or P5==OPFLAG_SEEKEQ ** and with P4 being a P4_KEYINFO object. Furthermore, the P3 value must ** be the same as every other ReopenIdx or OpenRead for the same cursor ** number. ** ** Allowed P5 bits: **
      **
    • 0x02 OPFLAG_SEEKEQ: This cursor will only be used for ** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT ** of OP_SeekLE/OP_IdxLT) **
    ** ** See also: OP_OpenRead, OP_OpenWrite */ /* Opcode: OpenWrite P1 P2 P3 P4 P5 ** Synopsis: root=P2 iDb=P3 ** ** Open a read/write cursor named P1 on the table or index whose root ** page is P2 (or whose root page is held in register P2 if the ** OPFLAG_P2ISREG bit is set in P5 - see below). ** ** The P4 value may be either an integer (P4_INT32) or a pointer to ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo ** object, then table being opened must be an [index b-tree] where the ** KeyInfo object defines the content and collating ** sequence of that index b-tree. Otherwise, if P4 is an integer ** value, then the table being opened must be a [table b-tree] with a ** number of columns no less than the value of P4. ** ** Allowed P5 bits: **
      **
    • 0x02 OPFLAG_SEEKEQ: This cursor will only be used for ** equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT ** of OP_SeekLE/OP_IdxLT) **
    • 0x08 OPFLAG_FORDELETE: This cursor is used only to seek ** and subsequently delete entries in an index btree. This is a ** hint to the storage engine that the storage engine is allowed to ** ignore. The hint is not used by the official SQLite b*tree storage ** engine, but is used by COMDB2. **
    • 0x10 OPFLAG_P2ISREG: Use the content of register P2 ** as the root page, not the value of P2 itself. **
    ** ** This instruction works like OpenRead except that it opens the cursor ** in read/write mode. ** ** See also: OP_OpenRead, OP_ReopenIdx */ _77: ; pCur = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) if pCur != 0 && (*TVdbeCursor)(unsafe.Pointer(pCur)).FpgnoRoot == libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2) { /* Guaranteed by the code generator */ _sqlite3BtreeClearCursor(tls, *(*uintptr)(unsafe.Pointer(pCur + 48))) goto open_cursor_set_hints } /* If the cursor is not currently open or is open on a different ** index, then fall through into OP_OpenRead to force a reopen */ _76: ; /* ncycle */ _75: ; if int32(Tbft(*(*uint16)(unsafe.Pointer(p + 200))&0x3>>0)) == int32(1) { rc = libc.Int32FromInt32(SQLITE_ABORT) | libc.Int32FromInt32(2)<>2))), 2, 0x4) *(*uintptr)(unsafe.Pointer(pCx + 16)) = *(*uintptr)(unsafe.Pointer(pOrig + 16)) libc.SetBitFieldPtr8Uint32(pCx+8, libc.Uint32FromInt32(1), 3, 0x8) libc.SetBitFieldPtr8Uint32(pOrig+8, libc.Uint32FromInt32(1), 3, 0x8) rc = _sqlite3BtreeCursor(tls, *(*uintptr)(unsafe.Pointer(pCx + 16)), (*TVdbeCursor)(unsafe.Pointer(pCx)).FpgnoRoot, int32(BTREE_WRCSR), (*TVdbeCursor)(unsafe.Pointer(pCx)).FpKeyInfo, *(*uintptr)(unsafe.Pointer(pCx + 48))) /* The sqlite3BtreeCursor() routine can only fail for the first cursor ** opened for a database. Since there is already an open cursor when this ** opcode is run, the sqlite3BtreeCursor() cannot fail */ goto _189 /* Opcode: OpenEphemeral P1 P2 P3 P4 P5 ** Synopsis: nColumn=P2 ** ** Open a new cursor P1 to a transient table. ** The cursor is always opened read/write even if ** the main database is read-only. The ephemeral ** table is deleted automatically when the cursor is closed. ** ** If the cursor P1 is already opened on an ephemeral table, the table ** is cleared (all content is erased). ** ** P2 is the number of columns in the ephemeral table. ** The cursor points to a BTree table if P4==0 and to a BTree index ** if P4 is not 0. If P4 is not NULL, it points to a KeyInfo structure ** that defines the format of keys in the index. ** ** The P5 parameter can be a mask of the BTREE_* flags defined ** in btree.h. These flags control aspects of the operation of ** the btree. The BTREE_OMIT_JOURNAL and BTREE_SINGLE flags are ** added automatically. ** ** If P3 is positive, then reg[P3] is modified slightly so that it ** can be used as zero-length data for OP_Insert. This is an optimization ** that avoids an extra OP_Blob opcode to initialize that register. */ /* Opcode: OpenAutoindex P1 P2 * P4 * ** Synopsis: nColumn=P2 ** ** This opcode works the same as OP_OpenEphemeral. It has a ** different name to distinguish its use. Tables created using ** by this opcode will be used for automatically created transient ** indices in joins. */ _80: ; /* ncycle */ _79: ; if (*TOp)(unsafe.Pointer(pOp)).Fp3 > 0 { /* Make register reg[P3] into a value that can be used as the data ** form sqlite3BtreeInsert() where the length of the data is zero. */ /* Only used when number of columns is zero */ (**(**TMem)(__ccgo_up(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56))).Fn = 0 (**(**TMem)(__ccgo_up(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56))).Fz = __ccgo_ts + 1704 } pCx1 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) if pCx1 != 0 && !(int32(TBool(*(*uint8)(unsafe.Pointer(pCx1 + 8))&0x8>>3)) != 0) && (*TOp)(unsafe.Pointer(pOp)).Fp2 <= int32((*TVdbeCursor)(unsafe.Pointer(pCx1)).FnField) { /* If the ephemeral table is already open and has no duplicates from ** OP_OpenDup, then erase all existing content so that the table is ** empty again, rather than creating a new table. */ (*TVdbeCursor)(unsafe.Pointer(pCx1)).FseqCount = 0 (*TVdbeCursor)(unsafe.Pointer(pCx1)).FcacheStatus = uint32(CACHE_STALE) rc = _sqlite3BtreeClearTable(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), libc.Int32FromUint32((*TVdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot), uintptr(0)) } else { pCx1 = _allocateCursor(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, (*TOp)(unsafe.Pointer(pOp)).Fp2, uint8(CURTYPE_BTREE)) if pCx1 == uintptr(0) { goto no_mem } libc.SetBitFieldPtr8Uint32(pCx1+8, libc.Uint32FromInt32(1), 0, 0x1) rc = _sqlite3BtreeOpen(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpVfs, uintptr(0), db, pCx1+16, libc.Int32FromInt32(BTREE_OMIT_JOURNAL)|libc.Int32FromInt32(BTREE_SINGLE)|libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5), _vfsFlags) if rc == SQLITE_OK { rc = _sqlite3BtreeBeginTrans(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), int32(1), uintptr(0)) if rc == SQLITE_OK { /* If a transient index is required, create it by calling ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before ** opening it. If a transient table is required, just use the ** automatically created table with root-page 1 (an BLOB_INTKEY table). */ v194 = *(*uintptr)(unsafe.Pointer(pOp + 16)) pKeyInfo2 = v194 v191 = v194 (*TVdbeCursor)(unsafe.Pointer(pCx1)).FpKeyInfo = v191 if v191 != uintptr(0) { rc = _sqlite3BtreeCreateTable(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), pCx1+68, int32(BTREE_BLOBKEY)|libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)) if rc == SQLITE_OK { rc = _sqlite3BtreeCursor(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), (*TVdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot, int32(BTREE_WRCSR), pKeyInfo2, *(*uintptr)(unsafe.Pointer(pCx1 + 48))) } (*TVdbeCursor)(unsafe.Pointer(pCx1)).FisTable = uint8(0) } else { (*TVdbeCursor)(unsafe.Pointer(pCx1)).FpgnoRoot = uint32(SCHEMA_ROOT) rc = _sqlite3BtreeCursor(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16)), uint32(SCHEMA_ROOT), int32(BTREE_WRCSR), uintptr(0), *(*uintptr)(unsafe.Pointer(pCx1 + 48))) (*TVdbeCursor)(unsafe.Pointer(pCx1)).FisTable = uint8(1) } } libc.SetBitFieldPtr8Uint32(pCx1+8, libc.BoolUint32(libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) != libc.Int32FromInt32(BTREE_UNORDERED)), 2, 0x4) if rc != 0 { _sqlite3BtreeClose(tls, *(*uintptr)(unsafe.Pointer(pCx1 + 16))) **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) = uintptr(0) /* Not required; helps with static analysis */ } else { } } } if rc != 0 { goto abort_due_to_error } (*TVdbeCursor)(unsafe.Pointer(pCx1)).FnullRow = uint8(1) goto _189 /* Opcode: SorterOpen P1 P2 P3 P4 * ** ** This opcode works like OP_OpenEphemeral except that it opens ** a transient index that is specifically designed to sort large ** tables using an external merge-sort algorithm. ** ** If argument P3 is non-zero, then it indicates that the sorter may ** assume that a stable sort considering the first P3 fields of each ** key is sufficient to produce the required results. */ _81: ; pCx2 = _allocateCursor(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, (*TOp)(unsafe.Pointer(pOp)).Fp2, uint8(CURTYPE_SORTER)) if pCx2 == uintptr(0) { goto no_mem } (*TVdbeCursor)(unsafe.Pointer(pCx2)).FpKeyInfo = *(*uintptr)(unsafe.Pointer(pOp + 16)) rc = _sqlite3VdbeSorterInit(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp3, pCx2) if rc != 0 { goto abort_due_to_error } goto _189 /* Opcode: SequenceTest P1 P2 * * * ** Synopsis: if( cursor[P1].ctr++ ) pc = P2 ** ** P1 is a sorter cursor. If the sequence counter is currently zero, jump ** to P2. Regardless of whether or not the jump is taken, increment the ** the sequence value. */ _82: ; pC4 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) v191 = pC4 + 24 v256 = *(*Ti64)(unsafe.Pointer(v191)) *(*Ti64)(unsafe.Pointer(v191)) = *(*Ti64)(unsafe.Pointer(v191)) + 1 if v256 == 0 { goto jump_to_p2 } goto _189 /* Opcode: OpenPseudo P1 P2 P3 * * ** Synopsis: P3 columns in r[P2] ** ** Open a new cursor that points to a fake table that contains a single ** row of data. The content of that one row is the content of memory ** register P2. In other words, cursor P1 becomes an alias for the ** MEM_Blob content contained in register P2. ** ** A pseudo-table created by this opcode is used to hold a single ** row output from the sorter so that the row can be decomposed into ** individual columns using the OP_Column opcode. The OP_Column opcode ** is the only cursor opcode that works with a pseudo-table. ** ** P3 is the number of fields in the records that will be stored by ** the pseudo-table. If P2 is 0 or negative then the pseudo-cursor ** will return NULL for every column. */ _83: ; pCx3 = _allocateCursor(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, (*TOp)(unsafe.Pointer(pOp)).Fp3, uint8(CURTYPE_PSEUDO)) if pCx3 == uintptr(0) { goto no_mem } (*TVdbeCursor)(unsafe.Pointer(pCx3)).FnullRow = uint8(1) (*TVdbeCursor)(unsafe.Pointer(pCx3)).FseekResult = (*TOp)(unsafe.Pointer(pOp)).Fp2 (*TVdbeCursor)(unsafe.Pointer(pCx3)).FisTable = uint8(1) /* Give this pseudo-cursor a fake BtCursor pointer so that pCx ** can be safely passed to sqlite3VdbeCursorMoveto(). This avoids a test ** for pCx->eCurType==CURTYPE_BTREE inside of sqlite3VdbeCursorMoveto() ** which is a performance optimization */ *(*uintptr)(unsafe.Pointer(pCx3 + 48)) = _sqlite3BtreeFakeValidCursor(tls) goto _189 /* Opcode: Close P1 * * * * ** ** Close a cursor previously opened as P1. If P1 is not ** currently open, this instruction is a no-op. */ _84: ; /* ncycle */ _sqlite3VdbeFreeCursor(tls, p, **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8))) **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) = uintptr(0) goto _189 /* Opcode: SeekGE P1 P2 P3 P4 * ** Synopsis: key=r[P3@P4] ** ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), ** use the value in register P3 as the key. If cursor P1 refers ** to an SQL index, then P3 is the first in an array of P4 registers ** that are used as an unpacked index key. ** ** Reposition cursor P1 so that it points to the smallest entry that ** is greater than or equal to the key value. If there are no records ** greater than or equal to the key and P2 is not zero, then jump to P2. ** ** If the cursor P1 was opened using the OPFLAG_SEEKEQ flag, then this ** opcode will either land on a record that exactly matches the key, or ** else it will cause a jump to P2. When the cursor is OPFLAG_SEEKEQ, ** this opcode must be followed by an IdxLE opcode with the same arguments. ** The IdxGT opcode will be skipped if this opcode succeeds, but the ** IdxGT opcode will be used on subsequent loop iterations. The ** OPFLAG_SEEKEQ flags is a hint to the btree layer to say that this ** is an equality search. ** ** This opcode leaves the cursor configured to move in forward order, ** from the beginning toward the end. In other words, the cursor is ** configured to use Next, not Prev. ** ** See also: Found, NotFound, SeekLt, SeekGt, SeekLe */ /* Opcode: SeekGT P1 P2 P3 P4 * ** Synopsis: key=r[P3@P4] ** ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), ** use the value in register P3 as a key. If cursor P1 refers ** to an SQL index, then P3 is the first in an array of P4 registers ** that are used as an unpacked index key. ** ** Reposition cursor P1 so that it points to the smallest entry that ** is greater than the key value. If there are no records greater than ** the key and P2 is not zero, then jump to P2. ** ** This opcode leaves the cursor configured to move in forward order, ** from the beginning toward the end. In other words, the cursor is ** configured to use Next, not Prev. ** ** See also: Found, NotFound, SeekLt, SeekGe, SeekLe */ /* Opcode: SeekLT P1 P2 P3 P4 * ** Synopsis: key=r[P3@P4] ** ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), ** use the value in register P3 as a key. If cursor P1 refers ** to an SQL index, then P3 is the first in an array of P4 registers ** that are used as an unpacked index key. ** ** Reposition cursor P1 so that it points to the largest entry that ** is less than the key value. If there are no records less than ** the key and P2 is not zero, then jump to P2. ** ** This opcode leaves the cursor configured to move in reverse order, ** from the end toward the beginning. In other words, the cursor is ** configured to use Prev, not Next. ** ** See also: Found, NotFound, SeekGt, SeekGe, SeekLe */ /* Opcode: SeekLE P1 P2 P3 P4 * ** Synopsis: key=r[P3@P4] ** ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), ** use the value in register P3 as a key. If cursor P1 refers ** to an SQL index, then P3 is the first in an array of P4 registers ** that are used as an unpacked index key. ** ** Reposition cursor P1 so that it points to the largest entry that ** is less than or equal to the key value. If there are no records ** less than or equal to the key and P2 is not zero, then jump to P2. ** ** This opcode leaves the cursor configured to move in reverse order, ** from the end toward the beginning. In other words, the cursor is ** configured to use Prev, not Next. ** ** If the cursor P1 was opened using the OPFLAG_SEEKEQ flag, then this ** opcode will either land on a record that exactly matches the key, or ** else it will cause a jump to P2. When the cursor is OPFLAG_SEEKEQ, ** this opcode must be followed by an IdxLE opcode with the same arguments. ** The IdxGE opcode will be skipped if this opcode succeeds, but the ** IdxGE opcode will be used on subsequent loop iterations. The ** OPFLAG_SEEKEQ flags is a hint to the btree layer to say that this ** is an equality search. ** ** See also: Found, NotFound, SeekGt, SeekGe, SeekLt */ _88: ; /* jump0, in3, group, ncycle */ _87: ; /* jump0, in3, group, ncycle */ _86: ; /* jump0, in3, group, ncycle */ _85: ; /* Only interested in == results */ pC5 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) oc = libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) eqOnly = 0 (*TVdbeCursor)(unsafe.Pointer(pC5)).FnullRow = uint8(0) (*TVdbeCursor)(unsafe.Pointer(pC5)).FdeferredMoveto = uint8(0) (*TVdbeCursor)(unsafe.Pointer(pC5)).FcacheStatus = uint32(CACHE_STALE) if (*TVdbeCursor)(unsafe.Pointer(pC5)).FisTable != 0 { /* The OPFLAG_SEEKEQ/BTREE_SEEK_EQ flag is only set on index cursors */ /* The input value in P3 might be of any type: integer, real, string, ** blob, or NULL. But it needs to be an integer before we can do ** the seek, so convert it. */ pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 flags31 = (*TMem)(unsafe.Pointer(pIn3)).Fflags if libc.Int32FromUint16(flags31)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_Real)|libc.Int32FromInt32(MEM_IntReal)|libc.Int32FromInt32(MEM_Str)) == int32(MEM_Str) { _applyNumericAffinity(tls, pIn3, 0) } iKey = _sqlite3VdbeIntValue(tls, pIn3) /* Get the integer key value */ newType = (*TMem)(unsafe.Pointer(pIn3)).Fflags /* Record the type after applying numeric affinity */ (*TMem)(unsafe.Pointer(pIn3)).Fflags = flags31 /* But convert the type back to its original */ /* If the P3 value could not be converted into an integer without ** loss of information, then special processing is required... */ if libc.Int32FromUint16(newType)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) == 0 { if libc.Int32FromUint16(newType)&int32(MEM_Real) == 0 { if libc.Int32FromUint16(newType)&int32(MEM_Null) != 0 || oc >= int32(OP_SeekGE) { goto jump_to_p2 } else { rc = _sqlite3BtreeLast(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), bp+112) if rc != SQLITE_OK { goto abort_due_to_error } goto seek_not_found } } c2 = _sqlite3IntFloatCompare(tls, iKey, *(*float64)(unsafe.Pointer(pIn3))) /* If the approximation iKey is larger than the actual real search ** term, substitute >= for > and < for <=. e.g. if the search term ** is 4.9 and the integer approximation 5: ** ** (x > 4.9) -> (x >= 5) ** (x <= 4.9) -> (x < 5) */ if c2 > 0 { if oc&int32(0x0001) == libc.Int32FromInt32(OP_SeekGT)&libc.Int32FromInt32(0x0001) { oc = oc - 1 } } else { if c2 < 0 { if oc&int32(0x0001) == libc.Int32FromInt32(OP_SeekLT)&libc.Int32FromInt32(0x0001) { oc = oc + 1 } } } } rc = _sqlite3BtreeTableMoveto(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), libc.Int64FromUint64(libc.Uint64FromInt64(iKey)), 0, bp+112) (*TVdbeCursor)(unsafe.Pointer(pC5)).FmovetoTarget = iKey /* Used by OP_Delete */ if rc != SQLITE_OK { goto abort_due_to_error } } else { /* For a cursor with the OPFLAG_SEEKEQ/BTREE_SEEK_EQ hint, only the ** OP_SeekGE and OP_SeekLE opcodes are allowed, and these must be ** immediately followed by an OP_IdxGT or OP_IdxLT opcode, respectively, ** with the same key. */ if _sqlite3BtreeCursorHasHint(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), uint32(BTREE_SEEK_EQ)) != 0 { eqOnly = int32(1) } nField2 = (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC5)).FpKeyInfo (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FnField = libc.Uint16FromInt32(nField2) /* The next line of code computes as follows, only faster: ** if( oc==OP_SeekGT || oc==OP_SeekLE ){ ** r.default_rc = -1; ** }else{ ** r.default_rc = +1; ** } */ if int32(1)&(oc-int32(OP_SeekLT)) != 0 { v190 = -int32(1) } else { v190 = +libc.Int32FromInt32(1) } (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).Fdefault_rc = int8(v190) (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 (**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FeqSeen = uint8(0) rc = _sqlite3BtreeIndexMoveto(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), bp+120, bp+112) if rc != SQLITE_OK { goto abort_due_to_error } if eqOnly != 0 && libc.Int32FromUint8((**(**TUnpackedRecord)(__ccgo_up(bp + 120))).FeqSeen) == 0 { goto seek_not_found } } if oc >= int32(OP_SeekGE) { if **(**int32)(__ccgo_up(bp + 112)) < 0 || **(**int32)(__ccgo_up(bp + 112)) == 0 && oc == int32(OP_SeekGT) { **(**int32)(__ccgo_up(bp + 112)) = 0 rc = _sqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), 0) if rc != SQLITE_OK { if rc == int32(SQLITE_DONE) { rc = SQLITE_OK **(**int32)(__ccgo_up(bp + 112)) = int32(1) } else { goto abort_due_to_error } } } else { **(**int32)(__ccgo_up(bp + 112)) = 0 } } else { if **(**int32)(__ccgo_up(bp + 112)) > 0 || **(**int32)(__ccgo_up(bp + 112)) == 0 && oc == int32(OP_SeekLT) { **(**int32)(__ccgo_up(bp + 112)) = 0 rc = _sqlite3BtreePrevious(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48)), 0) if rc != SQLITE_OK { if rc == int32(SQLITE_DONE) { rc = SQLITE_OK **(**int32)(__ccgo_up(bp + 112)) = int32(1) } else { goto abort_due_to_error } } } else { /* res might be negative because the table is empty. Check to ** see if this is the case. */ **(**int32)(__ccgo_up(bp + 112)) = _sqlite3BtreeEof(tls, *(*uintptr)(unsafe.Pointer(pC5 + 48))) } } goto seek_not_found seek_not_found: ; if **(**int32)(__ccgo_up(bp + 112)) != 0 { goto jump_to_p2 } else { if eqOnly != 0 { pOp += 24 /* Skip the OP_IdxLt or OP_IdxGT that follows */ } } goto _189 /* Opcode: SeekScan P1 P2 * * P5 ** Synopsis: Scan-ahead up to P1 rows ** ** This opcode is a prefix opcode to OP_SeekGE. In other words, this ** opcode must be immediately followed by OP_SeekGE. This constraint is ** checked by assert() statements. ** ** This opcode uses the P1 through P4 operands of the subsequent ** OP_SeekGE. In the text that follows, the operands of the subsequent ** OP_SeekGE opcode are denoted as SeekOP.P1 through SeekOP.P4. Only ** the P1, P2 and P5 operands of this opcode are also used, and are called ** This.P1, This.P2 and This.P5. ** ** This opcode helps to optimize IN operators on a multi-column index ** where the IN operator is on the later terms of the index by avoiding ** unnecessary seeks on the btree, substituting steps to the next row ** of the b-tree instead. A correct answer is obtained if this opcode ** is omitted or is a no-op. ** ** The SeekGE.P3 and SeekGE.P4 operands identify an unpacked key which ** is the desired entry that we want the cursor SeekGE.P1 to be pointing ** to. Call this SeekGE.P3/P4 row the "target". ** ** If the SeekGE.P1 cursor is not currently pointing to a valid row, ** then this opcode is a no-op and control passes through into the OP_SeekGE. ** ** If the SeekGE.P1 cursor is pointing to a valid row, then that row ** might be the target row, or it might be near and slightly before the ** target row, or it might be after the target row. If the cursor is ** currently before the target row, then this opcode attempts to position ** the cursor on or after the target row by invoking sqlite3BtreeStep() ** on the cursor between 1 and This.P1 times. ** ** The This.P5 parameter is a flag that indicates what to do if the ** cursor ends up pointing at a valid row that is past the target ** row. If This.P5 is false (0) then a jump is made to SeekGE.P2. If ** This.P5 is true (non-zero) then a jump is made to This.P2. The P5==0 ** case occurs when there are no inequality constraints to the right of ** the IN constraint. The jump to SeekGE.P2 ends the loop. The P5!=0 case ** occurs when there are inequality constraints to the right of the IN ** operator. In that case, the This.P2 will point either directly to or ** to setup code prior to the OP_IdxGT or OP_IdxGE opcode that checks for ** loop terminate. ** ** Possible outcomes from this opcode:
      ** **
    1. If the cursor is initially not pointed to any valid row, then ** fall through into the subsequent OP_SeekGE opcode. ** **
    2. If the cursor is left pointing to a row that is before the target ** row, even after making as many as This.P1 calls to ** sqlite3BtreeNext(), then also fall through into OP_SeekGE. ** **
    3. If the cursor is left pointing at the target row, either because it ** was at the target row to begin with or because one or more ** sqlite3BtreeNext() calls moved the cursor to the target row, ** then jump to This.P2.., ** **
    4. If the cursor started out before the target row and a call to ** to sqlite3BtreeNext() moved the cursor off the end of the index ** (indicating that the target row definitely does not exist in the ** btree) then jump to SeekGE.P2, ending the loop. ** **
    5. If the cursor ends up on a valid row that is past the target row ** (indicating that the target row does not exist in the btree) then ** jump to SeekOP.P2 if This.P5==0 or to This.P2 if This.P5>0. **
    */ _89: ; /* If pOp->p5 is clear, then pOp->p2 points to the first instruction past the ** OP_IdxGT that follows the OP_SeekGE. Otherwise, it points to the first ** opcode past the OP_SeekGE itself. */ pC6 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((**(**TOp)(__ccgo_up(pOp + 1*24))).Fp1)*8)) if !(_sqlite3BtreeCursorIsValidNN(tls, *(*uintptr)(unsafe.Pointer(pC6 + 48))) != 0) { goto _189 } nStep = (*TOp)(unsafe.Pointer(pOp)).Fp1 (**(**TUnpackedRecord)(__ccgo_up(bp + 168))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC6)).FpKeyInfo (**(**TUnpackedRecord)(__ccgo_up(bp + 168))).FnField = libc.Uint16FromInt32(*(*int32)(unsafe.Pointer(pOp + 1*24 + 16))) (**(**TUnpackedRecord)(__ccgo_up(bp + 168))).Fdefault_rc = 0 (**(**TUnpackedRecord)(__ccgo_up(bp + 168))).FaMem = aMem + uintptr((**(**TOp)(__ccgo_up(pOp + 1*24))).Fp3)*56 **(**int32)(__ccgo_up(bp + 160)) = 0 /* Not needed. Only used to silence a warning. */ _260: ; if !(int32(1) != 0) { goto _259 } rc = _sqlite3VdbeIdxKeyCompare(tls, db, pC6, bp+168, bp+160) if rc != 0 { goto abort_due_to_error } if !(**(**int32)(__ccgo_up(bp + 160)) > 0 && libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) == 0) { goto _261 } goto seekscan_search_fail seekscan_search_fail: ; /* Jump to SeekGE.P2, ending the loop */ pOp += 24 goto jump_to_p2 _261: ; if **(**int32)(__ccgo_up(bp + 160)) >= 0 { /* Jump to This.P2, bypassing the OP_SeekGE opcode */ goto jump_to_p2 goto _259 } if nStep <= 0 { goto _259 } nStep = nStep - 1 (*TVdbeCursor)(unsafe.Pointer(pC6)).FcacheStatus = uint32(CACHE_STALE) rc = _sqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC6 + 48)), 0) if rc != 0 { if rc == int32(SQLITE_DONE) { rc = SQLITE_OK goto seekscan_search_fail } else { goto abort_due_to_error } } goto _260 _259: ; goto _189 /* Opcode: SeekHit P1 P2 P3 * * ** Synopsis: set P2<=seekHit<=P3 ** ** Increase or decrease the seekHit value for cursor P1, if necessary, ** so that it is no less than P2 and no greater than P3. ** ** The seekHit integer represents the maximum of terms in an index for which ** there is known to be at least one match. If the seekHit value is smaller ** than the total number of equality terms in an index lookup, then the ** OP_IfNoHope opcode might run to see if the IN loop can be abandoned ** early, thus saving work. This is part of the IN-early-out optimization. ** ** P1 must be a valid b-tree cursor. */ _90: ; pC7 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) if libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC7)).FseekHit) < (*TOp)(unsafe.Pointer(pOp)).Fp2 { (*TVdbeCursor)(unsafe.Pointer(pC7)).FseekHit = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2) } else { if libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC7)).FseekHit) > (*TOp)(unsafe.Pointer(pOp)).Fp3 { (*TVdbeCursor)(unsafe.Pointer(pC7)).FseekHit = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) } } goto _189 /* Opcode: IfNotOpen P1 P2 * * * ** Synopsis: if( !csr[P1] ) goto P2 ** ** If cursor P1 is not open or if P1 is set to a NULL row using the ** OP_NullRow opcode, then jump to instruction P2. Otherwise, fall through. */ _91: ; pCur1 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) if pCur1 == uintptr(0) || (*TVdbeCursor)(unsafe.Pointer(pCur1)).FnullRow != 0 { goto jump_to_p2_and_check_for_interrupt } goto _189 /* Opcode: Found P1 P2 P3 P4 * ** Synopsis: key=r[P3@P4] ** ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If ** P4>0 then register P3 is the first of P4 registers that form an unpacked ** record. ** ** Cursor P1 is on an index btree. If the record identified by P3 and P4 ** is a prefix of any entry in P1 then a jump is made to P2 and ** P1 is left pointing at the matching entry. ** ** This operation leaves the cursor in a state where it can be ** advanced in the forward direction. The Next instruction will work, ** but not the Prev instruction. ** ** See also: NotFound, NoConflict, NotExists. SeekGe */ /* Opcode: NotFound P1 P2 P3 P4 * ** Synopsis: key=r[P3@P4] ** ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If ** P4>0 then register P3 is the first of P4 registers that form an unpacked ** record. ** ** Cursor P1 is on an index btree. If the record identified by P3 and P4 ** is not the prefix of any entry in P1 then a jump is made to P2. If P1 ** does contain an entry whose prefix matches the P3/P4 record then control ** falls through to the next instruction and P1 is left pointing at the ** matching entry. ** ** This operation leaves the cursor in a state where it cannot be ** advanced in either direction. In other words, the Next and Prev ** opcodes do not work after this operation. ** ** See also: Found, NotExists, NoConflict, IfNoHope */ /* Opcode: IfNoHope P1 P2 P3 P4 * ** Synopsis: key=r[P3@P4] ** ** Register P3 is the first of P4 registers that form an unpacked ** record. Cursor P1 is an index btree. P2 is a jump destination. ** In other words, the operands to this opcode are the same as the ** operands to OP_NotFound and OP_IdxGT. ** ** This opcode is an optimization attempt only. If this opcode always ** falls through, the correct answer is still obtained, but extra work ** is performed. ** ** A value of N in the seekHit flag of cursor P1 means that there exists ** a key P3:N that will match some record in the index. We want to know ** if it is possible for a record P3:P4 to match some record in the ** index. If it is not possible, we can skip some work. So if seekHit ** is less than P4, attempt to find out if a match is possible by running ** OP_NotFound. ** ** This opcode is used in IN clause processing for a multi-column key. ** If an IN clause is attached to an element of the key other than the ** left-most element, and if there are no matches on the most recent ** seek over the whole key, then it might be that one of the key element ** to the left is prohibiting a match, and hence there is "no hope" of ** any match regardless of how many IN clause elements are checked. ** In such a case, we abandon the IN clause search early, using this ** opcode. The opcode name comes from the fact that the ** jump is taken if there is "no hope" of achieving a match. ** ** See also: NotFound, SeekHit */ /* Opcode: NoConflict P1 P2 P3 P4 * ** Synopsis: key=r[P3@P4] ** ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If ** P4>0 then register P3 is the first of P4 registers that form an unpacked ** record. ** ** Cursor P1 is on an index btree. If the record identified by P3 and P4 ** contains any NULL value, jump immediately to P2. If all terms of the ** record are not-NULL then a check is done to determine if any row in the ** P1 index btree has a matching key prefix. If there are no matches, jump ** immediately to P2. If there is a match, fall through and leave the P1 ** cursor pointing to the matching row. ** ** This opcode is similar to OP_NotFound with the exceptions that the ** branch is always taken if any part of the search key input is NULL. ** ** This operation leaves the cursor in a state where it cannot be ** advanced in either direction. In other words, the Next and Prev ** opcodes do not work after this operation. ** ** See also: NotFound, Found, NotExists */ _92: ; pC8 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) if libc.Int32FromUint16((*TVdbeCursor)(unsafe.Pointer(pC8)).FseekHit) >= (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi { goto _189 } /* Fall through into OP_NotFound */ _95: ; /* jump, in3, ncycle */ _94: ; /* jump, in3, ncycle */ _93: ; pC9 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FnField = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi) if libc.Int32FromUint16((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FnField) > 0 { /* Key values in an array of registers */ (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC9)).FpKeyInfo (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).Fdefault_rc = 0 rc = _sqlite3BtreeIndexMoveto(tls, *(*uintptr)(unsafe.Pointer(pC9 + 48)), bp+208, pC9+36) } else { /* Composite key generated by OP_MakeRecord */ if libc.Int32FromUint16((*TMem)(unsafe.Pointer((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem)).Fflags)&int32(MEM_Zero) != 0 { v190 = _sqlite3VdbeMemExpandBlob(tls, (**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem) } else { v190 = 0 } rc = v190 if rc != 0 { goto no_mem } pIdxKey = _sqlite3VdbeAllocUnpackedRecord(tls, (*TVdbeCursor)(unsafe.Pointer(pC9)).FpKeyInfo) if pIdxKey == uintptr(0) { goto no_mem } _sqlite3VdbeRecordUnpack(tls, (*TMem)(unsafe.Pointer((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem)).Fn, (*TMem)(unsafe.Pointer((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem)).Fz, pIdxKey) (*TUnpackedRecord)(unsafe.Pointer(pIdxKey)).Fdefault_rc = 0 rc = _sqlite3BtreeIndexMoveto(tls, *(*uintptr)(unsafe.Pointer(pC9 + 48)), pIdxKey, pC9+36) _sqlite3DbFreeNN(tls, db, pIdxKey) } if rc != SQLITE_OK { goto abort_due_to_error } alreadyExists = libc.BoolInt32((*TVdbeCursor)(unsafe.Pointer(pC9)).FseekResult == 0) (*TVdbeCursor)(unsafe.Pointer(pC9)).FnullRow = libc.Uint8FromInt32(int32(1) - alreadyExists) (*TVdbeCursor)(unsafe.Pointer(pC9)).FdeferredMoveto = uint8(0) (*TVdbeCursor)(unsafe.Pointer(pC9)).FcacheStatus = uint32(CACHE_STALE) if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Found) { if alreadyExists != 0 { goto jump_to_p2 } } else { if !(alreadyExists != 0) { goto jump_to_p2 } if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_NoConflict) { /* For the OP_NoConflict opcode, take the jump if any of the ** input fields are NULL, since any key with a NULL will not ** conflict */ ii1 = 0 for { if !(ii1 < libc.Int32FromUint16((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FnField)) { break } if libc.Int32FromUint16((**(**TMem)(__ccgo_up((**(**TUnpackedRecord)(__ccgo_up(bp + 208))).FaMem + uintptr(ii1)*56))).Fflags)&int32(MEM_Null) != 0 { goto jump_to_p2 } goto _263 _263: ; ii1 = ii1 + 1 } } if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_IfNoHope) { (*TVdbeCursor)(unsafe.Pointer(pC9)).FseekHit = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi) } } goto _189 /* Opcode: SeekRowid P1 P2 P3 * * ** Synopsis: intkey=r[P3] ** ** P1 is the index of a cursor open on an SQL table btree (with integer ** keys). If register P3 does not contain an integer or if P1 does not ** contain a record with rowid P3 then jump immediately to P2. ** Or, if P2 is 0, raise an SQLITE_CORRUPT error. If P1 does contain ** a record with rowid P3 then ** leave the cursor pointing at that record and fall through to the next ** instruction. ** ** The OP_NotExists opcode performs the same operation, but with OP_NotExists ** the P3 register must be guaranteed to contain an integer value. With this ** opcode, register P3 might not contain an integer. ** ** The OP_NotFound opcode performs the same operation on index btrees ** (with arbitrary multi-value keys). ** ** This opcode leaves the cursor in a state where it cannot be advanced ** in either direction. In other words, the Next and Prev opcodes will ** not work following this opcode. ** ** See also: Found, NotFound, NoConflict, SeekRowid */ /* Opcode: NotExists P1 P2 P3 * * ** Synopsis: intkey=r[P3] ** ** P1 is the index of a cursor open on an SQL table btree (with integer ** keys). P3 is an integer rowid. If P1 does not contain a record with ** rowid P3 then jump immediately to P2. Or, if P2 is 0, raise an ** SQLITE_CORRUPT error. If P1 does contain a record with rowid P3 then ** leave the cursor pointing at that record and fall through to the next ** instruction. ** ** The OP_SeekRowid opcode performs the same operation but also allows the ** P3 register to contain a non-integer value, in which case the jump is ** always taken. This opcode requires that P3 always contain an integer. ** ** The OP_NotFound opcode performs the same operation on index btrees ** (with arbitrary multi-value keys). ** ** This opcode leaves the cursor in a state where it cannot be advanced ** in either direction. In other words, the Next and Prev opcodes will ** not work following this opcode. ** ** See also: Found, NotFound, NoConflict, SeekRowid */ _97: ; pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn3)).Fflags)&(libc.Int32FromInt32(MEM_Int)|libc.Int32FromInt32(MEM_IntReal)) == 0 { /* If pIn3->u.i does not contain an integer, compute iKey as the ** integer value of pIn3. Jump to P2 if pIn3 cannot be converted ** into an integer without loss of information. Take care to avoid ** changing the datatype of pIn3, however, as it is used by other ** parts of the prepared statement. */ *(*TMem)(unsafe.Pointer(bp + 256)) = TMem{} /* If pIn3->u.i does not contain an integer, compute iKey as the ** integer value of pIn3. Jump to P2 if pIn3 cannot be converted ** into an integer without loss of information. Take care to avoid ** changing the datatype of pIn3, however, as it is used by other ** parts of the prepared statement. */ *(*Tsqlite3_value)(unsafe.Pointer(bp + 256)) = **(**TMem)(__ccgo_up(pIn3)) _applyAffinity(tls, bp+256, uint8(SQLITE_AFF_NUMERIC), encoding) if libc.Int32FromUint16((**(**TMem)(__ccgo_up(bp + 256))).Fflags)&int32(MEM_Int) == 0 { goto jump_to_p2 } iKey1 = libc.Uint64FromInt64(*(*Ti64)(unsafe.Pointer(bp + 256))) goto notExistsWithKey } /* Fall through into OP_NotExists */ _96: ; /* jump, in3, ncycle */ pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 iKey1 = libc.Uint64FromInt64(*(*Ti64)(unsafe.Pointer(pIn3))) goto notExistsWithKey notExistsWithKey: ; pC10 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) pCrsr2 = *(*uintptr)(unsafe.Pointer(pC10 + 48)) **(**int32)(__ccgo_up(bp + 248)) = 0 rc = _sqlite3BtreeTableMoveto(tls, pCrsr2, libc.Int64FromUint64(iKey1), 0, bp+248) (*TVdbeCursor)(unsafe.Pointer(pC10)).FmovetoTarget = libc.Int64FromUint64(iKey1) /* Used by OP_Delete */ (*TVdbeCursor)(unsafe.Pointer(pC10)).FnullRow = uint8(0) (*TVdbeCursor)(unsafe.Pointer(pC10)).FcacheStatus = uint32(CACHE_STALE) (*TVdbeCursor)(unsafe.Pointer(pC10)).FdeferredMoveto = uint8(0) (*TVdbeCursor)(unsafe.Pointer(pC10)).FseekResult = **(**int32)(__ccgo_up(bp + 248)) if **(**int32)(__ccgo_up(bp + 248)) != 0 { if (*TOp)(unsafe.Pointer(pOp)).Fp2 == 0 { rc = _sqlite3CorruptError(tls, int32(102303)) } else { goto jump_to_p2 } } if rc != 0 { goto abort_due_to_error } goto _189 /* Opcode: Sequence P1 P2 * * * ** Synopsis: r[P2]=cursor[P1].ctr++ ** ** Find the next available sequence number for cursor P1. ** Write the sequence number into register P2. ** The sequence number on the cursor is incremented after this ** instruction. */ _98: ; /* out2 */ pOut = _out2Prerelease(tls, p, pOp) v191 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) + 24 v256 = *(*Ti64)(unsafe.Pointer(v191)) *(*Ti64)(unsafe.Pointer(v191)) = *(*Ti64)(unsafe.Pointer(v191)) + 1 *(*Ti64)(unsafe.Pointer(pOut)) = v256 goto _189 /* Opcode: NewRowid P1 P2 P3 * * ** Synopsis: r[P2]=rowid ** ** Get a new integer record number (a.k.a "rowid") used as the key to a table. ** The record number is not previously used as a key in the database ** table that cursor P1 points to. The new record number is written ** written to register P2. ** ** If P3>0 then P3 is a register in the root frame of this VDBE that holds ** the largest previously generated record number. No new record numbers are ** allowed to be less than this value. When this value reaches its maximum, ** an SQLITE_FULL error is generated. The P3 register is updated with the ' ** generated record number. This P3 mechanism is used to help implement the ** AUTOINCREMENT feature. */ _99: ; /* Root frame of VDBE */ **(**Ti64)(__ccgo_up(bp + 312)) = 0 **(**int32)(__ccgo_up(bp + 320)) = 0 pOut = _out2Prerelease(tls, p, pOp) pC11 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) /* The next rowid or record number (different terms for the same ** thing) is obtained in a two-step algorithm. ** ** First we attempt to find the largest existing rowid and add one ** to that. But if the largest existing rowid is already the maximum ** positive integer, we have to fall through to the second ** probabilistic algorithm ** ** The second algorithm is to select a rowid at random and see if ** it already exists in the table. If it does not exist, we have ** succeeded. If the random rowid does exist, we select a new one ** and try again, up to 100 times. */ /* Some compilers complain about constants of the form 0x7fffffffffffffff. ** Others complain about 0x7ffffffffffffffffLL. The following macro seems ** to provide the constant while making all compilers happy. */ if !(int32(TBool(*(*uint8)(unsafe.Pointer(pC11 + 8))&0x2>>1)) != 0) { rc = _sqlite3BtreeLast(tls, *(*uintptr)(unsafe.Pointer(pC11 + 48)), bp+320) if rc != SQLITE_OK { goto abort_due_to_error } if **(**int32)(__ccgo_up(bp + 320)) != 0 { **(**Ti64)(__ccgo_up(bp + 312)) = int64(1) /* IMP: R-61914-48074 */ } else { **(**Ti64)(__ccgo_up(bp + 312)) = _sqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC11 + 48))) if **(**Ti64)(__ccgo_up(bp + 312)) >= libc.Int64FromUint64(libc.Uint64FromInt32(0x7fffffff)<>1)) != 0 { rc = int32(SQLITE_FULL) /* IMP: R-17817-00630 */ goto abort_due_to_error } if **(**Ti64)(__ccgo_up(bp + 312)) < *(*Ti64)(unsafe.Pointer(pMem))+int64(1) { **(**Ti64)(__ccgo_up(bp + 312)) = *(*Ti64)(unsafe.Pointer(pMem)) + int64(1) } *(*Ti64)(unsafe.Pointer(pMem)) = **(**Ti64)(__ccgo_up(bp + 312)) } if int32(TBool(*(*uint8)(unsafe.Pointer(pC11 + 8))&0x2>>1)) != 0 { /* IMPLEMENTATION-OF: R-07677-41881 If the largest ROWID is equal to the ** largest possible integer (9223372036854775807) then the database ** engine starts picking positive candidate ROWIDs at random until ** it finds one that is not previously used. */ /* We cannot be in random rowid mode if this is ** an AUTOINCREMENT table. */ cnt1 = 0 for { Xsqlite3_randomness(tls, int32(8), bp+312) **(**Ti64)(__ccgo_up(bp + 312)) = **(**Ti64)(__ccgo_up(bp + 312)) & (libc.Int64FromUint64(libc.Uint64FromInt32(0x7fffffff)<> libc.Int32FromInt32(1)) **(**Ti64)(__ccgo_up(bp + 312)) = **(**Ti64)(__ccgo_up(bp + 312)) + 1 /* Ensure that v is greater than zero */ goto _270 _270: ; v190 = _sqlite3BtreeTableMoveto(tls, *(*uintptr)(unsafe.Pointer(pC11 + 48)), libc.Int64FromUint64(libc.Uint64FromInt64(**(**Ti64)(__ccgo_up(bp + 312)))), 0, bp+320) rc = v190 if v217 = v190 == SQLITE_OK && **(**int32)(__ccgo_up(bp + 320)) == 0; v217 { cnt1 = cnt1 + 1 v193 = cnt1 } if !(v217 && v193 < int32(100)) { break } } if rc != 0 { goto abort_due_to_error } if **(**int32)(__ccgo_up(bp + 320)) == 0 { rc = int32(SQLITE_FULL) /* IMP: R-38219-53002 */ goto abort_due_to_error } /* EV: R-40812-03570 */ } (*TVdbeCursor)(unsafe.Pointer(pC11)).FdeferredMoveto = uint8(0) (*TVdbeCursor)(unsafe.Pointer(pC11)).FcacheStatus = uint32(CACHE_STALE) *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(bp + 312)) goto _189 /* Opcode: Insert P1 P2 P3 P4 P5 ** Synopsis: intkey=r[P3] data=r[P2] ** ** Write an entry into the table of cursor P1. A new entry is ** created if it doesn't already exist or the data for an existing ** entry is overwritten. The data is the value MEM_Blob stored in register ** number P2. The key is stored in register P3. The key must ** be a MEM_Int. ** ** If the OPFLAG_NCHANGE flag of P5 is set, then the row change count is ** incremented (otherwise not). If the OPFLAG_LASTROWID flag of P5 is set, ** then rowid is stored for subsequent return by the ** sqlite3_last_insert_rowid() function (otherwise it is unmodified). ** ** If the OPFLAG_USESEEKRESULT flag of P5 is set, the implementation might ** run faster by avoiding an unnecessary seek on cursor P1. However, ** the OPFLAG_USESEEKRESULT flag must only be set if there have been no prior ** seeks on the cursor or if the most recent seek used a key equal to P3. ** ** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an ** UPDATE operation. Otherwise (if the flag is clear) then this opcode ** is part of an INSERT operation. The difference is only important to ** the update hook. ** ** Parameter P4 may point to a Table structure, or may be NULL. If it is ** not NULL, then the update-hook (sqlite3.xUpdateCallback) is invoked ** following a successful insert. ** ** (WARNING/TODO: If P1 is a pseudo-cursor and P2 is dynamically ** allocated, then ownership of P2 is transferred to the pseudo-cursor ** and register P2 becomes ephemeral. If the cursor is changed, the ** value of register P2 will then change. Make sure this does not ** cause any problems.) ** ** This instruction only works on tables. The equivalent instruction ** for indices is OP_IdxInsert. */ _100: ; /* Payload to be inserted */ pData = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 pC12 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) pKey = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnKey = *(*Ti64)(unsafe.Pointer(pKey)) if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == -int32(5) && ((*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0) { zDb = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TVdbeCursor)(unsafe.Pointer(pC12)).FiDb)*32))).FzDbSName pTab1 = *(*uintptr)(unsafe.Pointer(pOp + 16)) } else { pTab1 = uintptr(0) zDb = uintptr(0) } /* Invoke the pre-update hook, if any */ if pTab1 != 0 { if (*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 && !(libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&libc.Int32FromInt32(OPFLAG_ISUPDATE) != 0) { _sqlite3VdbePreUpdateHook(tls, p, pC12, int32(SQLITE_INSERT), zDb, pTab1, (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnKey, (*TOp)(unsafe.Pointer(pOp)).Fp2, -int32(1)) } if (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback == uintptr(0) || (*TTable)(unsafe.Pointer(pTab1)).FaCol == uintptr(0) { /* Prevent post-update hook from running in cases when it should not */ pTab1 = uintptr(0) } } if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_ISNOOP) != 0 { goto _189 } if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_NCHANGE) != 0 { (*TVdbe)(unsafe.Pointer(p)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + 1 if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_LASTROWID) != 0 { (*Tsqlite3)(unsafe.Pointer(db)).FlastRowid = (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnKey } } (**(**TBtreePayload)(__ccgo_up(bp + 328))).FpData = (*TMem)(unsafe.Pointer(pData)).Fz (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnData = (*TMem)(unsafe.Pointer(pData)).Fn if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_USESEEKRESULT) != 0 { v190 = (*TVdbeCursor)(unsafe.Pointer(pC12)).FseekResult } else { v190 = 0 } seekResult = v190 if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pData)).Fflags)&int32(MEM_Zero) != 0 { (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnZero = *(*int32)(unsafe.Pointer(&(*TMem)(unsafe.Pointer(pData)).Fu)) } else { (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnZero = 0 } (**(**TBtreePayload)(__ccgo_up(bp + 328))).FpKey = uintptr(0) rc = _sqlite3BtreeInsert(tls, *(*uintptr)(unsafe.Pointer(pC12 + 48)), bp+328, libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&(libc.Int32FromInt32(OPFLAG_APPEND)|libc.Int32FromInt32(OPFLAG_SAVEPOSITION)|libc.Int32FromInt32(OPFLAG_PREFORMAT)), seekResult) (*TVdbeCursor)(unsafe.Pointer(pC12)).FdeferredMoveto = uint8(0) (*TVdbeCursor)(unsafe.Pointer(pC12)).FcacheStatus = uint32(CACHE_STALE) colCacheCtr = colCacheCtr + 1 /* Invoke the update-hook if required. */ if rc != 0 { goto abort_due_to_error } if pTab1 != 0 { if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_ISUPDATE) != 0 { v190 = int32(SQLITE_UPDATE) } else { v190 = int32(SQLITE_INSERT) } (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, Tsqlite_int64))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpUpdateArg, v190, zDb, (*TTable)(unsafe.Pointer(pTab1)).FzName, (**(**TBtreePayload)(__ccgo_up(bp + 328))).FnKey) } goto _189 /* Opcode: RowCell P1 P2 P3 * * ** ** P1 and P2 are both open cursors. Both must be opened on the same type ** of table - intkey or index. This opcode is used as part of copying ** the current row from P2 into P1. If the cursors are opened on intkey ** tables, register P3 contains the rowid to use with the new record in ** P1. If they are opened on index tables, P3 is not used. ** ** This opcode must be followed by either an Insert or InsertIdx opcode ** with the OPFLAG_PREFORMAT flag set to complete the insert operation. */ _101: ; /* Rowid value to insert with */ pDest1 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) pSrc = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*8)) if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { v206 = *(*Ti64)(unsafe.Pointer(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56)) } else { v206 = 0 } iKey2 = v206 rc = _sqlite3BtreeTransferRow(tls, *(*uintptr)(unsafe.Pointer(pDest1 + 48)), *(*uintptr)(unsafe.Pointer(pSrc + 48)), iKey2) if rc != SQLITE_OK { goto abort_due_to_error } goto _189 /* Opcode: Delete P1 P2 P3 P4 P5 ** ** Delete the record at which the P1 cursor is currently pointing. ** ** If the OPFLAG_SAVEPOSITION bit of the P5 parameter is set, then ** the cursor will be left pointing at either the next or the previous ** record in the table. If it is left pointing at the next record, then ** the next Next instruction will be a no-op. As a result, in this case ** it is ok to delete a record from within a Next loop. If ** OPFLAG_SAVEPOSITION bit of P5 is clear, then the cursor will be ** left in an undefined state. ** ** If the OPFLAG_AUXDELETE bit is set on P5, that indicates that this ** delete is one of several associated with deleting a table row and ** all its associated index entries. Exactly one of those deletes is ** the "primary" delete. The others are all on OPFLAG_FORDELETE ** cursors or else are marked with the AUXDELETE flag. ** ** If the OPFLAG_NCHANGE (0x01) flag of P2 (NB: P2 not P5) is set, then ** the row change count is incremented (otherwise not). ** ** If the OPFLAG_ISNOOP (0x40) flag of P2 (not P5!) is set, then the ** pre-update-hook for deletes is run, but the btree is otherwise unchanged. ** This happens when the OP_Delete is to be shortly followed by an OP_Insert ** with the same key, causing the btree entry to be overwritten. ** ** P1 must not be pseudo-table. It has to be a real table with ** multiple rows. ** ** If P4 is not NULL then it points to a Table object. In this case either ** the update or pre-update hook, or both, may be invoked. The P1 cursor must ** have been positioned using OP_NotFound prior to invoking this opcode in ** this case. Specifically, if one is configured, the pre-update hook is ** invoked if P4 is not NULL. The update-hook is invoked if one is configured, ** P4 is not NULL, and the OPFLAG_NCHANGE flag is set in P2. ** ** If the OPFLAG_ISUPDATE flag is set in P2, then P3 contains the address ** of the memory cell that contains the value that the rowid of the row will ** be set to by the update. */ _102: ; opflags = (*TOp)(unsafe.Pointer(pOp)).Fp2 pC13 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) /* If the update-hook or pre-update-hook will be invoked, set zDb to ** the name of the db to pass as to it. Also set local pTab to a copy ** of p4.pTab. Finally, if p5 is true, indicating that this cursor was ** last moved with OP_Next or OP_Prev, not Seek or NotFound, set ** VdbeCursor.movetoTarget to the current rowid. */ if int32((*TOp)(unsafe.Pointer(pOp)).Fp4type) == -int32(5) && ((*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0) { zDb1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TVdbeCursor)(unsafe.Pointer(pC13)).FiDb)*32))).FzDbSName pTab2 = *(*uintptr)(unsafe.Pointer(pOp + 16)) if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_SAVEPOSITION) != 0 && (*TVdbeCursor)(unsafe.Pointer(pC13)).FisTable != 0 { (*TVdbeCursor)(unsafe.Pointer(pC13)).FmovetoTarget = _sqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC13 + 48))) } } else { zDb1 = uintptr(0) pTab2 = uintptr(0) } /* Invoke the pre-update-hook if required. */ if (*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback != 0 && pTab2 != 0 { if opflags&int32(OPFLAG_ISUPDATE) != 0 { v190 = int32(SQLITE_UPDATE) } else { v190 = int32(SQLITE_DELETE) } _sqlite3VdbePreUpdateHook(tls, p, pC13, v190, zDb1, pTab2, (*TVdbeCursor)(unsafe.Pointer(pC13)).FmovetoTarget, (*TOp)(unsafe.Pointer(pOp)).Fp3, -int32(1)) } if opflags&int32(OPFLAG_ISNOOP) != 0 { goto _189 } /* Only flags that can be set are SAVEPOISTION and AUXDELETE */ rc = _sqlite3BtreeDelete(tls, *(*uintptr)(unsafe.Pointer(pC13 + 48)), uint8((*TOp)(unsafe.Pointer(pOp)).Fp5)) (*TVdbeCursor)(unsafe.Pointer(pC13)).FcacheStatus = uint32(CACHE_STALE) colCacheCtr = colCacheCtr + 1 (*TVdbeCursor)(unsafe.Pointer(pC13)).FseekResult = 0 if rc != 0 { goto abort_due_to_error } /* Invoke the update-hook if required. */ if opflags&int32(OPFLAG_NCHANGE) != 0 { (*TVdbe)(unsafe.Pointer(p)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + 1 if (*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback != 0 && pTab2 != uintptr(0) && (*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_WithoutRowid) == uint32(0) { (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, Tsqlite_int64))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpUpdateArg, int32(SQLITE_DELETE), zDb1, (*TTable)(unsafe.Pointer(pTab2)).FzName, (*TVdbeCursor)(unsafe.Pointer(pC13)).FmovetoTarget) } } goto _189 /* Opcode: ResetCount * * * * * ** ** The value of the change counter is copied to the database handle ** change counter (returned by subsequent calls to sqlite3_changes()). ** Then the VMs internal change counter resets to 0. ** This is used by trigger programs. */ _103: ; _sqlite3VdbeSetChanges(tls, db, (*TVdbe)(unsafe.Pointer(p)).FnChange) (*TVdbe)(unsafe.Pointer(p)).FnChange = 0 goto _189 /* Opcode: SorterCompare P1 P2 P3 P4 ** Synopsis: if key(P1)!=trim(r[P3],P4) goto P2 ** ** P1 is a sorter cursor. This instruction compares a prefix of the ** record blob in register P3 against a prefix of the entry that ** the sorter cursor currently points to. Only the first P4 fields ** of r[P3] and the sorter record are compared. ** ** If either P3 or the sorter contains a NULL in one of their significant ** fields (not counting the P4 fields at the end which are ignored) then ** the comparison is assumed to be equal. ** ** Fall through to next instruction if the two records compare equal to ** each other. Jump to P2 if they are different. */ _104: ; pC14 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 nKeyCol = (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi **(**int32)(__ccgo_up(bp + 376)) = 0 rc = _sqlite3VdbeSorterCompare(tls, pC14, pIn3, nKeyCol, bp+376) if rc != 0 { goto abort_due_to_error } if **(**int32)(__ccgo_up(bp + 376)) != 0 { goto jump_to_p2 } goto _189 /* Opcode: SorterData P1 P2 P3 * * ** Synopsis: r[P2]=data ** ** Write into register P2 the current sorter data for sorter cursor P1. ** Then clear the column header cache on cursor P3. ** ** This opcode is normally used to move a record out of the sorter and into ** a register that is the source for a pseudo-table cursor created using ** OpenPseudo. That pseudo-table cursor is the one that is identified by ** parameter P3. Clearing the P3 column cache as part of this opcode saves ** us from having to issue a separate NullRow instruction to clear that cache. */ _105: ; pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 pC15 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) rc = _sqlite3VdbeSorterRowkey(tls, pC15, pOut) if rc != 0 { goto abort_due_to_error } (*TVdbeCursor)(unsafe.Pointer(**(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*8)))).FcacheStatus = uint32(CACHE_STALE) goto _189 /* Opcode: RowData P1 P2 P3 * * ** Synopsis: r[P2]=data ** ** Write into register P2 the complete row content for the row at ** which cursor P1 is currently pointing. ** There is no interpretation of the data. ** It is just copied onto the P2 register exactly as ** it is found in the database file. ** ** If cursor P1 is an index, then the content is the key of the row. ** If cursor P2 is a table, then the content extracted is the data. ** ** If the P1 cursor must be pointing to a valid row (not a NULL row) ** of a real table, not a pseudo-table. ** ** If P3!=0 then this opcode is allowed to make an ephemeral pointer ** into the database page. That means that the content of the output ** register will be invalidated as soon as the cursor moves - including ** moves caused by other cursors that "save" the current cursors ** position in order that they can write to the same table. If P3==0 ** then a copy of the data is made into memory. P3!=0 is faster, but ** P3==0 is safer. ** ** If P3!=0 then the content of the P2 register is unsuitable for use ** in OP_Result and any OP_Result will invalidate the P2 register content. ** The P2 register content is invalidated by opcodes like OP_Function or ** by any use of another cursor pointing to the same table. */ _106: ; pOut = _out2Prerelease(tls, p, pOp) pC16 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) pCrsr3 = *(*uintptr)(unsafe.Pointer(pC16 + 48)) /* The OP_RowData opcodes always follow OP_NotExists or ** OP_SeekRowid or OP_Rewind/Op_Next with no intervening instructions ** that might invalidate the cursor. ** If this were not the case, one of the following assert()s ** would fail. Should this ever change (because of changes in the code ** generator) then the fix would be to insert a call to ** sqlite3VdbeCursorMoveto(). */ n3 = _sqlite3BtreePayloadSize(tls, pCrsr3) if n3 > libc.Uint32FromInt32(**(**int32)(__ccgo_up(db + 136))) { goto too_big } rc = _sqlite3VdbeMemFromBtreeZeroOffset(tls, pCrsr3, n3, pOut) if rc != 0 { goto abort_due_to_error } if !((*TOp)(unsafe.Pointer(pOp)).Fp3 != 0) { if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags)&int32(MEM_Ephem) != 0 && _sqlite3VdbeMemMakeWriteable(tls, pOut) != 0 { goto no_mem } } goto _189 /* Opcode: Rowid P1 P2 * * * ** Synopsis: r[P2]=PX rowid of P1 ** ** Store in register P2 an integer which is the key of the table entry that ** P1 is currently point to. ** ** P1 can be either an ordinary table or a virtual table. There used to ** be a separate OP_VRowid opcode for use with virtual tables, but this ** one opcode now works for both table types. */ _107: ; pOut = _out2Prerelease(tls, p, pOp) pC17 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) if (*TVdbeCursor)(unsafe.Pointer(pC17)).FnullRow != 0 { (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Null) goto _189 } else { if (*TVdbeCursor)(unsafe.Pointer(pC17)).FdeferredMoveto != 0 { **(**Ti64)(__ccgo_up(bp + 384)) = (*TVdbeCursor)(unsafe.Pointer(pC17)).FmovetoTarget } else { if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC17)).FeCurType) == int32(CURTYPE_VTAB) { pVtab = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pC17 + 48)))).FpVtab pModule = (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FpModule rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule)).FxRowid})))(tls, *(*uintptr)(unsafe.Pointer(pC17 + 48)), bp+384) _sqlite3VtabImportErrmsg(tls, p, pVtab) if rc != 0 { goto abort_due_to_error } } else { rc = _sqlite3VdbeCursorRestore(tls, pC17) if rc != 0 { goto abort_due_to_error } if (*TVdbeCursor)(unsafe.Pointer(pC17)).FnullRow != 0 { (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Null) goto _189 } **(**Ti64)(__ccgo_up(bp + 384)) = _sqlite3BtreeIntegerKey(tls, *(*uintptr)(unsafe.Pointer(pC17 + 48))) } } } *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(bp + 384)) goto _189 /* Opcode: NullRow P1 * * * * ** ** Move the cursor P1 to a null row. Any OP_Column operations ** that occur while the cursor is on the null row will always ** write a NULL. ** ** If cursor P1 is not previously opened, open it now to a special ** pseudo-cursor that always returns NULL for every column. */ _108: ; pC18 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) if pC18 == uintptr(0) { /* If the cursor is not already open, create a special kind of ** pseudo-cursor that always gives null rows. */ pC18 = _allocateCursor(tls, p, (*TOp)(unsafe.Pointer(pOp)).Fp1, int32(1), uint8(CURTYPE_PSEUDO)) if pC18 == uintptr(0) { goto no_mem } (*TVdbeCursor)(unsafe.Pointer(pC18)).FseekResult = 0 (*TVdbeCursor)(unsafe.Pointer(pC18)).FisTable = uint8(1) libc.SetBitFieldPtr8Uint32(pC18+8, libc.Uint32FromInt32(1), 3, 0x8) *(*uintptr)(unsafe.Pointer(pC18 + 48)) = _sqlite3BtreeFakeValidCursor(tls) } (*TVdbeCursor)(unsafe.Pointer(pC18)).FnullRow = uint8(1) (*TVdbeCursor)(unsafe.Pointer(pC18)).FcacheStatus = uint32(CACHE_STALE) if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC18)).FeCurType) == CURTYPE_BTREE { _sqlite3BtreeClearCursor(tls, *(*uintptr)(unsafe.Pointer(pC18 + 48))) } goto _189 /* Opcode: SeekEnd P1 * * * * ** ** Position cursor P1 at the end of the btree for the purpose of ** appending a new entry onto the btree. ** ** It is assumed that the cursor is used only for appending and so ** if the cursor is valid, then the cursor must already be pointing ** at the end of the btree and so no changes are made to ** the cursor. */ /* Opcode: Last P1 P2 * * * ** ** The next use of the Rowid or Column or Prev instruction for P1 ** will refer to the last entry in the database table or index. ** If the table or index is empty and P2>0, then jump immediately to P2. ** If P2 is 0 or if the table or index is not empty, fall through ** to the following instruction. ** ** This opcode leaves the cursor configured to move in reverse order, ** from the end toward the beginning. In other words, the cursor is ** configured to use Prev, not Next. */ _110: ; /* ncycle */ _109: ; pC19 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) pCrsr4 = *(*uintptr)(unsafe.Pointer(pC19 + 48)) **(**int32)(__ccgo_up(bp + 392)) = 0 if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_SeekEnd) { (*TVdbeCursor)(unsafe.Pointer(pC19)).FseekResult = -int32(1) if _sqlite3BtreeCursorIsValidNN(tls, pCrsr4) != 0 { goto _189 } } rc = _sqlite3BtreeLast(tls, pCrsr4, bp+392) (*TVdbeCursor)(unsafe.Pointer(pC19)).FnullRow = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp + 392))) (*TVdbeCursor)(unsafe.Pointer(pC19)).FdeferredMoveto = uint8(0) (*TVdbeCursor)(unsafe.Pointer(pC19)).FcacheStatus = uint32(CACHE_STALE) if rc != 0 { goto abort_due_to_error } if (*TOp)(unsafe.Pointer(pOp)).Fp2 > 0 { if **(**int32)(__ccgo_up(bp + 392)) != 0 { goto jump_to_p2 } } goto _189 /* Opcode: IfSizeBetween P1 P2 P3 P4 * ** ** Let N be the approximate number of rows in the table or index ** with cursor P1 and let X be 10*log2(N) if N is positive or -1 ** if N is zero. ** ** Jump to P2 if X is in between P3 and P4, inclusive. */ _111: ; pC20 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) pCrsr5 = *(*uintptr)(unsafe.Pointer(pC20 + 48)) rc = _sqlite3BtreeFirst(tls, pCrsr5, bp+396) if rc != 0 { goto abort_due_to_error } if **(**int32)(__ccgo_up(bp + 396)) != 0 { sz = int64(-int32(1)) /* -Infinity encoding */ } else { sz = _sqlite3BtreeRowCountEst(tls, pCrsr5) sz = int64(_sqlite3LogEst(tls, libc.Uint64FromInt64(sz))) } **(**int32)(__ccgo_up(bp + 396)) = libc.BoolInt32(sz >= int64((*TOp)(unsafe.Pointer(pOp)).Fp3) && sz <= int64((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi)) if **(**int32)(__ccgo_up(bp + 396)) != 0 { goto jump_to_p2 } goto _189 /* Opcode: SorterSort P1 P2 * * * ** ** After all records have been inserted into the Sorter object ** identified by P1, invoke this opcode to actually do the sorting. ** Jump to P2 if there are no records to be sorted. ** ** This opcode is an alias for OP_Sort and OP_Rewind that is used ** for Sorter objects. */ /* Opcode: Sort P1 P2 * * * ** ** This opcode does exactly the same thing as OP_Rewind except that ** it increments an undocumented global variable used for testing. ** ** Sorting is accomplished by writing records into a sorting index, ** then rewinding that index and playing it back from beginning to ** end. We use the OP_Sort opcode instead of OP_Rewind to do the ** rewinding so that the global variable will be incremented and ** regression tests can determine whether or not the optimizer is ** correctly optimizing out sorts. */ _113: ; /* jump ncycle */ _112: ; /* jump ncycle */ **(**Tu32)(__ccgo_up(p + 212 + 2*4)) = **(**Tu32)(__ccgo_up(p + 212 + 2*4)) + 1 /* Fall through into OP_Rewind */ /* Opcode: Rewind P1 P2 * * * ** ** The next use of the Rowid or Column or Next instruction for P1 ** will refer to the first entry in the database table or index. ** If the table or index is empty, jump immediately to P2. ** If the table or index is not empty, fall through to the following ** instruction. ** ** If P2 is zero, that is an assertion that the P1 table is never ** empty and hence the jump will never be taken. ** ** This opcode leaves the cursor configured to move in forward order, ** from the beginning toward the end. In other words, the cursor is ** configured to use Next, not Prev. */ _114: ; pC21 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) **(**int32)(__ccgo_up(bp + 400)) = int32(1) if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC21)).FeCurType) == int32(CURTYPE_SORTER) { rc = _sqlite3VdbeSorterRewind(tls, pC21, bp+400) } else { pCrsr6 = *(*uintptr)(unsafe.Pointer(pC21 + 48)) rc = _sqlite3BtreeFirst(tls, pCrsr6, bp+400) (*TVdbeCursor)(unsafe.Pointer(pC21)).FdeferredMoveto = uint8(0) (*TVdbeCursor)(unsafe.Pointer(pC21)).FcacheStatus = uint32(CACHE_STALE) } if rc != 0 { goto abort_due_to_error } (*TVdbeCursor)(unsafe.Pointer(pC21)).FnullRow = libc.Uint8FromInt32(**(**int32)(__ccgo_up(bp + 400))) if (*TOp)(unsafe.Pointer(pOp)).Fp2 > 0 { if **(**int32)(__ccgo_up(bp + 400)) != 0 { goto jump_to_p2 } } goto _189 /* Opcode: IfEmpty P1 P2 * * * ** Synopsis: if( empty(P1) ) goto P2 ** ** Check to see if the b-tree table that cursor P1 references is empty ** and jump to P2 if it is. */ _115: ; pC22 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) pCrsr7 = *(*uintptr)(unsafe.Pointer(pC22 + 48)) rc = _sqlite3BtreeIsEmpty(tls, pCrsr7, bp+404) if rc != 0 { goto abort_due_to_error } if **(**int32)(__ccgo_up(bp + 404)) != 0 { goto jump_to_p2 } goto _189 /* Opcode: Next P1 P2 P3 * P5 ** ** Advance cursor P1 so that it points to the next key/data pair in its ** table or index. If there are no more key/value pairs then fall through ** to the following instruction. But if the cursor advance was successful, ** jump immediately to P2. ** ** The Next opcode is only valid following an SeekGT, SeekGE, or ** OP_Rewind opcode used to position the cursor. Next is not allowed ** to follow SeekLT, SeekLE, or OP_Last. ** ** The P1 cursor must be for a real table, not a pseudo-table. P1 must have ** been opened prior to this opcode or the program will segfault. ** ** The P3 value is a hint to the btree implementation. If P3==1, that ** means P1 is an SQL index and that this instruction could have been ** omitted if that index had been unique. P3 is usually 0. P3 is ** always either 0 or 1. ** ** If P5 is positive and the jump is taken, then event counter ** number P5-1 in the prepared statement is incremented. ** ** See also: Prev */ /* Opcode: Prev P1 P2 P3 * P5 ** ** Back up cursor P1 so that it points to the previous key/data pair in its ** table or index. If there is no previous key/value pairs then fall through ** to the following instruction. But if the cursor backup was successful, ** jump immediately to P2. ** ** ** The Prev opcode is only valid following an SeekLT, SeekLE, or ** OP_Last opcode used to position the cursor. Prev is not allowed ** to follow SeekGT, SeekGE, or OP_Rewind. ** ** The P1 cursor must be for a real table, not a pseudo-table. If P1 is ** not open then the behavior is undefined. ** ** The P3 value is a hint to the btree implementation. If P3==1, that ** means P1 is an SQL index and that this instruction could have been ** omitted if that index had been unique. P3 is usually 0. P3 is ** always either 0 or 1. ** ** If P5 is positive and the jump is taken, then event counter ** number P5-1 in the prepared statement is incremented. */ /* Opcode: SorterNext P1 P2 * * P5 ** ** This opcode works just like OP_Next except that P1 must be a ** sorter object for which the OP_SorterSort opcode has been ** invoked. This opcode advances the cursor to the next sorted ** record, or jumps to P2 if there are no more sorted records. */ _118: ; pC23 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) rc = _sqlite3VdbeSorterNext(tls, db, pC23) goto next_tail _116: ; /* jump, ncycle */ pC23 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) rc = _sqlite3BtreePrevious(tls, *(*uintptr)(unsafe.Pointer(pC23 + 48)), (*TOp)(unsafe.Pointer(pOp)).Fp3) goto next_tail _117: ; /* jump, ncycle */ pC23 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) rc = _sqlite3BtreeNext(tls, *(*uintptr)(unsafe.Pointer(pC23 + 48)), (*TOp)(unsafe.Pointer(pOp)).Fp3) goto next_tail next_tail: ; (*TVdbeCursor)(unsafe.Pointer(pC23)).FcacheStatus = uint32(CACHE_STALE) if rc == SQLITE_OK { (*TVdbeCursor)(unsafe.Pointer(pC23)).FnullRow = uint8(0) **(**Tu32)(__ccgo_up(p + 212 + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp5)*4)) = **(**Tu32)(__ccgo_up(p + 212 + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp5)*4)) + 1 goto jump_to_p2_and_check_for_interrupt } if rc != int32(SQLITE_DONE) { goto abort_due_to_error } rc = SQLITE_OK (*TVdbeCursor)(unsafe.Pointer(pC23)).FnullRow = uint8(1) goto check_for_interrupt /* Opcode: IdxInsert P1 P2 P3 P4 P5 ** Synopsis: key=r[P2] ** ** Register P2 holds an SQL index key made using the ** MakeRecord instructions. This opcode writes that key ** into the index P1. Data for the entry is nil. ** ** If P4 is not zero, then it is the number of values in the unpacked ** key of reg(P2). In that case, P3 is the index of the first register ** for the unpacked key. The availability of the unpacked key can sometimes ** be an optimization. ** ** If P5 has the OPFLAG_APPEND bit set, that is a hint to the b-tree layer ** that this insert is likely to be an append. ** ** If P5 has the OPFLAG_NCHANGE bit set, then the change counter is ** incremented by this instruction. If the OPFLAG_NCHANGE bit is clear, ** then the change counter is unchanged. ** ** If the OPFLAG_USESEEKRESULT flag of P5 is set, the implementation might ** run faster by avoiding an unnecessary seek on cursor P1. However, ** the OPFLAG_USESEEKRESULT flag must only be set if there have been no prior ** seeks on the cursor or if the most recent seek used a key equivalent ** to P2. ** ** This instruction only works for indices. The equivalent instruction ** for tables is OP_Insert. */ _119: ; pC24 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_NCHANGE) != 0 { (*TVdbe)(unsafe.Pointer(p)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + 1 } if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags)&int32(MEM_Zero) != 0 { v190 = _sqlite3VdbeMemExpandBlob(tls, pIn2) } else { v190 = 0 } rc = v190 if rc != 0 { goto abort_due_to_error } (**(**TBtreePayload)(__ccgo_up(bp + 408))).FnKey = int64((*TMem)(unsafe.Pointer(pIn2)).Fn) (**(**TBtreePayload)(__ccgo_up(bp + 408))).FpKey = (*TMem)(unsafe.Pointer(pIn2)).Fz (**(**TBtreePayload)(__ccgo_up(bp + 408))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 (**(**TBtreePayload)(__ccgo_up(bp + 408))).FnMem = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp4.Fi) if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&int32(OPFLAG_USESEEKRESULT) != 0 { v190 = (*TVdbeCursor)(unsafe.Pointer(pC24)).FseekResult } else { v190 = 0 } rc = _sqlite3BtreeInsert(tls, *(*uintptr)(unsafe.Pointer(pC24 + 48)), bp+408, libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5)&(libc.Int32FromInt32(OPFLAG_APPEND)|libc.Int32FromInt32(OPFLAG_SAVEPOSITION)|libc.Int32FromInt32(OPFLAG_PREFORMAT)), v190) (*TVdbeCursor)(unsafe.Pointer(pC24)).FcacheStatus = uint32(CACHE_STALE) if rc != 0 { goto abort_due_to_error } goto _189 /* Opcode: SorterInsert P1 P2 * * * ** Synopsis: key=r[P2] ** ** Register P2 holds an SQL index key made using the ** MakeRecord instructions. This opcode writes that key ** into the sorter P1. Data for the entry is nil. */ _120: ; pC25 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn2)).Fflags)&int32(MEM_Zero) != 0 { v190 = _sqlite3VdbeMemExpandBlob(tls, pIn2) } else { v190 = 0 } rc = v190 if rc != 0 { goto abort_due_to_error } rc = _sqlite3VdbeSorterWrite(tls, pC25, pIn2) if rc != 0 { goto abort_due_to_error } goto _189 /* Opcode: IdxDelete P1 P2 P3 P4 * ** Synopsis: key=r[P2@P3] ** ** The content of P3 registers starting at register P2 form ** an unpacked index key. This opcode removes that entry from the ** index opened by cursor P1. ** ** P4 is a pointer to an Index structure. ** ** Raise an SQLITE_CORRUPT_INDEX error if no matching index entry is found ** and not in writable_schema mode. */ _121: ; pC26 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) pCrsr8 = *(*uintptr)(unsafe.Pointer(pC26 + 48)) (**(**TUnpackedRecord)(__ccgo_up(bp + 464))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC26)).FpKeyInfo (**(**TUnpackedRecord)(__ccgo_up(bp + 464))).FnField = libc.Uint16FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) (**(**TUnpackedRecord)(__ccgo_up(bp + 464))).Fdefault_rc = 0 (**(**TUnpackedRecord)(__ccgo_up(bp + 464))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 rc = _sqlite3BtreeIndexMoveto(tls, pCrsr8, bp+464, bp+456) if rc != 0 { goto abort_due_to_error } if **(**int32)(__ccgo_up(bp + 456)) != 0 { rc = _sqlite3VdbeFindIndexKey(tls, pCrsr8, *(*uintptr)(unsafe.Pointer(pOp + 16)), bp+464, bp+456, 0) if rc != SQLITE_OK { goto abort_due_to_error } if **(**int32)(__ccgo_up(bp + 456)) != 0 { if !(_sqlite3WritableSchema(tls, db) != 0) { rc = _sqlite3ReportError(tls, libc.Int32FromInt32(SQLITE_CORRUPT)|libc.Int32FromInt32(3)< int64(0x7fffffff) { rc = _sqlite3CorruptError(tls, int32(103632)) goto abort_due_to_error } _sqlite3VdbeMemInit(tls, bp+552, db, uint16(0)) rc = _sqlite3VdbeMemFromBtreeZeroOffset(tls, pCur2, libc.Uint32FromInt64(nCellKey), bp+552) if rc != 0 { goto abort_due_to_error } res11 = _sqlite3VdbeRecordCompareWithSkip(tls, (**(**TMem)(__ccgo_up(bp + 552))).Fn, (**(**TMem)(__ccgo_up(bp + 552))).Fz, bp+512, 0) _sqlite3VdbeMemReleaseMalloc(tls, bp+552) /* End of inlined sqlite3VdbeIdxKeyCompare() */ if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode)&int32(1) == libc.Int32FromInt32(OP_IdxLT)&libc.Int32FromInt32(1) { res11 = -res11 } else { res11 = res11 + 1 } if res11 > 0 { goto jump_to_p2 } goto _189 /* Opcode: Destroy P1 P2 P3 * * ** ** Delete an entire database table or index whose root page in the database ** file is given by P1. ** ** The table being destroyed is in the main database file if P3==0. If ** P3==1 then the table to be destroyed is in the auxiliary database file ** that is used to store tables create using CREATE TEMPORARY TABLE. ** ** If AUTOVACUUM is enabled then it is possible that another root page ** might be moved into the newly deleted root page in order to keep all ** root pages contiguous at the beginning of the database. The former ** value of the root page that moved - its value before the move occurred - ** is stored in register P2. If no page movement was required (because the ** table being dropped was already the last one in the database) then a ** zero is stored in register P2. If AUTOVACUUM is disabled then a zero ** is stored in register P2. ** ** This opcode throws an error if there are any active reader VMs when ** it is invoked. This is done to avoid the difficulty associated with ** updating existing cursors when a root page is moved in an AUTOVACUUM ** database. This error is thrown even if the database is not an AUTOVACUUM ** db in order to avoid introducing an incompatibility between autovacuum ** and non-autovacuum modes. ** ** See also: Clear */ _129: ; pOut = _out2Prerelease(tls, p, pOp) (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Null) if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead > (*Tsqlite3)(unsafe.Pointer(db)).FnVDestroy+int32(1) { rc = int32(SQLITE_LOCKED) (*TVdbe)(unsafe.Pointer(p)).FerrorAction = uint8(OE_Abort) goto abort_due_to_error } else { iDb2 = (*TOp)(unsafe.Pointer(pOp)).Fp3 **(**int32)(__ccgo_up(bp + 608)) = 0 /* Not needed. Only to silence a warning. */ rc = _sqlite3BtreeDropTable(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb2)*32))).FpBt, (*TOp)(unsafe.Pointer(pOp)).Fp1, bp+608) (*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Int) *(*Ti64)(unsafe.Pointer(pOut)) = int64(**(**int32)(__ccgo_up(bp + 608))) if rc != 0 { goto abort_due_to_error } if **(**int32)(__ccgo_up(bp + 608)) != 0 { _sqlite3RootPageMoved(tls, db, iDb2, libc.Uint32FromInt32(**(**int32)(__ccgo_up(bp + 608))), libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp1)) /* All OP_Destroy operations occur on the same btree */ resetSchemaOnFault = libc.Uint8FromInt32(iDb2 + int32(1)) } } goto _189 /* Opcode: Clear P1 P2 P3 ** ** Delete all contents of the database table or index whose root page ** in the database file is given by P1. But, unlike Destroy, do not ** remove the table or index from the database file. ** ** The table being cleared is in the main database file if P2==0. If ** P2==1 then the table to be cleared is in the auxiliary database file ** that is used to store tables create using CREATE TEMPORARY TABLE. ** ** If the P3 value is non-zero, then the row change count is incremented ** by the number of rows in the table being cleared. If P3 is greater ** than zero, then the value stored in register P3 is also incremented ** by the number of rows in the table being cleared. ** ** See also: Destroy */ _130: ; **(**Ti64)(__ccgo_up(bp + 616)) = 0 rc = _sqlite3BtreeClearTable(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*32))).FpBt, libc.Int32FromUint32(libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp1)), bp+616) if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { **(**Ti64)(__ccgo_up(p + 56)) += **(**Ti64)(__ccgo_up(bp + 616)) if (*TOp)(unsafe.Pointer(pOp)).Fp3 > 0 { *(*Ti64)(unsafe.Pointer(aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56)) += **(**Ti64)(__ccgo_up(bp + 616)) } } if rc != 0 { goto abort_due_to_error } goto _189 /* Opcode: ResetSorter P1 * * * * ** ** Delete all contents from the ephemeral table or sorter ** that is open on cursor P1. ** ** This opcode only works for cursors used for sorting and ** opened with OP_OpenEphemeral or OP_SorterOpen. */ _131: ; pC30 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) if libc.Int32FromUint8((*TVdbeCursor)(unsafe.Pointer(pC30)).FeCurType) == int32(CURTYPE_SORTER) { _sqlite3VdbeSorterReset(tls, db, *(*uintptr)(unsafe.Pointer(pC30 + 48))) } else { rc = _sqlite3BtreeClearTableOfCursor(tls, *(*uintptr)(unsafe.Pointer(pC30 + 48))) if rc != 0 { goto abort_due_to_error } } goto _189 /* Opcode: CreateBtree P1 P2 P3 * * ** Synopsis: r[P2]=root iDb=P1 flags=P3 ** ** Allocate a new b-tree in the main database file if P1==0 or in the ** TEMP database file if P1==1 or in an attached database if ** P1>1. The P3 argument must be 1 (BTREE_INTKEY) for a rowid table ** it must be 2 (BTREE_BLOBKEY) for an index or WITHOUT ROWID table. ** The root page number of the new b-tree is stored in register P2. */ _132: ; pOut = _out2Prerelease(tls, p, pOp) **(**TPgno)(__ccgo_up(bp + 624)) = uint32(0) pDb3 = (*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32 rc = _sqlite3BtreeCreateTable(tls, (*TDb)(unsafe.Pointer(pDb3)).FpBt, bp+624, (*TOp)(unsafe.Pointer(pOp)).Fp3) if rc != 0 { goto abort_due_to_error } *(*Ti64)(unsafe.Pointer(pOut)) = libc.Int64FromUint32(**(**TPgno)(__ccgo_up(bp + 624))) goto _189 /* Opcode: SqlExec P1 P2 * P4 * ** ** Run the SQL statement or statements specified in the P4 string. ** ** The P1 parameter is a bitmask of options: ** ** 0x0001 Disable Auth and Trace callbacks while the statements ** in P4 are running. ** ** 0x0002 Set db->nAnalysisLimit to P2 while the statements in ** P4 are running. ** */ _133: ; (*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec = (*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec + 1 **(**uintptr)(__ccgo_up(bp + 632)) = uintptr(0) xAuth = (*Tsqlite3)(unsafe.Pointer(db)).FxAuth mTrace = (*Tsqlite3)(unsafe.Pointer(db)).FmTrace savedAnalysisLimit = (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit if (*TOp)(unsafe.Pointer(pOp)).Fp1&int32(0x0001) != 0 { (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = uintptr(0) (*Tsqlite3)(unsafe.Pointer(db)).FmTrace = uint8(0) } if (*TOp)(unsafe.Pointer(pOp)).Fp1&int32(0x0002) != 0 { (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit = (*TOp)(unsafe.Pointer(pOp)).Fp2 } rc = Xsqlite3_exec(tls, db, *(*uintptr)(unsafe.Pointer(pOp + 16)), uintptr(0), uintptr(0), bp+632) (*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec = (*Tsqlite3)(unsafe.Pointer(db)).FnSqlExec - 1 (*Tsqlite3)(unsafe.Pointer(db)).FxAuth = xAuth (*Tsqlite3)(unsafe.Pointer(db)).FmTrace = mTrace (*Tsqlite3)(unsafe.Pointer(db)).FnAnalysisLimit = savedAnalysisLimit if **(**uintptr)(__ccgo_up(bp + 632)) != 0 || rc != 0 { _sqlite3VdbeError(tls, p, __ccgo_ts+3968, libc.VaList(bp+984, **(**uintptr)(__ccgo_up(bp + 632)))) Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 632))) if rc == int32(SQLITE_NOMEM) { goto no_mem } goto abort_due_to_error } goto _189 /* Opcode: ParseSchema P1 * * P4 * ** ** Read and parse all entries from the schema table of database P1 ** that match the WHERE clause P4. If P4 is a NULL pointer, then the ** entire schema for P1 is reparsed. ** ** This opcode invokes the parser to create a new virtual machine, ** then runs the new virtual machine. It is thus a re-entrant opcode. */ _134: ; /* Any prepared statement that invokes this opcode will hold mutexes ** on every btree. This is a prerequisite for invoking ** sqlite3InitCallback(). */ iDb3 = (*TOp)(unsafe.Pointer(pOp)).Fp1 if *(*uintptr)(unsafe.Pointer(pOp + 16)) == uintptr(0) { _sqlite3SchemaClear(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb3)*32))).FpSchema) **(**Tu32)(__ccgo_up(db + 44)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(DBFLAG_SchemaKnownOk)) rc = _sqlite3InitOne(tls, db, iDb3, p+168, uint32((*TOp)(unsafe.Pointer(pOp)).Fp5)) **(**Tu32)(__ccgo_up(db + 44)) |= uint32(DBFLAG_SchemaChange) libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 0, 0x3) } else { zSchema = __ccgo_ts + 6312 (**(**TInitData)(__ccgo_up(bp + 640))).Fdb = db (**(**TInitData)(__ccgo_up(bp + 640))).FiDb = iDb3 (**(**TInitData)(__ccgo_up(bp + 640))).FpzErrMsg = p + 168 (**(**TInitData)(__ccgo_up(bp + 640))).FmInitFlags = uint32(0) (**(**TInitData)(__ccgo_up(bp + 640))).FmxPage = _sqlite3BtreeLastPage(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb3)*32))).FpBt) zSql = _sqlite3MPrintf(tls, db, __ccgo_ts+6326, libc.VaList(bp+984, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(iDb3)*32))).FzDbSName, zSchema, *(*uintptr)(unsafe.Pointer(pOp + 16)))) if zSql == uintptr(0) { rc = int32(SQLITE_NOMEM) } else { (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy = uint8(1) (**(**TInitData)(__ccgo_up(bp + 640))).Frc = SQLITE_OK (**(**TInitData)(__ccgo_up(bp + 640))).FnInitRow = uint32(0) rc = Xsqlite3_exec(tls, db, zSql, __ccgo_fp(_sqlite3InitCallback), bp+640, uintptr(0)) if rc == SQLITE_OK { rc = (**(**TInitData)(__ccgo_up(bp + 640))).Frc } if rc == SQLITE_OK && (**(**TInitData)(__ccgo_up(bp + 640))).FnInitRow == uint32(0) { /* The OP_ParseSchema opcode with a non-NULL P4 argument should parse ** at least one SQL statement. Any less than that indicates that ** the sqlite_schema table is corrupt. */ rc = _sqlite3CorruptError(tls, int32(103925)) } _sqlite3DbFreeNN(tls, db, zSql) (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy = uint8(0) } } if rc != 0 { _sqlite3ResetAllSchemasOfConnection(tls, db) if rc == int32(SQLITE_NOMEM) { goto no_mem } goto abort_due_to_error } goto _189 /* Opcode: LoadAnalysis P1 * * * * ** ** Read the sqlite_stat1 table for database P1 and load the content ** of that table into the internal index hash table. This will cause ** the analysis to be used when preparing all subsequent queries. */ _135: ; rc = _sqlite3AnalysisLoad(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1) if rc != 0 { goto abort_due_to_error } goto _189 /* Opcode: DropTable P1 * * P4 * ** ** Remove the internal (in-memory) data structures that describe ** the table named P4 in database P1. This is called after a table ** is dropped from disk (using the Destroy opcode) in order to keep ** the internal representation of the ** schema consistent with what is on disk. */ _136: ; _sqlite3UnlinkAndDeleteTable(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, *(*uintptr)(unsafe.Pointer(pOp + 16))) goto _189 /* Opcode: DropIndex P1 * * P4 * ** ** Remove the internal (in-memory) data structures that describe ** the index named P4 in database P1. This is called after an index ** is dropped from disk (using the Destroy opcode) ** in order to keep the internal representation of the ** schema consistent with what is on disk. */ _137: ; _sqlite3UnlinkAndDeleteIndex(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, *(*uintptr)(unsafe.Pointer(pOp + 16))) goto _189 /* Opcode: DropTrigger P1 * * P4 * ** ** Remove the internal (in-memory) data structures that describe ** the trigger named P4 in database P1. This is called after a trigger ** is dropped from disk (using the Destroy opcode) in order to keep ** the internal representation of the ** schema consistent with what is on disk. */ _138: ; _sqlite3UnlinkAndDeleteTrigger(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, *(*uintptr)(unsafe.Pointer(pOp + 16))) goto _189 /* Opcode: IntegrityCk P1 P2 P3 P4 P5 ** ** Do an analysis of the currently open database. Store in ** register (P1+1) the text of an error message describing any problems. ** If no problems are found, store a NULL in register (P1+1). ** ** The register (P1) contains one less than the maximum number of allowed ** errors. At most reg(P1) errors will be reported. ** In other words, the analysis stops as soon as reg(P1) errors are ** seen. Reg(P1) is updated with the number of errors remaining. ** ** The root page numbers of all tables in the database are integers ** stored in P4_INTARRAY argument. ** ** If P5 is not zero, the check is done on the auxiliary database ** file, not the main database file. ** ** This opcode is used to implement the integrity_check pragma. */ _139: ; /* Register keeping track of errors remaining */ nRoot = (*TOp)(unsafe.Pointer(pOp)).Fp2 aRoot = *(*uintptr)(unsafe.Pointer(pOp + 16)) pnErr = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1+int32(1))*56 rc = _sqlite3BtreeIntegrityCheck(tls, db, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp5)*32))).FpBt, aRoot+1*4, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56, nRoot, int32(*(*Ti64)(unsafe.Pointer(pnErr)))+int32(1), bp+680, bp+688) _sqlite3VdbeMemSetNull(tls, pIn1) if **(**int32)(__ccgo_up(bp + 680)) == 0 { } else { if rc != 0 { Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp + 688))) goto abort_due_to_error } else { *(*Ti64)(unsafe.Pointer(pnErr)) -= int64(**(**int32)(__ccgo_up(bp + 680)) - int32(1)) _sqlite3VdbeMemSetStr(tls, pIn1, **(**uintptr)(__ccgo_up(bp + 688)), int64(-int32(1)), uint8(SQLITE_UTF8), __ccgo_fp(Xsqlite3_free)) } } _sqlite3VdbeChangeEncoding(tls, pIn1, libc.Int32FromUint8(encoding)) goto check_for_interrupt /* Opcode: IFindKey P1 P2 P3 P4 * ** ** This instruction always follows an OP_Found with the same P1, P2 and P3 ** values as this instruction and a non-zero P4 value. The P4 value to ** this opcode is of type P4_INDEX and contains a pointer to the Index ** object of for the index being searched. ** ** This opcode uses sqlite3VdbeFindIndexKey() to search around the current ** cursor location for an index key that exactly matches all fields that ** are not indexed expressions or references to VIRTUAL generated columns, ** and either exactly match or are real numbers that are within 2 ULPs of ** each other if the don't match. ** ** To put it another way, this opcode looks for nearby index entries that ** are very close to the search key, but which might have small differences ** in floating-point values that come via an expression. ** ** If no nearby alternative entry is found in cursor P1, then jump to P2. ** But if a close match is found, fall through. ** ** This opcode is used by PRAGMA integrity_check to help distinguish ** between truely corrupt indexes and expression indexes that are holding ** floating-point values that are off by one or two ULPs. */ _140: ; pC31 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) libc.Xmemset(tls, bp+704, 0, uint64(40)) (**(**TUnpackedRecord)(__ccgo_up(bp + 704))).FaMem = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 (**(**TUnpackedRecord)(__ccgo_up(bp + 704))).FnField = (*TIndex)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FnColumn (**(**TUnpackedRecord)(__ccgo_up(bp + 704))).FpKeyInfo = (*TVdbeCursor)(unsafe.Pointer(pC31)).FpKeyInfo rc = _sqlite3VdbeFindIndexKey(tls, *(*uintptr)(unsafe.Pointer(pC31 + 48)), *(*uintptr)(unsafe.Pointer(pOp + 16)), bp+704, bp+696, int32(1)) if rc != 0 || **(**int32)(__ccgo_up(bp + 696)) != 0 { rc = SQLITE_OK goto jump_to_p2 } (*TVdbeCursor)(unsafe.Pointer(pC31)).FnullRow = uint8(0) goto _189 /* Opcode: RowSetAdd P1 P2 * * * ** Synopsis: rowset(P1)=r[P2] ** ** Insert the integer value held by register P2 into a RowSet object ** held in register P1. ** ** An assertion fails if P2 is not an integer. */ _141: ; /* in1, in2 */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Blob) == 0 { if _sqlite3VdbeMemSetRowSet(tls, pIn1) != 0 { goto no_mem } } _sqlite3RowSetInsert(tls, (*TMem)(unsafe.Pointer(pIn1)).Fz, *(*Ti64)(unsafe.Pointer(pIn2))) goto _189 /* Opcode: RowSetRead P1 P2 P3 * * ** Synopsis: r[P3]=rowset(P1) ** ** Extract the smallest value from the RowSet object in P1 ** and put that value into register P3. ** Or, if RowSet object P1 is initially empty, leave P3 ** unchanged and jump to instruction P2. */ _142: ; pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Blob) == 0 || _sqlite3RowSetNext(tls, (*TMem)(unsafe.Pointer(pIn1)).Fz, bp+744) == 0 { /* The boolean index is empty */ _sqlite3VdbeMemSetNull(tls, pIn1) goto jump_to_p2_and_check_for_interrupt } else { /* A value was pulled from the index */ _sqlite3VdbeMemSetInt64(tls, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56, **(**Ti64)(__ccgo_up(bp + 744))) } goto check_for_interrupt /* Opcode: RowSetTest P1 P2 P3 P4 ** Synopsis: if r[P3] in rowset(P1) goto P2 ** ** Register P3 is assumed to hold a 64-bit integer value. If register P1 ** contains a RowSet object and that RowSet object contains ** the value held in P3, jump to register P2. Otherwise, insert the ** integer in P3 into the RowSet and continue on to the ** next opcode. ** ** The RowSet object is optimized for the case where sets of integers ** are inserted in distinct phases, which each set contains no duplicates. ** Each set is identified by a unique P4 value. The first set ** must have P4==0, the final set must have P4==-1, and for all other sets ** must have P4>0. ** ** This allows optimizations: (a) when P4==0 there is no need to test ** the RowSet object for P3, as it is guaranteed not to contain it, ** (b) when P4==-1 there is no need to insert the value, as it will ** never be tested for, and (c) when a value that is part of set X is ** inserted, there is no need to search to see if the same value was ** previously inserted as part of set X (only if it was previously ** inserted as part of some other set). */ _143: ; pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 iSet = (*TOp)(unsafe.Pointer(pOp)).Fp4.Fi /* If there is anything other than a rowset object in memory cell P1, ** delete it now and initialize P1 with an empty rowset */ if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Blob) == 0 { if _sqlite3VdbeMemSetRowSet(tls, pIn1) != 0 { goto no_mem } } if iSet != 0 { exists = _sqlite3RowSetTest(tls, (*TMem)(unsafe.Pointer(pIn1)).Fz, iSet, *(*Ti64)(unsafe.Pointer(pIn3))) if exists != 0 { goto jump_to_p2 } } if iSet >= 0 { _sqlite3RowSetInsert(tls, (*TMem)(unsafe.Pointer(pIn1)).Fz, *(*Ti64)(unsafe.Pointer(pIn3))) } goto _189 /* Opcode: Program P1 P2 P3 P4 P5 ** ** Execute the trigger program passed as P4 (type P4_SUBPROGRAM). ** ** P1 contains the address of the memory cell that contains the first memory ** cell in an array of values used as arguments to the sub-program. P2 ** contains the address to jump to if the sub-program throws an IGNORE ** exception using the RAISE() function. P2 might be zero, if there is ** no possibility that an IGNORE exception will be raised. ** Register P3 contains the address ** of a memory cell in this (the parent) VM that is used to allocate the ** memory required by the sub-vdbe at runtime. ** ** P4 is a pointer to the VM containing the trigger program. ** ** If P5 is non-zero, then recursive program invocation is enabled. */ _144: ; /* Token identifying trigger */ pProgram = *(*uintptr)(unsafe.Pointer(pOp + 16)) pRt = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 /* If the p5 flag is clear, then recursive invocation of triggers is ** disabled for backwards compatibility (p5 is set if this sub-program ** is really a trigger, not a foreign key action, and the flag set ** and cleared by the "PRAGMA recursive_triggers" command is clear). ** ** It is recursive invocation of triggers, at the SQL level, that is ** disabled. In some cases a single trigger may generate more than one ** SubProgram (if the trigger may be executed with more than one different ** ON CONFLICT algorithm). SubProgram structures associated with a ** single trigger all have the same value for the SubProgram.token ** variable. */ if (*TOp)(unsafe.Pointer(pOp)).Fp5 != 0 { t1 = (*TSubProgram)(unsafe.Pointer(pProgram)).Ftoken pFrame2 = (*TVdbe)(unsafe.Pointer(p)).FpFrame for { if !(pFrame2 != 0 && (*TVdbeFrame)(unsafe.Pointer(pFrame2)).Ftoken != t1) { break } goto _278 _278: ; pFrame2 = (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FpParent } if pFrame2 != 0 { goto _189 } } if (*TVdbe)(unsafe.Pointer(p)).FnFrame >= **(**int32)(__ccgo_up(db + 136 + 10*4)) { rc = int32(SQLITE_ERROR) _sqlite3VdbeError(tls, p, __ccgo_ts+6369, 0) goto abort_due_to_error } /* Register pRt is used to store the memory required to save the state ** of the current program, and the memory required at runtime to execute ** the trigger program. If this trigger has been fired before, then pRt ** is already allocated. Otherwise, it must be initialized. */ if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pRt)).Fflags)&int32(MEM_Blob) == 0 { /* SubProgram.nMem is set to the number of memory cells used by the ** program stored in SubProgram.aOp. As well as these, one memory ** cell is required for each cursor used by the program. Set local ** variable nMem (and later, VdbeFrame.nChildMem) to this value. */ nMem = (*TSubProgram)(unsafe.Pointer(pProgram)).FnMem + (*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr if (*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr == 0 { nMem = nMem + 1 } nByte2 = libc.Int64FromUint64(uint64((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))+libc.Uint64FromInt32(nMem)*uint64(56)+libc.Uint64FromInt32((*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr)*uint64(8)) + libc.Uint64FromInt64((int64(7)+int64((*TSubProgram)(unsafe.Pointer(pProgram)).FnOp))/int64(8))) pFrame2 = _sqlite3DbMallocZero(tls, db, libc.Uint64FromInt64(nByte2)) if !(pFrame2 != 0) { goto no_mem } _sqlite3VdbeMemRelease(tls, pRt) (*TMem)(unsafe.Pointer(pRt)).Fflags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Blob) | libc.Int32FromInt32(MEM_Dyn)) (*TMem)(unsafe.Pointer(pRt)).Fz = pFrame2 (*TMem)(unsafe.Pointer(pRt)).Fn = int32(nByte2) (*TMem)(unsafe.Pointer(pRt)).FxDel = __ccgo_fp(_sqlite3VdbeFrameMemDel) (*TVdbeFrame)(unsafe.Pointer(pFrame2)).Fv = p (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem = nMem (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildCsr = (*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr (*TVdbeFrame)(unsafe.Pointer(pFrame2)).Fpc = int32((int64(pOp) - int64(aOp)) / 24) (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FaMem = (*TVdbe)(unsafe.Pointer(p)).FaMem (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnMem = (*TVdbe)(unsafe.Pointer(p)).FnMem (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FapCsr = (*TVdbe)(unsafe.Pointer(p)).FapCsr (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnCursor = (*TVdbe)(unsafe.Pointer(p)).FnCursor (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FaOp = (*TVdbe)(unsafe.Pointer(p)).FaOp (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnOp = (*TVdbe)(unsafe.Pointer(p)).FnOp (*TVdbeFrame)(unsafe.Pointer(pFrame2)).Ftoken = (*TSubProgram)(unsafe.Pointer(pProgram)).Ftoken pEnd = pFrame2 + uintptr((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) + uintptr((*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem)*56 pMem1 = pFrame2 + uintptr((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) for { if !(pMem1 != pEnd) { break } (*TMem)(unsafe.Pointer(pMem1)).Fflags = uint16(MEM_Undefined) (*TMem)(unsafe.Pointer(pMem1)).Fdb = db goto _279 _279: ; pMem1 += 56 } } else { pFrame2 = (*TMem)(unsafe.Pointer(pRt)).Fz } (*TVdbe)(unsafe.Pointer(p)).FnFrame = (*TVdbe)(unsafe.Pointer(p)).FnFrame + 1 (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FpParent = (*TVdbe)(unsafe.Pointer(p)).FpFrame (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FlastRowid = (*Tsqlite3)(unsafe.Pointer(db)).FlastRowid (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnDbChange = (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).FnChange (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FpAuxData = (*TVdbe)(unsafe.Pointer(p)).FpAuxData (*TVdbe)(unsafe.Pointer(p)).FpAuxData = uintptr(0) (*TVdbe)(unsafe.Pointer(p)).FnChange = 0 (*TVdbe)(unsafe.Pointer(p)).FpFrame = pFrame2 v191 = pFrame2 + uintptr((libc.Uint64FromInt64(112)+libc.Uint64FromInt32(7))&libc.Uint64FromInt32(^libc.Int32FromInt32(7))) aMem = v191 (*TVdbe)(unsafe.Pointer(p)).FaMem = v191 (*TVdbe)(unsafe.Pointer(p)).FnMem = (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildMem (*TVdbe)(unsafe.Pointer(p)).FnCursor = libc.Int32FromUint16(libc.Uint16FromInt32((*TVdbeFrame)(unsafe.Pointer(pFrame2)).FnChildCsr)) (*TVdbe)(unsafe.Pointer(p)).FapCsr = aMem + uintptr((*TVdbe)(unsafe.Pointer(p)).FnMem)*56 (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FaOnce = (*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TSubProgram)(unsafe.Pointer(pProgram)).FnCsr)*8 libc.Xmemset(tls, (*TVdbeFrame)(unsafe.Pointer(pFrame2)).FaOnce, 0, libc.Uint64FromInt32(((*TSubProgram)(unsafe.Pointer(pProgram)).FnOp+int32(7))/int32(8))) v191 = (*TSubProgram)(unsafe.Pointer(pProgram)).FaOp aOp = v191 (*TVdbe)(unsafe.Pointer(p)).FaOp = v191 (*TVdbe)(unsafe.Pointer(p)).FnOp = (*TSubProgram)(unsafe.Pointer(pProgram)).FnOp pOp = aOp + uintptr(-libc.Int32FromInt32(1))*24 goto check_for_interrupt /* Opcode: Param P1 P2 * * * ** ** This opcode is only ever present in sub-programs called via the ** OP_Program instruction. Copy a value currently stored in a memory ** cell of the calling (parent) frame to cell P2 in the current frames ** address space. This is used by trigger programs to access the new.* ** and old.* values. ** ** The address of the cell in the parent frame is determined by adding ** the value of the P1 argument to the value of the P1 argument to the ** calling OP_Program instruction. */ _145: ; pOut = _out2Prerelease(tls, p, pOp) pFrame3 = (*TVdbe)(unsafe.Pointer(p)).FpFrame pIn = (*TVdbeFrame)(unsafe.Pointer(pFrame3)).FaMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1+(**(**TOp)(__ccgo_up((*TVdbeFrame)(unsafe.Pointer(pFrame3)).FaOp + uintptr((*TVdbeFrame)(unsafe.Pointer(pFrame3)).Fpc)*24))).Fp1)*56 _sqlite3VdbeMemShallowCopy(tls, pOut, pIn, int32(MEM_Ephem)) goto _189 /* Opcode: FkCounter P1 P2 * * * ** Synopsis: fkctr[P1]+=P2 ** ** Increment a "constraint counter" by P2 (P2 may be negative or positive). ** If P1 is non-zero, the database constraint counter is incremented ** (deferred foreign key constraints). Otherwise, if P1 is zero, the ** statement counter is incremented (immediate foreign key constraints). */ _146: ; if (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { **(**Ti64)(__ccgo_up(db + 784)) += int64((*TOp)(unsafe.Pointer(pOp)).Fp2) } else { if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DeferFKs) != 0 { **(**Ti64)(__ccgo_up(db + 792)) += int64((*TOp)(unsafe.Pointer(pOp)).Fp2) } else { **(**Ti64)(__ccgo_up(p + 80)) += int64((*TOp)(unsafe.Pointer(pOp)).Fp2) } } goto _189 /* Opcode: FkIfZero P1 P2 * * * ** Synopsis: if fkctr[P1]==0 goto P2 ** ** This opcode tests if a foreign key constraint-counter is currently zero. ** If so, jump to instruction P2. Otherwise, fall through to the next ** instruction. ** ** If P1 is non-zero, then the jump is taken if the database constraint-counter ** is zero (the one that counts deferred constraint violations). If P1 is ** zero, the jump is taken if the statement constraint-counter is zero ** (immediate foreign key constraint violations). */ _147: ; /* jump */ if (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { if (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons == 0 && (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons == 0 { goto jump_to_p2 } } else { if (*TVdbe)(unsafe.Pointer(p)).FnFkConstraint == 0 && (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons == 0 { goto jump_to_p2 } } goto _189 /* Opcode: MemMax P1 P2 * * * ** Synopsis: r[P1]=max(r[P1],r[P2]) ** ** P1 is a register in the root frame of this VM (the root frame is ** different from the current frame if this instruction is being executed ** within a sub-program). Set the value of register P1 to the maximum of ** its current value and the value in register P2. ** ** This instruction throws an error if the memory cell is not initially ** an integer. */ _148: ; if (*TVdbe)(unsafe.Pointer(p)).FpFrame != 0 { pFrame4 = (*TVdbe)(unsafe.Pointer(p)).FpFrame for { if !((*TVdbeFrame)(unsafe.Pointer(pFrame4)).FpParent != 0) { break } goto _282 _282: ; pFrame4 = (*TVdbeFrame)(unsafe.Pointer(pFrame4)).FpParent } pIn1 = (*TVdbeFrame)(unsafe.Pointer(pFrame4)).FaMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 } else { pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 } _sqlite3VdbeMemIntegerify(tls, pIn1) pIn2 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 _sqlite3VdbeMemIntegerify(tls, pIn2) if *(*Ti64)(unsafe.Pointer(pIn1)) < *(*Ti64)(unsafe.Pointer(pIn2)) { *(*Ti64)(unsafe.Pointer(pIn1)) = *(*Ti64)(unsafe.Pointer(pIn2)) } goto _189 /* Opcode: IfPos P1 P2 P3 * * ** Synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 ** ** Register P1 must contain an integer. ** If the value of register P1 is 1 or greater, subtract P3 from the ** value in P1 and jump to P2. ** ** If the initial value of register P1 is less than 1, then the ** value is unchanged and control passes through to the next instruction. */ _149: ; /* jump, in1 */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 if *(*Ti64)(unsafe.Pointer(pIn1)) > 0 { *(*Ti64)(unsafe.Pointer(pIn1)) -= int64((*TOp)(unsafe.Pointer(pOp)).Fp3) goto jump_to_p2 } goto _189 /* Opcode: OffsetLimit P1 P2 P3 * * ** Synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) ** ** This opcode performs a commonly used computation associated with ** LIMIT and OFFSET processing. r[P1] holds the limit counter. r[P3] ** holds the offset counter. The opcode computes the combined value ** of the LIMIT and OFFSET and stores that value in r[P2]. The r[P2] ** value computed is the total number of rows that will need to be ** visited in order to complete the query. ** ** If r[P3] is zero or negative, that means there is no OFFSET ** and r[P2] is set to be the value of the LIMIT, r[P1]. ** ** if r[P1] is zero or negative, that means there is no LIMIT ** and r[P2] is set to -1. ** ** Otherwise, r[P2] is set to the sum of r[P1] and r[P3]. */ _150: ; pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 pIn3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 pOut = _out2Prerelease(tls, p, pOp) **(**Ti64)(__ccgo_up(bp + 752)) = *(*Ti64)(unsafe.Pointer(pIn1)) if v217 = **(**Ti64)(__ccgo_up(bp + 752)) <= 0; !v217 { if *(*Ti64)(unsafe.Pointer(pIn3)) > 0 { v206 = *(*Ti64)(unsafe.Pointer(pIn3)) } else { v206 = 0 } } if v217 || _sqlite3AddInt64(tls, bp+752, v206) != 0 { /* If the LIMIT is less than or equal to zero, loop forever. This ** is documented. But also, if the LIMIT+OFFSET exceeds 2^63 then ** also loop forever. This is undocumented. In fact, one could argue ** that the loop should terminate. But assuming 1 billion iterations ** per second (far exceeding the capabilities of any current hardware) ** it would take nearly 300 years to actually reach the limit. So ** looping forever is a reasonable approximation. */ *(*Ti64)(unsafe.Pointer(pOut)) = int64(-int32(1)) } else { *(*Ti64)(unsafe.Pointer(pOut)) = **(**Ti64)(__ccgo_up(bp + 752)) } goto _189 /* Opcode: IfNotZero P1 P2 * * * ** Synopsis: if r[P1]!=0 then r[P1]--, goto P2 ** ** Register P1 must contain an integer. If the content of register P1 is ** initially greater than zero, then decrement the value in register P1. ** If it is non-zero (negative or positive) and then also jump to P2. ** If register P1 is initially zero, leave it unchanged and fall through. */ _151: ; /* jump, in1 */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 if *(*Ti64)(unsafe.Pointer(pIn1)) != 0 { if *(*Ti64)(unsafe.Pointer(pIn1)) > 0 { *(*Ti64)(unsafe.Pointer(pIn1)) = *(*Ti64)(unsafe.Pointer(pIn1)) - 1 } goto jump_to_p2 } goto _189 /* Opcode: DecrJumpZero P1 P2 * * * ** Synopsis: if (--r[P1])==0 goto P2 ** ** Register P1 must hold an integer. Decrement the value in P1 ** and jump to P2 if the new value is exactly zero. */ _152: ; /* jump, in1 */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 if *(*Ti64)(unsafe.Pointer(pIn1)) > int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<= 0) { break } *(*uintptr)(unsafe.Pointer(pCtx1 + 48 + uintptr(i4)*8)) = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2+i4)*56 goto _285 _285: ; i4 = i4 - 1 } } (*TMem)(unsafe.Pointer(pMem2)).Fn = (*TMem)(unsafe.Pointer(pMem2)).Fn + 1 if (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDef)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpFunc)).FxInverse})))(tls, pCtx1, libc.Int32FromUint16((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).Fargc), pCtx1+48) } else { (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDef)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpFunc)).FxSFunc})))(tls, pCtx1, libc.Int32FromUint16((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).Fargc), pCtx1+48) } /* IMP: R-24505-23230 */ if (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FisError != 0 { if (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FisError > 0 { _sqlite3VdbeError(tls, p, __ccgo_ts+3968, libc.VaList(bp+984, Xsqlite3_value_text(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpOut))) rc = (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FisError } if (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FskipFlag != 0 { i4 = (**(**TOp)(__ccgo_up(pOp + uintptr(-libc.Int32FromInt32(1))*24))).Fp1 if i4 != 0 { _sqlite3VdbeMemSetInt64(tls, aMem+uintptr(i4)*56, int64(1)) } (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FskipFlag = uint8(0) } _sqlite3VdbeMemRelease(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpOut) (*TMem)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FpOut)).Fflags = uint16(MEM_Null) (*Tsqlite3_context)(unsafe.Pointer(pCtx1)).FisError = 0 if rc != 0 { goto abort_due_to_error } } goto _189 /* Opcode: AggFinal P1 P2 * P4 * ** Synopsis: accum=r[P1] N=P2 ** ** P1 is the memory location that is the accumulator for an aggregate ** or window function. Execute the finalizer function ** for an aggregate and store the result in P1. ** ** P2 is the number of arguments that the step function takes and ** P4 is a pointer to the FuncDef for this function. The P2 ** argument is not used by this opcode. It is only there to disambiguate ** functions that can take varying numbers of arguments. The ** P4 argument is only needed for the case where ** the step function was not previously called. */ /* Opcode: AggValue * P2 P3 P4 * ** Synopsis: r[P3]=value N=P2 ** ** Invoke the xValue() function and store the result in register P3. ** ** P2 is the number of arguments that the step function takes and ** P4 is a pointer to the FuncDef for this function. The P2 ** argument is not used by this opcode. It is only there to disambiguate ** functions that can take varying numbers of arguments. The ** P4 argument is only needed for the case where ** the step function was not previously called. */ _157: ; _156: ; pMem3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { rc = _sqlite3VdbeMemAggValue(tls, pMem3, aMem+uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56, *(*uintptr)(unsafe.Pointer(pOp + 16))) pMem3 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 } else { rc = _sqlite3VdbeMemFinalize(tls, pMem3, *(*uintptr)(unsafe.Pointer(pOp + 16))) } if rc != 0 { _sqlite3VdbeError(tls, p, __ccgo_ts+3968, libc.VaList(bp+984, Xsqlite3_value_text(tls, pMem3))) goto abort_due_to_error } _sqlite3VdbeChangeEncoding(tls, pMem3, libc.Int32FromUint8(encoding)) goto _189 /* Opcode: Checkpoint P1 P2 P3 * * ** ** Checkpoint database P1. This is a no-op if P1 is not currently in ** WAL mode. Parameter P2 is one of SQLITE_CHECKPOINT_PASSIVE, FULL, ** RESTART, or TRUNCATE. Write 1 or 0 into mem[P3] if the checkpoint returns ** SQLITE_BUSY or not, respectively. Write the number of pages in the ** WAL after the checkpoint into mem[P3+1] and the number of pages ** in the WAL that have been checkpointed after the checkpoint ** completes into mem[P3+2]. However on an error, mem[P3+1] and ** mem[P3+2] are initialized to -1. */ _158: ; /* Write results here */ (**(**[3]int32)(__ccgo_up(bp + 760)))[0] = 0 v190 = -libc.Int32FromInt32(1) (**(**[3]int32)(__ccgo_up(bp + 760)))[int32(2)] = v190 (**(**[3]int32)(__ccgo_up(bp + 760)))[int32(1)] = v190 rc = _sqlite3Checkpoint(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, (*TOp)(unsafe.Pointer(pOp)).Fp2, bp+760+1*4, bp+760+2*4) if rc != 0 { if rc != int32(SQLITE_BUSY) { goto abort_due_to_error } rc = SQLITE_OK (**(**[3]int32)(__ccgo_up(bp + 760)))[0] = int32(1) } i5 = 0 pMem4 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 for { if !(i5 < int32(3)) { break } _sqlite3VdbeMemSetInt64(tls, pMem4, int64((**(**[3]int32)(__ccgo_up(bp + 760)))[i5])) goto _287 _287: ; i5 = i5 + 1 pMem4 += 56 } goto _189 /* Opcode: JournalMode P1 P2 P3 * * ** ** Change the journal mode of database P1 to P3. P3 must be one of the ** PAGER_JOURNALMODE_XXX values. If changing between the various rollback ** modes (delete, truncate, persist, off and memory), this is a simple ** operation. No IO is required. ** ** If changing into or out of WAL mode the procedure is more complicated. ** ** Write a string containing the final journal-mode to register P2. */ _159: ; /* Name of database file for pPager */ pOut = _out2Prerelease(tls, p, pOp) eNew = (*TOp)(unsafe.Pointer(pOp)).Fp3 pBt1 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpBt pPager = _sqlite3BtreePager(tls, pBt1) eOld = _sqlite3PagerGetJournalMode(tls, pPager) if eNew == -int32(1) { eNew = eOld } if !(_sqlite3PagerOkToChangeJournalMode(tls, pPager) != 0) { eNew = eOld } zFilename = _sqlite3PagerFilename(tls, pPager, int32(1)) /* Do not allow a transition to journal_mode=WAL for a database ** in temporary storage or if the VFS does not support shared memory */ if eNew == int32(PAGER_JOURNALMODE_WAL) && (_sqlite3Strlen30(tls, zFilename) == 0 || !(_sqlite3PagerWalSupported(tls, pPager) != 0)) { eNew = eOld } if eNew != eOld && (eOld == int32(PAGER_JOURNALMODE_WAL) || eNew == int32(PAGER_JOURNALMODE_WAL)) { if !((*Tsqlite3)(unsafe.Pointer(db)).FautoCommit != 0) || (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeRead > int32(1) { rc = int32(SQLITE_ERROR) if eNew == int32(PAGER_JOURNALMODE_WAL) { v191 = __ccgo_ts + 6406 } else { v191 = __ccgo_ts + 6411 } _sqlite3VdbeError(tls, p, __ccgo_ts+6418, libc.VaList(bp+984, v191)) goto abort_due_to_error } else { if eOld == int32(PAGER_JOURNALMODE_WAL) { /* If leaving WAL mode, close the log file. If successful, the call ** to PagerCloseWal() checkpoints and deletes the write-ahead-log ** file. An EXCLUSIVE lock may still be held on the database file ** after a successful return. */ rc = _sqlite3PagerCloseWal(tls, pPager, db) if rc == SQLITE_OK { _sqlite3PagerSetJournalMode(tls, pPager, eNew) } } else { if eOld == int32(PAGER_JOURNALMODE_MEMORY) { /* Cannot transition directly from MEMORY to WAL. Use mode OFF ** as an intermediate */ _sqlite3PagerSetJournalMode(tls, pPager, int32(PAGER_JOURNALMODE_OFF)) } } /* Open a transaction on the database file. Regardless of the journal ** mode, this transaction always uses a rollback journal. */ if rc == SQLITE_OK { if eNew == int32(PAGER_JOURNALMODE_WAL) { v190 = int32(2) } else { v190 = int32(1) } rc = _sqlite3BtreeSetVersion(tls, pBt1, v190) } } } if rc != 0 { eNew = eOld } eNew = _sqlite3PagerSetJournalMode(tls, pPager, eNew) (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromInt32(MEM_Str) | libc.Int32FromInt32(MEM_Static) | libc.Int32FromInt32(MEM_Term)) (*TMem)(unsafe.Pointer(pOut)).Fz = _sqlite3JournalModename(tls, eNew) (*TMem)(unsafe.Pointer(pOut)).Fn = _sqlite3Strlen30(tls, (*TMem)(unsafe.Pointer(pOut)).Fz) (*TMem)(unsafe.Pointer(pOut)).Fenc = uint8(SQLITE_UTF8) _sqlite3VdbeChangeEncoding(tls, pOut, libc.Int32FromUint8(encoding)) if rc != 0 { goto abort_due_to_error } goto _189 /* Opcode: Vacuum P1 P2 * * * ** ** Vacuum the entire database P1. P1 is 0 for "main", and 2 or more ** for an attached database. The "temp" database may not be vacuumed. ** ** If P2 is not zero, then it is a register holding a string which is ** the file into which the result of vacuum should be written. When ** P2 is zero, the vacuum overwrites the original database. */ _160: ; if (*TOp)(unsafe.Pointer(pOp)).Fp2 != 0 { v191 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 } else { v191 = uintptr(0) } rc = _sqlite3RunVacuum(tls, p+168, db, (*TOp)(unsafe.Pointer(pOp)).Fp1, v191) if rc != 0 { goto abort_due_to_error } goto _189 /* Opcode: IncrVacuum P1 P2 * * * ** ** Perform a single step of the incremental vacuum procedure on ** the P1 database. If the vacuum has finished, jump to instruction ** P2. Otherwise, fall through to the next instruction. */ _161: ; pBt2 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpBt rc = _sqlite3BtreeIncrVacuum(tls, pBt2) if rc != 0 { if rc != int32(SQLITE_DONE) { goto abort_due_to_error } rc = SQLITE_OK goto jump_to_p2 } goto _189 /* Opcode: Expire P1 P2 * * * ** ** Cause precompiled statements to expire. When an expired statement ** is executed using sqlite3_step() it will either automatically ** reprepare itself (if it was originally created using sqlite3_prepare_v2()) ** or it will fail with SQLITE_SCHEMA. ** ** If P1 is 0, then all SQL statements become expired. If P1 is non-zero, ** then only the currently executing statement is expired. ** ** If P2 is 0, then SQL statements are expired immediately. If P2 is 1, ** then running SQL statements are allowed to continue to run to completion. ** The P2==1 case occurs when a CREATE INDEX or similar schema change happens ** that might help the statement run faster but which does not affect the ** correctness of operation. */ _162: ; if !((*TOp)(unsafe.Pointer(pOp)).Fp1 != 0) { _sqlite3ExpirePreparedStatements(tls, db, (*TOp)(unsafe.Pointer(pOp)).Fp2) } else { libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp2+libc.Int32FromInt32(1)), 0, 0x3) } goto _189 /* Opcode: CursorLock P1 * * * * ** ** Lock the btree to which cursor P1 is pointing so that the btree cannot be ** written by an other cursor. */ _163: ; pC32 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) _sqlite3BtreeCursorPin(tls, *(*uintptr)(unsafe.Pointer(pC32 + 48))) goto _189 /* Opcode: CursorUnlock P1 * * * * ** ** Unlock the btree to which cursor P1 is pointing so that it can be ** written by other cursors. */ _164: ; pC33 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) _sqlite3BtreeCursorUnpin(tls, *(*uintptr)(unsafe.Pointer(pC33 + 48))) goto _189 /* Opcode: TableLock P1 P2 P3 P4 * ** Synopsis: iDb=P1 root=P2 write=P3 ** ** Obtain a lock on a particular table. This instruction is only used when ** the shared-cache feature is enabled. ** ** P1 is the index of the database in sqlite3.aDb[] of the database ** on which the lock is acquired. A readlock is obtained if P3==0 or ** a write lock if P3==1. ** ** P2 contains the root-page of the table to lock. ** ** P4 contains a pointer to the name of the table being locked. This is only ** used to generate an error message if the lock cannot be obtained. */ _165: ; isWriteLock = libc.Uint8FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) if isWriteLock != 0 || uint64(0) == (*Tsqlite3)(unsafe.Pointer(db)).Fflags&(libc.Uint64FromInt32(libc.Int32FromInt32(0x00004))< 0 { _sqlite3VdbeError(tls, p, __ccgo_ts+3968, libc.VaList(bp+984, Xsqlite3_value_text(tls, pDest2))) rc = (**(**Tsqlite3_context)(__ccgo_up(bp + 848))).FisError } _sqlite3VdbeChangeEncoding(tls, pDest2, libc.Int32FromUint8(encoding)) if rc != 0 { goto abort_due_to_error } goto _189 /* Opcode: VNext P1 P2 * * * ** ** Advance virtual table P1 to the next row in its result set and ** jump to instruction P2. Or, if the virtual table has reached ** the end of its result set, then fall through to the next instruction. */ _174: ; pCur6 = **(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FapCsr + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*8)) if (*TVdbeCursor)(unsafe.Pointer(pCur6)).FnullRow != 0 { goto _189 } pVtab5 = (*Tsqlite3_vtab_cursor)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pCur6 + 48)))).FpVtab pModule5 = (*Tsqlite3_vtab)(unsafe.Pointer(pVtab5)).FpModule /* Invoke the xNext() method of the module. There is no way for the ** underlying implementation to return an error if one occurs during ** xNext(). Instead, if an error occurs, true is returned (indicating that ** data is available) and the error code returned when xColumn or ** some other method is next invoked on the save virtual table cursor. */ rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule5)).FxNext})))(tls, *(*uintptr)(unsafe.Pointer(pCur6 + 48))) _sqlite3VtabImportErrmsg(tls, p, pVtab5) if rc != 0 { goto abort_due_to_error } res14 = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule5)).FxEof})))(tls, *(*uintptr)(unsafe.Pointer(pCur6 + 48))) if !(res14 != 0) { /* If there is data, jump to P2 */ goto jump_to_p2_and_check_for_interrupt } goto check_for_interrupt /* Opcode: VRename P1 * * P4 * ** ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. ** This opcode invokes the corresponding xRename method. The value ** in register P1 is passed as the zName argument to the xRename method. */ _175: ; isLegacy = libc.Int32FromUint64((*Tsqlite3)(unsafe.Pointer(db)).Fflags & libc.Uint64FromInt32(SQLITE_LegacyAlter)) **(**Tu64)(__ccgo_up(db + 48)) |= uint64(SQLITE_LegacyAlter) pVtab6 = (*TVTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpVtab pName = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 rc = _sqlite3VdbeChangeEncoding(tls, pName, int32(SQLITE_UTF8)) if rc != 0 { goto abort_due_to_error } rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer(pVtab6)).FpModule)).FxRename})))(tls, pVtab6, (*TMem)(unsafe.Pointer(pName)).Fz) if isLegacy == 0 { **(**Tu64)(__ccgo_up(db + 48)) &= ^libc.Uint64FromInt32(SQLITE_LegacyAlter) } _sqlite3VtabImportErrmsg(tls, p, pVtab6) libc.SetBitFieldPtr16Uint32(p+200, libc.Uint32FromInt32(0), 0, 0x3) if rc != 0 { goto abort_due_to_error } goto _189 /* Opcode: VUpdate P1 P2 P3 P4 P5 ** Synopsis: data=r[P3@P2] ** ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. ** This opcode invokes the corresponding xUpdate method. P2 values ** are contiguous memory cells starting at P3 to pass to the xUpdate ** invocation. The value in register (P3+P2-1) corresponds to the ** p2th element of the argv array passed to xUpdate. ** ** The xUpdate method will do a DELETE or an INSERT or both. ** The argv[0] element (which corresponds to memory cell P3) ** is the rowid of a row to delete. If argv[0] is NULL then no ** deletion occurs. The argv[1] element is the rowid of the new ** row. This can be NULL to have the virtual table select the new ** rowid for itself. The subsequent elements in the array are ** the values of columns in the new row. ** ** If P2==1 then no insert is performed. argv[0] is the rowid of ** a row to delete. ** ** P1 is a boolean flag. If it is set to true and the xUpdate call ** is successful, then the value returned by sqlite3_last_insert_rowid() ** is set to the value of the rowid for the row just inserted. ** ** P5 is the error actions (OE_Replace, OE_Fail, OE_Ignore, etc) to ** apply in the case of a constraint failure on an insert or update. */ _176: ; **(**Tsqlite_int64)(__ccgo_up(bp + 968)) = 0 if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { goto no_mem } pVtab7 = (*TVTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FpVtab if pVtab7 == uintptr(0) || (*Tsqlite3_vtab)(unsafe.Pointer(pVtab7)).FpModule == uintptr(0) { rc = int32(SQLITE_LOCKED) goto abort_due_to_error } pModule6 = (*Tsqlite3_vtab)(unsafe.Pointer(pVtab7)).FpModule nArg1 = (*TOp)(unsafe.Pointer(pOp)).Fp2 if (*Tsqlite3_module)(unsafe.Pointer(pModule6)).FxUpdate != 0 { vtabOnConflict = (*Tsqlite3)(unsafe.Pointer(db)).FvtabOnConflict apArg1 = (*TVdbe)(unsafe.Pointer(p)).FapArg pX1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 i7 = 0 for { if !(i7 < nArg1) { break } **(**uintptr)(__ccgo_up(apArg1 + uintptr(i7)*8)) = pX1 pX1 += 56 goto _292 _292: ; i7 = i7 + 1 } (*Tsqlite3)(unsafe.Pointer(db)).FvtabOnConflict = uint8((*TOp)(unsafe.Pointer(pOp)).Fp5) rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer(pModule6)).FxUpdate})))(tls, pVtab7, nArg1, apArg1, bp+968) (*Tsqlite3)(unsafe.Pointer(db)).FvtabOnConflict = vtabOnConflict _sqlite3VtabImportErrmsg(tls, p, pVtab7) if rc == SQLITE_OK && (*TOp)(unsafe.Pointer(pOp)).Fp1 != 0 { (*Tsqlite3)(unsafe.Pointer(db)).FlastRowid = **(**Tsqlite_int64)(__ccgo_up(bp + 968)) } if rc&int32(0xff) == int32(SQLITE_CONSTRAINT) && (*TVTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pOp + 16)))).FbConstraint != 0 { if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) == int32(OE_Ignore) { rc = SQLITE_OK } else { if libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) == int32(OE_Replace) { v190 = int32(OE_Abort) } else { v190 = libc.Int32FromUint16((*TOp)(unsafe.Pointer(pOp)).Fp5) } (*TVdbe)(unsafe.Pointer(p)).FerrorAction = libc.Uint8FromInt32(v190) } } else { (*TVdbe)(unsafe.Pointer(p)).FnChange = (*TVdbe)(unsafe.Pointer(p)).FnChange + 1 } if rc != 0 { goto abort_due_to_error } } goto _189 /* Opcode: Pagecount P1 P2 * * * ** ** Write the current number of pages in database P1 to memory cell P2. */ _177: ; /* out2 */ pOut = _out2Prerelease(tls, p, pOp) *(*Ti64)(unsafe.Pointer(pOut)) = libc.Int64FromUint32(_sqlite3BtreeLastPage(tls, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpBt)) goto _189 /* Opcode: MaxPgcnt P1 P2 P3 * * ** ** Try to set the maximum page count for database P1 to the value in P3. ** Do not let the maximum page count fall below the current page count and ** do not change the maximum page count value if P3==0. ** ** Store the maximum page count after the change in register P2. */ _178: ; pOut = _out2Prerelease(tls, p, pOp) pBt3 = (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*32))).FpBt newMax = uint32(0) if (*TOp)(unsafe.Pointer(pOp)).Fp3 != 0 { newMax = _sqlite3BtreeLastPage(tls, pBt3) if newMax < libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) { newMax = libc.Uint32FromInt32((*TOp)(unsafe.Pointer(pOp)).Fp3) } } *(*Ti64)(unsafe.Pointer(pOut)) = libc.Int64FromUint32(_sqlite3BtreeMaxPageCount(tls, pBt3, newMax)) goto _189 /* Opcode: Function P1 P2 P3 P4 * ** Synopsis: r[P3]=func(r[P2@NP]) ** ** Invoke a user function (P4 is a pointer to an sqlite3_context object that ** contains a pointer to the function to be run) with arguments taken ** from register P2 and successors. The number of arguments is in ** the sqlite3_context object that P4 points to. ** The result of the function is stored ** in register P3. Register P3 must not be one of the function inputs. ** ** P1 is a 32-bit bitmask indicating whether or not each argument to the ** function was determined to be constant at compile time. If the first ** argument was constant then bit 0 of P1 is set. This is used to determine ** whether meta data associated with a user function argument using the ** sqlite3_set_auxdata() API may be safely retained until the next ** invocation of this opcode. ** ** See also: AggStep, AggFinal, PureFunc */ /* Opcode: PureFunc P1 P2 P3 P4 * ** Synopsis: r[P3]=func(r[P2@NP]) ** ** Invoke a user function (P4 is a pointer to an sqlite3_context object that ** contains a pointer to the function to be run) with arguments taken ** from register P2 and successors. The number of arguments is in ** the sqlite3_context object that P4 points to. ** The result of the function is stored ** in register P3. Register P3 must not be one of the function inputs. ** ** P1 is a 32-bit bitmask indicating whether or not each argument to the ** function was determined to be constant at compile time. If the first ** argument was constant then bit 0 of P1 is set. This is used to determine ** whether meta data associated with a user function argument using the ** sqlite3_set_auxdata() API may be safely retained until the next ** invocation of this opcode. ** ** This opcode works exactly like OP_Function. The only difference is in ** its name. This opcode is used in places where the function must be ** purely non-deterministic. Some built-in date/time functions can be ** either deterministic of non-deterministic, depending on their arguments. ** When those function are used in a non-deterministic way, they will check ** to see if they were called using OP_PureFunc instead of OP_Function, and ** if they were, they throw an error. ** ** See also: AggStep, AggFinal, Function */ _180: ; /* group */ _179: ; pCtx2 = *(*uintptr)(unsafe.Pointer(pOp + 16)) /* If this function is inside of a trigger, the register array in aMem[] ** might change from one evaluation to the next. The next block of code ** checks to see if the register array has changed, and if so it ** reinitializes the relevant parts of the sqlite3_context object */ pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp3)*56 if (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FpOut != pOut { (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FpVdbe = p (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FpOut = pOut (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).Fenc = encoding i8 = libc.Int32FromUint16((*Tsqlite3_context)(unsafe.Pointer(pCtx2)).Fargc) - int32(1) for { if !(i8 >= 0) { break } *(*uintptr)(unsafe.Pointer(pCtx2 + 48 + uintptr(i8)*8)) = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2+i8)*56 goto _294 _294: ; i8 = i8 - 1 } } (*TMem)(unsafe.Pointer(pOut)).Fflags = libc.Uint16FromInt32(libc.Int32FromUint16((*TMem)(unsafe.Pointer(pOut)).Fflags) & ^(libc.Int32FromInt32(MEM_TypeMask)|libc.Int32FromInt32(MEM_Zero)) | int32(MEM_Null)) (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFuncDef)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FpFunc)).FxSFunc})))(tls, pCtx2, libc.Int32FromUint16((*Tsqlite3_context)(unsafe.Pointer(pCtx2)).Fargc), pCtx2+48) /* IMP: R-24505-23230 */ /* If the function returned an error, throw an exception */ if (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FisError != 0 { if (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FisError > 0 { _sqlite3VdbeError(tls, p, __ccgo_ts+3968, libc.VaList(bp+984, Xsqlite3_value_text(tls, pOut))) rc = (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FisError } _sqlite3VdbeDeleteAuxData(tls, db, p+296, (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FiOp, (*TOp)(unsafe.Pointer(pOp)).Fp1) (*Tsqlite3_context)(unsafe.Pointer(pCtx2)).FisError = 0 if rc != 0 { goto abort_due_to_error } } goto _189 /* Opcode: ClrSubtype P1 * * * * ** Synopsis: r[P1].subtype = 0 ** ** Clear the subtype from register P1. */ _181: ; /* in1 */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 v191 = pIn1 + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Subtype)) goto _189 /* Opcode: GetSubtype P1 P2 * * * ** Synopsis: r[P2] = r[P1].subtype ** ** Extract the subtype value from register P1 and write that subtype ** into register P2. If P1 has no subtype, then P1 gets a NULL. */ _182: ; /* in1 out2 */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Subtype) != 0 { _sqlite3VdbeMemSetInt64(tls, pOut, libc.Int64FromUint8((*TMem)(unsafe.Pointer(pIn1)).FeSubtype)) } else { _sqlite3VdbeMemSetNull(tls, pOut) } goto _189 /* Opcode: SetSubtype P1 P2 * * * ** Synopsis: r[P2].subtype = r[P1] ** ** Set the subtype value of register P2 to the integer from register P1. ** If P1 is NULL, clear the subtype from p2. */ _183: ; /* in1 out2 */ pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 pOut = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp2)*56 if libc.Int32FromUint16((*TMem)(unsafe.Pointer(pIn1)).Fflags)&int32(MEM_Null) != 0 { v191 = pOut + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) & ^libc.Int32FromInt32(MEM_Subtype)) } else { v191 = pOut + 20 *(*Tu16)(unsafe.Pointer(v191)) = Tu16(int32(*(*Tu16)(unsafe.Pointer(v191))) | libc.Int32FromInt32(MEM_Subtype)) (*TMem)(unsafe.Pointer(pOut)).FeSubtype = libc.Uint8FromInt64(*(*Ti64)(unsafe.Pointer(pIn1)) & libc.Int64FromInt32(0xff)) } goto _189 /* Opcode: FilterAdd P1 * P3 P4 * ** Synopsis: filter(P1) += key(P3@P4) ** ** Compute a hash on the P4 registers starting with r[P3] and ** add that hash to the bloom filter contained in r[P1]. */ _184: ; pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 h = _filterHash(tls, aMem, pOp) h = h % libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pIn1)).Fn*libc.Int32FromInt32(8)) v191 = (*TMem)(unsafe.Pointer(pIn1)).Fz + uintptr(h/uint64(8)) *(*uint8)(unsafe.Pointer(v191)) = uint8(int32(*(*uint8)(unsafe.Pointer(v191))) | libc.Int32FromInt32(1)<<(h&libc.Uint64FromInt32(7))) goto _189 /* Opcode: Filter P1 P2 P3 P4 * ** Synopsis: if key(P3@P4) not in filter(P1) goto P2 ** ** Compute a hash on the key contained in the P4 registers starting ** with r[P3]. Check to see if that hash is found in the ** bloom filter hosted by register P1. If it is not present then ** maybe jump to P2. Otherwise fall through. ** ** False negatives are harmless. It is always safe to fall through, ** even if the value is in the bloom filter. A false negative causes ** more CPU cycles to be used, but it should still yield the correct ** answer. However, an incorrect answer may well arise from a ** false positive - if the jump is taken when it should fall through. */ _185: ; pIn1 = aMem + uintptr((*TOp)(unsafe.Pointer(pOp)).Fp1)*56 h1 = _filterHash(tls, aMem, pOp) h1 = h1 % libc.Uint64FromInt32((*TMem)(unsafe.Pointer(pIn1)).Fn*libc.Int32FromInt32(8)) if libc.Int32FromUint8(**(**uint8)(__ccgo_up((*TMem)(unsafe.Pointer(pIn1)).Fz + uintptr(h1/uint64(8)))))&(int32(1)<<(h1&uint64(7))) == 0 { **(**Tu32)(__ccgo_up(p + 212 + 8*4)) = **(**Tu32)(__ccgo_up(p + 212 + 8*4)) + 1 goto jump_to_p2 } else { **(**Tu32)(__ccgo_up(p + 212 + 7*4)) = **(**Tu32)(__ccgo_up(p + 212 + 7*4)) + 1 } goto _189 /* Opcode: Trace P1 P2 * P4 * ** ** Write P4 on the statement trace output if statement tracing is ** enabled. ** ** Operand P1 must be 0x7fffffff and P2 must positive. */ /* Opcode: Init P1 P2 P3 P4 * ** Synopsis: Start at P2 ** ** Programs contain a single instance of this opcode as the very first ** opcode. ** ** If tracing is enabled (by the sqlite3_trace()) interface, then ** the UTF-8 string contained in P4 is emitted on the trace callback. ** Or if P4 is blank, use the string returned by sqlite3_sql(). ** ** If P2 is not zero, jump to instruction P2. ** ** Increment the value of P1 so that OP_Once opcodes will jump the ** first time they are evaluated for this run. ** ** If P3 is not zero, then it is an address to jump to if an SQLITE_CORRUPT ** error is encountered. */ _187: ; _186: ; /* If the P4 argument is not NULL, then it must be an SQL comment string. ** The "--" string is broken up to prevent false-positives with srcck1.c. ** ** This assert() provides evidence for: ** EVIDENCE-OF: R-50676-09860 The callback can compute the same text that ** would have been returned by the legacy sqlite3_trace() interface by ** using the X argument when X begins with "--" and invoking ** sqlite3_expanded_sql(P) otherwise. */ /* OP_Init is always instruction 0 */ if v217 = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmTrace)&(libc.Int32FromInt32(SQLITE_TRACE_STMT)|libc.Int32FromInt32(SQLITE_TRACE_LEGACY)) != 0 && libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FminWriteFileFormat) != int32(254); v217 { if *(*uintptr)(unsafe.Pointer(pOp + 16)) != 0 { v194 = *(*uintptr)(unsafe.Pointer(pOp + 16)) } else { v194 = (*TVdbe)(unsafe.Pointer(p)).FzSql } v191 = v194 zTrace = v191 } if v217 && v191 != uintptr(0) { if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmTrace)&int32(SQLITE_TRACE_LEGACY) != 0 { z2 = _sqlite3VdbeExpandSql(tls, p, zTrace) (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).Ftrace.FxLegacy})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, z2) Xsqlite3_free(tls, z2) } else { if (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeExec > int32(1) { z3 = _sqlite3MPrintf(tls, db, __ccgo_ts+6509, libc.VaList(bp+984, zTrace)) (*(*func(*libc.TLS, Tu32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*Tsqlite3)(unsafe.Pointer(db)).Ftrace))})))(tls, uint32(SQLITE_TRACE_STMT), (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, p, z3) _sqlite3DbFree(tls, db, z3) } else { (*(*func(*libc.TLS, Tu32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*Tsqlite3)(unsafe.Pointer(db)).Ftrace))})))(tls, uint32(SQLITE_TRACE_STMT), (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, p, zTrace) } } } if (*TOp)(unsafe.Pointer(pOp)).Fp1 >= _sqlite3Config.FiOnceResetThreshold { if libc.Int32FromUint8((*TOp)(unsafe.Pointer(pOp)).Fopcode) == int32(OP_Trace) { goto _189 } i9 = int32(1) for { if !(i9 < (*TVdbe)(unsafe.Pointer(p)).FnOp) { break } if libc.Int32FromUint8((**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr(i9)*24))).Fopcode) == int32(OP_Once) { (**(**TOp)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FaOp + uintptr(i9)*24))).Fp1 = 0 } goto _302 _302: ; i9 = i9 + 1 } (*TOp)(unsafe.Pointer(pOp)).Fp1 = 0 } (*TOp)(unsafe.Pointer(pOp)).Fp1 = (*TOp)(unsafe.Pointer(pOp)).Fp1 + 1 **(**Tu32)(__ccgo_up(p + 212 + 6*4)) = **(**Tu32)(__ccgo_up(p + 212 + 6*4)) + 1 goto jump_to_p2 /* Opcode: Noop * * * * * ** ** Do nothing. Continue downward to the next opcode. */ /* Opcode: Explain P1 P2 P3 P4 * ** ** This is the same as OP_Noop during normal query execution. The ** purpose of this opcode is to hold information about the query ** plan for the purpose of EXPLAIN QUERY PLAN output. ** ** The P4 value is human-readable text that describes the query plan ** element. Something like "SCAN t1" or "SEARCH t2 USING INDEX t2x1". ** ** The P1 value is the ID of the current element and P2 is the parent ** element for the case of nested query plan elements. If P2 is zero ** then this element is a top-level element. ** ** For loop elements, P3 is the estimated code of each invocation of this ** element. ** ** As with all opcodes, the meanings of the parameters for OP_Explain ** are subject to change from one release to the next. Applications ** should not attempt to interpret or use any of the information ** contained in the OP_Explain opcode. The information provided by this ** opcode is intended for testing and debugging use only. */ _188: ; /* This is really OP_Noop, OP_Explain */ goto _189 /***************************************************************************** ** The cases of the switch statement above this line should all be indented ** by 6 spaces. But the left-most 6 spaces have been removed to improve the ** readability. From this point on down, the normal indentation rules are ** restored. *****************************************************************************/ _189: ; /* The following code adds nothing to the actual functionality ** of the program. It is only here for testing and debugging. ** On the other hand, it does burn CPU cycles every time through ** the evaluator loop. So we can leave it out when NDEBUG is defined. */ goto _1 _1: ; pOp += 24 } /* The end of the for(;;) loop the loops through opcodes */ /* If we reach this point, it means that execution is finished with ** an error of some kind. */ goto abort_due_to_error abort_due_to_error: ; if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { rc = int32(SQLITE_NOMEM) } else { if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(33)< 0 { _sqlite3ResetOneSchema(tls, db, libc.Int32FromUint8(resetSchemaOnFault)-int32(1)) } /* This is the only way out of this procedure. We have to ** release the mutexes on btrees that were acquired at the ** top. */ goto vdbe_return vdbe_return: ; for nVmStep >= nProgressLimit && (*Tsqlite3)(unsafe.Pointer(db)).FxProgress != uintptr(0) { nProgressLimit = nProgressLimit + uint64((*Tsqlite3)(unsafe.Pointer(db)).FnProgressOps) if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxProgress})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpProgressArg) != 0 { nProgressLimit = libc.Uint64FromUint32(0xffffffff) | libc.Uint64FromUint32(0xffffffff)< 0 || libc.Int32FromUint16(wctrlFlags)&(libc.Int32FromInt32(WHERE_ORDERBY_MIN)|libc.Int32FromInt32(WHERE_ORDERBY_MAX)) != 0) _sqlite3StrAccumInit(tls, bp, db, bp+32, int32(100), int32(SQLITE_MAX_LENGTH)) (**(**TStrAccum)(__ccgo_up(bp))).FprintfFlags = uint8(SQLITE_PRINTF_INTERNAL) if isSearch != 0 { v1 = __ccgo_ts + 23681 } else { v1 = __ccgo_ts + 23688 } if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x40000>>18) != 0 { v2 = __ccgo_ts + 23693 } else { v2 = __ccgo_ts + 1704 } Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23701, libc.VaList(bp+144, v1, pItem, v2)) if flags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IPK)|libc.Int32FromInt32(WHERE_VIRTUALTABLE)) == uint32(0) { zFmt = uintptr(0) pIdx = (*(*struct { FnEq Tu16 FnBtm Tu16 FnTop Tu16 FnDistinctCol Tu16 FpIndex uintptr FpOrderBy uintptr })(unsafe.Pointer(pLoop + 24))).FpIndex if !((*TTable)(unsafe.Pointer((*TSrcItem)(unsafe.Pointer(pItem)).FpSTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) && int32(uint32(*(*uint16)(unsafe.Pointer(pIdx + 100))&0x3>>0)) == int32(SQLITE_IDXTYPE_PRIMARYKEY) { if isSearch != 0 { zFmt = __ccgo_ts + 11620 } } else { if flags&uint32(WHERE_PARTIALIDX) != 0 { zFmt = __ccgo_ts + 23709 } else { if flags&uint32(WHERE_AUTO_INDEX) != 0 { zFmt = __ccgo_ts + 23742 } else { if flags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_IDX_ONLY)|libc.Int32FromInt32(WHERE_EXPRIDX)) != 0 { zFmt = __ccgo_ts + 23767 } else { zFmt = __ccgo_ts + 23785 } } } } if zFmt != 0 { Xsqlite3_str_append(tls, bp, __ccgo_ts+23794, int32(7)) Xsqlite3_str_appendf(tls, bp, zFmt, libc.VaList(bp+144, (*TIndex)(unsafe.Pointer(pIdx)).FzName)) _explainIndexRange(tls, bp, pLoop) } } else { if flags&uint32(WHERE_IPK) != uint32(0) && flags&uint32(WHERE_CONSTRAINT) != uint32(0) { zRowid = __ccgo_ts + 17991 Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23802, libc.VaList(bp+144, zRowid)) if flags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_COLUMN_EQ)|libc.Int32FromInt32(WHERE_COLUMN_IN)) != 0 { cRangeOp = uint8('=') } else { if flags&uint32(WHERE_BOTH_LIMIT) == uint32(WHERE_BOTH_LIMIT) { Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23833, libc.VaList(bp+144, zRowid)) cRangeOp = uint8('<') } else { if flags&uint32(WHERE_BTM_LIMIT) != 0 { cRangeOp = uint8('>') } else { cRangeOp = uint8('<') } } } Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23843, libc.VaList(bp+144, libc.Int32FromUint8(cRangeOp))) } else { if flags&uint32(WHERE_VIRTUALTABLE) != uint32(0) { Xsqlite3_str_appendall(tls, bp, __ccgo_ts+23848) if int32(Tu32(*(*uint8)(unsafe.Pointer(pLoop + 24 + 4))&0x4>>2)) != 0 { v1 = __ccgo_ts + 23870 } else { v1 = __ccgo_ts + 23878 } Xsqlite3_str_appendf(tls, bp, v1, libc.VaList(bp+144, (*(*struct { FidxNum int32 F__ccgo4 uint8 FisOrdered Ti8 FomitMask Tu16 FidxStr uintptr FmHandleIn Tu32 })(unsafe.Pointer(pLoop + 24))).FidxNum, (*(*struct { FidxNum int32 F__ccgo4 uint8 FisOrdered Ti8 FomitMask Tu16 FidxStr uintptr FmHandleIn Tu32 })(unsafe.Pointer(pLoop + 24))).FidxStr)) } } } if libc.Int32FromUint8((*TSrcItem)(unsafe.Pointer(pItem)).Ffg.Fjointype)&int32(JT_LEFT) != 0 { Xsqlite3_str_appendf(tls, bp, __ccgo_ts+23884, 0) } _sqlite3DbFree(tls, db, *(*uintptr)(unsafe.Pointer(pOp + 16))) (*TVdbeOp)(unsafe.Pointer(pOp)).Fp4type = int8(-libc.Int32FromInt32(7)) *(*uintptr)(unsafe.Pointer(pOp + 16)) = _sqlite3StrAccumFinish(tls, bp) } } // C documentation // // /* // ** strftime( FORMAT, TIMESTRING, MOD, MOD, ...) // ** // ** Return a string described by FORMAT. Conversions as follows: // ** // ** %d day of month 01-31 // ** %e day of month 1-31 // ** %f ** fractional seconds SS.SSS // ** %F ISO date. YYYY-MM-DD // ** %G ISO year corresponding to %V 0000-9999. // ** %g 2-digit ISO year corresponding to %V 00-99 // ** %H hour 00-24 // ** %k hour 0-24 (leading zero converted to space) // ** %I hour 01-12 // ** %j day of year 001-366 // ** %J ** julian day number // ** %l hour 1-12 (leading zero converted to space) // ** %m month 01-12 // ** %M minute 00-59 // ** %p "AM" or "PM" // ** %P "am" or "pm" // ** %R time as HH:MM // ** %s seconds since 1970-01-01 // ** %S seconds 00-59 // ** %T time as HH:MM:SS // ** %u day of week 1-7 Monday==1, Sunday==7 // ** %w day of week 0-6 Sunday==0, Monday==1 // ** %U week of year 00-53 (First Sunday is start of week 01) // ** %V week of year 01-53 (First week containing Thursday is week 01) // ** %W week of year 00-53 (First Monday is start of week 01) // ** %Y year 0000-9999 // ** %% % // */ func _strftimeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { bp := tls.Alloc(208) defer tls.Free(208) var c, cf uint8 var db, zFmt, v3 uintptr var h int32 var i, j, v2 Tsize_t var iS Ti64 var s float64 var _ /* sRes at bp+48 */ Tsqlite3_str var _ /* x at bp+0 */ TDateTime var _ /* y at bp+128 */ TDateTime var _ /* y at bp+80 */ TDateTime _, _, _, _, _, _, _, _, _, _, _ = c, cf, db, h, i, iS, j, s, zFmt, v2, v3 if argc == 0 { return } zFmt = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv))) if zFmt == uintptr(0) || _isDate(tls, context, argc-int32(1), argv+uintptr(1)*8, bp) != 0 { return } db = Xsqlite3_context_db_handle(tls, context) _sqlite3StrAccumInit(tls, bp+48, uintptr(0), uintptr(0), 0, **(**int32)(__ccgo_up(db + 136))) _computeJD(tls, bp) _computeYMD_HMS(tls, bp) v2 = libc.Uint64FromInt32(0) j = v2 i = v2 for { if !(**(**uint8)(__ccgo_up(zFmt + uintptr(i))) != 0) { break } if libc.Int32FromUint8(**(**uint8)(__ccgo_up(zFmt + uintptr(i)))) != int32('%') { goto _1 } if j < i { Xsqlite3_str_append(tls, bp+48, zFmt+uintptr(j), libc.Int32FromUint64(i-j)) } i = i + 1 j = i + uint64(1) cf = **(**uint8)(__ccgo_up(zFmt + uintptr(i))) switch libc.Int32FromUint8(cf) { case int32('d'): /* Fall thru */ fallthrough case int32('e'): if libc.Int32FromUint8(cf) == int32('d') { v3 = __ccgo_ts + 1391 } else { v3 = __ccgo_ts + 1396 } Xsqlite3_str_appendf(tls, bp+48, v3, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).FD)) case int32('f'): /* Fractional seconds. (Non-standard) */ s = (**(**TDateTime)(__ccgo_up(bp))).Fs if s > float64(59.999) { s = float64(59.999) } Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1400, libc.VaList(bp+184, s)) case int32('F'): Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1407, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).FY, (**(**TDateTime)(__ccgo_up(bp))).FM, (**(**TDateTime)(__ccgo_up(bp))).FD)) case int32('G'): /* Fall thru */ fallthrough case int32('g'): **(**TDateTime)(__ccgo_up(bp + 80)) = **(**TDateTime)(__ccgo_up(bp)) /* Move y so that it is the Thursday in the same week as x */ (**(**TDateTime)(__ccgo_up(bp + 80))).FiJD += int64((int32(3) - _daysAfterMonday(tls, bp)) * int32(86400000)) (**(**TDateTime)(__ccgo_up(bp + 80))).FvalidYMD = uint8(0) _computeYMD(tls, bp+80) if libc.Int32FromUint8(cf) == int32('g') { Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp + 80))).FY%int32(100))) } else { Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1422, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp + 80))).FY)) } case int32('H'): fallthrough case int32('k'): if libc.Int32FromUint8(cf) == int32('H') { v3 = __ccgo_ts + 1391 } else { v3 = __ccgo_ts + 1396 } Xsqlite3_str_appendf(tls, bp+48, v3, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).Fh)) case int32('I'): /* Fall thru */ fallthrough case int32('l'): h = (**(**TDateTime)(__ccgo_up(bp))).Fh if h > int32(12) { h = h - int32(12) } if h == 0 { h = int32(12) } if libc.Int32FromUint8(cf) == int32('I') { v3 = __ccgo_ts + 1391 } else { v3 = __ccgo_ts + 1396 } Xsqlite3_str_appendf(tls, bp+48, v3, libc.VaList(bp+184, h)) case int32('j'): /* Day of year. Jan01==1, Jan02==2, and so forth */ Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1427, libc.VaList(bp+184, _daysAfterJan01(tls, bp)+int32(1))) case int32('J'): /* Julian day number. (Non-standard) */ Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1432, libc.VaList(bp+184, float64((**(**TDateTime)(__ccgo_up(bp))).FiJD)/float64(8.64e+07))) case int32('m'): Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).FM)) case int32('M'): Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).Fm)) case int32('p'): /* Fall thru */ fallthrough case int32('P'): if (**(**TDateTime)(__ccgo_up(bp))).Fh >= int32(12) { if libc.Int32FromUint8(cf) == int32('p') { v3 = __ccgo_ts + 1438 } else { v3 = __ccgo_ts + 1441 } Xsqlite3_str_append(tls, bp+48, v3, int32(2)) } else { if libc.Int32FromUint8(cf) == int32('p') { v3 = __ccgo_ts + 1444 } else { v3 = __ccgo_ts + 1447 } Xsqlite3_str_append(tls, bp+48, v3, int32(2)) } case int32('R'): Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1450, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).Fh, (**(**TDateTime)(__ccgo_up(bp))).Fm)) case int32('s'): if int32(uint32(*(*uint8)(unsafe.Pointer(bp + 44))&0x4>>2)) != 0 { Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1460, libc.VaList(bp+184, float64((**(**TDateTime)(__ccgo_up(bp))).FiJD-libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000000))/float64(1000))) } else { iS = (**(**TDateTime)(__ccgo_up(bp))).FiJD/libc.Int64FromInt32(1000) - libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000) Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1465, libc.VaList(bp+184, iS)) } case int32('S'): Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, int32((**(**TDateTime)(__ccgo_up(bp))).Fs))) case int32('T'): Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1470, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).Fh, (**(**TDateTime)(__ccgo_up(bp))).Fm, int32((**(**TDateTime)(__ccgo_up(bp))).Fs))) case int32('u'): /* Day of week. 1 to 7. Monday==1, Sunday==7 */ fallthrough case int32('w'): /* Day of week. 0 to 6. Sunday==0, Monday==1 */ c = libc.Uint8FromInt32(libc.Int32FromUint8(libc.Uint8FromInt32(_daysAfterSunday(tls, bp))) + int32('0')) if libc.Int32FromUint8(c) == int32('0') && libc.Int32FromUint8(cf) == int32('u') { c = uint8('7') } Xsqlite3_str_appendchar(tls, bp+48, int32(1), c) case int32('U'): /* Week num. 00-53. First Sun of the year is week 01 */ Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, (_daysAfterJan01(tls, bp)-_daysAfterSunday(tls, bp)+int32(7))/int32(7))) case int32('V'): /* Week num. 01-53. First week with a Thur is week 01 */ **(**TDateTime)(__ccgo_up(bp + 128)) = **(**TDateTime)(__ccgo_up(bp)) /* Adjust y so that is the Thursday in the same week as x */ (**(**TDateTime)(__ccgo_up(bp + 128))).FiJD += int64((int32(3) - _daysAfterMonday(tls, bp)) * int32(86400000)) (**(**TDateTime)(__ccgo_up(bp + 128))).FvalidYMD = uint8(0) _computeYMD(tls, bp+128) Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, _daysAfterJan01(tls, bp+128)/int32(7)+int32(1))) case int32('W'): /* Week num. 00-53. First Mon of the year is week 01 */ Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1391, libc.VaList(bp+184, (_daysAfterJan01(tls, bp)-_daysAfterMonday(tls, bp)+int32(7))/int32(7))) case int32('Y'): Xsqlite3_str_appendf(tls, bp+48, __ccgo_ts+1422, libc.VaList(bp+184, (**(**TDateTime)(__ccgo_up(bp))).FY)) case int32('%'): Xsqlite3_str_appendchar(tls, bp+48, int32(1), uint8('%')) default: Xsqlite3_str_reset(tls, bp+48) return } goto _1 _1: ; i = i + 1 } if j < i { Xsqlite3_str_append(tls, bp+48, zFmt+uintptr(j), libc.Int32FromUint64(i-j)) } _sqlite3ResultStrAccum(tls, context, bp+48) } // C documentation // // /* // ** Assuming the input DateTime is UTC, move it to its localtime equivalent. // */ func _toLocaltime(tls *libc.TLS, p uintptr, pCtx uintptr) (r int32) { bp := tls.Alloc(112) defer tls.Free(112) var iYearDiff int32 var _ /* sLocal at bp+8 */ Ttm var _ /* t at bp+0 */ Ttime_t var _ /* x at bp+64 */ TDateTime _ = iYearDiff /* Initialize the contents of sLocal to avoid a compiler warning. */ libc.Xmemset(tls, bp+8, 0, uint64(56)) _computeJD(tls, p) if (*TDateTime)(unsafe.Pointer(p)).FiJD < libc.Int64FromInt32(2108667600)*libc.Int64FromInt32(100000) || (*TDateTime)(unsafe.Pointer(p)).FiJD > libc.Int64FromInt32(2130141456)*libc.Int64FromInt32(100000) { /* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only ** works for years between 1970 and 2037. For dates outside this range, ** SQLite attempts to map the year into an equivalent year within this ** range, do the calculation, then map the year back. */ **(**TDateTime)(__ccgo_up(bp + 64)) = **(**TDateTime)(__ccgo_up(p)) _computeYMD_HMS(tls, bp+64) iYearDiff = int32(2000) + (**(**TDateTime)(__ccgo_up(bp + 64))).FY%int32(4) - (**(**TDateTime)(__ccgo_up(bp + 64))).FY (**(**TDateTime)(__ccgo_up(bp + 64))).FY += iYearDiff (**(**TDateTime)(__ccgo_up(bp + 64))).FvalidJD = uint8(0) _computeJD(tls, bp+64) **(**Ttime_t)(__ccgo_up(bp)) = int64((**(**TDateTime)(__ccgo_up(bp + 64))).FiJD/libc.Int64FromInt32(1000) - libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000)) } else { iYearDiff = 0 **(**Ttime_t)(__ccgo_up(bp)) = int64((*TDateTime)(unsafe.Pointer(p)).FiJD/libc.Int64FromInt32(1000) - libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000)) } if _osLocaltime(tls, bp, bp+8) != 0 { Xsqlite3_result_error(tls, pCtx, __ccgo_ts+1249, -int32(1)) return int32(SQLITE_ERROR) } (*TDateTime)(unsafe.Pointer(p)).FY = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_year + int32(1900) - iYearDiff (*TDateTime)(unsafe.Pointer(p)).FM = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_mon + int32(1) (*TDateTime)(unsafe.Pointer(p)).FD = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_mday (*TDateTime)(unsafe.Pointer(p)).Fh = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_hour (*TDateTime)(unsafe.Pointer(p)).Fm = (**(**Ttm)(__ccgo_up(bp + 8))).Ftm_min (*TDateTime)(unsafe.Pointer(p)).Fs = float64((**(**Ttm)(__ccgo_up(bp + 8))).Ftm_sec) + float64(float64((*TDateTime)(unsafe.Pointer(p)).FiJD%libc.Int64FromInt32(1000))*float64(0.001)) (*TDateTime)(unsafe.Pointer(p)).FvalidYMD = uint8(1) (*TDateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(1) (*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(0) libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1) (*TDateTime)(unsafe.Pointer(p)).Ftz = 0 libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 1, 0x2) return SQLITE_OK } // C documentation // // /* // ** Perform a reduce action and the shift that must immediately // ** follow the reduce. // ** // ** The yyLookahead and yyLookaheadToken parameters provide reduce actions // ** access to the lookahead token (if any). The yyLookahead will be YYNOCODE // ** if the lookahead token has already been consumed. As this procedure is // ** only called from one place, optimizing compilers will in-line it, which // ** means that the extra parameters have no performance impact. // */ func _yy_reduce(tls *libc.TLS, yypParser uintptr, yyruleno uint32, yyLookahead int32, yyLookaheadToken TToken, pParse uintptr) (r uint16) { bp := tls.Alloc(160) defer tls.Free(160) var bNot, bNot1, i, nExpr, yygoto, yysize, v353 int32 var n Tu32 var op Tu8 var p, p1, p2, p3, p4, p5, pB, pDot, pFrom, pFromClause, pLeft, pLhs, pList, pList1, pList2, pList3, pList4, pNew, pOld, pRHS, pRhs, pRight, pSelect, pSelectRHS, pSrc, pSubquery, pSubquery1, temp1, temp11, temp2, temp21, temp3, temp4, yymsp, v352 uintptr var yyact uint16 var v357 TToken var _ /* all at bp+112 */ TToken var _ /* as at bp+72 */ TToken var _ /* dest at bp+16 */ TSelectDest var _ /* iValue at bp+88 */ int32 var _ /* t at bp+96 */ TToken var _ /* x at bp+56 */ TToken var _ /* yylhsminor at bp+0 */ TYYMINORTYPE _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bNot, bNot1, i, n, nExpr, op, p, p1, p2, p3, p4, p5, pB, pDot, pFrom, pFromClause, pLeft, pLhs, pList, pList1, pList2, pList3, pList4, pNew, pOld, pRHS, pRhs, pRight, pSelect, pSelectRHS, pSrc, pSubquery, pSubquery1, temp1, temp11, temp2, temp21, temp3, temp4, yyact, yygoto, yymsp, yysize, v352, v353, v357 /* Amount to pop the stack */ _ = yyLookahead _ = yyLookaheadToken yymsp = (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos switch yyruleno { case uint32(0): goto _1 case uint32(1): goto _2 case uint32(2): goto _3 case uint32(3): goto _4 case uint32(4): goto _5 case uint32(6): goto _6 case uint32(5): goto _7 case uint32(7): goto _8 case uint32(328): goto _9 case uint32(9): goto _10 case uint32(8): goto _11 case uint32(10): goto _12 case uint32(11): goto _13 case uint32(12): goto _14 case uint32(13): goto _15 case uint32(14): goto _16 case uint32(18): goto _17 case uint32(15): goto _18 case uint32(47): goto _19 case uint32(62): goto _20 case uint32(72): goto _21 case uint32(81): goto _22 case uint32(100): goto _23 case uint32(246): goto _24 case uint32(16): goto _25 case uint32(17): goto _26 case uint32(19): goto _27 case uint32(20): goto _28 case uint32(21): goto _29 case uint32(22): goto _30 case uint32(23): goto _31 case uint32(24): goto _32 case uint32(25): goto _33 case uint32(65): goto _34 case uint32(26): goto _35 case uint32(106): goto _36 case uint32(27): goto _37 case uint32(28): goto _38 case uint32(29): goto _39 case uint32(30): goto _40 case uint32(31): goto _41 case uint32(67): goto _42 case uint32(32): goto _43 case uint32(33): goto _44 case uint32(34): goto _45 case uint32(35): goto _46 case uint32(36): goto _47 case uint32(37): goto _48 case uint32(38): goto _49 case uint32(39): goto _50 case uint32(40): goto _51 case uint32(41): goto _52 case uint32(42): goto _53 case uint32(43): goto _54 case uint32(44): goto _55 case uint32(45): goto _56 case uint32(46): goto _57 case uint32(48): goto _58 case uint32(49): goto _59 case uint32(50): goto _60 case uint32(51): goto _61 case uint32(52): goto _62 case uint32(53): goto _63 case uint32(54): goto _64 case uint32(55): goto _65 case uint32(56): goto _66 case uint32(57): goto _67 case uint32(58): goto _68 case uint32(59): goto _69 case uint32(60): goto _70 case uint32(76): goto _71 case uint32(61): goto _72 case uint32(173): goto _73 case uint32(80): goto _74 case uint32(63): goto _75 case uint32(219): goto _76 case uint32(222): goto _77 case uint32(247): goto _78 case uint32(64): goto _79 case uint32(66): goto _80 case uint32(68): goto _81 case uint32(69): goto _82 case uint32(70): goto _83 case uint32(71): goto _84 case uint32(75): goto _85 case uint32(73): goto _86 case uint32(74): goto _87 case uint32(77): goto _88 case uint32(174): goto _89 case uint32(78): goto _90 case uint32(79): goto _91 case uint32(82): goto _92 case uint32(83): goto _93 case uint32(84): goto _94 case uint32(85): goto _95 case uint32(86): goto _96 case uint32(87): goto _97 case uint32(88): goto _98 case uint32(91): goto _99 case uint32(89): goto _100 case uint32(90): goto _101 case uint32(92): goto _102 case uint32(93): goto _103 case uint32(94): goto _104 case uint32(95): goto _105 case uint32(97): goto _106 case uint32(96): goto _107 case uint32(98): goto _108 case uint32(99): goto _109 case uint32(134): goto _110 case uint32(101): goto _111 case uint32(144): goto _112 case uint32(234): goto _113 case uint32(237): goto _114 case uint32(242): goto _115 case uint32(102): goto _116 case uint32(103): goto _117 case uint32(104): goto _118 case uint32(117): goto _119 case uint32(105): goto _120 case uint32(258): goto _121 case uint32(259): goto _122 case uint32(110): goto _123 case uint32(107): goto _124 case uint32(108): goto _125 case uint32(109): goto _126 case uint32(111): goto _127 case uint32(112): goto _128 case uint32(113): goto _129 case uint32(114): goto _130 case uint32(115): goto _131 case uint32(131): goto _132 case uint32(116): goto _133 case uint32(120): goto _134 case uint32(118): goto _135 case uint32(121): goto _136 case uint32(119): goto _137 case uint32(122): goto _138 case uint32(123): goto _139 case uint32(124): goto _140 case uint32(125): goto _141 case uint32(126): goto _142 case uint32(127): goto _143 case uint32(128): goto _144 case uint32(129): goto _145 case uint32(130): goto _146 case uint32(132): goto _147 case uint32(133): goto _148 case uint32(145): goto _149 case uint32(135): goto _150 case uint32(136): goto _151 case uint32(137): goto _152 case uint32(138): goto _153 case uint32(139): goto _154 case uint32(143): goto _155 case uint32(140): goto _156 case uint32(141): goto _157 case uint32(142): goto _158 case uint32(148): goto _159 case uint32(146): goto _160 case uint32(153): goto _161 case uint32(155): goto _162 case uint32(232): goto _163 case uint32(233): goto _164 case uint32(252): goto _165 case uint32(154): goto _166 case uint32(147): goto _167 case uint32(156): goto _168 case uint32(231): goto _169 case uint32(251): goto _170 case uint32(149): goto _171 case uint32(150): goto _172 case uint32(151): goto _173 case uint32(152): goto _174 case uint32(157): goto _175 case uint32(158): goto _176 case uint32(159): goto _177 case uint32(160): goto _178 case uint32(161): goto _179 case uint32(162): goto _180 case uint32(163): goto _181 case uint32(164): goto _182 case uint32(165): goto _183 case uint32(166): goto _184 case uint32(167): goto _185 case uint32(168): goto _186 case uint32(169): goto _187 case uint32(170): goto _188 case uint32(171): goto _189 case uint32(172): goto _190 case uint32(175): goto _191 case uint32(176): goto _192 case uint32(177): goto _193 case uint32(178): goto _194 case uint32(179): goto _195 case uint32(180): goto _196 case uint32(181): goto _197 case uint32(182): goto _198 case uint32(184): goto _199 case uint32(183): goto _200 case uint32(185): goto _201 case uint32(186): goto _202 case uint32(187): goto _203 case uint32(188): goto _204 case uint32(189): goto _205 case uint32(190): goto _206 case uint32(191): goto _207 case uint32(192): goto _208 case uint32(193): goto _209 case uint32(194): goto _210 case uint32(195): goto _211 case uint32(196): goto _212 case uint32(197): goto _213 case uint32(199): goto _214 case uint32(198): goto _215 case uint32(200): goto _216 case uint32(201): goto _217 case uint32(202): goto _218 case uint32(203): goto _219 case uint32(204): goto _220 case uint32(205): goto _221 case uint32(206): goto _222 case uint32(207): goto _223 case uint32(208): goto _224 case uint32(209): goto _225 case uint32(210): goto _226 case uint32(211): goto _227 case uint32(212): goto _228 case uint32(213): goto _229 case uint32(215): goto _230 case uint32(214): goto _231 case uint32(216): goto _232 case uint32(217): goto _233 case uint32(221): goto _234 case uint32(218): goto _235 case uint32(220): goto _236 case uint32(223): goto _237 case uint32(224): goto _238 case uint32(225): goto _239 case uint32(226): goto _240 case uint32(227): goto _241 case uint32(228): goto _242 case uint32(229): goto _243 case uint32(230): goto _244 case uint32(235): goto _245 case uint32(236): goto _246 case uint32(243): goto _247 case uint32(238): goto _248 case uint32(239): goto _249 case uint32(281): goto _250 case uint32(240): goto _251 case uint32(241): goto _252 case uint32(244): goto _253 case uint32(245): goto _254 case uint32(248): goto _255 case uint32(249): goto _256 case uint32(250): goto _257 case uint32(253): goto _258 case uint32(254): goto _259 case uint32(255): goto _260 case uint32(256): goto _261 case uint32(257): goto _262 case uint32(260): goto _263 case uint32(261): goto _264 case uint32(262): goto _265 case uint32(263): goto _266 case uint32(264): goto _267 case uint32(266): goto _268 case uint32(265): goto _269 case uint32(267): goto _270 case uint32(286): goto _271 case uint32(268): goto _272 case uint32(287): goto _273 case uint32(269): goto _274 case uint32(270): goto _275 case uint32(271): goto _276 case uint32(272): goto _277 case uint32(273): goto _278 case uint32(274): goto _279 case uint32(275): goto _280 case uint32(276): goto _281 case uint32(277): goto _282 case uint32(278): goto _283 case uint32(279): goto _284 case uint32(280): goto _285 case uint32(282): goto _286 case uint32(283): goto _287 case uint32(284): goto _288 case uint32(285): goto _289 case uint32(288): goto _290 case uint32(289): goto _291 case uint32(290): goto _292 case uint32(291): goto _293 case uint32(292): goto _294 case uint32(293): goto _295 case uint32(294): goto _296 case uint32(295): goto _297 case uint32(296): goto _298 case uint32(297): goto _299 case uint32(298): goto _300 case uint32(299): goto _301 case uint32(300): goto _302 case uint32(301): goto _303 case uint32(302): goto _304 case uint32(303): goto _305 case uint32(304): goto _306 case uint32(305): goto _307 case uint32(307): goto _308 case uint32(306): goto _309 case uint32(308): goto _310 case uint32(310): goto _311 case uint32(309): goto _312 case uint32(311): goto _313 case uint32(312): goto _314 case uint32(313): goto _315 case uint32(314): goto _316 case uint32(315): goto _317 case uint32(316): goto _318 case uint32(317): goto _319 case uint32(318): goto _320 case uint32(319): goto _321 case uint32(320): goto _322 case uint32(321): goto _323 case uint32(322): goto _324 case uint32(323): goto _325 case uint32(324): goto _326 case uint32(325): goto _327 case uint32(326): goto _328 case uint32(327): goto _329 case uint32(331): goto _330 case uint32(329): goto _331 case uint32(332): goto _332 case uint32(330): goto _333 case uint32(334): goto _334 case uint32(333): goto _335 case uint32(335): goto _336 case uint32(336): goto _337 case uint32(338): goto _338 case uint32(337): goto _339 case uint32(339): goto _340 case uint32(340): goto _341 case uint32(341): goto _342 case uint32(342): goto _343 case uint32(343): goto _344 case uint32(344): goto _345 case uint32(345): goto _346 case uint32(346): goto _347 case uint32(347): goto _348 default: goto _349 } goto _350 _1: ; /* explain ::= EXPLAIN */ if (*TParse)(unsafe.Pointer(pParse)).FpReprepare == uintptr(0) { (*TParse)(unsafe.Pointer(pParse)).Fexplain = uint8(1) } goto _350 _2: ; /* explain ::= EXPLAIN QUERY PLAN */ if (*TParse)(unsafe.Pointer(pParse)).FpReprepare == uintptr(0) { (*TParse)(unsafe.Pointer(pParse)).Fexplain = uint8(2) } goto _350 _3: ; /* cmdx ::= cmd */ _sqlite3FinishCoding(tls, pParse) goto _350 _4: ; /* cmd ::= BEGIN transtype trans_opt */ _sqlite3BeginTransaction(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) goto _350 _5: ; /* transtype ::= */ *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = int32(TK_DEFERRED) goto _350 _7: ; /* transtype ::= DEFERRED */ _6: ; _8: ; _9: ; *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-X*/ goto _350 _11: ; /* cmd ::= COMMIT|END trans_opt */ _10: ; _sqlite3EndTransaction(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor)) goto _350 _12: ; /* cmd ::= SAVEPOINT nm */ _sqlite3Savepoint(tls, pParse, SAVEPOINT_BEGIN, yymsp+8) goto _350 _13: ; /* cmd ::= RELEASE savepoint_opt nm */ _sqlite3Savepoint(tls, pParse, int32(SAVEPOINT_RELEASE), yymsp+8) goto _350 _14: ; /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ _sqlite3Savepoint(tls, pParse, int32(SAVEPOINT_ROLLBACK), yymsp+8) goto _350 _15: ; /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ _sqlite3StartTable(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, yymsp+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), 0, 0, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) goto _350 _16: ; /* createkw ::= CREATE */ _disableLookaside(tls, pParse) goto _350 _18: ; /* ifnotexists ::= */ _17: ; _19: ; _20: ; _21: ; _22: ; _23: ; _24: ; *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = 0 goto _350 _25: ; /* ifnotexists ::= IF NOT EXISTS */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = int32(1) goto _350 _26: ; /* temp ::= TEMP */ *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.BoolInt32(libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Finit1.Fbusy) == 0) goto _350 _27: ; /* create_table_args ::= LP columnlist conslist_opt RP table_option_set */ _sqlite3EndTable(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, *(*Tu32)(unsafe.Pointer(yymsp + 8)), uintptr(0)) goto _350 _28: ; /* create_table_args ::= AS select */ _sqlite3EndTable(tls, pParse, uintptr(0), uintptr(0), uint32(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _29: ; /* table_option_set ::= */ *(*Tu32)(unsafe.Pointer(yymsp + 1*24 + 8)) = uint32(0) goto _350 _30: ; /* table_option_set ::= table_option_set COMMA table_option */ *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*Tu32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) | *(*Tu32)(unsafe.Pointer(yymsp + 8)) *(*Tu32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _31: ; /* table_option ::= WITHOUT nm */ if *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) == uint32(5) && Xsqlite3_strnicmp(tls, *(*uintptr)(unsafe.Pointer(yymsp + 8)), __ccgo_ts+17991, int32(5)) == 0 { *(*Tu32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = libc.Uint32FromInt32(libc.Int32FromInt32(TF_WithoutRowid) | libc.Int32FromInt32(TF_NoVisibleRowid)) } else { *(*Tu32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uint32(0) _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25023, libc.VaList(bp+136, *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)))) } goto _350 _32: ; /* table_option ::= nm */ if *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) == uint32(6) && Xsqlite3_strnicmp(tls, *(*uintptr)(unsafe.Pointer(yymsp + 8)), __ccgo_ts+17927, int32(6)) == 0 { *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = uint32(TF_Strict) } else { *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = uint32(0) _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25023, libc.VaList(bp+136, *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)))) } *(*Tu32)(unsafe.Pointer(yymsp + 8)) = *(*Tu32)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _33: ; /* columnname ::= nm typetoken */ _sqlite3AddColumn(tls, pParse, *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*TToken)(unsafe.Pointer(yymsp + 8))) goto _350 _35: ; /* typetoken ::= */ _34: ; _36: ; *(*uint32)(unsafe.Pointer(yymsp + 1*24 + 8 + 8)) = uint32(0) *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) goto _350 _37: ; /* typetoken ::= typename LP signed RP */ *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)) = libc.Uint32FromInt32(int32(t__predefined_ptrdiff_t(*(*uintptr)(unsafe.Pointer(yymsp + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + 8 + 8)))) - int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))))) goto _350 _38: ; /* typetoken ::= typename LP signed COMMA signed RP */ *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8 + 8)) = libc.Uint32FromInt32(int32(t__predefined_ptrdiff_t(*(*uintptr)(unsafe.Pointer(yymsp + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + 8 + 8)))) - int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8))))) goto _350 _39: ; /* typename ::= typename ID|STRING */ *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) = *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) + libc.Uint32FromInt32(int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8)))-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))))) goto _350 _40: ; /* scanpt ::= */ *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = yyLookaheadToken.Fz goto _350 _41: ; /* scantok ::= */ *(*TToken)(unsafe.Pointer(yymsp + 1*24 + 8)) = yyLookaheadToken goto _350 _43: ; /* ccons ::= CONSTRAINT nm */ _42: ; (*(*struct { FaddrCrTab int32 FregRowid int32 FregRoot int32 FconstraintName TToken })(unsafe.Pointer(pParse + 256))).FconstraintName = *(*TToken)(unsafe.Pointer(yymsp + 8)) goto _350 _44: ; /* ccons ::= DEFAULT scantok term */ _sqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)))) goto _350 _45: ; /* ccons ::= DEFAULT LP expr RP */ _sqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))+uintptr(1), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _46: ; /* ccons ::= DEFAULT PLUS scantok term */ _sqlite3AddDefaultValue(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)))) goto _350 _47: ; /* ccons ::= DEFAULT MINUS scantok term */ p = _sqlite3PExpr(tls, pParse, int32(TK_UMINUS), *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0)) _sqlite3AddDefaultValue(tls, pParse, p, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)))) goto _350 _48: ; /* ccons ::= DEFAULT scantok ID|INDEXED */ p1 = _tokenExpr(tls, pParse, int32(TK_STRING), *(*TToken)(unsafe.Pointer(yymsp + 8))) if p1 != 0 { _sqlite3ExprIdToTrueFalse(tls, p1) } _sqlite3AddDefaultValue(tls, pParse, p1, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))+uintptr(*(*uint32)(unsafe.Pointer(yymsp + 8 + 8)))) goto _350 _49: ; /* ccons ::= NOT NULL onconf */ _sqlite3AddNotNull(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8))) goto _350 _50: ; /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ _sqlite3AddPrimaryKey(tls, pParse, uintptr(0), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) goto _350 _51: ; /* ccons ::= UNIQUE onconf */ _sqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), uintptr(0), *(*int32)(unsafe.Pointer(yymsp + 8)), uintptr(0), uintptr(0), 0, 0, uint8(SQLITE_IDXTYPE_UNIQUE)) goto _350 _52: ; /* ccons ::= CHECK LP expr RP */ _sqlite3AddCheckConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _53: ; /* ccons ::= REFERENCES nm eidlist_opt refargs */ _sqlite3CreateForeignKey(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) goto _350 _54: ; /* ccons ::= defer_subclause */ _sqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8))) goto _350 _55: ; /* ccons ::= COLLATE ID|STRING */ _sqlite3AddCollateType(tls, pParse, yymsp+8) goto _350 _56: ; /* generated ::= LP expr RP */ _sqlite3AddGenerated(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) goto _350 _57: ; /* generated ::= LP expr RP ID */ _sqlite3AddGenerated(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+8) goto _350 _58: ; /* autoinc ::= AUTOINCR */ *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(1) goto _350 _59: ; /* refargs ::= */ *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = libc.Int32FromInt32(OE_None) * libc.Int32FromInt32(0x0101) /* EV: R-19803-45884 */ goto _350 _60: ; /* refargs ::= refargs refarg */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) & ^*(*int32)(unsafe.Pointer(yymsp + 8 + 4)) | *(*int32)(unsafe.Pointer(yymsp + 8)) goto _350 _61: ; /* refarg ::= MATCH nm */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = 0 *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 4)) = 0x000000 goto _350 _62: ; /* refarg ::= ON INSERT refact */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = 0 *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8 + 4)) = 0x000000 goto _350 _63: ; /* refarg ::= ON DELETE refact */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + 8)) *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8 + 4)) = int32(0x0000ff) goto _350 _64: ; /* refarg ::= ON UPDATE refact */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + 8)) << int32(8) *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8 + 4)) = int32(0x00ff00) goto _350 _65: ; /* refact ::= SET NULL */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(OE_SetNull) /* EV: R-33326-45252 */ goto _350 _66: ; /* refact ::= SET DEFAULT */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(OE_SetDflt) /* EV: R-33326-45252 */ goto _350 _67: ; /* refact ::= CASCADE */ *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Cascade) /* EV: R-33326-45252 */ goto _350 _68: ; /* refact ::= RESTRICT */ *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Restrict) /* EV: R-33326-45252 */ goto _350 _69: ; /* refact ::= NO ACTION */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = OE_None /* EV: R-33326-45252 */ goto _350 _70: ; /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = 0 goto _350 _72: ; /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ _71: ; _73: ; *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + 8)) goto _350 _75: ; /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ _74: ; _76: ; _77: ; _78: ; *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(1) goto _350 _79: ; /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = 0 goto _350 _80: ; /* tconscomma ::= COMMA */ (*(*struct { FaddrCrTab int32 FregRowid int32 FregRoot int32 FconstraintName TToken })(unsafe.Pointer(pParse + 256))).FconstraintName.Fn = uint32(0) goto _350 _81: ; /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ _sqlite3AddPrimaryKey(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), 0) goto _350 _82: ; /* tcons ::= UNIQUE LP sortlist RP onconf */ _sqlite3CreateIndex(tls, pParse, uintptr(0), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8)), uintptr(0), uintptr(0), 0, 0, uint8(SQLITE_IDXTYPE_UNIQUE)) goto _350 _83: ; /* tcons ::= CHECK LP expr RP onconf */ _sqlite3AddCheckConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) goto _350 _84: ; /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ _sqlite3CreateForeignKey(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) _sqlite3DeferForeignKey(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + 8))) goto _350 _86: ; /* onconf ::= */ _85: ; *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = int32(OE_Default) goto _350 _87: ; /* onconf ::= ON CONFLICT resolvetype */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*int32)(unsafe.Pointer(yymsp + 8)) goto _350 _88: ; /* resolvetype ::= IGNORE */ *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Ignore) goto _350 _90: ; /* resolvetype ::= REPLACE */ _89: ; *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Replace) goto _350 _91: ; /* cmd ::= DROP TABLE ifexists fullname */ _sqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), 0, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) goto _350 _92: ; /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ _sqlite3CreateView(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(8))*24+8, yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8))) goto _350 _93: ; /* cmd ::= DROP VIEW ifexists fullname */ _sqlite3DropTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), int32(1), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) goto _350 _94: ; /* cmd ::= select */ **(**TSelectDest)(__ccgo_up(bp + 16)) = TSelectDest{ FeDest: uint8(SRT_Output), } if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmDbFlags&uint32(DBFLAG_EncodingFixed) != uint32(0) || _sqlite3ReadSchema(tls, pParse) == SQLITE_OK { _sqlite3Select(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), bp+16) } _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _95: ; /* select ::= WITH wqlist selectnowith */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _attachWithToSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) goto _350 _96: ; /* select ::= WITH RECURSIVE wqlist selectnowith */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _attachWithToSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) goto _350 _97: ; /* select ::= selectnowith */ p2 = *(*uintptr)(unsafe.Pointer(yymsp + 8)) if p2 != 0 { _parserDoubleLinkSelect(tls, pParse, p2) } goto _350 _98: ; /* selectnowith ::= selectnowith multiselect_op oneselect */ pRhs = *(*uintptr)(unsafe.Pointer(yymsp + 8)) pLhs = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) if pRhs != 0 && (*TSelect)(unsafe.Pointer(pRhs)).FpPrior != 0 { (**(**TToken)(__ccgo_up(bp + 56))).Fn = uint32(0) _parserDoubleLinkSelect(tls, pParse, pRhs) pFrom = _sqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp+56, pRhs, uintptr(0)) pRhs = _sqlite3SelectNew(tls, pParse, uintptr(0), pFrom, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) } if pRhs != 0 { (*TSelect)(unsafe.Pointer(pRhs)).Fop = libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) (*TSelect)(unsafe.Pointer(pRhs)).FpPrior = pLhs if pLhs != 0 { **(**Tu32)(__ccgo_up(pLhs + 4)) &= ^libc.Uint32FromInt32(SF_MultiValue) } **(**Tu32)(__ccgo_up(pRhs + 4)) &= ^libc.Uint32FromInt32(SF_MultiValue) if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != int32(TK_ALL) { libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 2, 0x4) } } else { _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pLhs) } *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = pRhs goto _350 _100: ; /* multiselect_op ::= UNION */ _99: ; *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-OP*/ goto _350 _101: ; /* multiselect_op ::= UNION ALL */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(TK_ALL) goto _350 _102: ; /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)) = _sqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _103: ; /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(9))*24 + 8)) = _sqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), libc.Uint32FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(9))*24 + 8)) != 0 { (*TSelect)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(9))*24 + 8)))).FpWinDefn = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) } else { _sqlite3WindowListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) } goto _350 _104: ; /* values ::= VALUES LP nexprlist RP */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3SelectNew(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_Values), uintptr(0)) goto _350 _105: ; /* oneselect ::= mvalues */ _sqlite3MultiValuesEnd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _107: ; /* mvalues ::= values COMMA LP nexprlist RP */ _106: ; *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3MultiValues(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) goto _350 _108: ; /* distinct ::= DISTINCT */ *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(SF_Distinct) goto _350 _109: ; /* distinct ::= ALL */ *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(SF_All) goto _350 _111: ; /* sclp ::= */ _110: ; _112: ; _113: ; _114: ; _115: ; *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) goto _350 _116: ; /* selcollist ::= sclp scanpt expr scanpt as */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) if *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) > uint32(0) { _sqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+8, int32(1)) } _sqlite3ExprListSetSpan(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) goto _350 _117: ; /* selcollist ::= sclp scanpt STAR */ p3 = _sqlite3Expr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_ASTERISK), uintptr(0)) _sqlite3ExprSetErrorOffset(tls, p3, int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8)))-int64((*TParse)(unsafe.Pointer(pParse)).FzTail))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), p3) goto _350 _118: ; /* selcollist ::= sclp scanpt nm DOT STAR */ pRight = _sqlite3PExpr(tls, pParse, int32(TK_ASTERISK), uintptr(0), uintptr(0)) _sqlite3ExprSetErrorOffset(tls, pRight, int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8)))-int64((*TParse)(unsafe.Pointer(pParse)).FzTail))) pLeft = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) pDot = _sqlite3PExpr(tls, pParse, int32(TK_DOT), pLeft, pRight) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), pDot) goto _350 _120: ; /* as ::= AS nm */ _119: ; _121: ; _122: ; *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TToken)(unsafe.Pointer(yymsp + 8)) goto _350 _124: ; /* from ::= */ _123: ; *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) goto _350 _125: ; /* from ::= FROM seltablist */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) _sqlite3SrcListShiftJoinType(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) goto _350 _126: ; /* stl_prefix ::= seltablist joinop */ if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 && (*TSrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FnSrc > 0 { (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + 8 + uintptr((*TSrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FnSrc-int32(1))*80))).Ffg.Fjointype = libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + 8))) } goto _350 _127: ; /* seltablist ::= stl_prefix nm dbnm as on_using */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0), yymsp+8) goto _350 _128: ; /* seltablist ::= stl_prefix nm dbnm as indexed_by on_using */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, uintptr(0), yymsp+8) _sqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) goto _350 _129: ; /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(6))*24+8, yymsp+uintptr(-libc.Int32FromInt32(5))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0), yymsp+8) _sqlite3SrcListFuncArgs(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) goto _350 _130: ; /* seltablist ::= stl_prefix LP select RP as on_using */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), uintptr(0), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), yymsp+8) goto _350 _131: ; /* seltablist ::= stl_prefix LP seltablist RP as on_using */ if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) == uintptr(0) && *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) == uint32(0) && *(*uintptr)(unsafe.Pointer(yymsp + 8)) == uintptr(0) && *(*uintptr)(unsafe.Pointer(yymsp + 8 + 8)) == uintptr(0) { *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) } else { if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != uintptr(0) && (*TSrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)))).FnSrc == int32(1) { *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), uintptr(0), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0), yymsp+8) if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) != 0 { pNew = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) + 8 + uintptr((*TSrcList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)))).FnSrc-int32(1))*80 pOld = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) + 8 (*TSrcItem)(unsafe.Pointer(pNew)).FzName = (*TSrcItem)(unsafe.Pointer(pOld)).FzName if int32(*(*uint32)(unsafe.Pointer(pOld + 24 + 4))&0x4>>2) != 0 { libc.SetBitFieldPtr32Uint32(pNew+24+4, libc.Uint32FromInt32(1), 2, 0x4) *(*uintptr)(unsafe.Pointer(pNew + 72)) = *(*uintptr)(unsafe.Pointer(pOld + 72)) *(*uintptr)(unsafe.Pointer(pOld + 72)) = uintptr(0) libc.SetBitFieldPtr32Uint32(pOld+24+4, libc.Uint32FromInt32(0), 2, 0x4) if (*TSelect)(unsafe.Pointer((*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pNew + 72)))).FpSelect)).FselFlags&uint32(SF_NestedFrom) != uint32(0) { libc.SetBitFieldPtr32Uint32(pNew+24+4, libc.Uint32FromInt32(1), 14, 0x4000) } } else { *(*uintptr)(unsafe.Pointer(pNew + 72)) = *(*uintptr)(unsafe.Pointer(pOld + 72)) *(*uintptr)(unsafe.Pointer(pOld + 72)) = uintptr(0) } if int32(*(*uint32)(unsafe.Pointer(pOld + 24 + 4))&0x8>>3) != 0 { *(*uintptr)(unsafe.Pointer(pNew + 48)) = *(*uintptr)(unsafe.Pointer(pOld + 48)) *(*uintptr)(unsafe.Pointer(pOld + 48)) = uintptr(0) libc.SetBitFieldPtr32Uint32(pOld+24+4, libc.Uint32FromInt32(0), 3, 0x8) libc.SetBitFieldPtr32Uint32(pNew+24+4, libc.Uint32FromInt32(1), 3, 0x8) } (*TSrcItem)(unsafe.Pointer(pOld)).FzName = uintptr(0) } _sqlite3SrcListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) } else { _sqlite3SrcListShiftJoinType(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) pSubquery = _sqlite3SelectNew(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_NestedFrom), uintptr(0)) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendFromTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), uintptr(0), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, pSubquery, yymsp+8) } } goto _350 _133: ; /* dbnm ::= */ _132: ; *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) *(*uint32)(unsafe.Pointer(yymsp + 1*24 + 8 + 8)) = uint32(0) goto _350 _135: ; /* fullname ::= nm */ _134: ; *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+8, uintptr(0)) if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { _sqlite3RenameTokenMap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzName, yymsp+8) } *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _137: ; /* fullname ::= nm DOT nm */ _136: ; *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8) if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { _sqlite3RenameTokenMap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzName, yymsp+8) } *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _138: ; /* xfullname ::= nm AS nm */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, uintptr(0)) if *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { _sqlite3RenameTokenMap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzName, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8) } else { (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzAlias = _sqlite3NameFromToken(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, yymsp+8) } } *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _139: ; /* xfullname ::= nm DOT nm AS nm */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8) if *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { _sqlite3RenameTokenMap(tls, pParse, (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzName, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8) } else { (*(*TSrcItem)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 8))).FzAlias = _sqlite3NameFromToken(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, yymsp+8) } } *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _140: ; /* joinop ::= COMMA|JOIN */ *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(JT_INNER) goto _350 _141: ; /* joinop ::= JOIN_KW JOIN */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3JoinType(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0), uintptr(0)) /*X-overwrites-A*/ goto _350 _142: ; /* joinop ::= JOIN_KW nm JOIN */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3JoinType(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, uintptr(0)) /*X-overwrites-A*/ goto _350 _143: ; /* joinop ::= JOIN_KW nm nm JOIN */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3JoinType(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) /*X-overwrites-A*/ goto _350 _144: ; /* on_using ::= ON expr */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) = uintptr(0) goto _350 _145: ; /* on_using ::= USING LP idlist RP */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = uintptr(0) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) goto _350 _146: ; /* on_using ::= */ *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8 + 8)) = uintptr(0) goto _350 _147: ; /* indexed_by ::= INDEXED BY nm */ *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*TToken)(unsafe.Pointer(yymsp + 8)) goto _350 _148: ; /* indexed_by ::= NOT INDEXED */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uintptr(0) *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) = uint32(1) goto _350 _150: ; /* orderby_opt ::= ORDER BY sortlist */ _149: ; *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) goto _350 _151: ; /* sortlist ::= sortlist COMMA expr sortorder nulls */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) _sqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) goto _350 _152: ; /* sortlist ::= expr sortorder nulls */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) /*A-overwrites-Y*/ _sqlite3ExprListSetSortOrder(tls, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) goto _350 _153: ; /* sortorder ::= ASC */ *(*int32)(unsafe.Pointer(yymsp + 8)) = SQLITE_SO_ASC goto _350 _154: ; /* sortorder ::= DESC */ *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(SQLITE_SO_DESC) goto _350 _156: ; /* sortorder ::= */ _155: ; *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = -int32(1) goto _350 _157: ; /* nulls ::= NULLS FIRST */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = SQLITE_SO_ASC goto _350 _158: ; /* nulls ::= NULLS LAST */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(SQLITE_SO_DESC) goto _350 _160: ; /* having_opt ::= */ _159: ; _161: ; _162: ; _163: ; _164: ; _165: ; *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) goto _350 _167: ; /* having_opt ::= HAVING expr */ _166: ; _168: ; _169: ; _170: ; *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) goto _350 _171: ; /* limit_opt ::= LIMIT expr */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_LIMIT), *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0)) goto _350 _172: ; /* limit_opt ::= LIMIT expr OFFSET expr */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_LIMIT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _173: ; /* limit_opt ::= LIMIT expr COMMA expr */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_LIMIT), *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) goto _350 _174: ; /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ _sqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) _sqlite3DeleteFrom(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0), uintptr(0)) goto _350 _175: ; /* where_opt_ret ::= RETURNING selcollist */ _sqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uintptr(0) goto _350 _176: ; /* where_opt_ret ::= WHERE expr RETURNING selcollist */ _sqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) goto _350 _177: ; /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ _sqlite3SrcListIndexedBy(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8) _sqlite3ExprListCheckLength(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), __ccgo_ts+25050) if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 { pFromClause = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) if (*TSrcList)(unsafe.Pointer(pFromClause)).FnSrc > int32(1) { pSubquery1 = _sqlite3SelectNew(tls, pParse, uintptr(0), pFromClause, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(SF_NestedFrom), uintptr(0)) (**(**TToken)(__ccgo_up(bp + 72))).Fn = uint32(0) (**(**TToken)(__ccgo_up(bp + 72))).Fz = uintptr(0) pFromClause = _sqlite3SrcListAppendFromTerm(tls, pParse, uintptr(0), uintptr(0), uintptr(0), bp+72, pSubquery1, uintptr(0)) } *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3SrcListAppendList(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), pFromClause) } _sqlite3Update(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), uintptr(0), uintptr(0), uintptr(0)) goto _350 _178: ; /* setlist ::= setlist COMMA nm EQ expr */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) _sqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, int32(1)) goto _350 _179: ; /* setlist ::= setlist COMMA LP idlist RP EQ expr */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)) = _sqlite3ExprListAppendVector(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _180: ; /* setlist ::= nm EQ expr */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) _sqlite3ExprListSetName(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, int32(1)) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _181: ; /* setlist ::= LP idlist RP EQ expr */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppendVector(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _182: ; /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ _sqlite3Insert(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _183: ; /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ _sqlite3Insert(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), uintptr(0)) goto _350 _184: ; /* upsert ::= */ *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) goto _350 _185: ; /* upsert ::= RETURNING selcollist */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uintptr(0) _sqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _186: ; /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(11))*24 + 8)) = _sqlite3UpsertNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _187: ; /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)) = _sqlite3UpsertNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _188: ; /* upsert ::= ON CONFLICT DO NOTHING returning */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3UpsertNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0)) goto _350 _189: ; /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) = _sqlite3UpsertNew(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) goto _350 _190: ; /* returning ::= RETURNING selcollist */ _sqlite3AddReturning(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _191: ; /* idlist_opt ::= */ *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) goto _350 _192: ; /* idlist_opt ::= LP idlist RP */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) goto _350 _193: ; /* idlist ::= idlist COMMA nm */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3IdListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+8) goto _350 _194: ; /* idlist ::= nm */ *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _sqlite3IdListAppend(tls, pParse, uintptr(0), yymsp+8) /*A-overwrites-Y*/ goto _350 _195: ; /* expr ::= LP expr RP */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) goto _350 _196: ; /* expr ::= ID|INDEXED|JOIN_KW */ *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-X*/ goto _350 _197: ; /* expr ::= nm DOT nm */ temp1 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) temp2 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + 8))) *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3PExpr(tls, pParse, int32(TK_DOT), temp1, temp2) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _198: ; /* expr ::= nm DOT nm DOT nm */ temp11 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) temp21 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) temp3 = _tokenExpr(tls, pParse, int32(TK_ID), *(*TToken)(unsafe.Pointer(yymsp + 8))) temp4 = _sqlite3PExpr(tls, pParse, int32(TK_DOT), temp21, temp3) if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) { _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), temp11) } *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3PExpr(tls, pParse, int32(TK_DOT), temp11, temp4) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _200: ; /* term ::= NULL|FLOAT|BLOB */ _199: ; *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _tokenExpr(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor), *(*TToken)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-X*/ goto _350 _201: ; /* term ::= INTEGER */ if _sqlite3GetInt32(tls, *(*uintptr)(unsafe.Pointer(yymsp + 8)), bp+88) == 0 { *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_INTEGER), yymsp+8, 0) } else { *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprInt32(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, **(**int32)(__ccgo_up(bp + 88))) } if *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { *(*int32)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) + 52)) = int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8))) - int64((*TParse)(unsafe.Pointer(pParse)).FzTail)) } *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _202: ; /* expr ::= VARIABLE */ if !(libc.Int32FromUint8(**(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + 8))))) == int32('#') && libc.Int32FromUint8(_sqlite3CtypeMap[uint8(**(**uint8)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + 8)) + 1)))])&int32(0x04) != 0) { n = *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _tokenExpr(tls, pParse, int32(TK_VARIABLE), *(*TToken)(unsafe.Pointer(yymsp + 8))) _sqlite3ExprAssignVarNumber(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), n) } else { /* When doing a nested parse, one can include terms in an expression ** that look like this: #1 #2 ... These terms refer to registers ** in the virtual machine. #N is the N-th register. */ **(**TToken)(__ccgo_up(bp + 96)) = *(*TToken)(unsafe.Pointer(yymsp + 8)) /*A-overwrites-X*/ if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).Fnested) == 0 { _parserSyntaxError(tls, pParse, bp+96) *(*uintptr)(unsafe.Pointer(yymsp + 8)) = uintptr(0) } else { *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_REGISTER), uintptr(0), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + 8)) != 0 { _sqlite3GetInt32(tls, (**(**TToken)(__ccgo_up(bp + 96))).Fz+1, *(*uintptr)(unsafe.Pointer(yymsp + 8))+44) } } } goto _350 _203: ; /* expr ::= expr COLLATE ID|STRING */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprAddCollateToken(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+8, int32(1)) goto _350 _204: ; /* expr ::= CAST LP expr AS typetoken RP */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3ExprAlloc(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_CAST), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, int32(1)) _sqlite3ExprAttachSubtrees(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), uintptr(0)) goto _350 _205: ; /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _206: ; /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(7))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8))) _sqlite3ExprAddFunctionOrderBy(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _207: ; /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, 0) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _208: ; /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(5))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) _sqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _209: ; /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(8))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8))) _sqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) _sqlite3ExprAddFunctionOrderBy(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _210: ; /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, 0) _sqlite3WindowAttach(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))), *(*uintptr)(unsafe.Pointer(yymsp + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _211: ; /* term ::= CTIME_KW */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, uintptr(0), yymsp+8, 0) *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _212: ; /* expr ::= LP nexprlist COMMA expr RP */ pList = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_VECTOR), uintptr(0), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) != 0 { *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 32)) = pList i = 0 for { if !(i < (*TExprList)(unsafe.Pointer(pList)).FnExpr) { break } **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 4)) |= (*TExpr)(unsafe.Pointer((*(*TExprList_item)(unsafe.Pointer(pList + 8 + uintptr(i)*32))).FpExpr)).Fflags & libc.Uint32FromInt32(libc.Int32FromInt32(EP_Collate)|libc.Int32FromInt32(EP_Subquery)|libc.Int32FromInt32(EP_HasFunc)) goto _351 _351: ; i = i + 1 } } else { _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pList) } goto _350 _213: ; /* expr ::= expr AND expr */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprAnd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _215: ; /* expr ::= expr OR expr */ _214: ; _216: ; _217: ; _218: ; _219: ; _220: ; *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExpr(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _221: ; /* likeop ::= NOT LIKE_KW|MATCH */ *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TToken)(unsafe.Pointer(yymsp + 8)) *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) |= uint32(0x80000000) /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/ goto _350 _222: ; /* expr ::= expr likeop expr */ bNot = libc.Int32FromUint32(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) & uint32(0x80000000)) *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) &= uint32(0x7fffffff) pList1 = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) pList1 = _sqlite3ExprListAppend(tls, pParse, pList1, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprFunction(tls, pParse, pList1, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, 0) if bNot != 0 { *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), uintptr(0)) } if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) != 0 { **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) + 4)) |= uint32(EP_InfixFunc) } goto _350 _223: ; /* expr ::= expr likeop expr ESCAPE expr */ bNot1 = libc.Int32FromUint32(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)) & uint32(0x80000000)) *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)) &= uint32(0x7fffffff) pList2 = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) pList2 = _sqlite3ExprListAppend(tls, pParse, pList2, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) pList2 = _sqlite3ExprListAppend(tls, pParse, pList2, *(*uintptr)(unsafe.Pointer(yymsp + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprFunction(tls, pParse, pList2, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, 0) if bNot1 != 0 { *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) } if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) != 0 { **(**Tu32)(__ccgo_up(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 4)) |= uint32(EP_InfixFunc) } goto _350 _224: ; /* expr ::= expr ISNULL|NOTNULL */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3PExprIsNull(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) goto _350 _225: ; /* expr ::= expr NOT NULL */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExprIsNull(tls, pParse, int32(TK_NOTNULL), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) goto _350 _226: ; /* expr ::= expr IS expr */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExprIs(tls, pParse, int32(TK_IS), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _227: ; /* expr ::= expr IS NOT expr */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3PExprIs(tls, pParse, int32(TK_ISNOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _228: ; /* expr ::= expr IS NOT DISTINCT FROM expr */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3PExprIs(tls, pParse, int32(TK_IS), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _229: ; /* expr ::= expr IS DISTINCT FROM expr */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExprIs(tls, pParse, int32(TK_ISNOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _231: ; /* expr ::= NOT expr */ _230: ; *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3PExpr(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor), *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0)) /*A-overwrites-B*/ goto _350 _232: ; /* expr ::= PLUS|MINUS expr */ p4 = *(*uintptr)(unsafe.Pointer(yymsp + 8)) op = libc.Uint8FromInt32(libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor) + (libc.Int32FromInt32(TK_UPLUS) - libc.Int32FromInt32(TK_PLUS))) if p4 != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(p4)).Fop) == int32(TK_UPLUS) { (*TExpr)(unsafe.Pointer(p4)).Fop = op *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = p4 } else { *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3PExpr(tls, pParse, libc.Int32FromUint8(op), p4, uintptr(0)) /*A-overwrites-B*/ } goto _350 _233: ; /* expr ::= expr PTR expr */ pList3 = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) pList3 = _sqlite3ExprListAppend(tls, pParse, pList3, *(*uintptr)(unsafe.Pointer(yymsp + 8))) *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3ExprFunction(tls, pParse, pList3, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, 0) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _235: ; /* between_op ::= BETWEEN */ _234: ; *(*int32)(unsafe.Pointer(yymsp + 8)) = 0 goto _350 _236: ; /* expr ::= expr between_op expr AND expr */ pList4 = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) pList4 = _sqlite3ExprListAppend(tls, pParse, pList4, *(*uintptr)(unsafe.Pointer(yymsp + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_BETWEEN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) != 0 { *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 32)) = pList4 _sqlite3ExprSetHeightAndFlags(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) } else { _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pList4) } if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) } goto _350 _237: ; /* expr ::= expr in_op LP exprlist RP */ if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) == uintptr(0) { if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { v352 = __ccgo_ts + 8206 } else { v352 = __ccgo_ts + 8211 } /* Expressions of the form ** ** expr1 IN () ** expr1 NOT IN () ** ** simplify to constants 0 (false) and 1 (true), respectively. ** ** Except, do not apply this optimization if expr1 contains a function ** because that function might be an aggregate (we don't know yet whether ** it is or not) and if it is an aggregate, that could change the meaning ** of the whole query. */ pB = _sqlite3Expr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, int32(TK_STRING), v352) if pB != 0 { _sqlite3ExprIdToTrueFalse(tls, pB) } if !((*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)))).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_HasFunc)) != libc.Uint32FromInt32(0)) { _sqlite3ExprUnmapAndDelete(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = pB } else { if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { v353 = int32(TK_OR) } else { v353 = int32(TK_AND) } *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, v353, pB, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) } } else { pRHS = (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + 8))).FpExpr if (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FnExpr == int32(1) && _sqlite3ExprIsConstant(tls, pParse, pRHS) != 0 && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)))).Fop) != int32(TK_VECTOR) { (*(*TExprList_item)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) + 8))).FpExpr = uintptr(0) _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) pRHS = _sqlite3PExpr(tls, pParse, int32(TK_UPLUS), pRHS, uintptr(0)) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_EQ), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), pRHS) } else { if (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FnExpr == int32(1) && libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pRHS)).Fop) == int32(TK_SELECT) { *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_IN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(pRHS + 32))) *(*uintptr)(unsafe.Pointer(pRHS + 32)) = uintptr(0) _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) } else { *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_IN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) == uintptr(0) { _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) } else { if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)))).FpLeft)).Fop) == int32(TK_VECTOR) { nExpr = (*TExprList)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)))).FpLeft + 32)))).FnExpr pSelectRHS = _sqlite3ExprListToValues(tls, pParse, nExpr, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) if pSelectRHS != 0 { _parserDoubleLinkSelect(tls, pParse, pSelectRHS) _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), pSelectRHS) } } else { *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 32)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) _sqlite3ExprSetHeightAndFlags(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) } } } } if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) } } goto _350 _238: ; /* expr ::= LP select RP */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_SELECT), uintptr(0), uintptr(0)) _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) goto _350 _239: ; /* expr ::= expr in_op LP select RP */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_IN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) } goto _350 _240: ; /* expr ::= expr in_op nm dbnm paren_exprlist */ pSrc = _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) pSelect = _sqlite3SelectNew(tls, pParse, uintptr(0), pSrc, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + 8)) != 0 { if pSelect != 0 { v352 = pSrc } else { v352 = uintptr(0) } _sqlite3SrcListFuncArgs(tls, pParse, v352, *(*uintptr)(unsafe.Pointer(yymsp + 8))) } *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_IN), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) _sqlite3PExprAddSelect(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), pSelect) if *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_NOT), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uintptr(0)) } goto _350 _241: ; /* expr ::= EXISTS LP select RP */ v352 = _sqlite3PExpr(tls, pParse, int32(TK_EXISTS), uintptr(0), uintptr(0)) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = v352 p5 = v352 _sqlite3PExprAddSelect(tls, pParse, p5, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) goto _350 _242: ; /* expr ::= CASE case_operand case_exprlist case_else END */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_CASE), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) != 0 { if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 { v352 = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) } else { v352 = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) } *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) + 32)) = v352 _sqlite3ExprSetHeightAndFlags(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) } else { _sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) } goto _350 _243: ; /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _244: ; /* case_exprlist ::= WHEN expr THEN expr */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _245: ; /* nexprlist ::= nexprlist COMMA expr */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3ExprListAppend(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _246: ; /* nexprlist ::= expr */ *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _sqlite3ExprListAppend(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-Y*/ goto _350 _248: ; /* paren_exprlist ::= LP exprlist RP */ _247: ; *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) goto _350 _249: ; /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ _sqlite3CreateIndex(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(7))*24+8, yymsp+uintptr(-libc.Int32FromInt32(6))*24+8, _sqlite3SrcListAppend(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, uintptr(0)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(10))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(11))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + 8)), SQLITE_SO_ASC, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)), uint8(SQLITE_IDXTYPE_APPDEF)) if libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) >= int32(PARSE_MODE_RENAME) && (*TParse)(unsafe.Pointer(pParse)).FpNewIndex != 0 { _sqlite3RenameTokenMap(tls, pParse, (*TIndex)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).FpNewIndex)).FzName, yymsp+uintptr(-libc.Int32FromInt32(4))*24+8) } goto _350 _251: ; /* uniqueflag ::= UNIQUE */ _250: ; *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Abort) goto _350 _252: ; /* uniqueflag ::= */ *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = OE_None goto _350 _253: ; /* eidlist ::= eidlist COMMA nm collate sortorder */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _parserAddExprIdListTerm(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) goto _350 _254: ; /* eidlist ::= nm collate sortorder */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _parserAddExprIdListTerm(tls, pParse, uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-Y*/ goto _350 _255: ; /* cmd ::= DROP INDEX ifexists fullname */ _sqlite3DropIndex(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) goto _350 _256: ; /* cmd ::= VACUUM vinto */ _sqlite3Vacuum(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _257: ; /* cmd ::= VACUUM nm vinto */ _sqlite3Vacuum(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _258: ; /* cmd ::= PRAGMA nm dbnm */ _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, yymsp+8, uintptr(0), 0) goto _350 _259: ; /* cmd ::= PRAGMA nm dbnm EQ nmnum */ _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8, 0) goto _350 _260: ; /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, 0) goto _350 _261: ; /* cmd ::= PRAGMA nm dbnm EQ minus_num */ _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8, int32(1)) goto _350 _262: ; /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ _sqlite3Pragma(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, int32(1)) goto _350 _263: ; /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ (**(**TToken)(__ccgo_up(bp + 112))).Fz = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) (**(**TToken)(__ccgo_up(bp + 112))).Fn = libc.Uint32FromInt32(int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + 8)))-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))))) + *(*uint32)(unsafe.Pointer(yymsp + 8 + 8)) _sqlite3FinishTrigger(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), bp+112) goto _350 _264: ; /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ _sqlite3BeginTrigger(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(7))*24+8, yymsp+uintptr(-libc.Int32FromInt32(6))*24+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(10))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8))) if *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8 + 8)) == uint32(0) { v357 = *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) } else { v357 = *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)) } *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(10))*24 + 8)) = v357 /*A-overwrites-T*/ goto _350 _265: ; /* trigger_time ::= BEFORE|AFTER */ *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-X*/ goto _350 _266: ; /* trigger_time ::= INSTEAD OF */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = int32(TK_INSTEAD) goto _350 _267: ; /* trigger_time ::= */ *(*int32)(unsafe.Pointer(yymsp + 1*24 + 8)) = int32(TK_BEFORE) goto _350 _269: ; /* trigger_event ::= DELETE|INSERT */ _268: ; *(*int32)(unsafe.Pointer(yymsp + 8)) = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-X*/ *(*uintptr)(unsafe.Pointer(yymsp + 8 + 8)) = uintptr(0) goto _350 _270: ; /* trigger_event ::= UPDATE OF idlist */ *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = int32(TK_UPDATE) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) goto _350 _272: ; /* when_clause ::= */ _271: ; *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = uintptr(0) goto _350 _274: ; /* when_clause ::= WHEN expr */ _273: ; *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) goto _350 _275: ; /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ (*TTriggerStep)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)))).FpLast)).FpNext = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) (*TTriggerStep)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)))).FpLast = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) goto _350 _276: ; /* trigger_cmd_list ::= trigger_cmd SEMI */ (*TTriggerStep)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FpLast = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) goto _350 _277: ; /* tridxby ::= INDEXED BY nm */ _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25059, 0) goto _350 _278: ; /* tridxby ::= NOT INDEXED */ _sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25143, 0) goto _350 _279: ; /* trigger_cmd ::= UPDATE orconf xfullname tridxby SET setlist from where_opt scanpt */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3TriggerUpdateStep(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _280: ; /* trigger_cmd ::= scanpt insert_cmd INTO xfullname idlist_opt select upsert scanpt */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3TriggerInsertStep(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8))), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) /*yylhsminor.yy427-overwrites-yymsp[-6].minor.yy144*/ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _281: ; /* trigger_cmd ::= DELETE FROM xfullname tridxby where_opt scanpt */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3TriggerDeleteStep(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _282: ; /* trigger_cmd ::= scanpt select scanpt */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3TriggerSelectStep(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) /*yylhsminor.yy427-overwrites-yymsp[-1].minor.yy555*/ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _283: ; /* expr ::= RAISE LP IGNORE RP */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_RAISE), uintptr(0), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) != 0 { (*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)))).FaffExpr = uint8(OE_Ignore) } goto _350 _284: ; /* expr ::= RAISE LP raisetype COMMA expr RP */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3PExpr(tls, pParse, int32(TK_RAISE), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) != 0 { (*TExpr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)))).FaffExpr = libc.Uint8FromInt32(*(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) } goto _350 _285: ; /* raisetype ::= ROLLBACK */ *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Rollback) goto _350 _286: ; /* raisetype ::= FAIL */ *(*int32)(unsafe.Pointer(yymsp + 8)) = int32(OE_Fail) goto _350 _287: ; /* cmd ::= DROP TRIGGER ifexists fullname */ _sqlite3DropTrigger(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) goto _350 _288: ; /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ _sqlite3Attach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _289: ; /* cmd ::= DETACH database_kw_opt expr */ _sqlite3Detach(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _290: ; /* cmd ::= REINDEX */ _sqlite3Reindex(tls, pParse, uintptr(0), uintptr(0)) goto _350 _291: ; /* cmd ::= REINDEX nm dbnm */ _sqlite3Reindex(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, yymsp+8) goto _350 _292: ; /* cmd ::= ANALYZE */ _sqlite3Analyze(tls, pParse, uintptr(0), uintptr(0)) goto _350 _293: ; /* cmd ::= ANALYZE nm dbnm */ _sqlite3Analyze(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8, yymsp+8) goto _350 _294: ; /* cmd ::= ALTER TABLE fullname RENAME TO nm */ _sqlite3AlterRenameTable(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), yymsp+8) goto _350 _295: ; /* cmd ::= alter_add carglist */ *(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)) = libc.Uint32FromInt32(int32(int64((*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fz)-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))))) + (*TParse)(unsafe.Pointer(pParse)).FsLastToken.Fn _sqlite3AlterFinishAddColumn(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) goto _350 _296: ; /* alter_add ::= ALTER TABLE fullname ADD kwcolumn_opt nm typetoken */ _disableLookaside(tls, pParse) _sqlite3AlterBeginAddColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) _sqlite3AddColumn(tls, pParse, *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*TToken)(unsafe.Pointer(yymsp + 8))) *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)) = *(*TToken)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) goto _350 _297: ; /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ _sqlite3AlterDropColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), yymsp+8) goto _350 _298: ; /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ _sqlite3AlterRenameColumn(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8) goto _350 _299: ; /* cmd ::= ALTER TABLE fullname DROP CONSTRAINT nm */ _sqlite3AlterDropConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), yymsp+8, uintptr(0)) goto _350 _300: ; /* cmd ::= ALTER TABLE fullname ALTER kwcolumn_opt nm DROP NOT NULL */ _sqlite3AlterDropConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(3))*24+8) goto _350 _301: ; /* cmd ::= ALTER TABLE fullname ALTER kwcolumn_opt nm SET NOT NULL onconf */ _sqlite3AlterSetNotNull(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(7))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8) goto _350 _302: ; /* cmd ::= ALTER TABLE fullname ADD CONSTRAINT nm CHECK LP expr RP onconf */ _sqlite3AlterAddConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(8))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(6))*24+8, yymsp+uintptr(-libc.Int32FromInt32(5))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))+uintptr(1), int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)))-libc.Int64FromInt32(1)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) goto _350 _303: ; /* cmd ::= ALTER TABLE fullname ADD CHECK LP expr RP onconf */ _sqlite3AlterAddConstraint(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(6))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))+uintptr(1), int32(int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))-int64(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)))-libc.Int64FromInt32(1)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) goto _350 _304: ; /* cmd ::= create_vtab */ _sqlite3VtabFinishParse(tls, pParse, uintptr(0)) goto _350 _305: ; /* cmd ::= create_vtab LP vtabarglist RP */ _sqlite3VtabFinishParse(tls, pParse, yymsp+8) goto _350 _306: ; /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ _sqlite3VtabBeginParse(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(3))*24+8, yymsp+uintptr(-libc.Int32FromInt32(2))*24+8, yymsp+8, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8))) goto _350 _307: ; /* vtabarg ::= */ _sqlite3VtabArgInit(tls, pParse) goto _350 _309: ; /* vtabargtoken ::= ANY */ _308: ; _310: ; _sqlite3VtabArgExtend(tls, pParse, yymsp+8) goto _350 _312: ; /* with ::= WITH wqlist */ _311: ; _sqlite3WithPush(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uint8(1)) goto _350 _313: ; /* wqas ::= AS */ *(*Tu8)(unsafe.Pointer(yymsp + 8)) = uint8(M10d_Any) goto _350 _314: ; /* wqas ::= AS MATERIALIZED */ *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uint8(M10d_Yes) goto _350 _315: ; /* wqas ::= AS NOT MATERIALIZED */ *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = uint8(M10d_No) goto _350 _316: ; /* wqitem ::= withnm eidlist_opt wqas LP select RP */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = _sqlite3CteNew(tls, pParse, yymsp+uintptr(-libc.Int32FromInt32(5))*24+8, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8))) /*A-overwrites-X*/ goto _350 _317: ; /* withnm ::= nm */ libc.SetBitFieldPtr16Uint32(pParse+40, libc.Uint32FromInt32(1), 6, 0x40) goto _350 _318: ; /* wqlist ::= wqitem */ *(*uintptr)(unsafe.Pointer(yymsp + 8)) = _sqlite3WithAdd(tls, pParse, uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + 8))) /*A-overwrites-X*/ goto _350 _319: ; /* wqlist ::= wqlist COMMA wqitem */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = _sqlite3WithAdd(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + 8))) goto _350 _320: ; /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ _sqlite3WindowChain(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8))) (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + 8)))).FpNextWin = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _321: ; /* windowdefn ::= nm AS LP window RP */ if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 { (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FzName = _sqlite3DbStrNDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)), uint64(*(*uint32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8 + 8)))) } *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _322: ; /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) goto _350 _323: ; /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(5))*24+8) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _324: ; /* window ::= ORDER BY sortlist frame_opt */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), uintptr(0)) goto _350 _325: ; /* window ::= nm ORDER BY sortlist frame_opt */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), yymsp+uintptr(-libc.Int32FromInt32(4))*24+8) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _326: ; /* window ::= nm frame_opt */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAssemble(tls, pParse, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uintptr(0), uintptr(0), yymsp+uintptr(-libc.Int32FromInt32(1))*24+8) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _327: ; /* frame_opt ::= */ *(*uintptr)(unsafe.Pointer(yymsp + 1*24 + 8)) = _sqlite3WindowAlloc(tls, pParse, 0, int32(TK_UNBOUNDED), uintptr(0), int32(TK_CURRENT), uintptr(0), uint8(0)) goto _350 _328: ; /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)), int32(TK_CURRENT), uintptr(0), *(*Tu8)(unsafe.Pointer(yymsp + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(2))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _329: ; /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3WindowAlloc(tls, pParse, *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8 + 8)), *(*int32)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)), *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8 + 8)), *(*Tu8)(unsafe.Pointer(yymsp + 8))) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(5))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _331: ; /* frame_bound_s ::= frame_bound */ _330: ; *(*TFrameBound)(unsafe.Pointer(bp)) = *(*TFrameBound)(unsafe.Pointer(yymsp + 8)) *(*TFrameBound)(unsafe.Pointer(yymsp + 8)) = *(*TFrameBound)(unsafe.Pointer(bp)) goto _350 _333: ; /* frame_bound_s ::= UNBOUNDED PRECEDING */ _332: ; _334: ; (*(*TFrameBound)(unsafe.Pointer(bp))).FeType = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor) (*(*TFrameBound)(unsafe.Pointer(bp))).FpExpr = uintptr(0) *(*TFrameBound)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TFrameBound)(unsafe.Pointer(bp)) goto _350 _335: ; /* frame_bound ::= expr PRECEDING|FOLLOWING */ (*(*TFrameBound)(unsafe.Pointer(bp))).FeType = libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) (*(*TFrameBound)(unsafe.Pointer(bp))).FpExpr = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) *(*TFrameBound)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*TFrameBound)(unsafe.Pointer(bp)) goto _350 _336: ; /* frame_exclude_opt ::= */ *(*Tu8)(unsafe.Pointer(yymsp + 1*24 + 8)) = uint8(0) goto _350 _337: ; /* frame_exclude_opt ::= EXCLUDE frame_exclude */ *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*Tu8)(unsafe.Pointer(yymsp + 8)) goto _350 _339: ; /* frame_exclude ::= NO OTHERS */ _338: ; *(*Tu8)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = uint8((**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(-libc.Int32FromInt32(1))*24))).Fmajor) /*A-overwrites-X*/ goto _350 _340: ; /* frame_exclude ::= GROUP|TIES */ *(*Tu8)(unsafe.Pointer(yymsp + 8)) = uint8((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor) /*A-overwrites-X*/ goto _350 _341: ; /* window_clause ::= WINDOW windowdefn_list */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) goto _350 _342: ; /* filter_over ::= filter_clause over_clause */ if *(*uintptr)(unsafe.Pointer(yymsp + 8)) != 0 { (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + 8)))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) } else { _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8))) } *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _343: ; /* filter_over ::= over_clause */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = *(*uintptr)(unsafe.Pointer(yymsp + 8)) *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _344: ; /* filter_over ::= filter_clause */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(144)) if *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) != 0 { (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))))).FeFrmType = uint8(TK_FILTER) (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))))).FpFilter = *(*uintptr)(unsafe.Pointer(yymsp + 8)) } else { _sqlite3ExprDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8))) } *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _345: ; /* over_clause ::= OVER LP window RP */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(3))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) goto _350 _346: ; /* over_clause ::= OVER nm */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) = _sqlite3DbMallocZero(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(144)) if *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) != 0 { (*TWindow)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)))).FzName = _sqlite3DbStrNDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(yymsp + 8)), uint64(*(*uint32)(unsafe.Pointer(yymsp + 8 + 8)))) } goto _350 _347: ; /* filter_clause ::= FILTER LP WHERE expr RP */ *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(4))*24 + 8)) = *(*uintptr)(unsafe.Pointer(yymsp + uintptr(-libc.Int32FromInt32(1))*24 + 8)) goto _350 _348: ; /* term ::= QNUMBER */ *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) = _tokenExpr(tls, pParse, libc.Int32FromUint16((**(**TyyStackEntry)(__ccgo_up(yymsp))).Fmajor), *(*TToken)(unsafe.Pointer(yymsp + 8))) _sqlite3DequoteNumber(tls, pParse, *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp))))) *(*uintptr)(unsafe.Pointer(yymsp + 8)) = *(*uintptr)(unsafe.Pointer(&**(**TYYMINORTYPE)(__ccgo_up(bp)))) goto _350 _349: ; goto _350 /********** End reduce actions ************************************************/ _350: ; yygoto = libc.Int32FromUint16(_yyRuleInfoLhs[yyruleno]) yysize = int32(_yyRuleInfoNRhs[yyruleno]) yyact = _yy_find_reduce_action(tls, (**(**TyyStackEntry)(__ccgo_up(yymsp + uintptr(yysize)*24))).Fstateno, libc.Uint16FromInt32(yygoto)) /* There are no SHIFTREDUCE actions on nonterminals because the table ** generator has simplified them to pure REDUCE actions. */ /* It is not possible for a REDUCE to be followed by an error */ yymsp = yymsp + uintptr(yysize+int32(1))*24 (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos = yymsp (*TyyStackEntry)(unsafe.Pointer(yymsp)).Fstateno = yyact (*TyyStackEntry)(unsafe.Pointer(yymsp)).Fmajor = libc.Uint16FromInt32(yygoto) return yyact } /* ** The following code executes when the parse fails */