6c92f85d10
Bring the Nexus/Praxis/Hexis integration in line with MAVEN_ECOSYSTEM_ARCHITECTURE.md: - Praxis over HTTP: drop the in-process praxis.db open (praxisstore/ praxistools) and call praxisd's /api/v1/tools/* API via a new praxisClient. Honors the "no component reads another's DB" invariant (AC#12). PraxisConfig.DBPath -> URL. - Hexis confirmation gate: mutating capabilities (ReadOnly=false) now park a bound pendingHexis confirmation and require a spoken "да" before executing; read-only run immediately (AC#7, no auto attention->action). - Capability safety: >1 verb match is ambiguous -> ask instead of firing the first; ambiguous Nexus resolution asks for clarification (AC#2). - Correlation IDs on Hexis execute, recorded in the cross-service trace. - Bug: importance arrives as JSON float64 over HTTP, not int. - Tests: confirm-gate, decline, read-only, and ambiguity paths. Build: vendor/ bakes in the hexis client (replace-directed at a sibling repo outside the Docker context); Dockerfile builds from vendor and no longer `go mod download`s the unreachable replace paths. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2492 lines
99 KiB
Go
2492 lines
99 KiB
Go
// 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
|
|
//
|
|
// /*
|
|
// ** 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 <id> */
|
|
zRight = uintptr(0) /* Nul-terminated UTF-8 string <value>, 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+19218, 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+3944, 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+19222) == 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 + 19013
|
|
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 + 19003
|
|
}
|
|
_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+19227, 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+3944, 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+19252, 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+19305) == 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(<table>)
|
|
**
|
|
** 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 + 19311
|
|
} else {
|
|
v1 = __ccgo_ts + 19319
|
|
}
|
|
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+19326, 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 + 11119
|
|
} else {
|
|
if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab2)).FeTabType) == int32(TABTYP_VTAB) {
|
|
zType = __ccgo_ts + 14304
|
|
} else {
|
|
if (*TTable)(unsafe.Pointer(pTab2)).FtabFlags&uint32(TF_Shadow) != 0 {
|
|
zType = __ccgo_ts + 19342
|
|
} else {
|
|
zType = __ccgo_ts + 9381
|
|
}
|
|
}
|
|
}
|
|
_sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19349, 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+19356, libc.VaList(bp+176, i1, int32(cnum), v1))
|
|
if (*TPragmaName)(unsafe.Pointer(pPragma)).FiArg != 0 {
|
|
_sqlite3VdbeMultiLoad(tls, v, int32(4), __ccgo_ts+19361, 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 + 19366,
|
|
1: __ccgo_ts + 19368,
|
|
2: __ccgo_ts + 17855,
|
|
}
|
|
_sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19370, 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+19376, 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+19380, 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+7913, 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+7913, 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+19383, 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+19392))
|
|
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+19397, 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 <db>.integrity_check",
|
|
** then iDb is set to the index of the database identified by <db>.
|
|
** 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+19401, 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+19425)
|
|
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+19454, 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+19490, 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+19510, 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+19532, 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+19555, -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+19557, 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+19577, 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+19607, 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+19666)
|
|
_sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3))
|
|
_sqlite3VdbeLoadString(tls, v, int32(4), __ccgo_ts+19671)
|
|
_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+19692)
|
|
_sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3))
|
|
_sqlite3VdbeLoadString(tls, v, int32(4), __ccgo_ts+19728)
|
|
_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+19666)
|
|
_sqlite3VdbeAddOp3(tls, v, int32(OP_Concat), int32(7), int32(3), int32(3))
|
|
_sqlite3VdbeLoadString(tls, v, int32(4), __ccgo_ts+19739)
|
|
_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+19766)
|
|
_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 + 19793
|
|
(**(**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+19854, libc.VaList(bp+176, zRight))
|
|
}
|
|
}
|
|
}
|
|
break
|
|
/*
|
|
** PRAGMA [schema.]schema_version
|
|
** PRAGMA [schema.]schema_version = <integer>
|
|
**
|
|
** PRAGMA [schema.]user_version
|
|
** PRAGMA [schema.]user_version = <integer>
|
|
**
|
|
** PRAGMA [schema.]freelist_count
|
|
**
|
|
** PRAGMA [schema.]data_version
|
|
**
|
|
** PRAGMA [schema.]application_id
|
|
** PRAGMA [schema.]application_id = <integer>
|
|
**
|
|
** 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+19020) == 0 {
|
|
eMode2 = int32(SQLITE_CHECKPOINT_FULL)
|
|
} else {
|
|
if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19879) == 0 {
|
|
eMode2 = int32(SQLITE_CHECKPOINT_RESTART)
|
|
} else {
|
|
if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19173) == 0 {
|
|
eMode2 = int32(SQLITE_CHECKPOINT_TRUNCATE)
|
|
} else {
|
|
if _sqlite3StrICmp(tls, zRight, __ccgo_ts+19887) == 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+6760, 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+19892, 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)
|
|
}
|