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>
888 lines
28 KiB
Go
888 lines
28 KiB
Go
// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT.
|
|
|
|
//go:build (linux && 386) || (linux && amd64)
|
|
|
|
package sqlite3
|
|
|
|
import (
|
|
"unsafe"
|
|
|
|
"modernc.org/libc"
|
|
)
|
|
|
|
const MAP_32BIT = 64
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Return TRUE if the given SQL string ends in a semicolon.
|
|
// **
|
|
// ** Special handling is require for CREATE TRIGGER statements.
|
|
// ** Whenever the CREATE TRIGGER keywords are seen, the statement
|
|
// ** must end with ";END;".
|
|
// **
|
|
// ** This implementation uses a state machine with 8 states:
|
|
// **
|
|
// ** (0) INVALID We have not yet seen a non-whitespace character.
|
|
// **
|
|
// ** (1) START At the beginning or end of an SQL statement. This routine
|
|
// ** returns 1 if it ends in the START state and 0 if it ends
|
|
// ** in any other state.
|
|
// **
|
|
// ** (2) NORMAL We are in the middle of statement which ends with a single
|
|
// ** semicolon.
|
|
// **
|
|
// ** (3) EXPLAIN The keyword EXPLAIN has been seen at the beginning of
|
|
// ** a statement.
|
|
// **
|
|
// ** (4) CREATE The keyword CREATE has been seen at the beginning of a
|
|
// ** statement, possibly preceded by EXPLAIN and/or followed by
|
|
// ** TEMP or TEMPORARY
|
|
// **
|
|
// ** (5) TRIGGER We are in the middle of a trigger definition that must be
|
|
// ** ended by a semicolon, the keyword END, and another semicolon.
|
|
// **
|
|
// ** (6) SEMI We've seen the first semicolon in the ";END;" that occurs at
|
|
// ** the end of a trigger definition.
|
|
// **
|
|
// ** (7) END We've seen the ";END" of the ";END;" that occurs at the end
|
|
// ** of a trigger definition.
|
|
// **
|
|
// ** Transitions between states above are determined by tokens extracted
|
|
// ** from the input. The following tokens are significant:
|
|
// **
|
|
// ** (0) tkSEMI A semicolon.
|
|
// ** (1) tkWS Whitespace.
|
|
// ** (2) tkOTHER Any other SQL token.
|
|
// ** (3) tkEXPLAIN The "explain" keyword.
|
|
// ** (4) tkCREATE The "create" keyword.
|
|
// ** (5) tkTEMP The "temp" or "temporary" keyword.
|
|
// ** (6) tkTRIGGER The "trigger" keyword.
|
|
// ** (7) tkEND The "end" keyword.
|
|
// **
|
|
// ** Whitespace never causes a state transition and is always ignored.
|
|
// ** This means that a SQL string of all whitespace is invalid.
|
|
// **
|
|
// ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed
|
|
// ** to recognize the end of a trigger can be omitted. All we have to do
|
|
// ** is look for a semicolon that is not part of an string or comment.
|
|
// */
|
|
func Xsqlite3_complete(tls *libc.TLS, zSql uintptr) (r int32) {
|
|
var c, nId int32
|
|
var state, token Tu8
|
|
_, _, _, _ = c, nId, state, token
|
|
state = uint8(0) /* Value of the next token */
|
|
for **(**int8)(__ccgo_up(zSql)) != 0 {
|
|
switch int32(**(**int8)(__ccgo_up(zSql))) {
|
|
case int32(';'): /* A semicolon */
|
|
token = uint8(tkSEMI)
|
|
case int32(' '):
|
|
fallthrough
|
|
case int32('\r'):
|
|
fallthrough
|
|
case int32('\t'):
|
|
fallthrough
|
|
case int32('\n'):
|
|
fallthrough
|
|
case int32('\f'): /* White space is ignored */
|
|
token = uint8(tkWS)
|
|
case int32('/'): /* C-style comments */
|
|
if int32(**(**int8)(__ccgo_up(zSql + 1))) != int32('*') {
|
|
token = uint8(tkOTHER)
|
|
break
|
|
}
|
|
zSql = zSql + uintptr(2)
|
|
for **(**int8)(__ccgo_up(zSql)) != 0 && (int32(**(**int8)(__ccgo_up(zSql))) != int32('*') || int32(**(**int8)(__ccgo_up(zSql + 1))) != int32('/')) {
|
|
zSql = zSql + 1
|
|
}
|
|
if int32(**(**int8)(__ccgo_up(zSql))) == 0 {
|
|
return 0
|
|
}
|
|
zSql = zSql + 1
|
|
token = uint8(tkWS)
|
|
case int32('-'): /* SQL-style comments from "--" to end of line */
|
|
if int32(**(**int8)(__ccgo_up(zSql + 1))) != int32('-') {
|
|
token = uint8(tkOTHER)
|
|
break
|
|
}
|
|
for **(**int8)(__ccgo_up(zSql)) != 0 && int32(**(**int8)(__ccgo_up(zSql))) != int32('\n') {
|
|
zSql = zSql + 1
|
|
}
|
|
if int32(**(**int8)(__ccgo_up(zSql))) == 0 {
|
|
return libc.BoolInt32(libc.Int32FromUint8(state) == int32(1))
|
|
}
|
|
token = uint8(tkWS)
|
|
case int32('['): /* Microsoft-style identifiers in [...] */
|
|
zSql = zSql + 1
|
|
for **(**int8)(__ccgo_up(zSql)) != 0 && int32(**(**int8)(__ccgo_up(zSql))) != int32(']') {
|
|
zSql = zSql + 1
|
|
}
|
|
if int32(**(**int8)(__ccgo_up(zSql))) == 0 {
|
|
return 0
|
|
}
|
|
token = uint8(tkOTHER)
|
|
case int32('`'): /* Grave-accent quoted symbols used by MySQL */
|
|
fallthrough
|
|
case int32('"'): /* single- and double-quoted strings */
|
|
fallthrough
|
|
case int32('\''):
|
|
c = int32(**(**int8)(__ccgo_up(zSql)))
|
|
zSql = zSql + 1
|
|
for **(**int8)(__ccgo_up(zSql)) != 0 && int32(**(**int8)(__ccgo_up(zSql))) != c {
|
|
zSql = zSql + 1
|
|
}
|
|
if int32(**(**int8)(__ccgo_up(zSql))) == 0 {
|
|
return 0
|
|
}
|
|
token = uint8(tkOTHER)
|
|
default:
|
|
if libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zSql)))])&int32(0x46) != 0 {
|
|
nId = int32(1)
|
|
for {
|
|
if !(libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zSql + uintptr(nId))))])&int32(0x46) != 0) {
|
|
break
|
|
}
|
|
goto _1
|
|
_1:
|
|
;
|
|
nId = nId + 1
|
|
}
|
|
switch int32(**(**int8)(__ccgo_up(zSql))) {
|
|
case int32('c'):
|
|
fallthrough
|
|
case int32('C'):
|
|
if nId == int32(6) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25257, int32(6)) == 0 {
|
|
token = uint8(tkCREATE)
|
|
} else {
|
|
token = uint8(tkOTHER)
|
|
}
|
|
case int32('t'):
|
|
fallthrough
|
|
case int32('T'):
|
|
if nId == int32(7) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+21886, int32(7)) == 0 {
|
|
token = uint8(tkTRIGGER)
|
|
} else {
|
|
if nId == int32(4) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25264, int32(4)) == 0 {
|
|
token = uint8(tkTEMP)
|
|
} else {
|
|
if nId == int32(9) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25269, int32(9)) == 0 {
|
|
token = uint8(tkTEMP)
|
|
} else {
|
|
token = uint8(tkOTHER)
|
|
}
|
|
}
|
|
}
|
|
case int32('e'):
|
|
fallthrough
|
|
case int32('E'):
|
|
if nId == int32(3) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25279, int32(3)) == 0 {
|
|
token = uint8(tkEND)
|
|
} else {
|
|
if nId == int32(7) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25283, int32(7)) == 0 {
|
|
token = uint8(tkEXPLAIN)
|
|
} else {
|
|
token = uint8(tkOTHER)
|
|
}
|
|
}
|
|
default:
|
|
token = uint8(tkOTHER)
|
|
break
|
|
}
|
|
zSql = zSql + uintptr(nId-int32(1))
|
|
} else {
|
|
/* Operators and special symbols */
|
|
token = uint8(tkOTHER)
|
|
}
|
|
break
|
|
}
|
|
state = **(**Tu8)(__ccgo_up(uintptr(unsafe.Pointer(&_trans)) + uintptr(state)*8 + uintptr(token)))
|
|
zSql = zSql + 1
|
|
}
|
|
return libc.BoolInt32(libc.Int32FromUint8(state) == int32(1))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Extra floating-point literals to allow in JSON.
|
|
// */
|
|
var _aNanInfName = [5]TNanInfName{
|
|
0: {
|
|
Fc1: int8('i'),
|
|
Fc2: int8('I'),
|
|
Fn: int8(3),
|
|
FeType: int8(JSONB_FLOAT),
|
|
FnRepl: int8(7),
|
|
FzMatch: __ccgo_ts + 26477,
|
|
FzRepl: __ccgo_ts + 26481,
|
|
},
|
|
1: {
|
|
Fc1: int8('i'),
|
|
Fc2: int8('I'),
|
|
Fn: int8(8),
|
|
FeType: int8(JSONB_FLOAT),
|
|
FnRepl: int8(7),
|
|
FzMatch: __ccgo_ts + 26489,
|
|
FzRepl: __ccgo_ts + 26481,
|
|
},
|
|
2: {
|
|
Fc1: int8('n'),
|
|
Fc2: int8('N'),
|
|
Fn: int8(3),
|
|
FnRepl: int8(4),
|
|
FzMatch: __ccgo_ts + 1695,
|
|
FzRepl: __ccgo_ts + 1690,
|
|
},
|
|
3: {
|
|
Fc1: int8('q'),
|
|
Fc2: int8('Q'),
|
|
Fn: int8(4),
|
|
FnRepl: int8(4),
|
|
FzMatch: __ccgo_ts + 26498,
|
|
FzRepl: __ccgo_ts + 1690,
|
|
},
|
|
4: {
|
|
Fc1: int8('s'),
|
|
Fc2: int8('S'),
|
|
Fn: int8(4),
|
|
FnRepl: int8(4),
|
|
FzMatch: __ccgo_ts + 26503,
|
|
FzRepl: __ccgo_ts + 1690,
|
|
},
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Compare the 19-character string zNum against the text representation
|
|
// ** value 2^63: 9223372036854775808. Return negative, zero, or positive
|
|
// ** if zNum is less than, equal to, or greater than the string.
|
|
// ** Note that zNum must contain exactly 19 characters.
|
|
// **
|
|
// ** Unlike memcmp() this routine is guaranteed to return the difference
|
|
// ** in the values of the last digit if the only difference is in the
|
|
// ** last digit. So, for example,
|
|
// **
|
|
// ** compare2pow63("9223372036854775800", 1)
|
|
// **
|
|
// ** will return -8.
|
|
// */
|
|
func _compare2pow63(tls *libc.TLS, zNum uintptr, incr int32) (r int32) {
|
|
var c, i int32
|
|
var pow63 uintptr
|
|
_, _, _ = c, i, pow63
|
|
c = 0
|
|
/* 012345678901234567 */
|
|
pow63 = __ccgo_ts + 1815
|
|
i = 0
|
|
for {
|
|
if !(c == 0 && i < int32(18)) {
|
|
break
|
|
}
|
|
c = (int32(**(**int8)(__ccgo_up(zNum + uintptr(i*incr)))) - int32(**(**int8)(__ccgo_up(pow63 + uintptr(i))))) * int32(10)
|
|
goto _1
|
|
_1:
|
|
;
|
|
i = i + 1
|
|
}
|
|
if c == 0 {
|
|
c = int32(**(**int8)(__ccgo_up(zNum + uintptr(int32(18)*incr)))) - int32('8')
|
|
}
|
|
return c
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Process a "special" query. A special query is identified as one with a
|
|
// ** MATCH expression that begins with a '*' character. The remainder of
|
|
// ** the text passed to the MATCH operator are used as the special query
|
|
// ** parameters.
|
|
// */
|
|
func _fts5SpecialMatch(tls *libc.TLS, pTab uintptr, pCsr uintptr, zQuery uintptr) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var n, rc int32
|
|
var z uintptr
|
|
_, _, _ = n, rc, z
|
|
rc = SQLITE_OK /* Return code */
|
|
z = zQuery /* Number of bytes in text at z */
|
|
for int32(**(**int8)(__ccgo_up(z))) == int32(' ') {
|
|
z = z + 1
|
|
}
|
|
n = 0
|
|
for {
|
|
if !(**(**int8)(__ccgo_up(z + uintptr(n))) != 0 && int32(**(**int8)(__ccgo_up(z + uintptr(n)))) != int32(' ')) {
|
|
break
|
|
}
|
|
goto _1
|
|
_1:
|
|
;
|
|
n = n + 1
|
|
}
|
|
(*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan = int32(FTS5_PLAN_SPECIAL)
|
|
if n == int32(5) && 0 == Xsqlite3_strnicmp(tls, __ccgo_ts+39819, z, n) {
|
|
(*TFts5Cursor)(unsafe.Pointer(pCsr)).FiSpecial = int64(_sqlite3Fts5IndexReads(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex))
|
|
} else {
|
|
if n == int32(2) && 0 == Xsqlite3_strnicmp(tls, __ccgo_ts+5652, z, n) {
|
|
(*TFts5Cursor)(unsafe.Pointer(pCsr)).FiSpecial = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiCsrId
|
|
} else {
|
|
/* An unrecognized directive. Return an error message. */
|
|
(*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.Fbase.FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+39825, libc.VaList(bp+8, n, z))
|
|
rc = int32(SQLITE_ERROR)
|
|
}
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Interpret the given string as a temp db location. Return 1 for file
|
|
// ** backed temporary databases, 2 for the Red-Black tree in memory database
|
|
// ** and 0 to use the compile-time default.
|
|
// */
|
|
func _getTempStore(tls *libc.TLS, z uintptr) (r int32) {
|
|
if int32(**(**int8)(__ccgo_up(z))) >= int32('0') && int32(**(**int8)(__ccgo_up(z))) <= int32('2') {
|
|
return int32(**(**int8)(__ccgo_up(z))) - int32('0')
|
|
} else {
|
|
if _sqlite3StrICmp(tls, z, __ccgo_ts+17996) == 0 {
|
|
return int32(1)
|
|
} else {
|
|
if _sqlite3StrICmp(tls, z, __ccgo_ts+19037) == 0 {
|
|
return int32(2)
|
|
} else {
|
|
return 0
|
|
}
|
|
}
|
|
}
|
|
return r
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Parse a complete JSON string. Return 0 on success or non-zero if there
|
|
// ** are any errors. If an error occurs, free all memory held by pParse,
|
|
// ** but not pParse itself.
|
|
// **
|
|
// ** pParse must be initialized to an empty parse object prior to calling
|
|
// ** this routine.
|
|
// */
|
|
func _jsonConvertTextToBlob(tls *libc.TLS, pParse uintptr, pCtx uintptr) (r int32) {
|
|
var i int32
|
|
var zJson uintptr
|
|
_, _ = i, zJson
|
|
zJson = (*TJsonParse)(unsafe.Pointer(pParse)).FzJson
|
|
i = _jsonTranslateTextToBlob(tls, pParse, uint32(0))
|
|
if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 {
|
|
i = -int32(1)
|
|
}
|
|
if i > 0 {
|
|
for _jsonIsSpace[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zJson + uintptr(i))))] != 0 {
|
|
i = i + 1
|
|
}
|
|
if **(**int8)(__ccgo_up(zJson + uintptr(i))) != 0 {
|
|
i = i + _json5Whitespace(tls, zJson+uintptr(i))
|
|
if **(**int8)(__ccgo_up(zJson + uintptr(i))) != 0 {
|
|
if pCtx != 0 {
|
|
Xsqlite3_result_error(tls, pCtx, __ccgo_ts+26462, -int32(1))
|
|
}
|
|
_jsonParseReset(tls, pParse)
|
|
return int32(1)
|
|
}
|
|
(*TJsonParse)(unsafe.Pointer(pParse)).FhasNonstd = uint8(1)
|
|
}
|
|
}
|
|
if i <= 0 {
|
|
if pCtx != uintptr(0) {
|
|
if (*TJsonParse)(unsafe.Pointer(pParse)).Foom != 0 {
|
|
Xsqlite3_result_error_nomem(tls, pCtx)
|
|
} else {
|
|
Xsqlite3_result_error(tls, pCtx, __ccgo_ts+26462, -int32(1))
|
|
}
|
|
}
|
|
_jsonParseReset(tls, pParse)
|
|
return int32(1)
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF.
|
|
// ** The HH, MM, and SS must each be exactly 2 digits. The
|
|
// ** fractional seconds FFFF can be one or more digits.
|
|
// **
|
|
// ** Return 1 if there is a parsing error and 0 on success.
|
|
// */
|
|
func _parseHhMmSs(tls *libc.TLS, zDate uintptr, p uintptr) (r int32) {
|
|
bp := tls.Alloc(48)
|
|
defer tls.Free(48)
|
|
var ms, rScale float64
|
|
var _ /* h at bp+0 */ int32
|
|
var _ /* m at bp+4 */ int32
|
|
var _ /* s at bp+8 */ int32
|
|
_, _ = ms, rScale
|
|
ms = float64(0)
|
|
if _getDigits(tls, zDate, __ccgo_ts+1204, libc.VaList(bp+24, bp, bp+4)) != int32(2) {
|
|
return int32(1)
|
|
}
|
|
zDate = zDate + uintptr(5)
|
|
if int32(**(**int8)(__ccgo_up(zDate))) == int32(':') {
|
|
zDate = zDate + 1
|
|
if _getDigits(tls, zDate, __ccgo_ts+1212, libc.VaList(bp+24, bp+8)) != int32(1) {
|
|
return int32(1)
|
|
}
|
|
zDate = zDate + uintptr(2)
|
|
if int32(**(**int8)(__ccgo_up(zDate))) == int32('.') && libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zDate + 1)))])&int32(0x04) != 0 {
|
|
rScale = float64(1)
|
|
zDate = zDate + 1
|
|
for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zDate)))])&int32(0x04) != 0 {
|
|
ms = float64(ms*float64(10)) + float64(**(**int8)(__ccgo_up(zDate))) - libc.Float64FromUint8('0')
|
|
rScale = rScale * float64(10)
|
|
zDate = zDate + 1
|
|
}
|
|
ms = ms / rScale
|
|
/* Truncate to avoid problems with sub-milliseconds
|
|
** rounding. https://sqlite.org/forum/forumpost/766a2c9231 */
|
|
if ms > float64(0.999) {
|
|
ms = float64(0.999)
|
|
}
|
|
}
|
|
} else {
|
|
**(**int32)(__ccgo_up(bp + 8)) = 0
|
|
}
|
|
(*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0
|
|
libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1)
|
|
(*TDateTime)(unsafe.Pointer(p)).FvalidHMS = int8(1)
|
|
(*TDateTime)(unsafe.Pointer(p)).Fh = **(**int32)(__ccgo_up(bp))
|
|
(*TDateTime)(unsafe.Pointer(p)).Fm = **(**int32)(__ccgo_up(bp + 4))
|
|
(*TDateTime)(unsafe.Pointer(p)).Fs = float64(**(**int32)(__ccgo_up(bp + 8))) + ms
|
|
if _parseTimezone(tls, zDate, p) != 0 {
|
|
return int32(1)
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Parse a timezone extension on the end of a date-time.
|
|
// ** The extension is of the form:
|
|
// **
|
|
// ** (+/-)HH:MM
|
|
// **
|
|
// ** Or the "zulu" notation:
|
|
// **
|
|
// ** Z
|
|
// **
|
|
// ** If the parse is successful, write the number of minutes
|
|
// ** of change in p->tz and return 0. If a parser error occurs,
|
|
// ** return non-zero.
|
|
// **
|
|
// ** A missing specifier is not considered an error.
|
|
// */
|
|
func _parseTimezone(tls *libc.TLS, zDate uintptr, p uintptr) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var c, sgn int32
|
|
var _ /* nHr at bp+0 */ int32
|
|
var _ /* nMn at bp+4 */ int32
|
|
_, _ = c, sgn
|
|
sgn = 0
|
|
for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zDate)))])&int32(0x01) != 0 {
|
|
zDate = zDate + 1
|
|
}
|
|
(*TDateTime)(unsafe.Pointer(p)).Ftz = 0
|
|
c = int32(**(**int8)(__ccgo_up(zDate)))
|
|
if c == int32('-') {
|
|
sgn = -int32(1)
|
|
} else {
|
|
if c == int32('+') {
|
|
sgn = +libc.Int32FromInt32(1)
|
|
} else {
|
|
if c == int32('Z') || c == int32('z') {
|
|
zDate = zDate + 1
|
|
libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10)
|
|
libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8)
|
|
goto zulu_time
|
|
} else {
|
|
return libc.BoolInt32(c != 0)
|
|
}
|
|
}
|
|
}
|
|
zDate = zDate + 1
|
|
if _getDigits(tls, zDate, __ccgo_ts+1196, libc.VaList(bp+16, bp, bp+4)) != int32(2) {
|
|
return int32(1)
|
|
}
|
|
zDate = zDate + uintptr(5)
|
|
(*TDateTime)(unsafe.Pointer(p)).Ftz = sgn * (**(**int32)(__ccgo_up(bp + 4)) + **(**int32)(__ccgo_up(bp))*int32(60))
|
|
if (*TDateTime)(unsafe.Pointer(p)).Ftz == 0 { /* Forum post 2025-09-17T10:12:14z */
|
|
libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10)
|
|
libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8)
|
|
}
|
|
goto zulu_time
|
|
zulu_time:
|
|
;
|
|
for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zDate)))])&int32(0x01) != 0 {
|
|
zDate = zDate + 1
|
|
}
|
|
return libc.BoolInt32(int32(**(**int8)(__ccgo_up(zDate))) != 0)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Parse dates of the form
|
|
// **
|
|
// ** YYYY-MM-DD HH:MM:SS.FFF
|
|
// ** YYYY-MM-DD HH:MM:SS
|
|
// ** YYYY-MM-DD HH:MM
|
|
// ** YYYY-MM-DD
|
|
// **
|
|
// ** Write the result into the DateTime structure and return 0
|
|
// ** on success and 1 if the input string is not a well-formed
|
|
// ** date.
|
|
// */
|
|
func _parseYyyyMmDd(tls *libc.TLS, zDate uintptr, p uintptr) (r int32) {
|
|
bp := tls.Alloc(48)
|
|
defer tls.Free(48)
|
|
var neg, v1 int32
|
|
var _ /* D at bp+8 */ int32
|
|
var _ /* M at bp+4 */ int32
|
|
var _ /* Y at bp+0 */ int32
|
|
_, _ = neg, v1
|
|
if int32(**(**int8)(__ccgo_up(zDate))) == int32('-') {
|
|
zDate = zDate + 1
|
|
neg = int32(1)
|
|
} else {
|
|
neg = 0
|
|
}
|
|
if _getDigits(tls, zDate, __ccgo_ts+1216, libc.VaList(bp+24, bp, bp+4, bp+8)) != int32(3) {
|
|
return int32(1)
|
|
}
|
|
zDate = zDate + uintptr(10)
|
|
for libc.Int32FromUint8(_sqlite3CtypeMap[libc.Uint8FromInt8(**(**int8)(__ccgo_up(zDate)))])&int32(0x01) != 0 || int32('T') == libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zDate))) {
|
|
zDate = zDate + 1
|
|
}
|
|
if _parseHhMmSs(tls, zDate, p) == 0 {
|
|
/* We got the time */
|
|
} else {
|
|
if int32(**(**int8)(__ccgo_up(zDate))) == 0 {
|
|
(*TDateTime)(unsafe.Pointer(p)).FvalidHMS = 0
|
|
} else {
|
|
return int32(1)
|
|
}
|
|
}
|
|
(*TDateTime)(unsafe.Pointer(p)).FvalidJD = 0
|
|
(*TDateTime)(unsafe.Pointer(p)).FvalidYMD = int8(1)
|
|
if neg != 0 {
|
|
v1 = -**(**int32)(__ccgo_up(bp))
|
|
} else {
|
|
v1 = **(**int32)(__ccgo_up(bp))
|
|
}
|
|
(*TDateTime)(unsafe.Pointer(p)).FY = v1
|
|
(*TDateTime)(unsafe.Pointer(p)).FM = **(**int32)(__ccgo_up(bp + 4))
|
|
(*TDateTime)(unsafe.Pointer(p)).FD = **(**int32)(__ccgo_up(bp + 8))
|
|
_computeFloor(tls, p)
|
|
if (*TDateTime)(unsafe.Pointer(p)).Ftz != 0 {
|
|
_computeJD(tls, p)
|
|
}
|
|
return 0
|
|
}
|
|
|
|
/* Forward declaration */
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Allocate a private rbu VFS for the rbu handle passed as the only
|
|
// ** argument. This VFS will be used unless the call to sqlite3rbu_open()
|
|
// ** specified a URI with a vfs=? option in place of a target database
|
|
// ** file name.
|
|
// */
|
|
func _rbuCreateVfs(tls *libc.TLS, p uintptr) {
|
|
bp := tls.Alloc(96)
|
|
defer tls.Free(96)
|
|
var pVfs uintptr
|
|
var _ /* rnd at bp+0 */ int32
|
|
var _ /* zRnd at bp+4 */ [64]int8
|
|
_ = pVfs
|
|
Xsqlite3_randomness(tls, int32(4), bp)
|
|
Xsqlite3_snprintf(tls, int32(64), bp+4, __ccgo_ts+34330, libc.VaList(bp+80, **(**int32)(__ccgo_up(bp))))
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3rbu_create_vfs(tls, bp+4, uintptr(0))
|
|
if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
|
|
pVfs = Xsqlite3_vfs_find(tls, bp+4)
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).FzVfsName = (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FzName
|
|
(*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRbu = p
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** An error occurred while parsing or otherwise processing a database
|
|
// ** object (either pParse->pNewTable, pNewIndex or pNewTrigger) as part of an
|
|
// ** ALTER TABLE RENAME COLUMN program. The error message emitted by the
|
|
// ** sub-routine is currently stored in pParse->zErrMsg. This function
|
|
// ** adds context to the error message and then stores it in pCtx.
|
|
// */
|
|
func _renameColumnParseError(tls *libc.TLS, pCtx uintptr, zWhen uintptr, pType uintptr, pObject uintptr, pParse uintptr) {
|
|
bp := tls.Alloc(48)
|
|
defer tls.Free(48)
|
|
var zErr, zN, zT, v1 uintptr
|
|
_, _, _, _ = zErr, zN, zT, v1
|
|
zT = Xsqlite3_value_text(tls, pType)
|
|
zN = Xsqlite3_value_text(tls, pObject)
|
|
if **(**int8)(__ccgo_up(zWhen)) != 0 {
|
|
v1 = __ccgo_ts + 11545
|
|
} else {
|
|
v1 = __ccgo_ts + 1704
|
|
}
|
|
zErr = _sqlite3MPrintf(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, __ccgo_ts+11547, libc.VaList(bp+8, zT, zN, v1, zWhen, (*TParse)(unsafe.Pointer(pParse)).FzErrMsg))
|
|
Xsqlite3_result_error(tls, pCtx, zErr, -int32(1))
|
|
_sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zErr)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /* IMP: R-25361-16150 This function is omitted from SQLite by default. It
|
|
// ** is only available if the SQLITE_SOUNDEX compile-time option is used
|
|
// ** when SQLite is built.
|
|
// */
|
|
// /*
|
|
// ** Compute the soundex encoding of a word.
|
|
// **
|
|
// ** IMP: R-59782-00072 The soundex(X) function returns a string that is the
|
|
// ** soundex encoding of the string X.
|
|
// */
|
|
func _soundexFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var code, i, j, v3 int32
|
|
var prevcode Tu8
|
|
var zIn uintptr
|
|
var _ /* zResult at bp+0 */ [8]int8
|
|
_, _, _, _, _, _ = code, i, j, prevcode, zIn, v3
|
|
zIn = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv)))
|
|
if zIn == uintptr(0) {
|
|
zIn = __ccgo_ts + 1704
|
|
}
|
|
i = 0
|
|
for {
|
|
if !(**(**Tu8)(__ccgo_up(zIn + uintptr(i))) != 0 && !(libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(zIn + uintptr(i)))])&libc.Int32FromInt32(0x02) != 0)) {
|
|
break
|
|
}
|
|
goto _1
|
|
_1:
|
|
;
|
|
i = i + 1
|
|
}
|
|
if **(**Tu8)(__ccgo_up(zIn + uintptr(i))) != 0 {
|
|
prevcode = _iCode[libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zIn + uintptr(i))))&int32(0x7f)]
|
|
(**(**[8]int8)(__ccgo_up(bp)))[0] = int8(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zIn + uintptr(i)))) & ^(libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(zIn + uintptr(i)))]) & libc.Int32FromInt32(0x20)))
|
|
j = int32(1)
|
|
for {
|
|
if !(j < int32(4) && **(**Tu8)(__ccgo_up(zIn + uintptr(i))) != 0) {
|
|
break
|
|
}
|
|
code = libc.Int32FromUint8(_iCode[libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zIn + uintptr(i))))&int32(0x7f)])
|
|
if code > 0 {
|
|
if code != libc.Int32FromUint8(prevcode) {
|
|
prevcode = libc.Uint8FromInt32(code)
|
|
v3 = j
|
|
j = j + 1
|
|
(**(**[8]int8)(__ccgo_up(bp)))[v3] = int8(code + int32('0'))
|
|
}
|
|
} else {
|
|
prevcode = uint8(0)
|
|
}
|
|
goto _2
|
|
_2:
|
|
;
|
|
i = i + 1
|
|
}
|
|
for j < int32(4) {
|
|
v3 = j
|
|
j = j + 1
|
|
(**(**[8]int8)(__ccgo_up(bp)))[v3] = int8('0')
|
|
}
|
|
(**(**[8]int8)(__ccgo_up(bp)))[j] = 0
|
|
Xsqlite3_result_text(tls, context, bp, int32(4), uintptr(-libc.Int32FromInt32(1)))
|
|
} else {
|
|
/* IMP: R-64894-50321 The string "?000" is returned if the argument
|
|
** is NULL or contains no ASCII alphabetic characters. */
|
|
Xsqlite3_result_text(tls, context, __ccgo_ts+16598, int32(4), libc.UintptrFromInt32(0))
|
|
}
|
|
}
|
|
|
|
func _sqlite3Fts5ParseSetDistance(tls *libc.TLS, pParse uintptr, pNear uintptr, p uintptr) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var c int8
|
|
var i, nNear int32
|
|
_, _, _ = c, i, nNear
|
|
if pNear != 0 {
|
|
nNear = 0
|
|
if (*TFts5Token)(unsafe.Pointer(p)).Fn != 0 {
|
|
i = 0
|
|
for {
|
|
if !(i < (*TFts5Token)(unsafe.Pointer(p)).Fn) {
|
|
break
|
|
}
|
|
c = **(**int8)(__ccgo_up((*TFts5Token)(unsafe.Pointer(p)).Fp + uintptr(i)))
|
|
if int32(c) < int32('0') || int32(c) > int32('9') {
|
|
_sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+38610, libc.VaList(bp+8, (*TFts5Token)(unsafe.Pointer(p)).Fn, (*TFts5Token)(unsafe.Pointer(p)).Fp))
|
|
return
|
|
}
|
|
if nNear < int32(214748363) {
|
|
nNear = nNear*int32(10) + (int32(**(**int8)(__ccgo_up((*TFts5Token)(unsafe.Pointer(p)).Fp + uintptr(i)))) - int32('0'))
|
|
}
|
|
/* ^^^^^^^^^^^^^^^--- Prevent integer overflow */
|
|
goto _1
|
|
_1:
|
|
;
|
|
i = i + 1
|
|
}
|
|
} else {
|
|
nNear = int32(FTS5_DEFAULT_NEARDIST)
|
|
}
|
|
(*TFts5ExprNearset)(unsafe.Pointer(pNear)).FnNear = nNear
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Append to pStr text that is the SQL literal representation of the
|
|
// ** value contained in pValue.
|
|
// */
|
|
func _sqlite3QuoteValue(tls *libc.TLS, pStr uintptr, pValue uintptr, bEscape int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var i int32
|
|
var nBlob Ti64
|
|
var zArg, zBlob, zText, v2 uintptr
|
|
_, _, _, _, _, _ = i, nBlob, zArg, zBlob, zText, v2
|
|
/* As currently implemented, the string must be initially empty.
|
|
** we might relax this requirement in the future, but that will
|
|
** require enhancements to the implementation. */
|
|
switch Xsqlite3_value_type(tls, pValue) {
|
|
case int32(SQLITE_FLOAT):
|
|
/* ,--- Show infinity as 9.0e+999
|
|
** |
|
|
** | ,--- 17 precision guarantees round-trip
|
|
** v v */
|
|
Xsqlite3_str_appendf(tls, pStr, __ccgo_ts+16563, libc.VaList(bp+8, Xsqlite3_value_double(tls, pValue)))
|
|
case int32(SQLITE_INTEGER):
|
|
Xsqlite3_str_appendf(tls, pStr, __ccgo_ts+1465, libc.VaList(bp+8, Xsqlite3_value_int64(tls, pValue)))
|
|
case int32(SQLITE_BLOB):
|
|
zBlob = Xsqlite3_value_blob(tls, pValue)
|
|
nBlob = int64(Xsqlite3_value_bytes(tls, pValue))
|
|
/* No encoding change */
|
|
_sqlite3StrAccumEnlarge(tls, pStr, nBlob*int64(2)+int64(4))
|
|
if libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(pStr)).FaccError) == 0 {
|
|
zText = (*TStrAccum)(unsafe.Pointer(pStr)).FzText
|
|
i = 0
|
|
for {
|
|
if !(int64(i) < nBlob) {
|
|
break
|
|
}
|
|
**(**int8)(__ccgo_up(zText + uintptr(i*int32(2)+int32(2)))) = _hexdigits[int32(**(**int8)(__ccgo_up(zBlob + uintptr(i))))>>int32(4)&int32(0x0F)]
|
|
**(**int8)(__ccgo_up(zText + uintptr(i*int32(2)+int32(3)))) = _hexdigits[int32(**(**int8)(__ccgo_up(zBlob + uintptr(i))))&int32(0x0F)]
|
|
goto _1
|
|
_1:
|
|
;
|
|
i = i + 1
|
|
}
|
|
**(**int8)(__ccgo_up(zText + uintptr(nBlob*int64(2)+int64(2)))) = int8('\'')
|
|
**(**int8)(__ccgo_up(zText + uintptr(nBlob*int64(2)+int64(3)))) = int8('\000')
|
|
**(**int8)(__ccgo_up(zText)) = int8('X')
|
|
**(**int8)(__ccgo_up(zText + 1)) = int8('\'')
|
|
(*TStrAccum)(unsafe.Pointer(pStr)).FnChar = libc.Uint32FromInt64(nBlob*int64(2) + int64(3))
|
|
}
|
|
case int32(SQLITE_TEXT):
|
|
zArg = Xsqlite3_value_text(tls, pValue)
|
|
if bEscape != 0 {
|
|
v2 = __ccgo_ts + 16571
|
|
} else {
|
|
v2 = __ccgo_ts + 11929
|
|
}
|
|
Xsqlite3_str_appendf(tls, pStr, v2, libc.VaList(bp+8, zArg))
|
|
default:
|
|
Xsqlite3_str_append(tls, pStr, __ccgo_ts+1705, int32(4))
|
|
break
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Create a temporary file name in zBuf. zBuf must be allocated
|
|
// ** by the calling process and must be big enough to hold at least
|
|
// ** pVfs->mxPathname bytes.
|
|
// */
|
|
func _unixGetTempname(tls *libc.TLS, nBuf int32, zBuf uintptr) (r int32) {
|
|
bp := tls.Alloc(48)
|
|
defer tls.Free(48)
|
|
var iLimit, rc, v1 int32
|
|
var zDir uintptr
|
|
var v2 bool
|
|
var _ /* r at bp+0 */ Tu64
|
|
_, _, _, _, _ = iLimit, rc, zDir, v1, v2
|
|
iLimit = 0
|
|
rc = SQLITE_OK
|
|
/* It's odd to simulate an io-error here, but really this is just
|
|
** using the io-error infrastructure to test that SQLite handles this
|
|
** function failing.
|
|
*/
|
|
**(**int8)(__ccgo_up(zBuf)) = 0
|
|
Xsqlite3_mutex_enter(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1)))
|
|
zDir = _unixTempFileDir(tls)
|
|
if zDir == uintptr(0) {
|
|
rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(25)<<libc.Int32FromInt32(8)
|
|
} else {
|
|
for cond := true; cond; cond = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(2)].FpCurrent})))(tls, zBuf, 0) == 0 {
|
|
Xsqlite3_randomness(tls, int32(8), bp)
|
|
**(**int8)(__ccgo_up(zBuf + uintptr(nBuf-int32(2)))) = 0
|
|
Xsqlite3_snprintf(tls, nBuf, zBuf, __ccgo_ts+4045, libc.VaList(bp+16, zDir, **(**Tu64)(__ccgo_up(bp)), 0))
|
|
if v2 = int32(**(**int8)(__ccgo_up(zBuf + uintptr(nBuf-int32(2))))) != 0; !v2 {
|
|
v1 = iLimit
|
|
iLimit = iLimit + 1
|
|
}
|
|
if v2 || v1 > int32(10) {
|
|
rc = int32(SQLITE_ERROR)
|
|
break
|
|
}
|
|
}
|
|
}
|
|
Xsqlite3_mutex_leave(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_VFS1)))
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** The following code executes when a syntax error first occurs.
|
|
// */
|
|
func _yy_syntax_error(tls *libc.TLS, yypParser uintptr, yymajor int32, _yyminor TToken) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
*(*TToken)(unsafe.Pointer(bp)) = _yyminor
|
|
var pParse uintptr
|
|
_ = pParse
|
|
pParse = (*TyyParser)(unsafe.Pointer(yypParser)).FpParse
|
|
/************ Begin %syntax_error code ****************************************/
|
|
_ = yymajor /* Silence some compiler warnings */
|
|
if **(**int8)(__ccgo_up((**(**TToken)(__ccgo_up(bp))).Fz)) != 0 {
|
|
_parserSyntaxError(tls, pParse, bp)
|
|
} else {
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25204, 0)
|
|
}
|
|
/************ End %syntax_error code ******************************************/
|
|
/* Suppress warning about unused %extra_argument variable */
|
|
(*TyyParser)(unsafe.Pointer(yypParser)).FpParse = pParse
|
|
}
|