// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT.

//go:build (freebsd && 386) || (freebsd && amd64)

package sqlite3

import (
	"unsafe"

	"modernc.org/libc"
)

type T___wchar_t = int32

type Tcrypt_data = struct {
	Finitialized int32
	F__buf       [256]int8
}

// 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+25255, 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+21884, int32(7)) == 0 {
						token = uint8(tkTRIGGER)
					} else {
						if nId == int32(4) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25262, int32(4)) == 0 {
							token = uint8(tkTEMP)
						} else {
							if nId == int32(9) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25267, 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+25277, int32(3)) == 0 {
						token = uint8(tkEND)
					} else {
						if nId == int32(7) && Xsqlite3_strnicmp(tls, zSql, __ccgo_ts+25281, 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))
}

const __MINSIGSTKSZ = 2048

const __WCHAR_MAX = 2147483647

const __WCHAR_MIN = -2147483648

// 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 + 26475,
		FzRepl:  __ccgo_ts + 26479,
	},
	1: {
		Fc1:     int8('i'),
		Fc2:     int8('I'),
		Fn:      int8(8),
		FeType:  int8(JSONB_FLOAT),
		FnRepl:  int8(7),
		FzMatch: __ccgo_ts + 26487,
		FzRepl:  __ccgo_ts + 26479,
	},
	2: {
		Fc1:     int8('n'),
		Fc2:     int8('N'),
		Fn:      int8(3),
		FnRepl:  int8(4),
		FzMatch: __ccgo_ts + 1693,
		FzRepl:  __ccgo_ts + 1688,
	},
	3: {
		Fc1:     int8('q'),
		Fc2:     int8('Q'),
		Fn:      int8(4),
		FnRepl:  int8(4),
		FzMatch: __ccgo_ts + 26496,
		FzRepl:  __ccgo_ts + 1688,
	},
	4: {
		Fc1:     int8('s'),
		Fc2:     int8('S'),
		Fn:      int8(4),
		FnRepl:  int8(4),
		FzMatch: __ccgo_ts + 26501,
		FzRepl:  __ccgo_ts + 1688,
	},
}

// 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+39817, 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+5650, 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+39823, 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+17994) == 0 {
			return int32(1)
		} else {
			if _sqlite3StrICmp(tls, z, __ccgo_ts+19035) == 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+26460, -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+26460, -int32(1))
			}
		}
		_jsonParseReset(tls, pParse)
		return int32(1)
	}
	return 0
}

// 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+34328, 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 + 11543
	} else {
		v1 = __ccgo_ts + 1702
	}
	zErr = _sqlite3MPrintf(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, __ccgo_ts+11545, 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 + 1702
	}
	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+16596, 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+38608, 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+16561, libc.VaList(bp+8, Xsqlite3_value_double(tls, pValue)))
	case int32(SQLITE_INTEGER):
		Xsqlite3_str_appendf(tls, pStr, __ccgo_ts+1463, 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 + 16569
		} else {
			v2 = __ccgo_ts + 11927
		}
		Xsqlite3_str_appendf(tls, pStr, v2, libc.VaList(bp+8, zArg))
	default:
		Xsqlite3_str_append(tls, pStr, __ccgo_ts+1703, 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+4043, 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+25202, 0)
	}
	/************ End %syntax_error code ******************************************/
	/* Suppress warning about unused %extra_argument variable */
	(*TyyParser)(unsafe.Pointer(yypParser)).FpParse = pParse
}

type t__mbstate_t = struct {
	F_mbstateL  [0]t__int64_t
	F__mbstate8 [128]int8
}
