// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. //go:build (freebsd && amd64) || (freebsd && arm64) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (netbsd && amd64) || (openbsd && amd64) || (openbsd && arm64) || (windows && (amd64 || arm64)) package sqlite3 import ( "unsafe" "modernc.org/libc" ) // C documentation // // /* // ** Put the DateTime object into its error state. // */ func _datetimeError(tls *libc.TLS, p uintptr) { libc.Xmemset(tls, p, 0, uint64(48)) libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 1, 0x2) } // C documentation // // /* // ** Resolve all symbols in the trigger at pParse->pNewTrigger, assuming // ** it was read from the schema of database zDb. Return SQLITE_OK if // ** successful. Otherwise, return an SQLite error code and leave an error // ** message in the Parse object. // */ func _renameResolveTrigger(tls *libc.TLS, pParse uintptr) (r int32) { bp := tls.Alloc(64) defer tls.Free(64) var db, p, pNew, pSel, pSrc, pStep, pUpsert, pUpsertSet uintptr var i, rc, v2 int32 var _ /* sNC at bp+0 */ TNameContext _, _, _, _, _, _, _, _, _, _, _ = db, i, p, pNew, pSel, pSrc, pStep, pUpsert, pUpsertSet, rc, v2 db = (*TParse)(unsafe.Pointer(pParse)).Fdb pNew = (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger rc = SQLITE_OK libc.Xmemset(tls, bp, 0, uint64(56)) (**(**TNameContext)(__ccgo_up(bp))).FpParse = pParse (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab = _sqlite3FindTable(tls, db, (*TTrigger)(unsafe.Pointer(pNew)).Ftable, (**(**TDb)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FaDb + uintptr(_sqlite3SchemaToIndex(tls, db, (*TTrigger)(unsafe.Pointer(pNew)).FpTabSchema))*32))).FzDbSName) (*TParse)(unsafe.Pointer(pParse)).FeTriggerOp = (*TTrigger)(unsafe.Pointer(pNew)).Fop /* ALWAYS() because if the table of the trigger does not exist, the ** error would have been hit before this point */ if (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab != 0 { rc = libc.BoolInt32(_sqlite3ViewGetColumnNames(tls, pParse, (*TParse)(unsafe.Pointer(pParse)).FpTriggerTab) != 0) } /* Resolve symbols in WHEN clause */ if rc == SQLITE_OK && (*TTrigger)(unsafe.Pointer(pNew)).FpWhen != 0 { rc = _sqlite3ResolveExprNames(tls, bp, (*TTrigger)(unsafe.Pointer(pNew)).FpWhen) } pStep = (*TTrigger)(unsafe.Pointer(pNew)).Fstep_list for { if !(rc == SQLITE_OK && pStep != 0) { break } if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSelect != 0 { _sqlite3SelectPrep(tls, pParse, (*TTriggerStep)(unsafe.Pointer(pStep)).FpSelect, bp) if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { rc = (*TParse)(unsafe.Pointer(pParse)).Frc } } if rc == SQLITE_OK && (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != 0 { pSrc = _sqlite3SrcListDup(tls, db, (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc, 0) if pSrc != 0 { pSel = _sqlite3SelectNew(tls, pParse, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList, pSrc, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uint32(0), uintptr(0)) if pSel == uintptr(0) { (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList = uintptr(0) pSrc = uintptr(0) rc = int32(SQLITE_NOMEM) } else { /* pStep->pExprList contains an expression-list used for an UPDATE ** statement. So the a[].zEName values are the RHS of the ** " = " clauses of the UPDATE statement. So, before ** running SelectPrep(), change all the eEName values in ** pStep->pExprList to ENAME_SPAN (from their current value of ** ENAME_NAME). This is to prevent any ids in ON() clauses that are ** part of pSrc from being incorrectly resolved against the ** a[].zEName values as if they were column aliases. */ _renameSetENames(tls, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList, int32(ENAME_SPAN)) _sqlite3SelectPrep(tls, pParse, pSel, uintptr(0)) _renameSetENames(tls, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList, ENAME_NAME) if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 { v2 = int32(SQLITE_ERROR) } else { v2 = SQLITE_OK } rc = v2 if (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList != 0 { (*TSelect)(unsafe.Pointer(pSel)).FpEList = uintptr(0) } (*TSelect)(unsafe.Pointer(pSel)).FpSrc = uintptr(0) _sqlite3SelectDelete(tls, db, pSel) } if (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc != 0 { i = 0 for { if !(i < (*TSrcList)(unsafe.Pointer((*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc)).FnSrc && rc == SQLITE_OK) { break } p = (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc + 8 + uintptr(i)*80 if int32(*(*uint32)(unsafe.Pointer(p + 24 + 4))&0x4>>2) != 0 { _sqlite3SelectPrep(tls, pParse, (*TSubquery)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(p + 72)))).FpSelect, uintptr(0)) } goto _3 _3: ; i = i + 1 } } if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 { rc = int32(SQLITE_NOMEM) } (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = pSrc if rc == SQLITE_OK && (*TTriggerStep)(unsafe.Pointer(pStep)).FpWhere != 0 { rc = _sqlite3ResolveExprNames(tls, bp, (*TTriggerStep)(unsafe.Pointer(pStep)).FpWhere) } if rc == SQLITE_OK { rc = _sqlite3ResolveExprListNames(tls, bp, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList) } if (*TTriggerStep)(unsafe.Pointer(pStep)).FpUpsert != 0 && rc == SQLITE_OK { pUpsert = (*TTriggerStep)(unsafe.Pointer(pStep)).FpUpsert (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertSrc = pSrc *(*uintptr)(unsafe.Pointer(bp + 16)) = pUpsert (**(**TNameContext)(__ccgo_up(bp))).FncFlags = int32(NC_UUpsert) rc = _sqlite3ResolveExprListNames(tls, bp, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget) if rc == SQLITE_OK { pUpsertSet = (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertSet rc = _sqlite3ResolveExprListNames(tls, bp, pUpsertSet) } if rc == SQLITE_OK { rc = _sqlite3ResolveExprNames(tls, bp, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertWhere) } if rc == SQLITE_OK { rc = _sqlite3ResolveExprNames(tls, bp, (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTargetWhere) } (**(**TNameContext)(__ccgo_up(bp))).FncFlags = 0 } (**(**TNameContext)(__ccgo_up(bp))).FpSrcList = uintptr(0) _sqlite3SrcListDelete(tls, db, pSrc) } else { rc = int32(SQLITE_NOMEM) } } goto _1 _1: ; pStep = (*TTriggerStep)(unsafe.Pointer(pStep)).FpNext } return rc } // C documentation // // /* // ** Check the leaf RTree cell given by pCellData against constraint p. // ** If this constraint is not satisfied, set *peWithin to NOT_WITHIN. // ** If the constraint is satisfied, leave *peWithin unchanged. // ** // ** The constraint is of the form: xN op $val // ** // ** The op is given by p->op. The xN is p->iCoord-th coordinate in // ** pCellData. $val is given by p->u.rValue. // */ func _rtreeLeafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uintptr, peWithin uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var xN TRtreeDValue var v1 Tsqlite3_rtree_dbl var _ /* c at bp+0 */ TRtreeCoord _, _ = xN, v1 /* Coordinate value converted to a double */ pCellData = pCellData + uintptr(int32(8)+(*TRtreeConstraint)(unsafe.Pointer(p)).FiCoord*int32(4)) /* Coordinate decoded */ libc.Xmemcpy(tls, bp, pCellData, uint64(4)) *(*Tu32)(unsafe.Pointer(bp)) = *(*Tu32)(unsafe.Pointer(bp))>>libc.Int32FromInt32(24)&uint32(0xff) | *(*Tu32)(unsafe.Pointer(bp))>>libc.Int32FromInt32(8)&uint32(0xff00) | *(*Tu32)(unsafe.Pointer(bp))&uint32(0xff)<= *(*TRtreeDValue)(unsafe.Pointer(p + 8)) { return } case int32(RTREE_GT): if xN > *(*TRtreeDValue)(unsafe.Pointer(p + 8)) { return } default: if xN == *(*TRtreeDValue)(unsafe.Pointer(p + 8)) { return } break } **(**int32)(__ccgo_up(peWithin)) = NOT_WITHIN } // C documentation // // /* // ** Check the internal RTree node given by pCellData against constraint p. // ** If this constraint cannot be satisfied by any child within the node, // ** set *peWithin to NOT_WITHIN. // */ func _rtreeNonleafConstraint(tls *libc.TLS, p uintptr, eInt int32, pCellData uintptr, peWithin uintptr) { bp := tls.Alloc(16) defer tls.Free(16) var val, v1 Tsqlite3_rtree_dbl var _ /* c at bp+0 */ TRtreeCoord var _ /* c at bp+12 */ TRtreeCoord var _ /* c at bp+4 */ TRtreeCoord var _ /* c at bp+8 */ TRtreeCoord _, _ = val, v1 /* Coordinate value convert to a double */ /* p->iCoord might point to either a lower or upper bound coordinate ** in a coordinate pair. But make pCellData point to the lower bound. */ pCellData = pCellData + uintptr(int32(8)+int32(4)*((*TRtreeConstraint)(unsafe.Pointer(p)).FiCoord&int32(0xfe))) switch (*TRtreeConstraint)(unsafe.Pointer(p)).Fop { case int32(RTREE_TRUE): return /* Always satisfied */ case int32(RTREE_FALSE): case int32(RTREE_EQ): /* Coordinate decoded */ libc.Xmemcpy(tls, bp, pCellData, uint64(4)) *(*Tu32)(unsafe.Pointer(bp)) = *(*Tu32)(unsafe.Pointer(bp))>>libc.Int32FromInt32(24)&uint32(0xff) | *(*Tu32)(unsafe.Pointer(bp))>>libc.Int32FromInt32(8)&uint32(0xff00) | *(*Tu32)(unsafe.Pointer(bp))&uint32(0xff)<= val { pCellData = pCellData + uintptr(4) /* Coordinate decoded */ libc.Xmemcpy(tls, bp+4, pCellData, uint64(4)) *(*Tu32)(unsafe.Pointer(bp + 4)) = *(*Tu32)(unsafe.Pointer(bp + 4))>>libc.Int32FromInt32(24)&uint32(0xff) | *(*Tu32)(unsafe.Pointer(bp + 4))>>libc.Int32FromInt32(8)&uint32(0xff00) | *(*Tu32)(unsafe.Pointer(bp + 4))&uint32(0xff)<>libc.Int32FromInt32(24)&uint32(0xff) | *(*Tu32)(unsafe.Pointer(bp + 8))>>libc.Int32FromInt32(8)&uint32(0xff00) | *(*Tu32)(unsafe.Pointer(bp + 8))&uint32(0xff)<= val { return } default: pCellData = pCellData + uintptr(4) /* Coordinate decoded */ libc.Xmemcpy(tls, bp+12, pCellData, uint64(4)) *(*Tu32)(unsafe.Pointer(bp + 12)) = *(*Tu32)(unsafe.Pointer(bp + 12))>>libc.Int32FromInt32(24)&uint32(0xff) | *(*Tu32)(unsafe.Pointer(bp + 12))>>libc.Int32FromInt32(8)&uint32(0xff00) | *(*Tu32)(unsafe.Pointer(bp + 12))&uint32(0xff)<>0)) == ENAME_NAME { _sqlite3RenameTokenRemap(tls, pParse, uintptr(0), (*(*TExprList_item)(unsafe.Pointer(pEList + 8 + uintptr(i)*32))).FzEName) } goto _1 _1: ; i = i + 1 } } } // C documentation // // /* // ** Attach a Subquery object to pItem->uv.pSubq. Set the // ** pSelect value but leave all the other values initialized // ** to zero. // ** // ** A copy of the Select object is made if dupSelect is true, and the // ** SrcItem takes responsibility for deleting the copy. If dupSelect is // ** false, ownership of the Select passes to the SrcItem. Either way, // ** the SrcItem will take responsibility for deleting the Select. // ** // ** When dupSelect is zero, that means the Select might get deleted right // ** away if there is an OOM error. Beware. // ** // ** Return non-zero on success. Return zero on an OOM error. // */ func _sqlite3SrcItemAttachSubquery(tls *libc.TLS, pParse uintptr, pItem uintptr, pSelect uintptr, dupSelect int32) (r int32) { var p, v1 uintptr _, _ = p, v1 if int32(*(*uint32)(unsafe.Pointer(pItem + 24 + 4))&0x10000>>16) != 0 { *(*uintptr)(unsafe.Pointer(pItem + 72)) = uintptr(0) libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(0), 16, 0x10000) } else { if *(*uintptr)(unsafe.Pointer(pItem + 72)) != uintptr(0) { _sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, *(*uintptr)(unsafe.Pointer(pItem + 72))) *(*uintptr)(unsafe.Pointer(pItem + 72)) = uintptr(0) } } if dupSelect != 0 { pSelect = _sqlite3SelectDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSelect, 0) if pSelect == uintptr(0) { return 0 } } v1 = _sqlite3DbMallocRawNN(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, uint64(24)) *(*uintptr)(unsafe.Pointer(pItem + 72)) = v1 p = v1 if p == uintptr(0) { _sqlite3SelectDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pSelect) return 0 } libc.SetBitFieldPtr32Uint32(pItem+24+4, libc.Uint32FromInt32(1), 2, 0x4) (*TSubquery)(unsafe.Pointer(p)).FpSelect = pSelect libc.Xmemset(tls, p+uintptr(8), 0, libc.Uint64FromInt64(24)-libc.Uint64FromInt64(8)) return int32(1) }