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

package sqlite3

import (
	"reflect"
	"sync"
	"unsafe"

	"modernc.org/libc"
)

const ALLBITS = -1

type AggInfo = TAggInfo

type AggInfo_col = TAggInfo_col

type AggInfo_func = TAggInfo_func

type AsciiTokenizer = TAsciiTokenizer

type AuthContext = TAuthContext

type AutoincInfo = TAutoincInfo

type AuxData = TAuxData

const BITVEC_MXHASH = 0

const BITVEC_NBIT = 0

const BITVEC_NELEM = 0

const BITVEC_NINT = 0

const BITVEC_SZ = 512

const BITVEC_SZELEM = 8

const BITVEC_TELEM = 0

const BITVEC_USIZE = 0

const BTALLOC_ANY = 0

const BTALLOC_EXACT = 1

const BTALLOC_LE = 2

const BTCF_AtLast = 8

const BTCF_Incrblob = 16

const BTCF_Multiple = 32

const BTCF_Pinned = 64

const BTCF_ValidNKey = 2

const BTCF_ValidOvfl = 4

const BTCF_WriteFlag = 1

const BTCURSOR_FIRST_UNINIT = 0

const BTCURSOR_MAX_DEPTH = 20

const BTREE_APPEND = 8

const BTREE_APPLICATION_ID = 8

const BTREE_AUTOVACUUM_FULL = 1

const BTREE_AUTOVACUUM_INCR = 2

const BTREE_AUTOVACUUM_NONE = 0

const BTREE_AUXDELETE = 4

const BTREE_BLOBKEY = 2

const BTREE_BULKLOAD = 1

const BTREE_DATA_VERSION = 15

const BTREE_DEFAULT_CACHE_SIZE = 3

const BTREE_FDK_RANGE = 10

const BTREE_FILE_FORMAT = 2

const BTREE_FORDELETE = 8

const BTREE_FREE_PAGE_COUNT = 0

const BTREE_HINT_RANGE = 0

const BTREE_INCR_VACUUM = 7

const BTREE_INTKEY = 1

const BTREE_LARGEST_ROOT_PAGE = 4

const BTREE_MEMORY = 2

const BTREE_OMIT_JOURNAL = 1

const BTREE_PREFORMAT = 128

const BTREE_SAVEPOSITION = 2

const BTREE_SCHEMA_VERSION = 1

const BTREE_SEEK_EQ = 2

const BTREE_SINGLE = 4

const BTREE_TEXT_ENCODING = 5

const BTREE_ULPDISTORTION = 2

const BTREE_UNORDERED = 8

const BTREE_USER_VERSION = 6

const BTREE_WRCSR = 4

const BTS_EXCLUSIVE = 64

const BTS_FAST_SECURE = 12

const BTS_INITIALLY_EMPTY = 16

const BTS_NO_WAL = 32

const BTS_OVERWRITE = 8

const BTS_PAGESIZE_FIXED = 2

const BTS_PENDING = 128

const BTS_READ_ONLY = 1

const BTS_SECURE_DELETE = 4

const BT_MAX_LOCAL = 65501

type BenignMallocHooks = TBenignMallocHooks

type Bitmask = TBitmask

/*
** The number of bits in a Bitmask.  "BMS" means "BitMask Size".
 */

/*
** A bit in a Bitmask
 */

type Bitvec = TBitvec

type Bool = TBool

type BtCursor = TBtCursor

type BtLock = TBtLock

type BtShared = TBtShared

type Btree = TBtree

type BtreePayload = TBtreePayload

/************** End of btree.h ***********************************************/
/************** Continuing where we left off in sqliteInt.h ******************/
/************** Include vdbe.h in the middle of sqliteInt.h ******************/
/************** Begin file vdbe.h ********************************************/
/*
** 2001 September 15
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Header file for the Virtual DataBase Engine (VDBE)
**
** This header defines the interface to the virtual database engine
** or VDBE.  The VDBE implements an abstract machine that runs a
** simple program to access and modify the underlying database.
 */
/* #include <stdio.h> */

type BusyHandler = TBusyHandler

/*
** Name of table that holds the database schema.
**
** The PREFERRED names are used wherever possible.  But LEGACY is also
** used for backwards compatibility.
**
**  1.  Queries can use either the PREFERRED or the LEGACY names
**  2.  The sqlite3_set_authorizer() callback uses the LEGACY name
**  3.  The PRAGMA table_list statement uses the PREFERRED name
**
** The LEGACY names are stored in the internal symbol hash table
** in support of (2).  Names are translated using sqlite3PreferredTableName()
** for (3).  The sqlite3FindTable() function takes care of translating
** names for (1).
**
** Note that "sqlite_temp_schema" can also be called "temp.sqlite_schema".
 */

/*
** The root-page of the schema table.
 */

/*
** The name of the schema table.  The name is different for TEMP.
 */

/*
** A convenience macro that returns the number of elements in
** an array.
 */

/*
** Determine if the argument is a power of two
 */

/*
** The following value as a destructor means to use sqlite3DbFree().
** The sqlite3DbFree() routine requires two parameters instead of the
** one parameter that destructors normally want.  So we have to introduce
** this magic value that the code knows to handle differently.  Any
** pointer will work here as long as it is distinct from SQLITE_STATIC
** and SQLITE_TRANSIENT.
 */

/*
** When SQLITE_OMIT_WSD is defined, it means that the target platform does
** not support Writable Static Data (WSD) such as global and static variables.
** All variables must either be on the stack or dynamically allocated from
** the heap.  When WSD is unsupported, the variable declarations scattered
** throughout the SQLite code must become constants instead.  The SQLITE_WSD
** macro is used for this purpose.  And instead of referencing the variable
** directly, we use its constant as a key to lookup the run-time allocated
** buffer that holds real variable.  The constant is also the initializer
** for the run-time allocated buffer.
**
** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL
** macros become no-ops and have zero performance impact.
 */

/*
** The following macros are used to suppress compiler warnings and to
** make it clear to human readers when a function parameter is deliberately
** left unused within the body of a function. This usually happens when
** a function is called via a function pointer. For example the
** implementation of an SQL aggregate step callback may not use the
** parameter indicating the number of arguments passed to the aggregate,
** if it knows that this is enforced elsewhere.
**
** When a function parameter is not used at all within the body of a function,
** it is generally named "NotUsed" or "NotUsed2" to make things even clearer.
** However, these macros may also be used to suppress warnings related to
** parameters that may or may not be used depending on compilation options.
** For example those parameters only used in assert() statements. In these
** cases the parameters are named as per the usual conventions.
 */

const CACHE_STALE = 0

const CARRAY_BLOB = 4

const CARRAY_DOUBLE = 2

const CARRAY_INT32 = 0

const CARRAY_INT64 = 1

const CARRAY_TEXT = 3

const CC_AND = 24

const CC_BANG = 15

const CC_BOM = 30

const CC_COMMA = 23

const CC_DIGIT = 3

const CC_DOLLAR = 4

const CC_DOT = 26

const CC_EQ = 14

const CC_GT = 13

const CC_ID = 27

const CC_ILLEGAL = 28

const CC_KYWD = 2

const CC_KYWD0 = 1

const CC_LP = 17

const CC_LT = 12

const CC_MINUS = 11

const CC_NUL = 29

const CC_PERCENT = 22

const CC_PIPE = 10

const CC_PLUS = 20

const CC_QUOTE = 8

const CC_QUOTE2 = 9

const CC_RP = 18

const CC_SEMI = 19

const CC_SLASH = 16

const CC_SPACE = 7

const CC_STAR = 21

const CC_TILDA = 25

const CC_VARALPHA = 5

const CC_VARNUM = 6

const CC_X = 0

type CInstIter = TCInstIter

const CKCNSTRNT_COLUMN = 1

const CKCNSTRNT_ROWID = 2

const CLOCK_REALTIME = 0

const COLFLAG_BUSY = 256

const COLFLAG_GENERATED = 96

const COLFLAG_HASCOLL = 512

const COLFLAG_HASTYPE = 4

const COLFLAG_HIDDEN = 2

const COLFLAG_NOEXPAND = 1024

const COLFLAG_NOINSERT = 98

const COLFLAG_NOTAVAIL = 128

const COLFLAG_PRIMKEY = 1

const COLFLAG_SORTERREF = 16

const COLFLAG_STORED = 64

const COLFLAG_UNIQUE = 8

const COLFLAG_VIRTUAL = 32

const COLNAME_COLUMN = 4

const COLNAME_DATABASE = 2

const COLNAME_DECLTYPE = 1

const COLNAME_N = 5

const COLNAME_NAME = 0

const COLNAME_TABLE = 3

const COLTYPE_ANY = 1

const COLTYPE_BLOB = 2

const COLTYPE_CUSTOM = 0

const COLTYPE_INT = 3

const COLTYPE_INTEGER = 4

const COLTYPE_REAL = 5

const COLTYPE_TEXT = 6

const CURSOR_FAULT = 4

const CURSOR_INVALID = 1

const CURSOR_REQUIRESEEK = 3

const CURSOR_SKIPNEXT = 2

const CURSOR_VALID = 0

const CURTYPE_BTREE = 0

const CURTYPE_PSEUDO = 3

const CURTYPE_SORTER = 1

const CURTYPE_VTAB = 2

type CallCount = TCallCount

type CellArray = TCellArray

type CellInfo = TCellInfo

/*
** Legal values for BtCursor.curFlags
 */

/*
** Potential values for BtCursor.eState.
**
** CURSOR_INVALID:
**   Cursor does not point to a valid entry. This can happen (for example)
**   because the table is empty or because BtreeCursorFirst() has not been
**   called.
**
** CURSOR_VALID:
**   Cursor points to a valid entry. getPayload() etc. may be called.
**
** CURSOR_SKIPNEXT:
**   Cursor is valid except that the Cursor.skipNext field is non-zero
**   indicating that the next sqlite3BtreeNext() or sqlite3BtreePrevious()
**   operation should be a no-op.
**
** CURSOR_REQUIRESEEK:
**   The table that this cursor was opened on still exists, but has been
**   modified since the cursor was last used. The cursor position is saved
**   in variables BtCursor.pKey and BtCursor.nKey. When a cursor is in
**   this state, restoreCursorPosition() can be called to attempt to
**   seek the cursor to the saved position.
**
** CURSOR_FAULT:
**   An unrecoverable error (an I/O error or a malloc failure) has occurred
**   on a different connection that shares the BtShared cache with this
**   cursor.  The error has left the cache in an inconsistent state.
**   Do nothing else with this cursor.  Any attempt to use the cursor
**   should return the error code stored in BtCursor.skipNext
 */

/*
** The database page the PENDING_BYTE occupies. This page is never used.
 */

/*
** These macros define the location of the pointer-map entry for a
** database page. The first argument to each is the number of usable
** bytes on each page of the database (often 1024). The second is the
** page number to look up in the pointer map.
**
** PTRMAP_PAGENO returns the database page number of the pointer-map
** page that stores the required pointer. PTRMAP_PTROFFSET returns
** the offset of the requested map entry.
**
** If the pgno argument passed to PTRMAP_PAGENO is a pointer-map page,
** then pgno is returned. So (pgno==PTRMAP_PAGENO(pgsz, pgno)) can be
** used to test if pgno is a pointer-map page. PTRMAP_ISPAGE implements
** this test.
 */

/*
** The pointer map is a lookup table that identifies the parent page for
** each child page in the database file.  The parent page is the page that
** contains a pointer to the child.  Every page in the database contains
** 0 or 1 parent pages.  (In this context 'database page' refers
** to any page that is not part of the pointer map itself.)  Each pointer map
** entry consists of a single byte 'type' and a 4 byte parent page number.
** The PTRMAP_XXX identifiers below are the valid types.
**
** The purpose of the pointer map is to facility moving pages from one
** position in the file to another as part of autovacuum.  When a page
** is moved, the pointer in its parent must be updated to point to the
** new location.  The pointer map is used to locate the parent page quickly.
**
** PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not
**                  used in this case.
**
** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number
**                  is not used in this case.
**
** PTRMAP_OVERFLOW1: The database page is the first page in a list of
**                   overflow pages. The page number identifies the page that
**                   contains the cell with a pointer to this overflow page.
**
** PTRMAP_OVERFLOW2: The database page is the second or later page in a list of
**                   overflow pages. The page-number identifies the previous
**                   page in the overflow page list.
**
** PTRMAP_BTREE: The database page is a non-root btree page. The page number
**               identifies the parent page in the btree.
 */

/* A bunch of assert() statements to check the transaction state variables
** of handle p (type Btree*) are internally consistent.
 */

/*
** The ISAUTOVACUUM macro is used within balance_nonroot() to determine
** if the database supports auto-vacuum or not. Because it is used
** within an expression that is an argument to another macro
** (sqliteMallocRaw), it is not possible to use conditional compilation.
** So, this macro is defined instead.
 */

type ChangeData = TChangeData

type CheckOnCtx = TCheckOnCtx

/*
** True if the SrcList passed as the only argument contains at least
** one RIGHT or FULL JOIN. False otherwise.
 */

type CollSeq = TCollSeq

type Column = TColumn

type CountCtx = TCountCtx

type CoveringIndexCheck = TCoveringIndexCheck

type Cte = TCte

type CteUse = TCteUse

const DBFLAG_EncodingFixed = 64

const DBFLAG_InternalFunc = 32

const DBFLAG_PreferBuiltin = 2

const DBFLAG_SchemaChange = 1

const DBFLAG_SchemaKnownOk = 16

const DBFLAG_Vacuum = 4

const DBFLAG_VacuumInto = 8

const DBPAGE_COLUMN_DATA = 1

const DBPAGE_COLUMN_PGNO = 0

const DBPAGE_COLUMN_SCHEMA = 2

const DBSTAT_PAGE_PADDING_BYTES = 256

const DB_ResetWanted = 8

const DB_SchemaLoaded = 1

const DB_UnresetViews = 2

const DIRECT_MODE = 0

type DateTime = TDateTime

type Db = TDb

type DbClientData = TDbClientData

type DbFixer = TDbFixer

type DbPage = TDbPage

type DblquoteStr = TDblquoteStr

type DbpageCursor = TDbpageCursor

/* Columns */

type DbpageTable = TDbpageTable

type DistinctCtx = TDistinctCtx

const E2BIG = 7

const EACCES = 13

const EBADF = 9

const EBUSY = 16

const ECHILD = 10

const EDOM = 33

const EEXIST = 17

const EFAULT = 14

const EFBIG = 27

const EINTR = 4

const EINVAL = 22

const EIO = 5

const EISDIR = 21

const EMFILE = 24

const EMLINK = 31

const ENAME_NAME = 0

const ENAME_ROWID = 3

const ENAME_SPAN = 1

const ENAME_TAB = 2

const ENFILE = 23

const ENODEV = 19

const ENOENT = 2

const ENOEXEC = 8

const ENOMEM = 12

const ENOSPC = 28

const ENOTDIR = 20

const ENOTTY = 25

const ENXIO = 6

const EPERM = 1

const EPIPE = 32

const EP_Agg = 16

const EP_CanBeNull = 2097152

const EP_Collate = 512

const EP_Commuted = 1024

const EP_ConstFunc = 1048576

const EP_DblQuoted = 128

const EP_Distinct = 4

const EP_FixedCol = 32

const EP_FromDDL = 1073741824

const EP_FullSize = 131072

const EP_HasFunc = 8

const EP_IfNullRow = 262144

const EP_Immutable = 2

const EP_InfixFunc = 256

const EP_InnerON = 2

const EP_IntValue = 2048

const EP_IsFalse = 536870912

const EP_IsTrue = 268435456

const EP_Leaf = 8388608

const EP_NoReduce = 1

const EP_OuterON = 1

const EP_Propagate = 4194824

const EP_Quoted = 67108864

const EP_Reduced = 16384

const EP_Skip = 8192

const EP_Static = 134217728

const EP_Subquery = 4194304

const EP_Subrtn = 33554432

const EP_SubtArg = 2147483648

const EP_TokenOnly = 65536

const EP_Unlikely = 524288

const EP_VarSelect = 64

const EP_Win = 32768

const EP_WinFunc = 16777216

const EP_xIsSelect = 4096

const ERANGE = 34

const EROFS = 30

const ESPIPE = 29

const ESRCH = 3

const EU4_EXPR = 2

const EU4_IDX = 1

const EU4_NONE = 0

const EXCLUDED_TABLE_NUMBER = 2

const EXCLUSIVE_LOCK = 4

const EXDEV = 18

const EXIT_FAILURE = 1

const EXIT_SUCCESS = 0

const EXPRDUP_REDUCE = 1

const EXPR_FULLSIZE = 0

type EdupBuf = TEdupBuf

type Expr = TExpr

type ExprList = TExprList

type ExprList_item = TExprList_item

type FKey = TFKey

const FLAG_SIGNED = 1

const FLAG_STRING = 4

const FTS5CSR_EOF = 1

const FTS5CSR_FREE_ZRANK = 16

const FTS5CSR_REQUIRE_CONTENT = 2

const FTS5CSR_REQUIRE_DOCSIZE = 4

const FTS5CSR_REQUIRE_INST = 8

const FTS5CSR_REQUIRE_POSLIST = 64

const FTS5CSR_REQUIRE_RESEEK = 32

const FTS5INDEX_QUERY_DESC = 2

const FTS5INDEX_QUERY_NOOUTPUT = 32

const FTS5INDEX_QUERY_NOTOKENDATA = 128

const FTS5INDEX_QUERY_PREFIX = 1

const FTS5INDEX_QUERY_SCAN = 8

const FTS5INDEX_QUERY_SCANONETERM = 256

const FTS5INDEX_QUERY_SKIPEMPTY = 16

const FTS5INDEX_QUERY_SKIPHASH = 64

const FTS5INDEX_QUERY_TEST_NOIDX = 4

const FTS5TOKEN = 0

const FTS5_AND = 2

const FTS5_AVERAGES_ROWID = 1

const FTS5_BI_MATCH = 1

const FTS5_BI_ORDER_DESC = 128

const FTS5_BI_ORDER_RANK = 32

const FTS5_BI_ORDER_ROWID = 64

const FTS5_BI_RANK = 2

const FTS5_BI_ROWID_EQ = 4

const FTS5_BI_ROWID_GE = 16

const FTS5_BI_ROWID_LE = 8

const FTS5_CARET = 12

const FTS5_COLON = 5

const FTS5_COMMA = 13

const FTS5_CONTENT_EXTERNAL = 2

const FTS5_CONTENT_NONE = 1

const FTS5_CONTENT_NORMAL = 0

const FTS5_CONTENT_UNINDEXED = 3

const FTS5_CORRUPT = 267

const FTS5_CURRENT_VERSION = 4

const FTS5_CURRENT_VERSION_SECUREDELETE = 5

const FTS5_DATA_DLI_B = 1

const FTS5_DATA_HEIGHT_B = 5

const FTS5_DATA_ID_B = 16

const FTS5_DATA_PADDING = 20

const FTS5_DATA_PAGE_B = 31

const FTS5_DATA_ZERO_PADDING = 8

const FTS5_DEFAULT_AUTOMERGE = 4

const FTS5_DEFAULT_CRISISMERGE = 16

const FTS5_DEFAULT_DELETE_AUTOMERGE = 10

const FTS5_DEFAULT_HASHSIZE = 1048576

const FTS5_DEFAULT_NEARDIST = 10

const FTS5_DEFAULT_PAGE_SIZE = 4050

const FTS5_DEFAULT_RANK = "bm25"

const FTS5_DEFAULT_USERMERGE = 4

const FTS5_DETAIL_COLUMNS = 2

const FTS5_DETAIL_FULL = 0

const FTS5_DETAIL_NONE = 1

const FTS5_EOF = 0

const FTS5_INSTTOKEN_SUBTYPE = 73

const FTS5_LCP = 7

const FTS5_LP = 10

const FTS5_MAIN_PREFIX = 48

const FTS5_MAX_LEVEL = 64

const FTS5_MAX_PAGE_SIZE = 65536

const FTS5_MAX_PREFIX_INDEXES = 31

const FTS5_MAX_SEGMENT = 2000

const FTS5_MAX_TOKEN_SIZE = 32768

const FTS5_MERGE_NLIST = 16

const FTS5_MINUS = 6

const FTS5_MIN_DLIDX_SIZE = 4

const FTS5_NOINLINE = "SQLITE_NOINLINE"

const FTS5_NOT = 3

const FTS5_OPT_WORK_UNIT = 1000

const FTS5_OR = 1

const FTS5_PATTERN_GLOB = 66

const FTS5_PATTERN_LIKE = 65

const FTS5_PATTERN_NONE = 0

const FTS5_PLAN_MATCH = 1

const FTS5_PLAN_ROWID = 6

const FTS5_PLAN_SCAN = 5

const FTS5_PLAN_SORTED_MATCH = 4

const FTS5_PLAN_SOURCE = 2

const FTS5_PLAN_SPECIAL = 3

const FTS5_PLUS = 14

const FTS5_PORTER_MAX_TOKEN = 64

const FTS5_RANK_NAME = "rank"

const FTS5_RCP = 8

const FTS5_REMOVE_DIACRITICS_COMPLEX = 2

const FTS5_REMOVE_DIACRITICS_NONE = 0

const FTS5_REMOVE_DIACRITICS_SIMPLE = 1

const FTS5_ROWID_NAME = "rowid"

const FTS5_RP = 11

const FTS5_SEGITER_ONETERM = 1

const FTS5_SEGITER_REVERSE = 2

const FTS5_STAR = 15

const FTS5_STMT_DELETE_CONTENT = 6

const FTS5_STMT_DELETE_DOCSIZE = 8

const FTS5_STMT_INSERT_CONTENT = 4

const FTS5_STMT_LOOKUP = 2

const FTS5_STMT_LOOKUP2 = 3

const FTS5_STMT_LOOKUP_DOCSIZE = 9

const FTS5_STMT_REPLACE_CONFIG = 10

const FTS5_STMT_REPLACE_CONTENT = 5

const FTS5_STMT_REPLACE_DOCSIZE = 7

const FTS5_STMT_SCAN = 11

const FTS5_STMT_SCAN_ASC = 0

const FTS5_STMT_SCAN_DESC = 1

const FTS5_STRING = 9

const FTS5_STRUCTURE_ROWID = 10

const FTS5_STRUCTURE_V2 = "\xff\x00\x00\x01"

const FTS5_TERM = 4

const FTS5_TOKENIZE_AUX = 8

const FTS5_TOKENIZE_DOCUMENT = 4

const FTS5_TOKENIZE_PREFIX = 2

const FTS5_TOKENIZE_QUERY = 1

const FTS5_TOKEN_COLOCATED = 1

const FTS5_VOCAB_COL = 0

const FTS5_VOCAB_COLUSED_MASK = 255

const FTS5_VOCAB_COL_SCHEMA = "term, col, doc, cnt"

const FTS5_VOCAB_INSTANCE = 2

const FTS5_VOCAB_INST_SCHEMA = "term, doc, col, offset"

const FTS5_VOCAB_ROW = 1

const FTS5_VOCAB_ROW_SCHEMA = "term, doc, cnt"

const FTS5_VOCAB_TERM_EQ = 256

const FTS5_VOCAB_TERM_GE = 512

const FTS5_VOCAB_TERM_LE = 1024

const FTS5_WORK_UNIT = 64

const FULLY_WITHIN = 2

const FUNC_PERFECT_MATCH = 6

type FileChunk = TFileChunk

type FilePoint = TFilePoint

type FpDecode = TFpDecode

type FrameBound = TFrameBound

type Fts5Auxdata = TFts5Auxdata

type Fts5Auxiliary = TFts5Auxiliary

type Fts5Bm25Data = TFts5Bm25Data

type Fts5Buffer = TFts5Buffer

type Fts5CResult = TFts5CResult

type Fts5Colset = TFts5Colset

/* Size (int bytes) of a complete Fts5Colset object with N columns. */

/**************************************************************************
** Interface to code in fts5_config.c. fts5_config.c contains contains code
** to parse the arguments passed to the CREATE VIRTUAL TABLE statement.
 */

type Fts5Config = TFts5Config

type Fts5Cursor = TFts5Cursor

type Fts5Data = TFts5Data

type Fts5DlidxIter = TFts5DlidxIter

type Fts5DlidxLvl = TFts5DlidxLvl

type Fts5DlidxWriter = TFts5DlidxWriter

type Fts5DoclistIter = TFts5DoclistIter

type Fts5Enum = TFts5Enum

type Fts5Expr = TFts5Expr

type Fts5ExprCtx = TFts5ExprCtx

type Fts5ExprNearset = TFts5ExprNearset

type Fts5ExprNode = TFts5ExprNode

type Fts5ExprPhrase = TFts5ExprPhrase

type Fts5ExprTerm = TFts5ExprTerm

/*
** Check that the Fts5ExprNode.iHeight variables are set correctly in
** the expression tree passed as the only argument.
 */

type Fts5ExtensionApi = TFts5ExtensionApi

type Fts5FlushCtx = TFts5FlushCtx

type Fts5FullTable = TFts5FullTable

type Fts5Global = TFts5Global

type Fts5Hash = TFts5Hash

/*
** End of interface to code in fts5_hash.c.
**************************************************************************/

/**************************************************************************
** Interface to code in fts5_storage.c. fts5_storage.c contains contains
** code to access the data stored in the %_content and %_docsize tables.
 */

type Fts5HashEntry = TFts5HashEntry

/*
** Equivalent to:
**
**   char *fts5EntryKey(Fts5HashEntry *pEntry){ return zKey; }
 */

type Fts5Index = TFts5Index

type Fts5IndexIter = TFts5IndexIter

/*
** End of interface to code in fts5_varint.c.
**************************************************************************/

/**************************************************************************
** Interface to code in fts5_main.c.
 */

type Fts5InsertCtx = TFts5InsertCtx

type Fts5IntegrityCtx = TFts5IntegrityCtx

type Fts5Iter = TFts5Iter

type Fts5LookaheadReader = TFts5LookaheadReader

type Fts5MatchPhrase = TFts5MatchPhrase

type Fts5NearTrimmer = TFts5NearTrimmer

type Fts5PageWriter = TFts5PageWriter

type Fts5Parse = TFts5Parse

type Fts5PhraseIter = TFts5PhraseIter

type Fts5PoslistPopulator = TFts5PoslistPopulator

/*
** End of interface to code in fts5_unicode2.c.
**************************************************************************/

/* This file is automatically generated by Lemon from input grammar
** source file "fts5parse.y".
 */
/*
** 2000-05-29
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Driver template for the LEMON parser generator.
**
** The "lemon" program processes an LALR(1) input grammar file, then uses
** this template to construct a parser.  The "lemon" program inserts text
** at each "%%" line.  Also, any "P-a-r-s-e" identifier prefix (without the
** interstitial "-" characters) contained in this template is changed into
** the value of the %name directive from the grammar.  Otherwise, the content
** of this template is copied straight through into the generate parser
** source file.
**
** The following is the concatenation of all %include directives from the
** input grammar file:
 */
/************ Begin %include sections from the grammar ************************/

/* #include "fts5Int.h" */
/* #include "fts5parse.h" */

/*
** Disable all error recovery processing in the parser push-down
** automaton.
 */

/*
** Make fts5yytestcase() the same as testcase()
 */

/*
** Indicate that sqlite3ParserFree() will never be called with a null
** pointer.
 */

/*
** Alternative datatype for the argument to the malloc() routine passed
** into sqlite3ParserAlloc().  The default is size_t.
 */

/**************** End of %include directives **********************************/
/* These constants specify the various numeric values for terminal symbols.
***************** Begin token definitions *************************************/
/**************** End token definitions ***************************************/

type Fts5PoslistReader = TFts5PoslistReader

type Fts5PoslistWriter = TFts5PoslistWriter

type Fts5SFinder = TFts5SFinder

type Fts5SegIter = TFts5SegIter

type Fts5SegWriter = TFts5SegWriter

type Fts5Sorter = TFts5Sorter

type Fts5Storage = TFts5Storage

/*
** End of interface to code in fts5_storage.c.
**************************************************************************/

type Fts5Structure = TFts5Structure

type Fts5StructureLevel = TFts5StructureLevel

type Fts5StructureSegment = TFts5StructureSegment

type Fts5Table = TFts5Table

/*
** End of interface to code in fts5.c.
**************************************************************************/

type Fts5Termset = TFts5Termset

/*
** End of interface to code in fts5_buffer.c.
**************************************************************************/

/**************************************************************************
** Interface to code in fts5_index.c. fts5_index.c contains contains code
** to access the data stored in the %_data table.
 */

type Fts5TermsetEntry = TFts5TermsetEntry

type Fts5Token = TFts5Token

type Fts5TokenDataIter = TFts5TokenDataIter

type Fts5TokenDataMap = TFts5TokenDataMap

type Fts5TokenizerConfig = TFts5TokenizerConfig

/*
** End of interface to code in fts5_config.c.
**************************************************************************/

/**************************************************************************
** Interface to code in fts5_buffer.c.
 */

type Fts5TokenizerModule = TFts5TokenizerModule

type Fts5TombstoneArray = TFts5TombstoneArray

type Fts5TransactionState = TFts5TransactionState

type Fts5VocabCursor = TFts5VocabCursor

/*
** Bits for the mask used as the idxNum value by xBestIndex/xFilter.
 */

type Fts5VocabTable = TFts5VocabTable

type Fts5VtoVTokenizer = TFts5VtoVTokenizer

type FuncDef = TFuncDef

type FuncDefHash = TFuncDefHash

type FuncDestructor = TFuncDestructor

const GCC_VERSION = 0

const GEOPOLY_PI = 3.141592653589793

type GeoBBox = TGeoBBox

type GeoCoord = TGeoCoord

type GeoEvent = TGeoEvent

type GeoOverlap = TGeoOverlap

type GeoParse = TGeoParse

type GeoPoly = TGeoPoly

/* The size of a memory allocation needed for a GeoPoly object sufficient
** to hold N coordinate pairs.
 */

/* Macros to access coordinates of a GeoPoly.
** We have to use these macros, rather than just say p->a[i] in order
** to silence (incorrect) UBSAN warnings if the array index is too large.
 */

type GeoSegment = TGeoSegment

type GroupConcatCtx = TGroupConcatCtx

const HASHSIZE = 97

const HASHTABLE_HASH_1 = 383

const HASHTABLE_NPAGE = 4096

const HASHTABLE_NPAGE_ONE = 4096

const HASHTABLE_NSLOT = 8192

const HAVE_FCHOWN = 1

const HAVE_LSTAT = 1

const HAVE_READLINK = 1

const HAVE_USLEEP = 1

const HUGE_VALF = 0

type Hash = THash

type HashElem = THashElem

type HiddenIndexInfo = THiddenIndexInfo

type HighlightContext = THighlightContext

const INCRINIT_NORMAL = 0

const INCRINIT_ROOT = 2

const INCRINIT_TASK = 1

const INFINITY = 0

const INITFLAG_AlterAdd = 3

const INITFLAG_AlterDrop = 2

const INITFLAG_AlterDropCons = 4

const INITFLAG_AlterMask = 7

const INITFLAG_AlterRename = 1

const INLINEFUNC_affinity = 4

const INLINEFUNC_coalesce = 0

const INLINEFUNC_expr_compare = 3

const INLINEFUNC_expr_implies_expr = 2

const INLINEFUNC_iif = 5

const INLINEFUNC_implies_nonnull_row = 1

const INLINEFUNC_sqlite_offset = 6

const INLINEFUNC_unlikely = 99

const INT16_MAX = 32767

const INT16_MIN = -32768

const INT32_MAX = 2147483647

const INT32_MIN = -2147483648

const INT64_MAX = 9223372036854775807

const INT64_MIN = -9223372036854775808

const INT8_MAX = 127

const INT8_MIN = -128

const INTMAX_MAX = 9223372036854775807

const INTMAX_MIN = -9223372036854775808

const INT_FAST32_MAX = 2147483647

const INT_FAST32_MIN = -2147483648

const INT_FAST64_MAX = 9223372036854775807

const INT_FAST64_MIN = -9223372036854775808

const INT_LEAST16_MAX = 32767

const INT_LEAST16_MIN = -32768

const INT_LEAST32_MAX = 2147483647

const INT_LEAST32_MIN = -2147483648

const INT_LEAST64_MAX = 9223372036854775807

const INT_LEAST64_MIN = -9223372036854775808

const INT_LEAST8_MAX = 127

const INT_LEAST8_MIN = -128

const IN_INDEX_EPH = 2

const IN_INDEX_INDEX_ASC = 3

const IN_INDEX_INDEX_DESC = 4

const IN_INDEX_LOOP = 4

const IN_INDEX_MEMBERSHIP = 2

const IN_INDEX_NOOP = 5

const IN_INDEX_NOOP_OK = 1

const IN_INDEX_ROWID = 1

type IdList = TIdList

type IdList_item = TIdList_item

type IdxCover = TIdxCover

type InLoop = TInLoop

type IncrMerger = TIncrMerger

type Incrblob = TIncrblob

type Index = TIndex

type IndexIterator = TIndexIterator

type IndexListTerm = TIndexListTerm

type IndexSample = TIndexSample

type IndexedExpr = TIndexedExpr

type InitData = TInitData

/*
** Allowed values for mInitFlags
 */

/* Tuning parameters are set using SQLITE_TESTCTRL_TUNE and are controlled
** on debug-builds of the CLI using ".testctrl tune ID VALUE".  Tuning
** parameters are for temporary use during development, to help find
** optimal values for parameters in the query planner.  The should not
** be used on trunk check-ins.  They are a temporary mechanism available
** for transient development builds only.
**
** Tuning parameters are numbered starting with 1.
 */

type IntegrityCk = TIntegrityCk

/*
** Routines to read or write a two- and four-byte big-endian integer values.
 */

/*
** get2byteAligned(), unlike get2byte(), requires that its argument point to a
** two-byte aligned address.  get2byteAligned() is only used for accessing the
** cell addresses in a btree header.
 */

/************** End of btreeInt.h ********************************************/
/************** Continuing where we left off in btmutex.c ********************/

const IsStat4 = 1

const JEACH_ATOM = 3

const JEACH_FULLKEY = 6

const JEACH_ID = 4

const JEACH_JSON = 8

const JEACH_KEY = 0

const JEACH_PARENT = 5

const JEACH_PATH = 7

const JEACH_ROOT = 9

const JEACH_TYPE = 2

const JEACH_VALUE = 1

const JEDIT_AINS = 5

const JEDIT_DEL = 1

const JEDIT_INS = 3

const JEDIT_REPL = 2

const JEDIT_SET = 4

const JSONB_ARRAY = 11

const JSONB_FALSE = 2

const JSONB_FLOAT = 5

const JSONB_FLOAT5 = 6

const JSONB_INT = 3

const JSONB_INT5 = 4

const JSONB_NULL = 0

const JSONB_OBJECT = 12

const JSONB_TEXT = 7

const JSONB_TEXT5 = 9

const JSONB_TEXTJ = 8

const JSONB_TEXTRAW = 10

const JSONB_TRUE = 1

const JSON_ABPATH = 3

const JSON_AINS = 8

const JSON_BLOB = 16

const JSON_CACHE_ID = -429938

const JSON_CACHE_SIZE = 4

const JSON_EDITABLE = 1

const JSON_INVALID_CHAR = 629145

const JSON_ISSET = 4

const JSON_JSON = 1

const JSON_KEEPERROR = 2

const JSON_LOOKUP_ERROR = 4294967295

const JSON_LOOKUP_NOTARRAY = 4294967293

const JSON_LOOKUP_NOTFOUND = 4294967294

const JSON_LOOKUP_PATHERROR = 4294967291

const JSON_LOOKUP_TOODEEP = 4294967292

const JSON_MAX_DEPTH = 1000

const JSON_MERGE_BADPATCH = 2

const JSON_MERGE_BADTARGET = 1

const JSON_MERGE_OK = 0

const JSON_MERGE_OOM = 3

const JSON_MERGE_TOODEEP = 4

const JSON_SQL = 2

const JSON_SUBTYPE = 74

const JSTRING_ERR = 8

const JSTRING_MALFORMED = 2

const JSTRING_OOM = 1

const JSTRING_TOODEEP = 4

const JT_CROSS = 2

const JT_ERROR = 128

const JT_INNER = 1

const JT_LEFT = 8

const JT_LTORJ = 64

const JT_NATURAL = 4

const JT_OUTER = 32

const JT_RIGHT = 16

type JsonCache = TJsonCache

type JsonEachConnection = TJsonEachConnection

type JsonEachCursor = TJsonEachCursor

type JsonParent = TJsonParent

type JsonParse = TJsonParse

/**************************************************************************
** Utility routines for dealing with JsonCache objects
**************************************************************************/

type JsonPretty = TJsonPretty

type JsonString = TJsonString

const KEYINFO_ORDER_BIGNULL = 2

const KEYINFO_ORDER_DESC = 1

type KeyInfo = TKeyInfo

const LEGACY_SCHEMA_TABLE = "sqlite_master"

const LEGACY_TEMP_SCHEMA_TABLE = "sqlite_temp_master"

const LOCATE_NOERR = 2

const LOCATE_VIEW = 1

const LOGEST_MAX = 32767

const LOGEST_MIN = -32768

const LONGDOUBLE_TYPE = 0

const LOOKASIDE_SMALL = 128

type LastValueCtx = TLastValueCtx

type LogEst = TLogEst

/*
** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer
 */

type Lookaside = TLookaside

type LookasideSlot = TLookasideSlot

const M10d_Any = 1

const M10d_No = 2

const M10d_Yes = 0

const MAX_SECTOR_SIZE = 65536

const MEMJOURNAL_DFLT_FILECHUNKSIZE = 1024

const MEMTYPE_HEAP = 1

const MEMTYPE_LOOKASIDE = 2

const MEMTYPE_PCACHE = 4

const MEM_AffMask = 63

const MEM_Agg = 32768

const MEM_Blob = 16

const MEM_Cleared = 256

const MEM_Dyn = 4096

const MEM_Ephem = 16384

const MEM_FromBind = 64

const MEM_Int = 4

const MEM_IntReal = 32

const MEM_Null = 1

const MEM_Real = 8

const MEM_Static = 8192

const MEM_Str = 2

const MEM_Subtype = 2048

const MEM_Term = 512

const MEM_TypeMask = 3519

const MEM_Undefined = 0

const MEM_Zero = 1024

const MSVC_VERSION = 0

type Mem = TMem

type Mem0Global = TMem0Global

/*
** Default value of the hard heap limit.  0 means "no limit".
 */

type MemFS = TMemFS

type MemFile = TMemFile

type MemJournal = TMemJournal

type MemPage = TMemPage

type MemStore = TMemStore

type MemValue = TMemValue

type MemVfs = TMemVfs

type MergeEngine = TMergeEngine

type Module = TModule

const NAN = 0

const NB = 3

const NC_AllowAgg = 1

const NC_AllowWin = 16384

const NC_FromDDL = 262144

const NC_GenCol = 8

const NC_HasAgg = 16

const NC_HasWin = 32768

const NC_IdxExpr = 32

const NC_InAggFunc = 131072

const NC_IsCheck = 4

const NC_IsDDL = 65536

const NC_MinMaxAgg = 4096

const NC_NoSelect = 524288

const NC_OrderAgg = 134217728

const NC_PartIdx = 2

const NC_SelfRef = 46

const NC_Subquery = 64

const NC_UAggInfo = 256

const NC_UBaseReg = 1024

const NC_UEList = 128

const NC_UUpsert = 512

const NC_Where = 1048576

const NDEBUG = 1

const NN = 1

const NOT_WITHIN = 0

const NO_LOCK = 0

const N_OR_COST = 3

const N_SORT_BUCKET = 32

const N_STATEMENT = 8

type NameContext = TNameContext

type NanInfName = TNanInfName

type NthValueCtx = TNthValueCtx

type NtileCtx = TNtileCtx

const OE_Abort = 2

const OE_Cascade = 10

const OE_Default = 11

const OE_Fail = 3

const OE_Ignore = 4

const OE_None = 0

const OE_Replace = 5

const OE_Restrict = 7

const OE_Rollback = 1

const OE_SetDflt = 9

const OE_SetNull = 8

const OE_Update = 6

const OMIT_TEMPDB = 0

const ONEPASS_MULTI = 2

const ONEPASS_OFF = 0

const ONEPASS_SINGLE = 1

const OPFLAG_APPEND = 8

const OPFLAG_AUXDELETE = 4

const OPFLAG_BULKCSR = 1

const OPFLAG_BYTELENARG = 192

const OPFLAG_EPHEM = 1

const OPFLAG_FORDELETE = 8

const OPFLAG_ISNOOP = 64

const OPFLAG_ISUPDATE = 4

const OPFLAG_LASTROWID = 32

const OPFLAG_LENGTHARG = 64

const OPFLAG_NCHANGE = 1

const OPFLAG_NOCHNG = 1

const OPFLAG_NOCHNG_MAGIC = 109

const OPFLAG_P2ISREG = 16

const OPFLAG_PERMUTE = 1

const OPFLAG_PREFORMAT = 128

const OPFLAG_SAVEPOSITION = 2

const OPFLAG_SEEKEQ = 2

const OPFLAG_TYPEOFARG = 128

const OPFLAG_USESEEKRESULT = 16

const OPFLG_IN1 = 2

const OPFLG_IN2 = 4

const OPFLG_IN3 = 8

const OPFLG_JUMP = 1

const OPFLG_JUMP0 = 128

const OPFLG_NCYCLE = 64

const OPFLG_OUT2 = 16

const OPFLG_OUT3 = 32

const OP_Abortable = 191

const OP_Add = 107

const OP_AddImm = 88

const OP_Affinity = 98

const OP_AggFinal = 167

const OP_AggInverse = 163

const OP_AggStep = 164

const OP_AggStep1 = 165

const OP_AggValue = 166

const OP_And = 44

const OP_AutoCommit = 1

const OP_BeginSubrtn = 76

const OP_BitAnd = 103

const OP_BitNot = 115

const OP_BitOr = 104

const OP_Blob = 79

const OP_Cast = 90

const OP_Checkpoint = 3

const OP_Clear = 147

const OP_Close = 124

const OP_ClrSubtype = 182

const OP_CollSeq = 87

const OP_Column = 96

const OP_ColumnsUsed = 125

const OP_Compare = 92

const OP_Concat = 112

const OP_Copy = 82

const OP_Count = 100

const OP_CreateBtree = 149

const OP_CursorHint = 187

const OP_CursorLock = 169

const OP_CursorUnlock = 170

const OP_DecrJumpZero = 63

const OP_DeferredSeek = 143

const OP_Delete = 132

const OP_Destroy = 146

const OP_Divide = 110

const OP_DropIndex = 155

const OP_DropTable = 153

const OP_DropTrigger = 156

const OP_ElseEq = 59

const OP_EndCoroutine = 70

const OP_Eq = 54

const OP_Expire = 168

const OP_Explain = 190

const OP_Filter = 66

const OP_FilterAdd = 185

const OP_FinishSeek = 145

const OP_FkCheck = 85

const OP_FkCounter = 160

const OP_FkIfZero = 60

const OP_Found = 29

const OP_Function = 68

const OP_Ge = 58

const OP_GetSubtype = 183

const OP_Gosub = 10

const OP_Goto = 9

const OP_Gt = 55

const OP_Halt = 72

const OP_HaltIfNull = 71

const OP_IFindKey = 47

const OP_IdxDelete = 142

const OP_IdxGE = 46

const OP_IdxGT = 42

const OP_IdxInsert = 140

const OP_IdxLE = 41

const OP_IdxLT = 45

const OP_IdxRowid = 144

const OP_If = 16

const OP_IfEmpty = 37

const OP_IfNoHope = 26

const OP_IfNot = 17

const OP_IfNotOpen = 25

const OP_IfNotZero = 62

const OP_IfNullRow = 20

const OP_IfPos = 61

const OP_IfSizeBetween = 33

const OP_IncrVacuum = 64

const OP_Init = 8

const OP_InitCoroutine = 11

const OP_Insert = 130

const OP_Int64 = 74

const OP_IntCopy = 84

const OP_Integer = 73

const OP_IntegrityCk = 157

const OP_IsNull = 51

const OP_IsTrue = 93

const OP_IsType = 18

const OP_JournalMode = 4

const OP_Jump = 14

const OP_Last = 32

const OP_Le = 56

const OP_LoadAnalysis = 152

const OP_Lt = 57

const OP_MakeRecord = 99

const OP_MaxPgcnt = 181

const OP_MemMax = 161

const OP_Move = 81

const OP_Multiply = 109

const OP_MustBeInt = 13

const OP_Ne = 53

const OP_NewRowid = 129

const OP_Next = 40

const OP_NoConflict = 27

const OP_Noop = 189

const OP_Not = 19

const OP_NotExists = 31

const OP_NotFound = 28

const OP_NotNull = 52

const OP_Null = 77

const OP_NullRow = 138

const OP_Offset = 95

const OP_OffsetLimit = 162

const OP_Once = 15

const OP_OpenAutoindex = 119

const OP_OpenDup = 117

const OP_OpenEphemeral = 120

const OP_OpenPseudo = 123

const OP_OpenRead = 114

const OP_OpenWrite = 116

const OP_Or = 43

const OP_Pagecount = 180

const OP_Param = 159

const OP_ParseSchema = 151

const OP_Permutation = 91

const OP_Prev = 39

const OP_Program = 50

const OP_PureFunc = 67

const OP_ReadCookie = 101

const OP_Real = 154

const OP_RealAffinity = 89

const OP_ReleaseReg = 188

const OP_Remainder = 111

const OP_ReopenIdx = 113

const OP_ResetCount = 133

const OP_ResetSorter = 148

const OP_ResultRow = 86

const OP_Return = 69

const OP_Rewind = 36

const OP_RowCell = 131

const OP_RowData = 136

const OP_RowSetAdd = 158

const OP_RowSetRead = 48

const OP_RowSetTest = 49

const OP_Rowid = 137

const OP_SCopy = 83

const OP_Savepoint = 0

const OP_SeekEnd = 139

const OP_SeekGE = 23

const OP_SeekGT = 24

const OP_SeekHit = 127

const OP_SeekLE = 22

const OP_SeekLT = 21

const OP_SeekRowid = 30

const OP_SeekScan = 126

const OP_Sequence = 128

const OP_SequenceTest = 122

const OP_SetCookie = 102

const OP_SetSubtype = 184

const OP_ShiftLeft = 105

const OP_ShiftRight = 106

const OP_SoftNull = 78

const OP_Sort = 35

const OP_SorterCompare = 134

const OP_SorterData = 135

const OP_SorterInsert = 141

const OP_SorterNext = 38

const OP_SorterOpen = 121

const OP_SorterSort = 34

const OP_SqlExec = 150

const OP_String = 75

const OP_String8 = 118

const OP_Subtract = 108

const OP_TableLock = 171

const OP_Trace = 186

const OP_Transaction = 2

const OP_TypeCheck = 97

const OP_VBegin = 172

const OP_VCheck = 176

const OP_VColumn = 178

const OP_VCreate = 173

const OP_VDestroy = 174

const OP_VFilter = 6

const OP_VInitIn = 177

const OP_VNext = 65

const OP_VOpen = 175

const OP_VRename = 179

const OP_VUpdate = 7

const OP_Vacuum = 5

const OP_Variable = 80

const OP_Yield = 12

const OP_ZeroOrNull = 94

const OS_VXWORKS = 0

type OnOrUsing = TOnOrUsing

type Op = TOp

const P4_COLLSEQ = -2

const P4_DYNAMIC = -7

const P4_EXPR = -10

const P4_FREE_IF_LE = -7

const P4_FUNCCTX = -16

const P4_FUNCDEF = -8

const P4_INDEX = -6

const P4_INT32 = -3

const P4_INT64 = -14

const P4_INTARRAY = -15

const P4_KEYINFO = -9

const P4_MEM = -11

const P4_NOTUSED = 0

const P4_REAL = -13

const P4_STATIC = -1

const P4_SUBPROGRAM = -4

const P4_SUBRTNSIG = -18

const P4_TABLE = -5

const P4_TABLEREF = -17

const P4_TRANSIENT = 0

const P4_VTAB = -12

const P5_ConstraintCheck = 3

const P5_ConstraintFK = 4

const P5_ConstraintNotNull = 1

const P5_ConstraintUnique = 2

const PAGER_CACHESPILL = 32

const PAGER_CKPT_FULLFSYNC = 16

const PAGER_ERROR = 6

const PAGER_FLAGS_MASK = 56

const PAGER_FULLFSYNC = 8

const PAGER_GET_NOCONTENT = 1

const PAGER_GET_READONLY = 2

const PAGER_JOURNALMODE_DELETE = 0

const PAGER_JOURNALMODE_MEMORY = 4

const PAGER_JOURNALMODE_OFF = 2

const PAGER_JOURNALMODE_PERSIST = 1

const PAGER_JOURNALMODE_QUERY = -1

const PAGER_JOURNALMODE_TRUNCATE = 3

const PAGER_JOURNALMODE_WAL = 5

const PAGER_LOCKINGMODE_EXCLUSIVE = 1

const PAGER_LOCKINGMODE_NORMAL = 0

const PAGER_LOCKINGMODE_QUERY = -1

const PAGER_MEMORY = 2

const PAGER_OMIT_JOURNAL = 1

const PAGER_OPEN = 0

const PAGER_READER = 1

const PAGER_STAT_HIT = 0

const PAGER_STAT_MISS = 1

const PAGER_STAT_SPILL = 3

const PAGER_STAT_WRITE = 2

const PAGER_SYNCHRONOUS_EXTRA = 4

const PAGER_SYNCHRONOUS_FULL = 3

const PAGER_SYNCHRONOUS_MASK = 7

const PAGER_SYNCHRONOUS_NORMAL = 2

const PAGER_SYNCHRONOUS_OFF = 1

const PAGER_WRITER_CACHEMOD = 3

const PAGER_WRITER_DBMOD = 4

const PAGER_WRITER_FINISHED = 5

const PAGER_WRITER_LOCKED = 2

const PARSE_MODE_DECLARE_VTAB = 1

const PARSE_MODE_NORMAL = 0

const PARSE_MODE_RENAME = 2

const PARSE_MODE_UNMAP = 3

const PARTLY_WITHIN = 1

const PCACHE1_MIGHT_USE_GROUP_MUTEX = 1

const PCACHE_DIRTYLIST_ADD = 2

const PCACHE_DIRTYLIST_FRONT = 3

const PCACHE_DIRTYLIST_REMOVE = 1

type PCache = TPCache

type PCache1 = TPCache1

type PCacheGlobal = TPCacheGlobal

const PENDING_BYTE = 0

const PENDING_LOCK = 3

const PGHDR_CLEAN = 1

const PGHDR_DIRTY = 2

const PGHDR_DONT_WRITE = 16

const PGHDR_MMAP = 32

const PGHDR_NEED_SYNC = 8

const PGHDR_WAL_APPEND = 64

const PGHDR_WRITEABLE = 4

type PGroup = TPGroup

const POWERSOF10_FIRST = -348

const POWERSOF10_LAST = 347

const PREFERRED_SCHEMA_TABLE = "sqlite_schema"

const PREFERRED_TEMP_SCHEMA_TABLE = "sqlite_temp_schema"

const PTF_INTKEY = 1

const PTF_LEAF = 8

const PTF_LEAFDATA = 4

const PTF_ZERODATA = 2

const PTRMAP_BTREE = 5

const PTRMAP_FREEPAGE = 2

const PTRMAP_OVERFLOW1 = 3

const PTRMAP_OVERFLOW2 = 4

const PTRMAP_ROOTPAGE = 1

type Pager = TPager

type PagerSavepoint = TPagerSavepoint

/*
** Indexes for use with Pager.aStat[]. The Pager.aStat[] array contains
** the values accessed by passing SQLITE_DBSTATUS_CACHE_HIT, CACHE_MISS
** or CACHE_WRITE to sqlite3_db_status().
 */

/*
** The following global variables hold counters used for
** testing purposes only.  These variables do not exist in
** a non-testing build.  These variables are not thread-safe.
 */

type Parse = TParse

type ParseCleanup = TParseCleanup

type PgFreeslot = TPgFreeslot

type PgHdr = TPgHdr

/* Functions to support testing and debugging. */

/************** End of pager.h ***********************************************/
/************** Continuing where we left off in sqliteInt.h ******************/
/************** Include btree.h in the middle of sqliteInt.h *****************/
/************** Begin file btree.h *******************************************/
/*
** 2001 September 15
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This header file defines the interface that the sqlite B-Tree file
** subsystem.  See comments in the source code for a detailed description
** of what each interface routine does.
 */

/* TODO: This definition is just included so other modules compile. It
** needs to be revisited.
 */

/*
** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
 */

type PgHdr1 = TPgHdr1

type Pgno = TPgno

type PmaReader = TPmaReader

type PmaWriter = TPmaWriter

type PorterContext = TPorterContext

type PorterRule = TPorterRule

type PorterTokenizer = TPorterTokenizer

type PoslistCallbackCtx = TPoslistCallbackCtx

type PoslistOffsetsCtx = TPoslistOffsetsCtx

const PragFlg_NeedSchema = 1

const PragFlg_NoColumns = 2

const PragFlg_NoColumns1 = 4

const PragFlg_ReadOnly = 8

const PragFlg_Result0 = 16

const PragFlg_Result1 = 32

const PragFlg_SchemaOpt = 64

const PragFlg_SchemaReq = 128

const PragTyp_ACTIVATE_EXTENSIONS = 0

const PragTyp_ANALYSIS_LIMIT = 1

const PragTyp_AUTO_VACUUM = 3

const PragTyp_BUSY_TIMEOUT = 5

const PragTyp_CACHE_SIZE = 6

const PragTyp_CACHE_SPILL = 7

const PragTyp_CASE_SENSITIVE_LIKE = 8

const PragTyp_COLLATION_LIST = 9

const PragTyp_COMPILE_OPTIONS = 10

const PragTyp_DATABASE_LIST = 12

const PragTyp_DATA_STORE_DIRECTORY = 11

const PragTyp_DEFAULT_CACHE_SIZE = 13

const PragTyp_ENCODING = 14

const PragTyp_FLAG = 4

const PragTyp_FOREIGN_KEY_CHECK = 15

const PragTyp_FOREIGN_KEY_LIST = 16

const PragTyp_FUNCTION_LIST = 17

const PragTyp_HARD_HEAP_LIMIT = 18

const PragTyp_HEADER_VALUE = 2

const PragTyp_INCREMENTAL_VACUUM = 19

const PragTyp_INDEX_INFO = 20

const PragTyp_INDEX_LIST = 21

const PragTyp_INTEGRITY_CHECK = 22

const PragTyp_JOURNAL_MODE = 23

const PragTyp_JOURNAL_SIZE_LIMIT = 24

const PragTyp_LOCKING_MODE = 26

const PragTyp_LOCK_PROXY_FILE = 25

const PragTyp_LOCK_STATUS = 44

const PragTyp_MMAP_SIZE = 28

const PragTyp_MODULE_LIST = 29

const PragTyp_OPTIMIZE = 30

const PragTyp_PAGE_COUNT = 27

const PragTyp_PAGE_SIZE = 31

const PragTyp_PRAGMA_LIST = 32

const PragTyp_SECURE_DELETE = 33

const PragTyp_SHRINK_MEMORY = 34

const PragTyp_SOFT_HEAP_LIMIT = 35

const PragTyp_STATS = 45

const PragTyp_SYNCHRONOUS = 36

const PragTyp_TABLE_INFO = 37

const PragTyp_TABLE_LIST = 38

const PragTyp_TEMP_STORE = 39

const PragTyp_TEMP_STORE_DIRECTORY = 40

const PragTyp_THREADS = 41

const PragTyp_WAL_AUTOCHECKPOINT = 42

const PragTyp_WAL_CHECKPOINT = 43

type PragmaName = TPragmaName

type PragmaVtab = TPragmaVtab

type PragmaVtabCursor = TPragmaVtabCursor

type PreUpdate = TPreUpdate

type PrefixMerger = TPrefixMerger

type PrefixSetupCtx = TPrefixSetupCtx

type PrintfArguments = TPrintfArguments

const RBU_CREATE_STATE = "CREATE TABLE IF NOT EXISTS %s.rbu_state(k INTEGER PRIMARY KEY, v)"

const RBU_DELETE = 2

const RBU_ENABLE_DELTA_CKSUM = 0

const RBU_EXCLUSIVE_CHECKPOINT = "rbu_exclusive_checkpoint"

const RBU_IDX_DELETE = 4

const RBU_IDX_INSERT = 5

const RBU_INSERT = 1

const RBU_PK_EXTERNAL = 3

const RBU_PK_IPK = 2

const RBU_PK_NONE = 1

const RBU_PK_NOTABLE = 0

const RBU_PK_VTAB = 5

const RBU_PK_WITHOUT_ROWID = 4

const RBU_REPLACE = 3

const RBU_STAGE_CAPTURE = 3

const RBU_STAGE_CKPT = 4

const RBU_STAGE_DONE = 5

const RBU_STAGE_MOVE = 2

const RBU_STAGE_OAL = 1

const RBU_STATE_CKPT = 6

const RBU_STATE_COOKIE = 7

const RBU_STATE_DATATBL = 10

const RBU_STATE_IDX = 3

const RBU_STATE_OALSZ = 8

const RBU_STATE_PHASEONESTEP = 9

const RBU_STATE_PROGRESS = 5

const RBU_STATE_ROW = 4

const RBU_STATE_STAGE = 1

const RBU_STATE_TBL = 2

const RBU_UPDATE = 6

const RBU_ZIPVFS_CTRL_FILE_POINTER = 230439

type RCStr = TRCStr

const READMARK_NOT_USED = 4294967295

const READ_LOCK = 1

const RESERVED_BYTE = 1

const RESERVED_LOCK = 2

const RNDAWAY = 0

const RNDTOWARDS = 0

const ROWSET_ALLOCATION_SIZE = 1024

const ROWSET_ENTRY_PER_CHUNK = 1016

const ROWSET_NEXT = 2

const ROWSET_SORTED = 1

const RTREE_CACHE_SZ = 5

const RTREE_CHECK_MAX_ERROR = 100

const RTREE_COORD_INT32 = 1

const RTREE_COORD_REAL32 = 0

const RTREE_DEFAULT_ROWEST = 1048576

const RTREE_EQ = 65

const RTREE_FALSE = 64

const RTREE_GE = 68

const RTREE_GT = 69

const RTREE_LE = 66

const RTREE_LT = 67

const RTREE_MATCH = 70

const RTREE_MAXCELLS = 51

const RTREE_MAX_AUX_COLUMN = 100

const RTREE_MAX_DEPTH = 40

const RTREE_MAX_DIMENSIONS = 5

const RTREE_MIN_ROWEST = 100

const RTREE_QUERY = 71

const RTREE_TRUE = 63

const RTREE_ZERO = 0

type RbuFrame = TRbuFrame

type RbuObjIter = TRbuObjIter

type RbuSpan = TRbuSpan

type RbuState = TRbuState

type RbuUpdateStmt = TRbuUpdateStmt

/*
** True for an RBU vacuum handle, or false otherwise.
 */

/*************************************************************************
** The following three functions, found below:
**
**   rbuDeltaGetInt()
**   rbuDeltaChecksum()
**   rbuDeltaApply()
**
** are lifted from the fossil source code (http://fossil-scm.org). They
** are used to implement the scalar SQL function rbu_fossil_delta().
 */

type RecordCompare = TRecordCompare

type RefSrcList = TRefSrcList

type RenameCtx = TRenameCtx

type RenameToken = TRenameToken

type Returning = TReturning

type ReusableSpace = TReusableSpace

type RowLoadInfo = TRowLoadInfo

type RowSet = TRowSet

type RowSetChunk = TRowSetChunk

/*
** Allowed values for RowSet.rsFlags
 */

type RowSetEntry = TRowSetEntry

type Rtree = TRtree

type RtreeCell = TRtreeCell

type RtreeCheck = TRtreeCheck

type RtreeConstraint = TRtreeConstraint

type RtreeCoord = TRtreeCoord

type RtreeCursor = TRtreeCursor

type RtreeDValue = TRtreeDValue

/* High accuracy coordinate */

type RtreeGeomCallback = TRtreeGeomCallback

type RtreeMatchArg = TRtreeMatchArg

type RtreeNode = TRtreeNode

type RtreeSearchPoint = TRtreeSearchPoint

/* Possible values for Rtree.eCoordType: */

type RtreeValue = TRtreeValue

/* Size of an RtreeMatchArg object with N parameters */

/* What version of GCC is being used.  0 means GCC is not being used .
** Note that the GCC_VERSION macro will also be set correctly when using
** clang, since clang works hard to be gcc compatible.  So the gcc
** optimizations will also work when compiling with clang.
 */

/* The testcase() macro should already be defined in the amalgamation.  If
** it is not, make it a no-op.
 */

/*
** Make sure that the compiler intrinsics we desire are enabled when
** compiling with an appropriate version of MSVC unless prevented by
** the SQLITE_DISABLE_INTRINSIC define.
 */

/*
** Macros to determine whether the machine is big or little endian,
** and whether or not that determination is run-time or compile-time.
**
** For best performance, an attempt is made to guess at the byte-order
** using C-preprocessor macros.  If that is unsuccessful, or if
** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined
** at run-time.
 */

/* What version of MSVC is being used.  0 means MSVC is not being used */

const SAVEPOINT_BEGIN = 0

const SAVEPOINT_RELEASE = 1

const SAVEPOINT_ROLLBACK = 2

const SCHEMA_ROOT = 1

const SESSIONS_ROWID = "_rowid_"

const SESSIONS_STRM_CHUNK_SIZE = 1024

const SESSION_MAX_BUFFER_SZ = 2147483391

const SESSION_UPDATE_CACHE_SZ = 12

const SF_Aggregate = 8

const SF_All = 2

const SF_ClonedRhsIn = 32

const SF_ComplexResult = 262144

const SF_Compound = 256

const SF_Converted = 65536

const SF_CopyCte = 67108864

const SF_Correlated = 536870912

const SF_Distinct = 1

const SF_Expanded = 64

const SF_FixedLimit = 16384

const SF_HasAgg = 16

const SF_HasTypeInfo = 128

const SF_IncludeHidden = 131072

const SF_MinMaxAgg = 4096

const SF_MultiPart = 33554432

const SF_MultiValue = 1024

const SF_NestedFrom = 2048

const SF_OnToWhere = 1073741824

const SF_OrderByReqd = 134217728

const SF_PushDown = 16777216

const SF_Recursive = 8192

const SF_Resolved = 4

const SF_UFSrcCheck = 8388608

const SF_UpdateFrom = 268435456

const SF_Values = 512

const SF_View = 2097152

const SF_WhereBegin = 524288

const SF_WinRewrite = 1048576

const SHARED_FIRST = 2

const SHARED_LOCK = 1

const SHARED_SIZE = 510

const SLOT_2_0 = 2080895

const SLOT_4_2_0 = 4028612735

const SORTER_MAX_MERGE_COUNT = 16

const SORTER_TYPE_INTEGER = 1

const SORTER_TYPE_TEXT = 2

const SORTFLAG_UseSorter = 1

const SPILLFLAG_NOSYNC = 4

const SPILLFLAG_OFF = 1

const SPILLFLAG_ROLLBACK = 2

const SQLITE3_TEXT = 3

const SQLITE_ABORT = 4

const SQLITE_ABORT_ROLLBACK = 516

const SQLITE_ACCESS_EXISTS = 0

const SQLITE_ACCESS_READ = 2

const SQLITE_ACCESS_READWRITE = 1

const SQLITE_AFF_BLOB = 65

const SQLITE_AFF_DEFER = 88

const SQLITE_AFF_FLEXNUM = 70

const SQLITE_AFF_INTEGER = 68

const SQLITE_AFF_MASK = 71

const SQLITE_AFF_NONE = 64

const SQLITE_AFF_NUMERIC = 67

const SQLITE_AFF_REAL = 69

const SQLITE_AFF_TEXT = 66

const SQLITE_ALLOW_COVERING_INDEX_SCAN = 1

const SQLITE_ALTER_TABLE = 26

const SQLITE_AMALGAMATION = 1

const SQLITE_ANALYZE = 28

const SQLITE_ANY = 5

const SQLITE_ASCII = 1

const SQLITE_ATOMIC_INTRINSICS = 1

const SQLITE_ATTACH = 24

const SQLITE_AUTH = 23

const SQLITE_AUTH_USER = 279

const SQLITE_AllOpts = 4294967295

const SQLITE_AutoIndex = 32768

const SQLITE_BIG_DBL = 1e+99

const SQLITE_BLDF1_INDEXED = 1

const SQLITE_BLDF1_UNIQUE = 2

const SQLITE_BLDF2_2NDPASS = 4

const SQLITE_BLOB = 4

const SQLITE_BUSY = 5

const SQLITE_BUSY_RECOVERY = 261

const SQLITE_BUSY_SNAPSHOT = 517

const SQLITE_BUSY_TIMEOUT = 773

const SQLITE_BalancedMerge = 2097152

const SQLITE_BloomFilter = 524288

const SQLITE_BloomPulldown = 1048576

const SQLITE_CANTOPEN = 14

const SQLITE_CANTOPEN_BKPT = 0

const SQLITE_CANTOPEN_CONVPATH = 1038

const SQLITE_CANTOPEN_DIRTYWAL = 1294

const SQLITE_CANTOPEN_FULLPATH = 782

const SQLITE_CANTOPEN_ISDIR = 526

const SQLITE_CANTOPEN_NOTEMPDIR = 270

const SQLITE_CANTOPEN_SYMLINK = 1550

const SQLITE_CARRAY_BLOB = 4

const SQLITE_CARRAY_DOUBLE = 2

const SQLITE_CARRAY_INT32 = 0

const SQLITE_CARRAY_INT64 = 1

const SQLITE_CARRAY_TEXT = 3

const SQLITE_CHANGEGROUP_CONFIG_PATCHSET = 1

const SQLITE_CHANGESETAPPLY_FKNOACTION = 8

const SQLITE_CHANGESETAPPLY_IGNORENOOP = 4

const SQLITE_CHANGESETAPPLY_INVERT = 2

const SQLITE_CHANGESETAPPLY_NOSAVEPOINT = 1

const SQLITE_CHANGESETAPPLY_NOUPDATELOOP = 16

const SQLITE_CHANGESETSTART_INVERT = 2

const SQLITE_CHANGESET_ABORT = 2

const SQLITE_CHANGESET_CONFLICT = 3

const SQLITE_CHANGESET_CONSTRAINT = 4

const SQLITE_CHANGESET_DATA = 1

const SQLITE_CHANGESET_FOREIGN_KEY = 5

const SQLITE_CHANGESET_NOTFOUND = 2

const SQLITE_CHANGESET_OMIT = 0

const SQLITE_CHANGESET_REPLACE = 1

const SQLITE_CHECKPOINT_FULL = 1

const SQLITE_CHECKPOINT_NOOP = -1

const SQLITE_CHECKPOINT_PASSIVE = 0

const SQLITE_CHECKPOINT_RESTART = 2

const SQLITE_CHECKPOINT_TRUNCATE = 3

const SQLITE_CONFIG_COVERING_INDEX_SCAN = 20

const SQLITE_CONFIG_GETMALLOC = 5

const SQLITE_CONFIG_GETMUTEX = 11

const SQLITE_CONFIG_GETPCACHE = 15

const SQLITE_CONFIG_GETPCACHE2 = 19

const SQLITE_CONFIG_HEAP = 8

const SQLITE_CONFIG_LOG = 16

const SQLITE_CONFIG_LOOKASIDE = 13

const SQLITE_CONFIG_MALLOC = 4

const SQLITE_CONFIG_MEMDB_MAXSIZE = 29

const SQLITE_CONFIG_MEMSTATUS = 9

const SQLITE_CONFIG_MMAP_SIZE = 22

const SQLITE_CONFIG_MULTITHREAD = 2

const SQLITE_CONFIG_MUTEX = 10

const SQLITE_CONFIG_PAGECACHE = 7

const SQLITE_CONFIG_PCACHE = 14

const SQLITE_CONFIG_PCACHE2 = 18

const SQLITE_CONFIG_PCACHE_HDRSZ = 24

const SQLITE_CONFIG_PMASZ = 25

const SQLITE_CONFIG_ROWID_IN_VIEW = 30

const SQLITE_CONFIG_SCRATCH = 6

const SQLITE_CONFIG_SERIALIZED = 3

const SQLITE_CONFIG_SINGLETHREAD = 1

const SQLITE_CONFIG_SMALL_MALLOC = 27

const SQLITE_CONFIG_SORTERREF_SIZE = 28

const SQLITE_CONFIG_SQLLOG = 21

const SQLITE_CONFIG_STMTJRNL_SPILL = 26

const SQLITE_CONFIG_URI = 17

const SQLITE_CONFIG_WIN32_HEAPSIZE = 23

const SQLITE_CONSTRAINT = 19

const SQLITE_CONSTRAINT_CHECK = 275

const SQLITE_CONSTRAINT_COMMITHOOK = 531

const SQLITE_CONSTRAINT_DATATYPE = 3091

const SQLITE_CONSTRAINT_FOREIGNKEY = 787

const SQLITE_CONSTRAINT_FUNCTION = 1043

const SQLITE_CONSTRAINT_NOTNULL = 1299

const SQLITE_CONSTRAINT_PINNED = 2835

const SQLITE_CONSTRAINT_PRIMARYKEY = 1555

const SQLITE_CONSTRAINT_ROWID = 2579

const SQLITE_CONSTRAINT_TRIGGER = 1811

const SQLITE_CONSTRAINT_UNIQUE = 2067

const SQLITE_CONSTRAINT_VTAB = 2323

const SQLITE_COPY = 0

const SQLITE_CORE = 1

const SQLITE_CORRUPT = 11

const SQLITE_CORRUPT_BKPT = 0

const SQLITE_CORRUPT_INDEX = 779

const SQLITE_CORRUPT_SEQUENCE = 523

const SQLITE_CORRUPT_VTAB = 267

const SQLITE_CREATE_INDEX = 1

const SQLITE_CREATE_TABLE = 2

const SQLITE_CREATE_TEMP_INDEX = 3

const SQLITE_CREATE_TEMP_TABLE = 4

const SQLITE_CREATE_TEMP_TRIGGER = 5

const SQLITE_CREATE_TEMP_VIEW = 6

const SQLITE_CREATE_TRIGGER = 7

const SQLITE_CREATE_VIEW = 8

const SQLITE_CREATE_VTABLE = 29

const SQLITE_CacheSpill = 32

const SQLITE_CellSizeCk = 2097152

const SQLITE_CkptFullFSync = 16

const SQLITE_Coroutines = 33554432

const SQLITE_CountOfView = 512

const SQLITE_CoverIdxScan = 32

const SQLITE_CursorHints = 1024

const SQLITE_DBCONFIG_DEFENSIVE = 1010

const SQLITE_DBCONFIG_DQS_DDL = 1014

const SQLITE_DBCONFIG_DQS_DML = 1013

const SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE = 1020

const SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE = 1021

const SQLITE_DBCONFIG_ENABLE_COMMENTS = 1022

const SQLITE_DBCONFIG_ENABLE_FKEY = 1002

const SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER = 1004

const SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION = 1005

const SQLITE_DBCONFIG_ENABLE_QPSG = 1007

const SQLITE_DBCONFIG_ENABLE_TRIGGER = 1003

const SQLITE_DBCONFIG_ENABLE_VIEW = 1015

const SQLITE_DBCONFIG_FP_DIGITS = 1023

const SQLITE_DBCONFIG_LEGACY_ALTER_TABLE = 1012

const SQLITE_DBCONFIG_LEGACY_FILE_FORMAT = 1016

const SQLITE_DBCONFIG_LOOKASIDE = 1001

const SQLITE_DBCONFIG_MAINDBNAME = 1000

const SQLITE_DBCONFIG_MAX = 1023

const SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE = 1006

const SQLITE_DBCONFIG_RESET_DATABASE = 1009

const SQLITE_DBCONFIG_REVERSE_SCANORDER = 1019

const SQLITE_DBCONFIG_STMT_SCANSTATUS = 1018

const SQLITE_DBCONFIG_TRIGGER_EQP = 1008

const SQLITE_DBCONFIG_TRUSTED_SCHEMA = 1017

const SQLITE_DBCONFIG_WRITABLE_SCHEMA = 1011

const SQLITE_DBSTATUS_CACHE_HIT = 7

const SQLITE_DBSTATUS_CACHE_MISS = 8

const SQLITE_DBSTATUS_CACHE_SPILL = 12

const SQLITE_DBSTATUS_CACHE_USED = 1

const SQLITE_DBSTATUS_CACHE_USED_SHARED = 11

const SQLITE_DBSTATUS_CACHE_WRITE = 9

const SQLITE_DBSTATUS_DEFERRED_FKS = 10

const SQLITE_DBSTATUS_LOOKASIDE_HIT = 4

const SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL = 6

const SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE = 5

const SQLITE_DBSTATUS_LOOKASIDE_USED = 0

const SQLITE_DBSTATUS_MAX = 13

const SQLITE_DBSTATUS_SCHEMA_USED = 2

const SQLITE_DBSTATUS_STMT_USED = 3

const SQLITE_DBSTATUS_TEMPBUF_SPILL = 13

const SQLITE_DEFAULT_AUTOVACUUM = 0

const SQLITE_DEFAULT_CACHE_SIZE = -2000

const SQLITE_DEFAULT_FILE_FORMAT = 4

const SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT = -1

const SQLITE_DEFAULT_LOOKASIDE = 40

const SQLITE_DEFAULT_MEMSTATUS = 0

const SQLITE_DEFAULT_MMAP_SIZE = 0

const SQLITE_DEFAULT_OPTIMIZE_LIMIT = 2000

const SQLITE_DEFAULT_PAGE_SIZE = 4096

const SQLITE_DEFAULT_PCACHE_INITSZ = 20

const SQLITE_DEFAULT_RECURSIVE_TRIGGERS = 0

const SQLITE_DEFAULT_SECTOR_SIZE = 4096

const SQLITE_DEFAULT_SORTERREF_SIZE = 2147483647

const SQLITE_DEFAULT_SYNCHRONOUS = 2

const SQLITE_DEFAULT_WAL_AUTOCHECKPOINT = 1000

const SQLITE_DEFAULT_WAL_SYNCHRONOUS = 2

const SQLITE_DEFAULT_WORKER_THREADS = 0

const SQLITE_DELETE = 9

const SQLITE_DENY = 1

const SQLITE_DESERIALIZE_FREEONCLOSE = 1

const SQLITE_DESERIALIZE_READONLY = 4

const SQLITE_DESERIALIZE_RESIZEABLE = 2

const SQLITE_DETACH = 25

const SQLITE_DETERMINISTIC = 2048

const SQLITE_DIGIT_SEPARATOR = 95

const SQLITE_DIRECTONLY = 524288

const SQLITE_DIRECT_OVERFLOW_READ = 1

const SQLITE_DISABLE_INTRINSIC = 1

const SQLITE_DONE = 101

const SQLITE_DQS = 3

const SQLITE_DROP_INDEX = 10

const SQLITE_DROP_TABLE = 11

const SQLITE_DROP_TEMP_INDEX = 12

const SQLITE_DROP_TEMP_TABLE = 13

const SQLITE_DROP_TEMP_TRIGGER = 14

const SQLITE_DROP_TEMP_VIEW = 15

const SQLITE_DROP_TRIGGER = 16

const SQLITE_DROP_VIEW = 17

const SQLITE_DROP_VTABLE = 30

const SQLITE_Defensive = 268435456

const SQLITE_DeferFKs = 524288

const SQLITE_DistinctOpt = 16

const SQLITE_DqsDDL = 536870912

const SQLITE_DqsDML = 1073741824

const SQLITE_ECEL_DUP = 1

const SQLITE_ECEL_FACTOR = 2

const SQLITE_ECEL_OMITREF = 8

const SQLITE_ECEL_REF = 4

const SQLITE_EMPTY = 16

const SQLITE_ENABLE_COLUMN_METADATA = 1

const SQLITE_ENABLE_DBPAGE_VTAB = 1

const SQLITE_ENABLE_DBSTAT_VTAB = 1

const SQLITE_ENABLE_FTS5 = 1

const SQLITE_ENABLE_GEOPOLY = 1

const SQLITE_ENABLE_JSON1 = 1

const SQLITE_ENABLE_MATH_FUNCTIONS = 1

const SQLITE_ENABLE_MEMORY_MANAGEMENT = 1

const SQLITE_ENABLE_OFFSET_SQL_FUNC = 1

const SQLITE_ENABLE_PREUPDATE_HOOK = 1

const SQLITE_ENABLE_RBU = 1

const SQLITE_ENABLE_RTREE = 1

const SQLITE_ENABLE_SESSION = 1

const SQLITE_ENABLE_SNAPSHOT = 1

const SQLITE_ENABLE_STAT4 = 1

const SQLITE_ENABLE_UNLOCK_NOTIFY = 1

const SQLITE_ERROR = 1

const SQLITE_ERROR_KEY = 1281

const SQLITE_ERROR_MISSING_COLLSEQ = 257

const SQLITE_ERROR_RESERVESIZE = 1025

const SQLITE_ERROR_RETRY = 513

const SQLITE_ERROR_SNAPSHOT = 769

const SQLITE_ERROR_UNABLE = 1537

const SQLITE_EXTERN = 0

const SQLITE_EnableQPSG = 8388608

const SQLITE_EnableTrigger = 262144

const SQLITE_EnableView = 2147483648

const SQLITE_ExistsToJoin = 1073741824

const SQLITE_FAIL = 3

const SQLITE_FAULTINJECTOR_COUNT = 1

const SQLITE_FAULTINJECTOR_MALLOC = 0

const SQLITE_FCNTL_BEGIN_ATOMIC_WRITE = 31

const SQLITE_FCNTL_BLOCK_ON_CONNECT = 44

const SQLITE_FCNTL_BUSYHANDLER = 15

const SQLITE_FCNTL_CHUNK_SIZE = 6

const SQLITE_FCNTL_CKPT_DONE = 37

const SQLITE_FCNTL_CKPT_START = 39

const SQLITE_FCNTL_CKSM_FILE = 41

const SQLITE_FCNTL_COMMIT_ATOMIC_WRITE = 32

const SQLITE_FCNTL_COMMIT_PHASETWO = 22

const SQLITE_FCNTL_DATA_VERSION = 35

const SQLITE_FCNTL_DB_UNCHANGED = 3389603744

const SQLITE_FCNTL_EXTERNAL_READER = 40

const SQLITE_FCNTL_FILESTAT = 45

const SQLITE_FCNTL_FILE_POINTER = 7

const SQLITE_FCNTL_GET_LOCKPROXYFILE = 2

const SQLITE_FCNTL_HAS_MOVED = 20

const SQLITE_FCNTL_JOURNAL_POINTER = 28

const SQLITE_FCNTL_LAST_ERRNO = 4

const SQLITE_FCNTL_LOCKSTATE = 1

const SQLITE_FCNTL_LOCK_TIMEOUT = 34

const SQLITE_FCNTL_MMAP_SIZE = 18

const SQLITE_FCNTL_NULL_IO = 43

const SQLITE_FCNTL_OVERWRITE = 11

const SQLITE_FCNTL_PDB = 30

const SQLITE_FCNTL_PERSIST_WAL = 10

const SQLITE_FCNTL_POWERSAFE_OVERWRITE = 13

const SQLITE_FCNTL_PRAGMA = 14

const SQLITE_FCNTL_RBU = 26

const SQLITE_FCNTL_RBUCNT = 5149216

const SQLITE_FCNTL_RESERVE_BYTES = 38

const SQLITE_FCNTL_RESET_CACHE = 42

const SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE = 33

const SQLITE_FCNTL_SET_LOCKPROXYFILE = 3

const SQLITE_FCNTL_SIZE_HINT = 5

const SQLITE_FCNTL_SIZE_LIMIT = 36

const SQLITE_FCNTL_SYNC = 21

const SQLITE_FCNTL_SYNC_OMITTED = 8

const SQLITE_FCNTL_TEMPFILENAME = 16

const SQLITE_FCNTL_TRACE = 19

const SQLITE_FCNTL_VFSNAME = 12

const SQLITE_FCNTL_VFS_POINTER = 27

const SQLITE_FCNTL_WAL_BLOCK = 24

const SQLITE_FCNTL_WIN32_AV_RETRY = 9

const SQLITE_FCNTL_WIN32_GET_HANDLE = 29

const SQLITE_FCNTL_WIN32_SET_HANDLE = 23

const SQLITE_FCNTL_ZIPVFS = 25

const SQLITE_FILE_HEADER = "SQLite format 3"

const SQLITE_FLOAT = 2

const SQLITE_FORMAT = 24

const SQLITE_FP_PRECISION_LIMIT = 100000000

const SQLITE_FRAME_MAGIC = 2275391262

const SQLITE_FTS5_MAX_EXPR_DEPTH = 256

const SQLITE_FULL = 13

const SQLITE_FUNCTION = 31

const SQLITE_FUNC_ANYORDER = 134217728

const SQLITE_FUNC_BUILTIN = 8388608

const SQLITE_FUNC_BYTELEN = 192

const SQLITE_FUNC_CASE = 8

const SQLITE_FUNC_CONSTANT = 2048

const SQLITE_FUNC_COUNT = 256

const SQLITE_FUNC_DIRECT = 524288

const SQLITE_FUNC_ENCMASK = 3

const SQLITE_FUNC_EPHEM = 16

const SQLITE_FUNC_HASH_SZ = 23

const SQLITE_FUNC_INLINE = 4194304

const SQLITE_FUNC_INTERNAL = 262144

const SQLITE_FUNC_LENGTH = 64

const SQLITE_FUNC_LIKE = 4

const SQLITE_FUNC_MINMAX = 4096

const SQLITE_FUNC_NEEDCOLL = 32

const SQLITE_FUNC_RUNONLY = 32768

const SQLITE_FUNC_SLOCHNG = 8192

const SQLITE_FUNC_TEST = 16384

const SQLITE_FUNC_TYPEOF = 128

const SQLITE_FUNC_UNLIKELY = 1024

const SQLITE_FUNC_UNSAFE = 2097152

const SQLITE_FUNC_WINDOW = 65536

const SQLITE_FactorOutConst = 8

const SQLITE_FlttnUnionAll = 8388608

const SQLITE_ForeignKeys = 16384

const SQLITE_Fts3Tokenizer = 4194304

const SQLITE_FullColNames = 4

const SQLITE_FullFSync = 8

const SQLITE_GET_LOCKPROXYFILE = 2

const SQLITE_GroupByOrder = 4

const SQLITE_HAVE_C99_MATH_FUNCS = 1

const SQLITE_HAVE_ZLIB = 1

const SQLITE_IDXTYPE_APPDEF = 0

const SQLITE_IDXTYPE_IPK = 3

const SQLITE_IDXTYPE_PRIMARYKEY = 2

const SQLITE_IDXTYPE_UNIQUE = 1

const SQLITE_IGNORE = 2

const SQLITE_INDEX_CONSTRAINT_EQ = 2

const SQLITE_INDEX_CONSTRAINT_FUNCTION = 150

const SQLITE_INDEX_CONSTRAINT_GE = 32

const SQLITE_INDEX_CONSTRAINT_GLOB = 66

const SQLITE_INDEX_CONSTRAINT_GT = 4

const SQLITE_INDEX_CONSTRAINT_IS = 72

const SQLITE_INDEX_CONSTRAINT_ISNOT = 69

const SQLITE_INDEX_CONSTRAINT_ISNOTNULL = 70

const SQLITE_INDEX_CONSTRAINT_ISNULL = 71

const SQLITE_INDEX_CONSTRAINT_LE = 8

const SQLITE_INDEX_CONSTRAINT_LIKE = 65

const SQLITE_INDEX_CONSTRAINT_LIMIT = 73

const SQLITE_INDEX_CONSTRAINT_LT = 16

const SQLITE_INDEX_CONSTRAINT_MATCH = 64

const SQLITE_INDEX_CONSTRAINT_NE = 68

const SQLITE_INDEX_CONSTRAINT_OFFSET = 74

const SQLITE_INDEX_CONSTRAINT_REGEXP = 67

const SQLITE_INDEX_SCAN_HEX = 2

const SQLITE_INDEX_SCAN_UNIQUE = 1

const SQLITE_INNOCUOUS = 2097152

const SQLITE_INSERT = 18

const SQLITE_INTEGER = 1

const SQLITE_INTEGRITY_CHECK_ERROR_MAX = 100

const SQLITE_INTERNAL = 2

const SQLITE_INTERRUPT = 9

const SQLITE_IOCAP_ATOMIC = 1

const SQLITE_IOCAP_ATOMIC16K = 64

const SQLITE_IOCAP_ATOMIC1K = 4

const SQLITE_IOCAP_ATOMIC2K = 8

const SQLITE_IOCAP_ATOMIC32K = 128

const SQLITE_IOCAP_ATOMIC4K = 16

const SQLITE_IOCAP_ATOMIC512 = 2

const SQLITE_IOCAP_ATOMIC64K = 256

const SQLITE_IOCAP_ATOMIC8K = 32

const SQLITE_IOCAP_BATCH_ATOMIC = 16384

const SQLITE_IOCAP_IMMUTABLE = 8192

const SQLITE_IOCAP_POWERSAFE_OVERWRITE = 4096

const SQLITE_IOCAP_SAFE_APPEND = 512

const SQLITE_IOCAP_SEQUENTIAL = 1024

const SQLITE_IOCAP_SUBPAGE_READ = 32768

const SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN = 2048

const SQLITE_IOERR = 10

const SQLITE_IOERR_ACCESS = 3338

const SQLITE_IOERR_AUTH = 7178

const SQLITE_IOERR_BADKEY = 8970

const SQLITE_IOERR_BEGIN_ATOMIC = 7434

const SQLITE_IOERR_BLOCKED = 2826

const SQLITE_IOERR_CHECKRESERVEDLOCK = 3594

const SQLITE_IOERR_CLOSE = 4106

const SQLITE_IOERR_CODEC = 9226

const SQLITE_IOERR_COMMIT_ATOMIC = 7690

const SQLITE_IOERR_CONVPATH = 6666

const SQLITE_IOERR_CORRUPTFS = 8458

const SQLITE_IOERR_DATA = 8202

const SQLITE_IOERR_DELETE = 2570

const SQLITE_IOERR_DELETE_NOENT = 5898

const SQLITE_IOERR_DIR_CLOSE = 4362

const SQLITE_IOERR_DIR_FSYNC = 1290

const SQLITE_IOERR_FSTAT = 1802

const SQLITE_IOERR_FSYNC = 1034

const SQLITE_IOERR_GETTEMPPATH = 6410

const SQLITE_IOERR_IN_PAGE = 8714

const SQLITE_IOERR_LOCK = 3850

const SQLITE_IOERR_MMAP = 6154

const SQLITE_IOERR_NOMEM = 3082

const SQLITE_IOERR_NOMEM_BKPT = 3082

const SQLITE_IOERR_RDLOCK = 2314

const SQLITE_IOERR_READ = 266

const SQLITE_IOERR_ROLLBACK_ATOMIC = 7946

const SQLITE_IOERR_SEEK = 5642

const SQLITE_IOERR_SHMLOCK = 5130

const SQLITE_IOERR_SHMMAP = 5386

const SQLITE_IOERR_SHMOPEN = 4618

const SQLITE_IOERR_SHMSIZE = 4874

const SQLITE_IOERR_SHORT_READ = 522

const SQLITE_IOERR_TRUNCATE = 1546

const SQLITE_IOERR_UNLOCK = 2058

const SQLITE_IOERR_VNODE = 6922

const SQLITE_IOERR_WRITE = 778

const SQLITE_IgnoreChecks = 512

const SQLITE_IndexedExpr = 16777216

const SQLITE_JUMPIFNULL = 16

const SQLITE_LAST_ERRNO = 4

const SQLITE_LIKE_DOESNT_MATCH_BLOBS = 1

const SQLITE_LIMIT_ATTACHED = 7

const SQLITE_LIMIT_COLUMN = 2

const SQLITE_LIMIT_COMPOUND_SELECT = 4

const SQLITE_LIMIT_EXPR_DEPTH = 3

const SQLITE_LIMIT_FUNCTION_ARG = 6

const SQLITE_LIMIT_LENGTH = 0

const SQLITE_LIMIT_LIKE_PATTERN_LENGTH = 8

const SQLITE_LIMIT_PARSER_DEPTH = 12

const SQLITE_LIMIT_SQL_LENGTH = 1

const SQLITE_LIMIT_TRIGGER_DEPTH = 10

const SQLITE_LIMIT_VARIABLE_NUMBER = 9

const SQLITE_LIMIT_VDBE_OP = 5

const SQLITE_LIMIT_WORKER_THREADS = 11

const SQLITE_LOCKED = 6

const SQLITE_LOCKED_SHAREDCACHE = 262

const SQLITE_LOCKED_VTAB = 518

const SQLITE_LOCK_EXCLUSIVE = 4

const SQLITE_LOCK_NONE = 0

const SQLITE_LOCK_PENDING = 3

const SQLITE_LOCK_RESERVED = 2

const SQLITE_LOCK_SHARED = 1

const SQLITE_LegacyAlter = 67108864

const SQLITE_LegacyFileFmt = 2

const SQLITE_LoadExtFunc = 131072

const SQLITE_LoadExtension = 65536

const SQLITE_MALLOC_SOFT_LIMIT = 1024

const SQLITE_MATCH = 0

const SQLITE_MAX_ALLOCATION_SIZE = 2147483391

const SQLITE_MAX_ATTACHED = 10

const SQLITE_MAX_COLUMN = 2000

const SQLITE_MAX_COMPOUND_SELECT = 500

const SQLITE_MAX_DB = 12

const SQLITE_MAX_DEFAULT_PAGE_SIZE = 8192

const SQLITE_MAX_EXPR_DEPTH = 1000

const SQLITE_MAX_FILE_FORMAT = 4

const SQLITE_MAX_FUNCTION_ARG = 1000

const SQLITE_MAX_LENGTH = 1000000000

const SQLITE_MAX_LIKE_PATTERN_LENGTH = 50000

const SQLITE_MAX_LOG_MESSAGE = 700

const SQLITE_MAX_MEMORY = 0

const SQLITE_MAX_PAGE_COUNT = 4294967294

const SQLITE_MAX_PAGE_SIZE = 65536

const SQLITE_MAX_PARSER_DEPTH = 2500

const SQLITE_MAX_PMASZ = 536870912

const SQLITE_MAX_PREPARE_RETRY = 25

const SQLITE_MAX_SCHEMA_RETRY = 50

const SQLITE_MAX_SQL_LENGTH = 1000000000

const SQLITE_MAX_SRCLIST = 200

const SQLITE_MAX_SYMLINK = 200

const SQLITE_MAX_TRIGGER_DEPTH = 1000

const SQLITE_MAX_VARIABLE_NUMBER = 32766

const SQLITE_MAX_VDBE_OP = 250000000

const SQLITE_MAX_WORKER_THREADS = 8

const SQLITE_MEMDB_DEFAULT_MAXSIZE = 1073741824

const SQLITE_MIN_LENGTH = 30

const SQLITE_MISMATCH = 20

const SQLITE_MISUSE = 21

const SQLITE_MISUSE_BKPT = 0

const SQLITE_MUTEX_FAST = 0

const SQLITE_MUTEX_RECURSIVE = 1

const SQLITE_MUTEX_STATIC_APP1 = 8

const SQLITE_MUTEX_STATIC_APP2 = 9

const SQLITE_MUTEX_STATIC_APP3 = 10

const SQLITE_MUTEX_STATIC_LRU = 6

const SQLITE_MUTEX_STATIC_LRU2 = 7

const SQLITE_MUTEX_STATIC_MAIN = 2

const SQLITE_MUTEX_STATIC_MASTER = 2

const SQLITE_MUTEX_STATIC_MEM = 3

const SQLITE_MUTEX_STATIC_MEM2 = 4

const SQLITE_MUTEX_STATIC_OPEN = 4

const SQLITE_MUTEX_STATIC_PMEM = 7

const SQLITE_MUTEX_STATIC_PRNG = 5

const SQLITE_MUTEX_STATIC_TEMPDIR = 11

const SQLITE_MUTEX_STATIC_VFS1 = 11

const SQLITE_MUTEX_STATIC_VFS2 = 12

const SQLITE_MUTEX_STATIC_VFS3 = 13

const SQLITE_MX_JUMP_OPCODE = 66

const SQLITE_MinMaxOpt = 65536

const SQLITE_NOLFS = 22

const SQLITE_NOMATCH = 1

const SQLITE_NOMEM = 7

const SQLITE_NOMEM_BKPT = 7

const SQLITE_NOTADB = 26

const SQLITE_NOTFOUND = 12

const SQLITE_NOTICE = 27

const SQLITE_NOTICE_RBU = 795

const SQLITE_NOTICE_RECOVER_ROLLBACK = 539

const SQLITE_NOTICE_RECOVER_WAL = 283

const SQLITE_NOTNULL = 144

const SQLITE_NOWILDCARDMATCH = 2

const SQLITE_NTUNE = 6

const SQLITE_NULL = 5

const SQLITE_NULLEQ = 128

const SQLITE_N_BTREE_META = 16

const SQLITE_N_KEYWORD = 147

const SQLITE_N_LIMIT = 13

const SQLITE_N_STDTYPE = 6

const SQLITE_NoCkptOnClose = 2048

const SQLITE_NoSchemaError = 134217728

const SQLITE_NullCallback = 256

const SQLITE_NullUnusedCols = 67108864

const SQLITE_OK = 0

const SQLITE_OK_LOAD_PERMANENTLY = 256

const SQLITE_OK_SYMLINK = 512

const SQLITE_OPEN_AUTOPROXY = 32

const SQLITE_OPEN_CREATE = 4

const SQLITE_OPEN_DELETEONCLOSE = 8

const SQLITE_OPEN_EXCLUSIVE = 16

const SQLITE_OPEN_EXRESCODE = 33554432

const SQLITE_OPEN_FULLMUTEX = 65536

const SQLITE_OPEN_MAIN_DB = 256

const SQLITE_OPEN_MAIN_JOURNAL = 2048

const SQLITE_OPEN_MASTER_JOURNAL = 16384

const SQLITE_OPEN_MEMORY = 128

const SQLITE_OPEN_NOFOLLOW = 16777216

const SQLITE_OPEN_NOMUTEX = 32768

const SQLITE_OPEN_PRIVATECACHE = 262144

const SQLITE_OPEN_READONLY = 1

const SQLITE_OPEN_READWRITE = 2

const SQLITE_OPEN_SHAREDCACHE = 131072

const SQLITE_OPEN_SUBJOURNAL = 8192

const SQLITE_OPEN_SUPER_JOURNAL = 16384

const SQLITE_OPEN_TEMP_DB = 512

const SQLITE_OPEN_TEMP_JOURNAL = 4096

const SQLITE_OPEN_TRANSIENT_DB = 1024

const SQLITE_OPEN_URI = 64

const SQLITE_OPEN_WAL = 524288

const SQLITE_OmitNoopJoin = 256

const SQLITE_OmitOrderBy = 262144

const SQLITE_OnePass = 134217728

const SQLITE_OrderByIdxJoin = 64

const SQLITE_OrderBySubq = 268435456

const SQLITE_PERM = 3

const SQLITE_POWERSAFE_OVERWRITE = 1

const SQLITE_PRAGMA = 19

const SQLITE_PREPARE_DONT_LOG = 16

const SQLITE_PREPARE_FROM_DDL = 32

const SQLITE_PREPARE_MASK = 63

const SQLITE_PREPARE_NORMALIZE = 2

const SQLITE_PREPARE_NO_VTAB = 4

const SQLITE_PREPARE_PERSISTENT = 1

const SQLITE_PREPARE_SAVESQL = 128

const SQLITE_PRINTF_INTERNAL = 1

const SQLITE_PRINTF_MALLOCED = 4

const SQLITE_PRINTF_SQLFUNC = 2

const SQLITE_PRINT_BUF_SIZE = 70

const SQLITE_PRIVATE = 0

const SQLITE_PROTOCOL = 15

const SQLITE_PropagateConst = 32768

const SQLITE_PushDown = 4096

const SQLITE_QUERY_PLANNER_LIMIT = 20000

const SQLITE_QUERY_PLANNER_LIMIT_INCR = 1000

const SQLITE_QueryFlattener = 1

const SQLITE_QueryOnly = 1048576

const SQLITE_RANGE = 25

const SQLITE_RBU_STATE_CHECKPOINT = 3

const SQLITE_RBU_STATE_DONE = 4

const SQLITE_RBU_STATE_ERROR = 5

const SQLITE_RBU_STATE_MOVE = 2

const SQLITE_RBU_STATE_OAL = 1

const SQLITE_RBU_UPDATE_CACHESIZE = 16

const SQLITE_READ = 20

const SQLITE_READONLY = 8

const SQLITE_READONLY_CANTINIT = 1288

const SQLITE_READONLY_CANTLOCK = 520

const SQLITE_READONLY_DBMOVED = 1032

const SQLITE_READONLY_DIRECTORY = 1544

const SQLITE_READONLY_RECOVERY = 264

const SQLITE_READONLY_ROLLBACK = 776

const SQLITE_RECURSIVE = 33

const SQLITE_REINDEX = 27

const SQLITE_REPLACE = 5

const SQLITE_RESULT_SUBTYPE = 16777216

const SQLITE_ROLLBACK = 1

const SQLITE_ROW = 100

const SQLITE_RecTriggers = 8192

const SQLITE_ReleaseReg = 4194304

const SQLITE_ResetDatabase = 33554432

const SQLITE_ReverseOrder = 4096

const SQLITE_SAVEPOINT = 32

const SQLITE_SCANSTAT_COMPLEX = 1

const SQLITE_SCANSTAT_EST = 2

const SQLITE_SCANSTAT_EXPLAIN = 4

const SQLITE_SCANSTAT_NAME = 3

const SQLITE_SCANSTAT_NCYCLE = 7

const SQLITE_SCANSTAT_NLOOP = 0

const SQLITE_SCANSTAT_NVISIT = 1

const SQLITE_SCANSTAT_PARENTID = 6

const SQLITE_SCANSTAT_SELECTID = 5

const SQLITE_SCHEMA = 17

const SQLITE_SCM_BRANCH = "branch-3.53"

const SQLITE_SCM_DATETIME = "2026-06-26T20:14:12.354Z"

const SQLITE_SCM_TAGS = "release version-3.53.3"

const SQLITE_SELECT = 21

const SQLITE_SELFORDER1 = 33554432

const SQLITE_SERIALIZE_NOCOPY = 1

const SQLITE_SESSION_CONFIG_STRMSIZE = 1

const SQLITE_SESSION_OBJCONFIG_ROWID = 2

const SQLITE_SESSION_OBJCONFIG_SIZE = 1

const SQLITE_SETLK_BLOCK_ON_CONNECT = 1

const SQLITE_SET_LOCKPROXYFILE = 3

const SQLITE_SHM_EXCLUSIVE = 8

const SQLITE_SHM_LOCK = 2

const SQLITE_SHM_NLOCK = 8

const SQLITE_SHM_SHARED = 4

const SQLITE_SHM_UNLOCK = 1

const SQLITE_SORTER_PMASZ = 250

const SQLITE_SOUNDEX = 1

const SQLITE_SOURCE_ID = "2026-06-26 20:14:12 d4c0e51e4aeb96955b99185ab9cde75c339e2c29c3f3f12428d364a10d782c62"

const SQLITE_SO_ASC = 0

const SQLITE_SO_DESC = 1

const SQLITE_SO_UNDEFINED = -1

const SQLITE_STAT4_SAMPLES = 24

const SQLITE_STATE_BUSY = 109

const SQLITE_STATE_CLOSED = 206

const SQLITE_STATE_ERROR = 213

const SQLITE_STATE_OPEN = 118

const SQLITE_STATE_SICK = 186

const SQLITE_STATE_ZOMBIE = 167

const SQLITE_STATUS_MALLOC_COUNT = 9

const SQLITE_STATUS_MALLOC_SIZE = 5

const SQLITE_STATUS_MEMORY_USED = 0

const SQLITE_STATUS_PAGECACHE_OVERFLOW = 2

const SQLITE_STATUS_PAGECACHE_SIZE = 7

const SQLITE_STATUS_PAGECACHE_USED = 1

const SQLITE_STATUS_PARSER_STACK = 6

const SQLITE_STATUS_SCRATCH_OVERFLOW = 4

const SQLITE_STATUS_SCRATCH_SIZE = 8

const SQLITE_STATUS_SCRATCH_USED = 3

const SQLITE_STDCALL = 0

const SQLITE_STMTJRNL_SPILL = 65536

const SQLITE_STMTSTATUS_AUTOINDEX = 3

const SQLITE_STMTSTATUS_FILTER_HIT = 8

const SQLITE_STMTSTATUS_FILTER_MISS = 7

const SQLITE_STMTSTATUS_FULLSCAN_STEP = 1

const SQLITE_STMTSTATUS_MEMUSED = 99

const SQLITE_STMTSTATUS_REPREPARE = 5

const SQLITE_STMTSTATUS_RUN = 6

const SQLITE_STMTSTATUS_SORT = 2

const SQLITE_STMTSTATUS_VM_STEP = 4

const SQLITE_SUBTYPE = 1048576

const SQLITE_SYNC_DATAONLY = 16

const SQLITE_SYNC_FULL = 3

const SQLITE_SYNC_NORMAL = 2

const SQLITE_SYSTEM_MALLOC = 1

const SQLITE_SeekScan = 131072

const SQLITE_ShortColNames = 64

const SQLITE_SimplifyJoin = 8192

const SQLITE_SkipScan = 16384

const SQLITE_StarQuery = 536870912

const SQLITE_Stat4 = 2048

const SQLITE_StmtScanStatus = 1024

const SQLITE_TEMP_FILE_PREFIX = "etilqs_"

const SQLITE_TEMP_STORE = 1

const SQLITE_TESTCTRL_ALWAYS = 13

const SQLITE_TESTCTRL_ASSERT = 12

const SQLITE_TESTCTRL_ATOF = 34

const SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS = 10

const SQLITE_TESTCTRL_BITVEC_TEST = 8

const SQLITE_TESTCTRL_BYTEORDER = 22

const SQLITE_TESTCTRL_EXPLAIN_STMT = 19

const SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS = 29

const SQLITE_TESTCTRL_FAULT_INSTALL = 9

const SQLITE_TESTCTRL_FIRST = 5

const SQLITE_TESTCTRL_FK_NO_ACTION = 7

const SQLITE_TESTCTRL_GETOPT = 16

const SQLITE_TESTCTRL_IMPOSTER = 25

const SQLITE_TESTCTRL_INTERNAL_FUNCTIONS = 17

const SQLITE_TESTCTRL_ISINIT = 23

const SQLITE_TESTCTRL_ISKEYWORD = 16

const SQLITE_TESTCTRL_JSON_SELFCHECK = 14

const SQLITE_TESTCTRL_LAST = 34

const SQLITE_TESTCTRL_LOCALTIME_FAULT = 18

const SQLITE_TESTCTRL_LOGEST = 33

const SQLITE_TESTCTRL_NEVER_CORRUPT = 20

const SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD = 19

const SQLITE_TESTCTRL_OPTIMIZATIONS = 15

const SQLITE_TESTCTRL_PARSER_COVERAGE = 26

const SQLITE_TESTCTRL_PENDING_BYTE = 11

const SQLITE_TESTCTRL_PRNG_RESET = 7

const SQLITE_TESTCTRL_PRNG_RESTORE = 6

const SQLITE_TESTCTRL_PRNG_SAVE = 5

const SQLITE_TESTCTRL_PRNG_SEED = 28

const SQLITE_TESTCTRL_RESERVE = 14

const SQLITE_TESTCTRL_RESULT_INTREAL = 27

const SQLITE_TESTCTRL_SCRATCHMALLOC = 17

const SQLITE_TESTCTRL_SEEK_COUNT = 30

const SQLITE_TESTCTRL_SORTER_MMAP = 24

const SQLITE_TESTCTRL_TRACEFLAGS = 31

const SQLITE_TESTCTRL_TUNE = 32

const SQLITE_TESTCTRL_USELONGDOUBLE = 34

const SQLITE_TESTCTRL_VDBE_COVERAGE = 21

const SQLITE_TEXT = 3

const SQLITE_THREADSAFE = 1

const SQLITE_TOKEN_KEYWORD = 2

const SQLITE_TOKEN_QUOTED = 1

const SQLITE_TOOBIG = 18

const SQLITE_TRACE_CLOSE = 8

const SQLITE_TRACE_LEGACY = 64

const SQLITE_TRACE_NONLEGACY_MASK = 15

const SQLITE_TRACE_PROFILE = 2

const SQLITE_TRACE_ROW = 4

const SQLITE_TRACE_STMT = 1

const SQLITE_TRACE_XPROFILE = 128

const SQLITE_TRANSACTION = 22

const SQLITE_TXN_NONE = 0

const SQLITE_TXN_READ = 1

const SQLITE_TXN_WRITE = 2

const SQLITE_Transitive = 128

const SQLITE_TriggerEQP = 16777216

const SQLITE_TrustedSchema = 128

const SQLITE_U64_DIGITS = 20

const SQLITE_UPDATE = 23

const SQLITE_USE_URI = 0

const SQLITE_UTF16 = 4

const SQLITE_UTF16BE = 3

const SQLITE_UTF16LE = 2

const SQLITE_UTF16_ALIGNED = 8

const SQLITE_UTF8 = 1

const SQLITE_UTF8_ZT = 16

const SQLITE_VERSION = "3.53.3"

const SQLITE_VERSION_NUMBER = 3053003

const SQLITE_VTABRISK_High = 2

const SQLITE_VTABRISK_Low = 0

const SQLITE_VTABRISK_Normal = 1

const SQLITE_VTAB_CONSTRAINT_SUPPORT = 1

const SQLITE_VTAB_DIRECTONLY = 3

const SQLITE_VTAB_INNOCUOUS = 2

const SQLITE_VTAB_USES_ALL_SCHEMAS = 4

const SQLITE_WARNING = 28

const SQLITE_WARNING_AUTOINDEX = 284

const SQLITE_WIN32_DATA_DIRECTORY_TYPE = 1

const SQLITE_WIN32_TEMP_DIRECTORY_TYPE = 2

const SQLITE_WITHOUT_ZONEMALLOC = 1

const SQLITE_WindowFunc = 2

const SQLITE_WriteSchema = 1

type SQLiteThread = TSQLiteThread

const SRT_Coroutine = 11

const SRT_Discard = 2

const SRT_DistFifo = 3

const SRT_DistQueue = 4

const SRT_EphemTab = 10

const SRT_Exists = 1

const SRT_Fifo = 6

const SRT_Mem = 8

const SRT_Output = 7

const SRT_Queue = 5

const SRT_Set = 9

const SRT_Table = 12

const SRT_Upfrom = 13

const STAT_GET_NDLT = 4

const STAT_GET_NEQ = 2

const STAT_GET_NLT = 3

const STAT_GET_ROWID = 1

const STAT_GET_STAT1 = 0

const STDERR_FILENO = 2

const STDIN_FILENO = 0

const STDOUT_FILENO = 1

const SZ_KEYINFO_0 = 0

type Savepoint = TSavepoint

type ScanStatus = TScanStatus

type Schema = TSchema

type Select = TSelect

type SelectDest = TSelectDest

type SessionApplyCtx = TSessionApplyCtx

/* Number of prepared UPDATE statements to cache. */

type SessionBuffer = TSessionBuffer

type SessionChange = TSessionChange

type SessionDiffCtx = TSessionDiffCtx

type SessionHook = TSessionHook

type SessionInput = TSessionInput

/*
** Minimum chunk size used by streaming versions of functions.
 */

type SessionStat1Ctx = TSessionStat1Ctx

type SessionTable = TSessionTable

type SessionUpdate = TSessionUpdate

type SortCtx = TSortCtx

type SortSubtask = TSortSubtask

type SorterCompare = TSorterCompare

type SorterFile = TSorterFile

type SorterList = TSorterList

type SorterRecord = TSorterRecord

type Sqlite3Config = TSqlite3Config

/************** End of sqliteInt.h *******************************************/
/************** Begin file os_common.h ***************************************/
/*
** 2004 May 22
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file contains macros and a little bit of code that is common to
** all of the platform-specific files (os_*.c) and is #included into those
** files.
**
** This file should be #included by the os_*.c files only.  It is not a
** general purpose header file.
 */

/*
** At least two bugs have slipped in because we changed the MEMORY_DEBUG
** macro to SQLITE_DEBUG and some older makefiles have not yet made the
** switch.  The following code should catch this problem at compile-time.
 */

/*
** Macros for performance tracing.  Normally turned off.  Only works
** on i486 hardware.
 */

/*
** If we compile with the SQLITE_TEST macro set, then the following block
** of code will give us the ability to simulate a disk I/O error.  This
** is used for testing the I/O recovery logic.
 */

/*
** When testing, keep a count of the number of open files.
 */

/************** End of os_common.h *******************************************/
/************** Begin file ctime.c *******************************************/
/* DO NOT EDIT!
** This file is automatically generated by the script in the canonical
** SQLite source tree at tool/mkctimec.tcl.
**
** To modify this header, edit any of the various lists in that script
** which specify categories of generated conditionals in this file.
 */

/*
** 2010 February 23
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file implements routines used to report what compile-time options
** SQLite was built with.
 */

/*
** Include the configuration header output by 'configure' if we're using the
** autoconf-based build
 */

/* These macros are provided to "stringify" the value of the define
** for those options in which the value is meaningful. */

/* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This
** option requires a separate macro because legal values contain a single
** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE="100,100") */
/* #include "sqliteInt.h" */

type Sqlite3_index_info = sqlite3_index_info

type Sqlite3_int64 = sqlite3_int64

type Sqlite3_module = sqlite3_module

type Sqlite3_mutex_methods = sqlite3_mutex_methods

type Sqlite3_value = sqlite3_value

type Sqlite3_vtab = sqlite3_vtab

type Sqlite3_vtab_cursor = sqlite3_vtab_cursor

type SrcItem = TSrcItem

type SrcList = TSrcList

type StatAccum = TStatAccum

type StatCell = TStatCell

type StatCursor = TStatCursor

type StatPage = TStatPage

type StatSample = TStatSample

type StatTable = TStatTable

type StrAccum = TStrAccum

type SubProgram = TSubProgram

type Subquery = TSubquery

type SubrtnSig = TSubrtnSig

type SubstContext = TSubstContext

type SumCtx = TSumCtx

const TABTYP_NORM = 0

const TABTYP_VIEW = 2

const TABTYP_VTAB = 1

// C documentation
//
//	/*
//	** Forward references to structures
//	*/
type TAggInfo = struct {
	FdirectMode     Tu8
	FuseSortingIdx  Tu8
	FnSortingColumn Tu32
	FsortingIdx     int32
	FsortingIdxPTab int32
	FiFirstReg      int32
	FpGroupBy       uintptr
	FaCol           uintptr
	FnColumn        int32
	FnAccumulator   int32
	FaFunc          uintptr
	FnFunc          int32
	FselId          Tu32
}

type TAggInfo_col = struct {
	FpTab          uintptr
	FpCExpr        uintptr
	FiTable        int32
	FiColumn       int32
	FiSorterColumn int32
}

type TAggInfo_func = struct {
	FpFExpr      uintptr
	FpFunc       uintptr
	FiDistinct   int32
	FiDistAddr   int32
	FiOBTab      int32
	FbOBPayload  Tu8
	FbOBUnique   Tu8
	FbUseSubtype Tu8
}

type TAsciiTokenizer = struct {
	FaTokenChar [128]uint8
}

type TAuthContext = struct {
	FzAuthContext uintptr
	FpParse       uintptr
}

type TAutoincInfo = struct {
	FpNext  uintptr
	FpTab   uintptr
	FiDb    int32
	FregCtr int32
}

// C documentation
//
//	/* Elements of the linked list at Vdbe.pAuxData */
type TAuxData = struct {
	FiAuxOp     int32
	FiAuxArg    int32
	FpAux       uintptr
	FxDeleteAux uintptr
	FpNextAux   uintptr
}

// C documentation
//
//	/*
//	** Global variables.
//	*/
type TBenignMallocHooks = struct {
	FxBenignBegin uintptr
	FxBenignEnd   uintptr
}

// C documentation
//
//	/*
//	** The bitmask datatype defined below is used for various optimizations.
//	**
//	** Changing this from a 64-bit to a 32-bit type limits the number of
//	** tables in a join to 32 instead of 64.  But it also reduces the size
//	** of the library by 738 bytes on ix86.
//	*/
type TBitmask = uint64

// C documentation
//
//	/*
//	** Boolean values
//	*/
type TBool = uint32

type TBtLock = struct {
	FpBtree uintptr
	FiTable TPgno
	FeLock  Tu8
	FpNext  uintptr
}

type TBtShared = struct {
	FpPager          uintptr
	Fdb              uintptr
	FpCursor         uintptr
	FpPage1          uintptr
	FopenFlags       Tu8
	FautoVacuum      Tu8
	FincrVacuum      Tu8
	FbDoTruncate     Tu8
	FinTransaction   Tu8
	Fmax1bytePayload Tu8
	FnReserveWanted  Tu8
	FbtsFlags        Tu16
	FmaxLocal        Tu16
	FminLocal        Tu16
	FmaxLeaf         Tu16
	FminLeaf         Tu16
	FpageSize        Tu32
	FusableSize      Tu32
	FnTransaction    int32
	FnPage           Tu32
	FpSchema         uintptr
	FxFreeSchema     uintptr
	Fmutex           uintptr
	FpHasContent     uintptr
	FnRef            int32
	FpNext           uintptr
	FpLock           uintptr
	FpWriter         uintptr
	FpTmpSpace       uintptr
	FnPreformatSize  int32
}

// C documentation
//
//	/*
//	** Forward declarations of structure
//	*/
type TBtree = struct {
	Fdb             uintptr
	FpBt            uintptr
	FinTrans        Tu8
	Fsharable       Tu8
	Flocked         Tu8
	FhasIncrblobCur Tu8
	FwantToLock     int32
	FnBackup        int32
	FiBDataVersion  Tu32
	FpNext          uintptr
	FpPrev          uintptr
	Flock           TBtLock
}

// C documentation
//
//	/*
//	** An instance of the following structure is used to store the busy-handler
//	** callback for a given sqlite handle.
//	**
//	** The sqlite.busyHandler member of the sqlite struct contains the busy
//	** callback for the database handle. Each pager opened via the sqlite
//	** handle is passed a pointer to sqlite.busyHandler. The busy-handler
//	** callback is currently invoked only from within pager.c.
//	*/
type TBusyHandler = struct {
	FxBusyHandler uintptr
	FpBusyArg     uintptr
	FnBusy        int32
}

// C documentation
//
//	/*
//	** Object used to iterate through all "coalesced phrase instances" in
//	** a single column of the current row. If the phrase instances in the
//	** column being considered do not overlap, this object simply iterates
//	** through them. Or, if they do overlap (share one or more tokens in
//	** common), each set of overlapping instances is treated as a single
//	** match. See documentation for the highlight() auxiliary function for
//	** details.
//	**
//	** Usage is:
//	**
//	**   for(rc = fts5CInstIterNext(pApi, pFts, iCol, &iter);
//	**      (rc==SQLITE_OK && 0==fts5CInstIterEof(&iter);
//	**      rc = fts5CInstIterNext(&iter)
//	**   ){
//	**     printf("instance starts at %d, ends at %d\n", iter.iStart, iter.iEnd);
//	**   }
//	**
//	*/
type TCInstIter = struct {
	FpApi   uintptr
	FpFts   uintptr
	FiCol   int32
	FiInst  int32
	FnInst  int32
	FiStart int32
	FiEnd   int32
}

// C documentation
//
//	/*
//	** A CellArray object contains a cache of pointers and sizes for a
//	** consecutive sequence of cells that might be held on multiple pages.
//	**
//	** The cells in this array are the divider cell or cells from the pParent
//	** page plus up to three child pages.  There are a total of nCell cells.
//	**
//	** pRef is a pointer to one of the pages that contributes cells.  This is
//	** used to access information such as MemPage.intKey and MemPage.pBt->pageSize
//	** which should be common to all pages that contribute cells to this array.
//	**
//	** apCell[] and szCell[] hold, respectively, pointers to the start of each
//	** cell and the size of each cell.  Some of the apCell[] pointers might refer
//	** to overflow cells.  In other words, some apCel[] pointers might not point
//	** to content area of the pages.
//	**
//	** A szCell[] of zero means the size of that cell has not yet been computed.
//	**
//	** The cells come from as many as four different pages:
//	**
//	**             -----------
//	**             | Parent  |
//	**             -----------
//	**            /     |     **           /      |      **  ---------   ---------   ---------
//	**  |Child-1|   |Child-2|   |Child-3|
//	**  ---------   ---------   ---------
//	**
//	** The order of cells is in the array is for an index btree is:
//	**
//	**       1.  All cells from Child-1 in order
//	**       2.  The first divider cell from Parent
//	**       3.  All cells from Child-2 in order
//	**       4.  The second divider cell from Parent
//	**       5.  All cells from Child-3 in order
//	**
//	** For a table-btree (with rowids) the items 2 and 4 are empty because
//	** content exists only in leaves and there are no divider cells.
//	**
//	** For an index btree, the apEnd[] array holds pointer to the end of page
//	** for Child-1, the Parent, Child-2, the Parent (again), and Child-3,
//	** respectively. The ixNx[] array holds the number of cells contained in
//	** each of these 5 stages, and all stages to the left.  Hence:
//	**
//	**    ixNx[0] = Number of cells in Child-1.
//	**    ixNx[1] = Number of cells in Child-1 plus 1 for first divider.
//	**    ixNx[2] = Number of cells in Child-1 and Child-2 + 1 for 1st divider.
//	**    ixNx[3] = Number of cells in Child-1 and Child-2 + both divider cells
//	**    ixNx[4] = Total number of cells.
//	**
//	** For a table-btree, the concept is similar, except only apEnd[0]..apEnd[2]
//	** are used and they point to the leaf pages only, and the ixNx value are:
//	**
//	**    ixNx[0] = Number of cells in Child-1.
//	**    ixNx[1] = Number of cells in Child-1 and Child-2.
//	**    ixNx[2] = Total number of cells.
//	**
//	** Sometimes when deleting, a child page can have zero cells.  In those
//	** cases, ixNx[] entries with higher indexes, and the corresponding apEnd[]
//	** entries, shift down.  The end result is that each ixNx[] entry should
//	** be larger than the previous
//	*/
type TCellArray = struct {
	FnCell  int32
	FpRef   uintptr
	FapCell uintptr
	FszCell uintptr
	FapEnd  [6]uintptr
	FixNx   [6]int32
}

// C documentation
//
//	/*
//	** The parts of the sqlite3_changegroup structure used by the
//	** sqlite3changegroup_change_xxx() APIs.
//	*/
type TChangeData = struct {
	FpTab      uintptr
	FbIndirect int32
	FeOp       int32
	FnBufAlloc int32
	FaBuf      uintptr
	Frecord    TSessionBuffer
}

// C documentation
//
//	/*
//	** Type used for Walker callbacks by selectCheckOnClauses().
//	*/
type TCheckOnCtx = struct {
	FpSrc     uintptr
	FiJoin    int32
	FbFuncArg int32
	FpParent  uintptr
}

type TCollSeq = struct {
	FzName uintptr
	Fenc   Tu8
	FpUser uintptr
	FxCmp  uintptr
	FxDel  uintptr
}

// C documentation
//
//	/*
//	** Structure passed to the whereIsCoveringIndex Walker callback.
//	*/
type TCoveringIndexCheck = struct {
	FpIdx    uintptr
	FiTabCur int32
	FbExpr   Tu8
	FbUnidx  Tu8
}

type TCte = struct {
	FzName   uintptr
	FpCols   uintptr
	FpSelect uintptr
	FzCteErr uintptr
	FpUse    uintptr
	FeM10d   Tu8
}

type TCteUse = struct {
	FnUse    int32
	FaddrM9e int32
	FregRtn  int32
	FiCur    int32
	FnRowEst TLogEst
	FeM10d   Tu8
}

type TDb = struct {
	FzDbSName     uintptr
	FpBt          uintptr
	Fsafety_level Tu8
	FbSyncSet     Tu8
	FpSchema      uintptr
}

type TDbClientData = struct {
	FpNext       uintptr
	FpData       uintptr
	FxDestructor uintptr
}

type TDbFixer = struct {
	FpParse  uintptr
	Fw       TWalker
	FpSchema uintptr
	FbTemp   Tu8
	FzDb     uintptr
	FzType   uintptr
	FpName   uintptr
}

type TDbpageCursor = struct {
	Fbase   Tsqlite3_vtab_cursor
	Fpgno   TPgno
	FmxPgno TPgno
	FpPager uintptr
	FpPage1 uintptr
	FiDb    int32
	FszPage int32
}

type TDbpageTable = struct {
	Fbase      Tsqlite3_vtab
	Fdb        uintptr
	FiDbTrunc  int32
	FpgnoTrunc TPgno
}

// C documentation
//
//	/*
//	** An instance of the following object is used to record information about
//	** how to process the DISTINCT keyword, to simplify passing that information
//	** into the selectInnerLoop() routine.
//	*/
type TDistinctCtx = struct {
	FisTnct    Tu8
	FeTnctType Tu8
	FtabTnct   int32
	FaddrTnct  int32
}

const TERM_ANDINFO = 32

const TERM_CODED = 4

const TERM_COPIED = 8

const TERM_DYNAMIC = 1

const TERM_HEURTRUTH = 8192

const TERM_HIGHTRUTH = 16384

const TERM_IS = 2048

const TERM_LIKE = 1024

const TERM_LIKECOND = 512

const TERM_LIKEOPT = 256

const TERM_OK = 64

const TERM_ORINFO = 16

const TERM_SLICE = 32768

const TERM_VARSELECT = 4096

const TERM_VIRTUAL = 2

const TERM_VNULL = 128

// C documentation
//
//	/*
//	** An EdupBuf is a memory allocation used to stored multiple Expr objects
//	** together with their Expr.zToken content.  This is used to help implement
//	** compression while doing sqlite3ExprDup().  The top-level Expr does the
//	** allocation for itself and many of its decendents, then passes an instance
//	** of the structure down into exprDup() so that they decendents can have
//	** access to that memory.
//	*/
type TEdupBuf = struct {
	FzAlloc uintptr
}

// C documentation
//
//	/*
//	** Add a new element to the end of an expression list.  If pList is
//	** initially NULL, then create a new expression list.
//	**
//	** The pList argument must be either NULL or a pointer to an ExprList
//	** obtained from a prior call to sqlite3ExprListAppend().
//	**
//	** If a memory allocation error occurs, the entire list is freed and
//	** NULL is returned.  If non-NULL is returned, then it is guaranteed
//	** that the new entry was successfully appended.
//	*/
type TExprList_item = struct {
	FpExpr  uintptr
	FzEName uintptr
	Ffg     struct {
		F__ccgo_align  [0]uint32
		FsortFlags     Tu8
		F__ccgo_align1 [2]byte
		F__ccgo4       uint16
	}
	Fu struct {
		FiConstExprReg [0]int32
		Fx             struct {
			FiOrderByCol Tu16
			FiAlias      Tu16
		}
	}
}

type TFKey = struct {
	FpFrom      uintptr
	FpNextFrom  uintptr
	FzTo        uintptr
	FpNextTo    uintptr
	FpPrevTo    uintptr
	FnCol       int32
	FisDeferred Tu8
	FaAction    [2]Tu8
	FapTrigger  [2]uintptr
}

const TF_Autoincrement = 8

const TF_Ephemeral = 16384

const TF_Eponymous = 32768

const TF_HasGenerated = 96

const TF_HasHidden = 2

const TF_HasNotNull = 2048

const TF_HasPrimaryKey = 4

const TF_HasStat1 = 16

const TF_HasStat4 = 8192

const TF_HasStored = 64

const TF_HasVirtual = 32

const TF_Imposter = 131072

const TF_MaybeReanalyze = 256

const TF_NoVisibleRowid = 512

const TF_OOOHidden = 1024

const TF_Readonly = 1

const TF_Shadow = 4096

const TF_Strict = 65536

const TF_WithoutRowid = 128

type TFileChunk = struct {
	FpNext  uintptr
	FzChunk [8]Tu8
}

type TFrameBound = struct {
	FeType int32
	FpExpr uintptr
}

type TFts5Auxdata = struct {
	FpAux    uintptr
	FpPtr    uintptr
	FxDelete uintptr
	FpNext   uintptr
}

type TFts5Auxiliary = struct {
	FpGlobal   uintptr
	FzFunc     uintptr
	FpUserData uintptr
	FxFunc     Tfts5_extension_function
	FxDestroy  uintptr
	FpNext     uintptr
}

// C documentation
//
//	/*
//	** Buffer object for the incremental building of string data.
//	*/
type TFts5Buffer = struct {
	Fp      uintptr
	Fn      int32
	FnSpace int32
}

type TFts5CResult = struct {
	FiFirst  Tu16
	FbTermEq Tu8
}

type TFts5Colset = struct {
	FnCol int32
}

type TFts5Config = struct {
	Fdb                    uintptr
	FpGlobal               uintptr
	FzDb                   uintptr
	FzName                 uintptr
	FnCol                  int32
	FazCol                 uintptr
	FabUnindexed           uintptr
	FnPrefix               int32
	FaPrefix               uintptr
	FeContent              int32
	FbContentlessDelete    int32
	FbContentlessUnindexed int32
	FzContent              uintptr
	FzContentRowid         uintptr
	FbColumnsize           int32
	FbTokendata            int32
	FbLocale               int32
	FeDetail               int32
	FzContentExprlist      uintptr
	Ft                     TFts5TokenizerConfig
	FbLock                 int32
	FiVersion              int32
	FiCookie               int32
	Fpgsz                  int32
	FnAutomerge            int32
	FnCrisisMerge          int32
	FnUsermerge            int32
	FnHashSize             int32
	FzRank                 uintptr
	FzRankArgs             uintptr
	FbSecureDelete         int32
	FnDeleteMerge          int32
	FbPrefixInsttoken      int32
	FpzErrmsg              uintptr
}

type TFts5Data = struct {
	Fp      uintptr
	Fnn     int32
	FszLeaf int32
}

type TFts5Enum = struct {
	FzName uintptr
	FeVal  int32
}

// C documentation
//
//	/**************************************************************************
//	** Interface to code in fts5_expr.c.
//	*/
type TFts5Expr = struct {
	FpIndex       uintptr
	FpConfig      uintptr
	FpRoot        uintptr
	FbDesc        int32
	FnPhrase      int32
	FapExprPhrase uintptr
}

type TFts5ExprNearset = struct {
	FnNear   int32
	FpColset uintptr
	FnPhrase int32
}

type TFts5ExprPhrase = struct {
	FpNode   uintptr
	Fposlist TFts5Buffer
	FnTerm   int32
}

type TFts5ExprTerm = struct {
	FbPrefix    Tu8
	FbFirst     Tu8
	FpTerm      uintptr
	FnQueryTerm int32
	FnFullTerm  int32
	FpIter      uintptr
	FpSynonym   uintptr
}

type TFts5ExtensionApi = struct {
	FiVersion           int32
	FxUserData          uintptr
	FxColumnCount       uintptr
	FxRowCount          uintptr
	FxColumnTotalSize   uintptr
	FxTokenize          uintptr
	FxPhraseCount       uintptr
	FxPhraseSize        uintptr
	FxInstCount         uintptr
	FxInst              uintptr
	FxRowid             uintptr
	FxColumnText        uintptr
	FxColumnSize        uintptr
	FxQueryPhrase       uintptr
	FxSetAuxdata        uintptr
	FxGetAuxdata        uintptr
	FxPhraseFirst       uintptr
	FxPhraseNext        uintptr
	FxPhraseFirstColumn uintptr
	FxPhraseNextColumn  uintptr
	FxQueryToken        uintptr
	FxInstToken         uintptr
	FxColumnLocale      uintptr
	FxTokenize_v2       uintptr
}

type TFts5FullTable = struct {
	Fp          TFts5Table
	FpStorage   uintptr
	FpGlobal    uintptr
	FpSortCsr   uintptr
	FiSavepoint int32
}

// C documentation
//
//	/**************************************************************************
//	** Interface to code in fts5_hash.c.
//	*/
type TFts5Hash = struct {
	FeDetail int32
	FpnByte  uintptr
	FnEntry  int32
	FnSlot   int32
	FpScan   uintptr
	FaSlot   uintptr
}

type TFts5InsertCtx = struct {
	FpStorage uintptr
	FiCol     int32
	FszCol    int32
}

type TFts5MatchPhrase = struct {
	FpPoslist uintptr
	FnTerm    int32
}

type TFts5PageWriter = struct {
	Fpgno       int32
	FiPrevPgidx int32
	Fbuf        TFts5Buffer
	Fpgidx      TFts5Buffer
	Fterm       TFts5Buffer
}

type TFts5Parse = struct {
	FpConfig      uintptr
	FzErr         uintptr
	Frc           int32
	FnPhrase      int32
	FapPhrase     uintptr
	FpExpr        uintptr
	FbPhraseToAnd int32
}

type TFts5PhraseIter = struct {
	Fa uintptr
	Fb uintptr
}

// C documentation
//
//	/*
//	** Context object passed to the fts5SentenceFinderCb() function.
//	*/
type TFts5SFinder = struct {
	FiPos        int32
	FnFirstAlloc int32
	FnFirst      int32
	FaFirst      uintptr
	FzDoc        uintptr
}

type TFts5StructureLevel = struct {
	FnMerge int32
	FnSeg   int32
	FaSeg   uintptr
}

// C documentation
//
//	/*
//	** Virtual-table object.
//	*/
type TFts5Table = struct {
	Fbase    Tsqlite3_vtab
	FpConfig uintptr
	FpIndex  uintptr
}

// C documentation
//
//	/* Bucket of terms object used by the integrity-check in offsets=0 mode. */
type TFts5Termset = struct {
	FapHash [512]uintptr
}

// C documentation
//
//	/*************************************************************************
//	*/
type TFts5TermsetEntry = struct {
	FpTerm uintptr
	FnTerm int32
	FiIdx  int32
	FpNext uintptr
}

type TFts5Token = struct {
	Fp uintptr
	Fn int32
}

type TFts5TokenizerConfig = struct {
	FpTok     uintptr
	FpApi2    uintptr
	FpApi1    uintptr
	FazArg    uintptr
	FnArg     int32
	FePattern int32
	FpLocale  uintptr
	FnLocale  int32
}

type TFts5TokenizerModule = struct {
	FzName     uintptr
	FpUserData uintptr
	FbV2Native int32
	Fx1        Tfts5_tokenizer
	Fx2        Tfts5_tokenizer_v2
	FxDestroy  uintptr
	FpNext     uintptr
}

/*
** NOTES ON TRANSACTIONS:
**
** SQLite invokes the following virtual table methods as transactions are
** opened and closed by the user:
**
**     xBegin():    Start of a new transaction.
**     xSync():     Initial part of two-phase commit.
**     xCommit():   Final part of two-phase commit.
**     xRollback(): Rollback the transaction.
**
** Anything that is required as part of a commit that may fail is performed
** in the xSync() callback. Current versions of SQLite ignore any errors
** returned by xCommit().
**
** And as sub-transactions are opened/closed:
**
**     xSavepoint(int S):  Open savepoint S.
**     xRelease(int S):    Commit and close savepoint S.
**     xRollbackTo(int S): Rollback to start of savepoint S.
**
** During a write-transaction the fts5_index.c module may cache some data
** in-memory. It is flushed to disk whenever xSync(), xRelease() or
** xSavepoint() is called. And discarded whenever xRollback() or xRollbackTo()
** is called.
**
** Additionally, if SQLITE_DEBUG is defined, an instance of the following
** structure is used to record the current transaction state. This information
** is not required, but it is used in the assert() statements executed by
** function fts5CheckTransactionState() (see below).
 */
type TFts5TransactionState = struct {
	FeState     int32
	FiSavepoint int32
}

type TFts5VocabTable = struct {
	Fbase     Tsqlite3_vtab
	FzFts5Tbl uintptr
	FzFts5Db  uintptr
	Fdb       uintptr
	FpGlobal  uintptr
	FeType    int32
	FbBusy    uint32
}

// C documentation
//
//	/*
//	** An instance of this type is used as the Fts5Tokenizer object for
//	** wrapper tokenizers - those that provide access to a v1 tokenizer via
//	** the fts5_tokenizer_v2 API, and those that provide access to a v2 tokenizer
//	** via the fts5_tokenizer API.
//	*/
type TFts5VtoVTokenizer = struct {
	FbV2Native int32
	Fx1        Tfts5_tokenizer
	Fx2        Tfts5_tokenizer_v2
	FpReal     uintptr
}

type TFuncDef = struct {
	FnArg      Ti16
	FfuncFlags Tu32
	FpUserData uintptr
	FpNext     uintptr
	FxSFunc    uintptr
	FxFinalize uintptr
	FxValue    uintptr
	FxInverse  uintptr
	FzName     uintptr
	Fu         struct {
		FpDestructor [0]uintptr
		FpHash       uintptr
	}
}

type TFuncDefHash = struct {
	Fa [23]uintptr
}

type TFuncDestructor = struct {
	FnRef      int32
	FxDestroy  uintptr
	FpUserData uintptr
}

// C documentation
//
//	/*
//	** State vector for the geopoly_group_bbox() aggregate function.
//	*/
type TGeoBBox = struct {
	FisInit int32
	Fa      [4]TRtreeCoord
}

// C documentation
//
//	/* Datatype for coordinates
//	*/
type TGeoCoord = float32

type TGeoOverlap = struct {
	FaEvent   uintptr
	FaSegment uintptr
	FnEvent   int32
	FnSegment int32
}

// C documentation
//
//	/*
//	** State of a parse of a GeoJSON input.
//	*/
type TGeoParse = struct {
	Fz       uintptr
	FnVertex int32
	FnAlloc  int32
	FnErr    int32
	Fa       uintptr
}

// C documentation
//
//	/*
//	** Internal representation of a polygon.
//	**
//	** The polygon consists of a sequence of vertexes.  There is a line
//	** segment between each pair of vertexes, and one final segment from
//	** the last vertex back to the first.  (This differs from the GeoJSON
//	** standard in which the final vertex is a repeat of the first.)
//	**
//	** The polygon follows the right-hand rule.  The area to the right of
//	** each segment is "outside" and the area to the left is "inside".
//	**
//	** The on-disk representation consists of a 4-byte header followed by
//	** the values.  The 4-byte header is:
//	**
//	**      encoding    (1 byte)   0=big-endian, 1=little-endian
//	**      nvertex     (3 bytes)  Number of vertexes as a big-endian integer
//	**
//	** Enough space is allocated for 4 coordinates, to work around over-zealous
//	** warnings coming from some compiler (notably, clang). In reality, the size
//	** of each GeoPoly memory allocate is adjusted as necessary so that the
//	** GeoPoly.a[] array at the end is the appropriate size.
//	*/
type TGeoPoly = struct {
	FnVertex int32
	Fhdr     [4]uint8
	Fa       [8]TGeoCoord
}

// C documentation
//
//	/*
//	** group_concat(EXPR, ?SEPARATOR?)
//	** string_agg(EXPR, SEPARATOR)
//	**
//	** Content is accumulated in GroupConcatCtx.str with the SEPARATOR
//	** coming before the EXPR value, except for the first entry which
//	** omits the SEPARATOR.
//	**
//	** It is tragic that the SEPARATOR goes before the EXPR string.  The
//	** groupConcatInverse() implementation would have been easier if the
//	** SEPARATOR were appended after EXPR.  And the order is undocumented,
//	** so we could change it, in theory.  But the old behavior has been
//	** around for so long that we dare not, for fear of breaking something.
//	*/
type TGroupConcatCtx = struct {
	Fstr             TStrAccum
	FnAccum          int32
	FnFirstSepLength int32
	FpnSepLengths    uintptr
}

// C documentation
//
//	/* Forward declarations of structures. */
type THash = struct {
	Fhtsize uint32
	Fcount  uint32
	Ffirst  uintptr
	Fht     uintptr
}

type THashElem = struct {
	Fnext uintptr
	Fprev uintptr
	Fdata uintptr
	FpKey uintptr
	Fh    uint32
}

// C documentation
//
//	/*
//	** Extra information appended to the end of sqlite3_index_info but not
//	** visible to the xBestIndex function, at least not directly.  The
//	** sqlite3_vtab_collation() interface knows how to reach it, however.
//	**
//	** This object is not an API and can be changed from one release to the
//	** next.  As long as allocateIndexInfo() and sqlite3_vtab_collation()
//	** agree on the structure, all will be well.
//	*/
type THiddenIndexInfo = struct {
	FpWC       uintptr
	FpParse    uintptr
	FeDistinct int32
	FmIn       Tu32
	FmHandleIn Tu32
}

// C documentation
//
//	/*************************************************************************
//	** Start of highlight() implementation.
//	*/
type THighlightContext = struct {
	FiRangeStart int32
	FiRangeEnd   int32
	FzOpen       uintptr
	FzClose      uintptr
	FzIn         uintptr
	FnIn         int32
	Fiter        TCInstIter
	FiPos        int32
	FiOff        int32
	FbOpen       int32
	FzOut        uintptr
}

type TIdList_item = struct {
	FzName uintptr
}

/*
** An instance of the following structure is used by the tree walker
** to determine if an expression can be evaluated by reference to the
** index only, without having to do a search for the corresponding
** table entry.  The IdxCover.pIdx field is the index.  IdxCover.iCur
** is the cursor for the table.
 */
type TIdxCover = struct {
	FpIdx uintptr
	FiCur int32
}

type TInLoop = struct {
	FiCur       int32
	FaddrInTop  int32
	FiBase      int32
	FnPrefix    int32
	FeEndLoopOp Tu8
}

// C documentation
//
//	/*
//	** Valid sqlite3_blob* handles point to Incrblob structures.
//	*/
type TIncrblob = struct {
	FnByte   int32
	FiOffset int32
	FiCol    Tu16
	FpCsr    uintptr
	FpStmt   uintptr
	Fdb      uintptr
	FzDb     uintptr
	FpTab    uintptr
}

// C documentation
//
//	/*
//	** The sqlite3GenerateConstraintChecks() routine usually wants to visit
//	** the indexes of a table in the order provided in the Table->pIndex list.
//	** However, sometimes (rarely - when there is an upsert) it wants to visit
//	** the indexes in a different order.  The following data structures accomplish
//	** this.
//	**
//	** The IndexIterator object is used to walk through all of the indexes
//	** of a table in either Index.pNext order, or in some other order established
//	** by an array of IndexListTerm objects.
//	*/
type TIndexListTerm = struct {
	Fp  uintptr
	Fix int32
}

type TIndexSample = struct {
	Fp     uintptr
	Fn     int32
	FanEq  uintptr
	FanLt  uintptr
	FanDLt uintptr
}

type TIndexedExpr = struct {
	FpExpr         uintptr
	FiDataCur      int32
	FiIdxCur       int32
	FiIdxCol       int32
	FbMaybeNullRow Tu8
	Faff           Tu8
	FpIENext       uintptr
}

// C documentation
//
//	/*
//	** A pointer to this structure is used to communicate information
//	** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback.
//	*/
type TInitData = struct {
	Fdb         uintptr
	FpzErrMsg   uintptr
	FiDb        int32
	Frc         int32
	FmInitFlags Tu32
	FnInitRow   Tu32
	FmxPage     TPgno
}

// C documentation
//
//	/* Objects */
type TJsonCache = struct {
	Fdb    uintptr
	FnUsed int32
	Fa     [4]uintptr
}

type TJsonEachConnection = struct {
	Fbase       Tsqlite3_vtab
	Fdb         uintptr
	FeMode      Tu8
	FbRecursive Tu8
}

type TJsonParse = struct {
	FaBlob        uintptr
	FnBlob        Tu32
	FnBlobAlloc   Tu32
	FzJson        uintptr
	Fdb           uintptr
	FnJson        int32
	FnJPRef       Tu32
	FiErr         Tu32
	FiDepth       Tu16
	FnErr         Tu8
	Foom          Tu8
	FbJsonIsRCStr Tu8
	FhasNonstd    Tu8
	FbReadOnly    Tu8
	FeEdit        Tu8
	Fdelta        int32
	FnIns         Tu32
	FiLabel       Tu32
	FaIns         uintptr
}

// C documentation
//
//	/* Context for recursion of json_pretty()
//	*/
type TJsonPretty = struct {
	FpParse   uintptr
	FpOut     uintptr
	FzIndent  uintptr
	FszIndent Tu32
	FnIndent  Tu32
}

const TK_ABORT = 27

const TK_ACTION = 28

const TK_ADD = 164

const TK_AFTER = 29

const TK_AGG_COLUMN = 170

const TK_AGG_FUNCTION = 169

const TK_ALL = 136

const TK_ALTER = 163

const TK_ALWAYS = 97

const TK_ANALYZE = 30

const TK_AND = 44

const TK_ANY = 102

const TK_AS = 24

const TK_ASC = 31

const TK_ASTERISK = 180

const TK_ATTACH = 32

const TK_AUTOINCR = 127

const TK_BEFORE = 33

const TK_BEGIN = 5

const TK_BETWEEN = 49

const TK_BITAND = 103

const TK_BITNOT = 115

const TK_BITOR = 104

const TK_BLOB = 155

const TK_BY = 34

const TK_CASCADE = 35

const TK_CASE = 158

const TK_CAST = 36

const TK_CHECK = 125

const TK_COLLATE = 114

const TK_COLUMN = 168

const TK_COLUMNKW = 61

const TK_COMMA = 25

const TK_COMMENT = 185

const TK_COMMIT = 10

const TK_CONCAT = 112

const TK_CONFLICT = 37

const TK_CONSTRAINT = 120

const TK_CREATE = 17

const TK_CTIME_KW = 101

const TK_CURRENT = 86

const TK_DATABASE = 38

const TK_DEFAULT = 121

const TK_DEFERRABLE = 132

const TK_DEFERRED = 7

const TK_DELETE = 129

const TK_DESC = 39

const TK_DETACH = 40

const TK_DISTINCT = 141

const TK_DO = 62

const TK_DOT = 142

const TK_DROP = 134

const TK_EACH = 41

const TK_ELSE = 161

const TK_END = 11

const TK_EQ = 54

const TK_ERROR = 182

const TK_ESCAPE = 59

const TK_EXCEPT = 137

const TK_EXCLUDE = 92

const TK_EXCLUSIVE = 9

const TK_EXISTS = 20

const TK_EXPLAIN = 2

const TK_FAIL = 42

const TK_FILTER = 167

const TK_FIRST = 84

const TK_FLOAT = 154

const TK_FOLLOWING = 87

const TK_FOR = 63

const TK_FOREIGN = 133

const TK_FROM = 143

const TK_FUNCTION = 172

const TK_GE = 58

const TK_GENERATED = 96

const TK_GROUP = 147

const TK_GROUPS = 93

const TK_GT = 55

const TK_HAVING = 148

const TK_ID = 60

const TK_IF = 18

const TK_IF_NULL_ROW = 179

const TK_IGNORE = 64

const TK_ILLEGAL = 186

const TK_IMMEDIATE = 8

const TK_IN = 50

const TK_INDEX = 162

const TK_INDEXED = 117

const TK_INITIALLY = 65

const TK_INSERT = 128

const TK_INSTEAD = 66

const TK_INTEGER = 156

const TK_INTERSECT = 138

const TK_INTO = 152

const TK_IS = 45

const TK_ISNOT = 46

const TK_ISNULL = 51

const TK_JOIN = 144

const TK_JOIN_KW = 119

const TK_KEY = 68

const TK_LAST = 85

const TK_LE = 56

const TK_LIKE_KW = 48

const TK_LIMIT = 149

const TK_LP = 22

const TK_LSHIFT = 105

const TK_LT = 57

const TK_MATCH = 47

const TK_MATERIALIZED = 98

const TK_MINUS = 108

const TK_NE = 53

const TK_NO = 67

const TK_NOT = 19

const TK_NOTHING = 153

const TK_NOTNULL = 52

const TK_NULL = 122

const TK_NULLS = 83

const TK_OF = 69

const TK_OFFSET = 70

const TK_ON = 116

const TK_OR = 43

const TK_ORDER = 146

const TK_OTHERS = 94

const TK_OVER = 166

const TK_PARTITION = 88

const TK_PLAN = 4

const TK_PLUS = 107

const TK_PRAGMA = 71

const TK_PRECEDING = 89

const TK_PRIMARY = 123

const TK_PTR = 113

const TK_QNUMBER = 183

const TK_QUERY = 3

const TK_RAISE = 72

const TK_RANGE = 90

const TK_RECURSIVE = 73

const TK_REFERENCES = 126

const TK_REGISTER = 176

const TK_REINDEX = 99

const TK_RELEASE = 14

const TK_REM = 111

const TK_RENAME = 100

const TK_REPLACE = 74

const TK_RESTRICT = 75

const TK_RETURNING = 151

const TK_ROLLBACK = 12

const TK_ROW = 76

const TK_ROWS = 77

const TK_RP = 23

const TK_RSHIFT = 106

const TK_SAVEPOINT = 13

const TK_SELECT = 139

const TK_SELECT_COLUMN = 178

const TK_SEMI = 1

const TK_SET = 131

const TK_SLASH = 110

const TK_SPACE = 184

const TK_SPAN = 181

const TK_STAR = 109

const TK_STRING = 118

const TK_TABLE = 16

const TK_TEMP = 21

const TK_THEN = 160

const TK_TIES = 95

const TK_TO = 15

const TK_TRANSACTION = 6

const TK_TRIGGER = 78

const TK_TRUEFALSE = 171

const TK_TRUTH = 175

const TK_UMINUS = 174

const TK_UNBOUNDED = 91

const TK_UNION = 135

const TK_UNIQUE = 124

const TK_UPDATE = 130

const TK_UPLUS = 173

const TK_USING = 145

const TK_VACUUM = 79

const TK_VALUES = 140

const TK_VARIABLE = 157

const TK_VECTOR = 177

const TK_VIEW = 80

const TK_VIRTUAL = 81

const TK_WHEN = 159

const TK_WHERE = 150

const TK_WINDOW = 165

const TK_WITH = 82

const TK_WITHOUT = 26

type TKeyInfo = struct {
	FnRef       Tu32
	Fenc        Tu8
	FnKeyField  Tu16
	FnAllField  Tu16
	Fdb         uintptr
	FaSortFlags uintptr
}

/*
** Context object for last_value() window function.
 */
type TLastValueCtx = struct {
	FpVal uintptr
	FnVal int32
}

// C documentation
//
//	/*
//	** Estimated quantities used for query planning are stored as 16-bit
//	** logarithms.  For quantity X, the value stored is 10*log2(X).  This
//	** gives a possible range of values of approximately 1.0e986 to 1e-986.
//	** But the allowed values are "grainy".  Not every value is representable.
//	** For example, quantities 16 and 17 are both represented by a LogEst
//	** of 40.  However, since LogEst quantities are suppose to be estimates,
//	** not exact values, this imprecision is not a problem.
//	**
//	** "LogEst" is short for "Logarithmic Estimate".
//	**
//	** Examples:
//	**      1 -> 0              20 -> 43          10000 -> 132
//	**      2 -> 10             25 -> 46          25000 -> 146
//	**      3 -> 16            100 -> 66        1000000 -> 199
//	**      4 -> 20           1000 -> 99        1048576 -> 200
//	**     10 -> 33           1024 -> 100    4294967296 -> 320
//	**
//	** The LogEst can be negative to indicate fractional values.
//	** Examples:
//	**
//	**    0.5 -> -10           0.1 -> -33        0.0625 -> -40
//	*/
type TLogEst = int16

type TLookaside = struct {
	FbDisable   Tu32
	Fsz         Tu16
	FszTrue     Tu16
	FbMalloced  Tu8
	FnSlot      Tu32
	FanStat     [3]Tu32
	FpInit      uintptr
	FpFree      uintptr
	FpSmallInit uintptr
	FpSmallFree uintptr
	FpMiddle    uintptr
	FpStart     uintptr
	FpEnd       uintptr
	FpTrueEnd   uintptr
}

type TLookasideSlot = struct {
	FpNext uintptr
}

// C documentation
//
//	/*
//	** File-scope variables for holding the memdb files that are accessible
//	** to multiple database connections in separate threads.
//	**
//	** Must hold SQLITE_MUTEX_STATIC_VFS1 to access any part of this object.
//	*/
type TMemFS = struct {
	FnMemStore  int32
	FapMemStore uintptr
}

type TMemFile = struct {
	Fbase   Tsqlite3_file
	FpStore uintptr
	FeLock  int32
}

// C documentation
//
//	/* Forward declarations */
type TMemPage = struct {
	FisInit          Tu8
	FintKey          Tu8
	FintKeyLeaf      Tu8
	Fpgno            TPgno
	Fleaf            Tu8
	FhdrOffset       Tu8
	FchildPtrSize    Tu8
	Fmax1bytePayload Tu8
	FnOverflow       Tu8
	FmaxLocal        Tu16
	FminLocal        Tu16
	FcellOffset      Tu16
	FnFree           int32
	FnCell           Tu16
	FmaskPage        Tu16
	FaiOvfl          [4]Tu16
	FapOvfl          [4]uintptr
	FpBt             uintptr
	FaData           uintptr
	FaDataEnd        uintptr
	FaCellIdx        uintptr
	FaDataOfst       uintptr
	FpDbPage         uintptr
	FxCellSize       uintptr
	FxParseCell      uintptr
}

// C documentation
//
//	/*
//	** Forward declaration of objects used by this utility
//	*/
type TMemVfs = struct {
	FiVersion          int32
	FszOsFile          int32
	FmxPathname        int32
	FpNext             uintptr
	FzName             uintptr
	FpAppData          uintptr
	FxOpen             uintptr
	FxDelete           uintptr
	FxAccess           uintptr
	FxFullPathname     uintptr
	FxDlOpen           uintptr
	FxDlError          uintptr
	FxDlSym            uintptr
	FxDlClose          uintptr
	FxRandomness       uintptr
	FxSleep            uintptr
	FxCurrentTime      uintptr
	FxGetLastError     uintptr
	FxCurrentTimeInt64 uintptr
	FxSetSystemCall    uintptr
	FxGetSystemCall    uintptr
	FxNextSystemCall   uintptr
}

// C documentation
//
//	/*
//	** Private objects used by the sorter
//	*/
type TMergeEngine = struct {
	FnTree  int32
	FpTask  uintptr
	FaTree  uintptr
	FaReadr uintptr
}

type TModule = struct {
	FpModule    uintptr
	FzName      uintptr
	FnRefModule int32
	FpAux       uintptr
	FxDestroy   uintptr
	FpEpoTab    uintptr
}

type TNameContext = struct {
	FpParse   uintptr
	FpSrcList uintptr
	FuNC      struct {
		FpAggInfo [0]uintptr
		FpUpsert  [0]uintptr
		FiBaseReg [0]int32
		FpEList   uintptr
	}
	FpNext         uintptr
	FnRef          int32
	FnNcErr        int32
	FncFlags       int32
	FnNestedSelect Tu32
	FpWinSelect    uintptr
}

const TOKEN = 0

type TOnOrUsing = struct {
	FpOn    uintptr
	FpUsing uintptr
}

// C documentation
//
//	/*
//	** SQL is translated into a sequence of instructions to be
//	** executed by a virtual machine.  Each instruction is an instance
//	** of the following structure.
//	*/
type TOp = struct {
	Fopcode Tu8
	Fp4type int8
	Fp5     Tu16
	Fp1     int32
	Fp2     int32
	Fp3     int32
	Fp4     Tp4union
}

type TPCache1 = struct {
	FpGroup          uintptr
	FpnPurgeable     uintptr
	FszPage          int32
	FszExtra         int32
	FszAlloc         int32
	FbPurgeable      int32
	FnMin            uint32
	FnMax            uint32
	Fn90pct          uint32
	FiMaxKey         uint32
	FnPurgeableDummy uint32
	FnRecyclable     uint32
	FnPage           uint32
	FnHash           uint32
	FapHash          uintptr
	FpFree           uintptr
	FpBulk           uintptr
}

// C documentation
//
//	/*
//	** Global data used by this cache.
//	*/
type TPCacheGlobal = struct {
	Fgrp            TPGroup
	FisInit         int32
	FseparateCache  int32
	FnInitPage      int32
	FszSlot         int32
	FnSlot          int32
	FnReserve       int32
	FpStart         uintptr
	FpEnd           uintptr
	Fmutex          uintptr
	FpFree          uintptr
	FnFreeSlot      int32
	FbUnderPressure int32
}

type TPGroup = struct {
	Fmutex      uintptr
	FnMaxPage   uint32
	FnMinPage   uint32
	FmxPinned   uint32
	FnPurgeable uint32
	Flru        TPgHdr1
}

type TParseCleanup = struct {
	FpNext    uintptr
	FpPtr     uintptr
	FxCleanup uintptr
}

type TPgFreeslot = struct {
	FpNext uintptr
}

// C documentation
//
//	/*
//	** Handle type for pages.
//	*/
type TPgHdr = TDbPage

type TPgHdr1 = struct {
	Fpage        Tsqlite3_pcache_page
	FiKey        uint32
	FisBulkLocal Tu16
	FisAnchor    Tu16
	FpNext       uintptr
	FpCache      uintptr
	FpLruNext    uintptr
	FpLruPrev    uintptr
}

// C documentation
//
//	/*
//	** The type used to represent a page number.  The first page in a file
//	** is called page 1.  0 is used to represent "not a page".
//	*/
type TPgno = uint32

type TPorterContext = struct {
	FpCtx   uintptr
	FxToken uintptr
	FaBuf   uintptr
}

type TPorterRule = struct {
	FzSuffix uintptr
	FnSuffix int32
	FxCond   uintptr
	FzOutput uintptr
	FnOutput int32
}

type TPoslistCallbackCtx = struct {
	FpBuf    uintptr
	FpColset uintptr
	FeState  int32
}

type TPoslistOffsetsCtx = struct {
	FpBuf    uintptr
	FpColset uintptr
	FiRead   int32
	FiWrite  int32
}

// C documentation
//
//	/*****************************************************************************
//	** Implementation of an eponymous virtual table that runs a pragma.
//	**
//	*/
type TPragmaVtab = struct {
	Fbase    Tsqlite3_vtab
	Fdb      uintptr
	FpName   uintptr
	FnHidden Tu8
	FiHidden Tu8
}

type TPrintfArguments = struct {
	FnArg  int32
	FnUsed int32
	FapArg uintptr
}

const TRANS_NONE = 0

const TRANS_READ = 1

const TRANS_WRITE = 2

const TREETRACE_ENABLED = 0

const TRIGGER_AFTER = 2

const TRIGGER_BEFORE = 1

type TRbuFrame = struct {
	FiDbPage   Tu32
	FiWalFrame Tu32
}

type TRbuObjIter = struct {
	FpTblIter   uintptr
	FpIdxIter   uintptr
	FnTblCol    int32
	FazTblCol   uintptr
	FazTblType  uintptr
	FaiSrcOrder uintptr
	FabTblPk    uintptr
	FabNotNull  uintptr
	FabIndexed  uintptr
	FeType      int32
	FbCleanup   int32
	FzTbl       uintptr
	FzDataTbl   uintptr
	FzIdx       uintptr
	FiTnum      int32
	FiPkTnum    int32
	FbUnique    int32
	FnIndex     int32
	FnCol       int32
	FpSelect    uintptr
	FpInsert    uintptr
	FpDelete    uintptr
	FpTmpInsert uintptr
	FnIdxCol    int32
	FaIdxCol    uintptr
	FzIdxSql    uintptr
	FpRbuUpdate uintptr
}

type TRbuSpan = struct {
	FzSpan uintptr
	FnSpan int32
}

type TRbuUpdateStmt = struct {
	FzMask   uintptr
	FpUpdate uintptr
	FpNext   uintptr
}

type TRecordCompare = uintptr

// C documentation
//
//	/*
//	** The context of an ALTER TABLE RENAME COLUMN operation that gets passed
//	** down into the Walker.
//	*/
type TRenameCtx = struct {
	FpList uintptr
	FnList int32
	FiCol  int32
	FpTab  uintptr
	FzOld  uintptr
}

type TRenameToken = struct {
	Fp     uintptr
	Ft     TToken
	FpNext uintptr
}

// C documentation
//
//	/*
//	** An instance of this object holds information (beyond pParse and pSelect)
//	** needed to load the next result row that is to be added to the sorter.
//	*/
type TRowLoadInfo = struct {
	FregResult int32
	FecelFlags Tu8
}

type TRowSet = struct {
	FpChunk  uintptr
	Fdb      uintptr
	FpEntry  uintptr
	FpLast   uintptr
	FpFresh  uintptr
	FpForest uintptr
	FnFresh  Tu16
	FrsFlags Tu16
	FiBatch  int32
}

// C documentation
//
//	/*
//	** Context object passed between the various routines that make up the
//	** implementation of integrity-check function rtreecheck().
//	*/
type TRtreeCheck = struct {
	Fdb            uintptr
	FzDb           uintptr
	FzTab          uintptr
	FbInt          int32
	FnDim          int32
	FpGetNode      uintptr
	FaCheckMapping [2]uintptr
	FnLeaf         int32
	FnNonLeaf      int32
	Frc            int32
	FzReport       uintptr
	FnErr          int32
}

type TRtreeCoord = struct {
	Fi [0]int32
	Fu [0]Tu32
	Ff TRtreeValue
}

// C documentation
//
//	/*
//	** If SQLITE_RTREE_INT_ONLY is defined, then this virtual table will
//	** only deal with integer coordinates.  No floating point operations
//	** will be done.
//	*/
type TRtreeDValue = float64

type TRtreeGeomCallback = struct {
	FxGeom       uintptr
	FxQueryFunc  uintptr
	FxDestructor uintptr
	FpContext    uintptr
}

type TRtreeValue = float32

// C documentation
//
//	/* The ScanStatus object holds a single value for the
//	** sqlite3_stmt_scanstatus() interface.
//	**
//	** aAddrRange[]:
//	**   This array is used by ScanStatus elements associated with EQP
//	**   notes that make an SQLITE_SCANSTAT_NCYCLE value available. It is
//	**   an array of up to 3 ranges of VM addresses for which the Vdbe.anCycle[]
//	**   values should be summed to calculate the NCYCLE value. Each pair of
//	**   integer addresses is a start and end address (both inclusive) for a range
//	**   instructions. A start value of 0 indicates an empty range.
//	*/
type TScanStatus = struct {
	FaddrExplain int32
	FaAddrRange  [6]int32
	FaddrLoop    int32
	FaddrVisit   int32
	FiSelectID   int32
	FnEst        TLogEst
	FzName       uintptr
}

type TSchema = struct {
	Fschema_cookie int32
	FiGeneration   int32
	FtblHash       THash
	FidxHash       THash
	FtrigHash      THash
	FfkeyHash      THash
	FpSeqTab       uintptr
	Ffile_format   Tu8
	Fenc           Tu8
	FschemaFlags   Tu16
	Fcache_size    int32
}

type TSelect = struct {
	Fop         Tu8
	FnSelectRow TLogEst
	FselFlags   Tu32
	FiLimit     int32
	FiOffset    int32
	FselId      Tu32
	FpEList     uintptr
	FpSrc       uintptr
	FpWhere     uintptr
	FpGroupBy   uintptr
	FpHaving    uintptr
	FpOrderBy   uintptr
	FpPrior     uintptr
	FpNext      uintptr
	FpLimit     uintptr
	FpWith      uintptr
	FpWin       uintptr
	FpWinDefn   uintptr
}

type TSelectDest = struct {
	FeDest    Tu8
	FiSDParm  int32
	FiSDParm2 int32
	FiSdst    int32
	FnSdst    int32
	FzAffSdst uintptr
	FpOrderBy uintptr
}

type TSessionApplyCtx = struct {
	Fdb                 uintptr
	FpDelete            uintptr
	FpInsert            uintptr
	FpSelect            uintptr
	FnCol               int32
	FazCol              uintptr
	FabPK               uintptr
	FaUpdateMask        uintptr
	FpUp                uintptr
	FbStat1             int32
	FbDeferConstraints  int32
	FbInvertConstraints int32
	Fconstraints        TSessionBuffer
	Frebase             TSessionBuffer
	FbRebaseStarted     Tu8
	FbRebase            Tu8
	FbIgnoreNoop        Tu8
	FbNoUpdateLoop      Tu8
	FbRowid             int32
	FzErr               uintptr
}

type TSessionBuffer = struct {
	FaBuf   uintptr
	FnBuf   int32
	FnAlloc int32
}

type TSessionChange = struct {
	Fop           Tu8
	FbIndirect    Tu8
	FnRecordField Tu16
	FnMaxSize     int32
	FnRecord      int32
	FaRecord      uintptr
	FpNext        uintptr
}

type TSessionDiffCtx = struct {
	FpStmt   uintptr
	FbRowid  int32
	FnOldOff int32
}

type TSessionHook = struct {
	FpCtx   uintptr
	FxOld   uintptr
	FxNew   uintptr
	FxCount uintptr
	FxDepth uintptr
}

type TSessionInput = struct {
	FbNoDiscard int32
	FiCurrent   int32
	FiNext      int32
	FaData      uintptr
	FnData      int32
	Fbuf        TSessionBuffer
	FxInput     uintptr
	FpIn        uintptr
	FbEof       int32
}

// C documentation
//
//	/*
//	** Versions of the four methods in object SessionHook for use with the
//	** sqlite_stat1 table. The purpose of this is to substitute a zero-length
//	** blob each time a NULL value is read from the "idx" column of the
//	** sqlite_stat1 table.
//	*/
type TSessionStat1Ctx = struct {
	Fhook     TSessionHook
	FpSession uintptr
}

type TSessionTable = struct {
	FpNext     uintptr
	FzName     uintptr
	FnCol      int32
	FnTotalCol int32
	FbStat1    int32
	FbRowid    int32
	FazCol     uintptr
	FazDflt    uintptr
	FaiIdx     uintptr
	FabPK      uintptr
	FnEntry    int32
	FnChange   int32
	FapChange  uintptr
	FpDfltStmt uintptr
}

type TSessionUpdate = struct {
	FpStmt uintptr
	FaMask uintptr
	FpNext uintptr
}

// C documentation
//
//	/*
//	** An instance of the following object is used to record information about
//	** the ORDER BY (or GROUP BY) clause of query is being coded.
//	**
//	** The aDefer[] array is used by the sorter-references optimization. For
//	** example, assuming there is no index that can be used for the ORDER BY,
//	** for the query:
//	**
//	**     SELECT a, bigblob FROM t1 ORDER BY a LIMIT 10;
//	**
//	** it may be more efficient to add just the "a" values to the sorter, and
//	** retrieve the associated "bigblob" values directly from table t1 as the
//	** 10 smallest "a" values are extracted from the sorter.
//	**
//	** When the sorter-reference optimization is used, there is one entry in the
//	** aDefer[] array for each database table that may be read as values are
//	** extracted from the sorter.
//	*/
type TSortCtx = struct {
	FpOrderBy         uintptr
	FnOBSat           int32
	FiECursor         int32
	FregReturn        int32
	FlabelBkOut       int32
	FaddrSortIndex    int32
	FlabelDone        int32
	FlabelOBLopt      int32
	FsortFlags        Tu8
	FpDeferredRowLoad uintptr
}

// C documentation
//
//	/*
//	** This object represents a single thread of control in a sort operation.
//	** Exactly VdbeSorter.nTask instances of this object are allocated
//	** as part of each VdbeSorter object. Instances are never allocated any
//	** other way. VdbeSorter.nTask is set to the number of worker threads allowed
//	** (see SQLITE_CONFIG_WORKER_THREADS) plus one (the main thread).  Thus for
//	** single-threaded operation, there is exactly one instance of this object
//	** and for multi-threaded operation there are two or more instances.
//	**
//	** Essentially, this structure contains all those fields of the VdbeSorter
//	** structure for which each thread requires a separate instance. For example,
//	** each thread requeries its own UnpackedRecord object to unpack records in
//	** as part of comparison operations.
//	**
//	** Before a background thread is launched, variable bDone is set to 0. Then,
//	** right before it exits, the thread itself sets bDone to 1. This is used for
//	** two purposes:
//	**
//	**   1. When flushing the contents of memory to a level-0 PMA on disk, to
//	**      attempt to select a SortSubtask for which there is not already an
//	**      active background thread (since doing so causes the main thread
//	**      to block until it finishes).
//	**
//	**   2. If SQLITE_DEBUG_SORTER_THREADS is defined, to determine if a call
//	**      to sqlite3ThreadJoin() is likely to block. Cases that are likely to
//	**      block provoke debugging output.
//	**
//	** In both cases, the effects of the main thread seeing (bDone==0) even
//	** after the thread has finished are not dire. So we don't worry about
//	** memory barriers and such here.
//	*/
type TSorterCompare = uintptr

/* Incrementally write one PMA */
type TSorterRecord = struct {
	FnVal int32
	Fu    struct {
		FiNext [0]int32
		FpNext uintptr
	}
}

type TStatCell = struct {
	FnLocal    int32
	FiChildPg  Tu32
	FnOvfl     int32
	FaOvfl     uintptr
	FnLastOvfl int32
	FiOvfl     int32
}

type TStatPage = struct {
	FiPgno         Tu32
	FaPg           uintptr
	FiCell         int32
	FzPath         uintptr
	Fflags         Tu8
	FnCell         int32
	FnUnused       int32
	FaCell         uintptr
	FiRightChildPg Tu32
	FnMxPayload    int32
}

// C documentation
//
//	/* Forward reference to data structured used in this module */
type TStatTable = struct {
	Fbase Tsqlite3_vtab
	Fdb   uintptr
	FiDb  int32
}

type TStrAccum = struct {
	Fdb          uintptr
	FzText       uintptr
	FnAlloc      Tu32
	FmxAlloc     Tu32
	FnChar       Tu32
	FaccError    Tu8
	FprintfFlags Tu8
}

type TSubProgram = struct {
	FaOp   uintptr
	FnOp   int32
	FnMem  int32
	FnCsr  int32
	FaOnce uintptr
	Ftoken uintptr
	FpNext uintptr
}

type TSubquery = struct {
	FpSelect     uintptr
	FaddrFillSub int32
	FregReturn   int32
	FregResult   int32
}

type TSubrtnSig = struct {
	FselId     int32
	FbComplete Tu8
	FzAff      uintptr
	FiTable    int32
	FiAddr     int32
	FregReturn int32
}

// C documentation
//
//	/* An instance of the SubstContext object describes an substitution edit
//	** to be performed on a parse tree.
//	**
//	** All references to columns in table iTable are to be replaced by corresponding
//	** expressions in pEList.
//	**
//	** ## About "isOuterJoin":
//	**
//	** The isOuterJoin column indicates that the replacement will occur into a
//	** position in the parent that is NULL-able due to an OUTER JOIN.  Either the
//	** target slot in the parent is the right operand of a LEFT JOIN, or one of
//	** the left operands of a RIGHT JOIN.  In either case, we need to potentially
//	** bypass the substituted expression with OP_IfNullRow.
//	**
//	** Suppose the original expression is an integer constant. Even though the table
//	** has the nullRow flag set, because the expression is an integer constant,
//	** it will not be NULLed out.  So instead, we insert an OP_IfNullRow opcode
//	** that checks to see if the nullRow flag is set on the table.  If the nullRow
//	** flag is set, then the value in the register is set to NULL and the original
//	** expression is bypassed.  If the nullRow flag is not set, then the original
//	** expression runs to populate the register.
//	**
//	** Example where this is needed:
//	**
//	**      CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT);
//	**      CREATE TABLE t2(x INT UNIQUE);
//	**
//	**      SELECT a,b,m,x FROM t1 LEFT JOIN (SELECT 59 AS m,x FROM t2) ON b=x;
//	**
//	** When the subquery on the right side of the LEFT JOIN is flattened, we
//	** have to add OP_IfNullRow in front of the OP_Integer that implements the
//	** "m" value of the subquery so that a NULL will be loaded instead of 59
//	** when processing a non-matched row of the left.
//	*/
type TSubstContext = struct {
	FpParse      uintptr
	FiTable      int32
	FiNewTable   int32
	FisOuterJoin int32
	FnSelDepth   int32
	FpEList      uintptr
	FpCList      uintptr
}

// C documentation
//
//	/*
//	** This structure is used to pass data from sqlite3_get_table() through
//	** to the callback function is uses to build the result.
//	*/
type TTabResult = struct {
	FazResult uintptr
	FzErrMsg  uintptr
	FnAlloc   Tu32
	FnRow     Tu32
	FnColumn  Tu32
	FnData    Tu32
	Frc       int32
}

/* Internal alias for sqlite3_str */
type TTable = struct {
	FzName      uintptr
	FaCol       uintptr
	FpIndex     uintptr
	FzColAff    uintptr
	FpCheck     uintptr
	Ftnum       TPgno
	FnTabRef    Tu32
	FtabFlags   Tu32
	FiPKey      Ti16
	FnCol       Ti16
	FnNVCol     Ti16
	FnRowLogEst TLogEst
	FszTabRow   TLogEst
	FkeyConf    Tu8
	FeTabType   Tu8
	Fu          struct {
		Fview [0]struct {
			FpSelect uintptr
		}
		Fvtab [0]struct {
			FnArg  int32
			FazArg uintptr
			Fp     uintptr
		}
		Ftab struct {
			FaddColOffset int32
			FpFKey        uintptr
			FpDfltList    uintptr
		}
	}
	FpTrigger uintptr
	FpSchema  uintptr
	FaHx      [16]Tu8
}

type TTableLock = struct {
	FiDb         int32
	FiTab        TPgno
	FisWriteLock Tu8
	FzLockName   uintptr
}

type TToken = struct {
	Fz uintptr
	Fn uint32
}

type TTokenCtx = struct {
	FpPhrase uintptr
	FpConfig uintptr
	Frc      int32
}

// C documentation
//
//	/*
//	** fts5VisitEntries() context object used by fts5SetupPrefixIterTokendata()
//	** to pass data to prefixIterSetupTokendataCb().
//	*/
type TTokendataSetupCtx = struct {
	FpT        uintptr
	FiTermOff  int32
	FnTermByte int32
}

/*
** An instance of the following structure describes the event of a
** TRIGGER.  "a" is the event type, one of TK_UPDATE, TK_INSERT,
** TK_DELETE, or TK_INSTEAD.  If the event is of the form
**
**      UPDATE ON (a,b,c)
**
** Then the "b" IdList records the list "a,b,c".
 */
type TTrigEvent = struct {
	Fa int32
	Fb uintptr
}

type TTrigger = struct {
	FzName      uintptr
	Ftable      uintptr
	Fop         Tu8
	Ftr_tm      Tu8
	FbReturning Tu8
	FpWhen      uintptr
	FpColumns   uintptr
	FpSchema    uintptr
	FpTabSchema uintptr
	Fstep_list  uintptr
	FpNext      uintptr
}

type TTriggerPrg = struct {
	FpTrigger uintptr
	FpNext    uintptr
	FpProgram uintptr
	Forconf   int32
	FaColmask [2]Tu32
}

type TTriggerStep = struct {
	Fop        Tu8
	Forconf    Tu8
	FpTrig     uintptr
	FpSelect   uintptr
	FpSrc      uintptr
	FpWhere    uintptr
	FpExprList uintptr
	FpIdList   uintptr
	FpUpsert   uintptr
	FzSpan     uintptr
	FpNext     uintptr
	FpLast     uintptr
}

// C documentation
//
//	/**************************************************************************
//	** Start of trigram implementation.
//	*/
type TTrigramTokenizer = struct {
	FbFold      int32
	FiFoldParam int32
}

type TUnicode61Tokenizer = struct {
	FaTokenChar       [128]uint8
	FaFold            uintptr
	FnFold            int32
	FeRemoveDiacritic int32
	FnException       int32
	FaiException      uintptr
	FaCategory        [32]uint8
}

type TUpsert = struct {
	FpUpsertTarget      uintptr
	FpUpsertTargetWhere uintptr
	FpUpsertSet         uintptr
	FpUpsertWhere       uintptr
	FpNextUpsert        uintptr
	FisDoUpdate         Tu8
	FisDup              Tu8
	FpToFree            uintptr
	FpUpsertIdx         uintptr
	FpUpsertSrc         uintptr
	FregData            int32
	FiDataCur           int32
	FiIdxCur            int32
}

// C documentation
//
//	/* A VList object records a mapping between parameters/variables/wildcards
//	** in the SQL statement (such as $abc, @pqr, or :xyz) and the integer
//	** variable number associated with that parameter.  See the format description
//	** on the sqlite3VListAdd() routine for more information.  A VList is really
//	** just an array of integers.
//	*/
type TVList = int32

type TVTable = struct {
	Fdb          uintptr
	FpMod        uintptr
	FpVtab       uintptr
	FnRef        int32
	FbConstraint Tu8
	FbAllSchemas Tu8
	FeVtabRisk   Tu8
	FiSavepoint  int32
	FpNext       uintptr
}

// C documentation
//
//	/*
//	** An instance of this object is used to pass an vector of values into
//	** OP_VFilter, the xFilter method of a virtual table.  The vector is the
//	** set of values on the right-hand side of an IN constraint.
//	**
//	** The value as passed into xFilter is an sqlite3_value with a "pointer"
//	** type, such as is generated by sqlite3_result_pointer() and read by
//	** sqlite3_value_pointer.  Such values have MEM_Term|MEM_Subtype|MEM_Null
//	** and a subtype of 'p'.  The sqlite3_vtab_in_first() and _next() interfaces
//	** know how to use this object to step through all the values in the
//	** right operand of the IN constraint.
//	*/
type TValueList = struct {
	FpCsr uintptr
	FpOut uintptr
}

/*
** Context object passed by sqlite3Stat4ProbeSetValue() through to
** valueNew(). See comments above valueNew() for details.
 */
type TValueNewStat4Ctx = struct {
	FpParse uintptr
	FpIdx   uintptr
	FppRec  uintptr
	FiVal   int32
}

/*
** A single instruction of the virtual machine has an opcode
** and as many as three operands.  The instruction is recorded
** as an instance of the following structure:
 */
type TVdbeOp = struct {
	Fopcode Tu8
	Fp4type int8
	Fp5     Tu16
	Fp1     int32
	Fp2     int32
	Fp3     int32
	Fp4     Tp4union
}

/*
** A smaller version of VdbeOp used for the VdbeAddOpList() function because
** it takes up less space.
 */
type TVdbeOpList = struct {
	Fopcode Tu8
	Fp1     int8
	Fp2     int8
	Fp3     int8
}

type TVtabCtx = struct {
	FpVTable   uintptr
	FpTab      uintptr
	FpPrior    uintptr
	FbDeclared int32
}

type TWalCkptInfo = struct {
	FnBackfill          Tu32
	FaReadMark          [5]Tu32
	FaLock              [8]Tu8
	FnBackfillAttempted Tu32
	FnotUsed0           Tu32
}

// C documentation
//
//	/*
//	** An instance of the WalHashLoc object is used to describe the location
//	** of a page hash table in the wal-index.  This becomes the return value
//	** from walHashGet().
//	*/
type TWalHashLoc = struct {
	FaHash uintptr
	FaPgno uintptr
	FiZero Tu32
}

// C documentation
//
//	/* Object declarations */
type TWalIndexHdr = struct {
	FiVersion    Tu32
	Funused      Tu32
	FiChange     Tu32
	FisInit      Tu8
	FbigEndCksum Tu8
	FszPage      Tu16
	FmxFrame     Tu32
	FnPage       Tu32
	FaFrameCksum [2]Tu32
	FaSalt       [2]Tu32
	FaCksum      [2]Tu32
}

type TWalSegment = struct {
	FiNext  int32
	FaIndex uintptr
	FaPgno  uintptr
	FnEntry int32
	FiZero  int32
}

type TWalker = struct {
	FpParse           uintptr
	FxExprCallback    uintptr
	FxSelectCallback  uintptr
	FxSelectCallback2 uintptr
	FwalkerDepth      int32
	FeCode            Tu16
	FmWFlags          Tu16
	Fu                struct {
		Fn           [0]int32
		FiCur        [0]int32
		Fsz          [0]int32
		FpSrcList    [0]uintptr
		FpCCurHint   [0]uintptr
		FpRefSrcList [0]uintptr
		FaiCol       [0]uintptr
		FpIdxCover   [0]uintptr
		FpGroupBy    [0]uintptr
		FpSelect     [0]uintptr
		FpRewrite    [0]uintptr
		FpConst      [0]uintptr
		FpRename     [0]uintptr
		FpTab        [0]uintptr
		FpCovIdxCk   [0]uintptr
		FpSrcItem    [0]uintptr
		FpFix        [0]uintptr
		FaMem        [0]uintptr
		FpCheckOnCtx [0]uintptr
		FpNC         uintptr
	}
}

// C documentation
//
//	/*
//	** A structure to keep track of all of the column values that are fixed to
//	** a known value due to WHERE clause constraints of the form COLUMN=VALUE.
//	*/
type TWhereConst = struct {
	FpParse      uintptr
	FpOomFault   uintptr
	FnConst      int32
	FnChng       int32
	FbHasAffBlob int32
	FmExcludeOn  Tu32
	FapExpr      uintptr
}

type TWhereLoopBuilder = struct {
	FpWInfo     uintptr
	FpWC        uintptr
	FpNew       uintptr
	FpOrSet     uintptr
	FpRec       uintptr
	FnRecValid  int32
	FbldFlags1  uint8
	FbldFlags2  uint8
	FiPlanLimit uint32
}

type TWhereMaskSet = struct {
	FbVarSelect int32
	Fn          int32
	Fix         [64]int32
}

type TWhereRightJoin = struct {
	FiMatch     int32
	FregBloom   int32
	FregReturn  int32
	FaddrSubrtn int32
	FendSubrtn  int32
}

type TWindow = struct {
	FzName          uintptr
	FzBase          uintptr
	FpPartition     uintptr
	FpOrderBy       uintptr
	FeFrmType       Tu8
	FeStart         Tu8
	FeEnd           Tu8
	FbImplicitFrame Tu8
	FeExclude       Tu8
	FpStart         uintptr
	FpEnd           uintptr
	FppThis         uintptr
	FpNextWin       uintptr
	FpFilter        uintptr
	FpWFunc         uintptr
	FiEphCsr        int32
	FregAccum       int32
	FregResult      int32
	FcsrApp         int32
	FregApp         int32
	FregPart        int32
	FpOwner         uintptr
	FnBufferCol     int32
	FiArgCol        int32
	FregOne         int32
	FregStartRowid  int32
	FregEndRowid    int32
	FbExprArgs      Tu8
}

type TWindowCodeArg = struct {
	FpParse    uintptr
	FpMWin     uintptr
	FpVdbe     uintptr
	FaddrGosub int32
	FregGosub  int32
	FregArg    int32
	FeDelete   int32
	FregRowid  int32
	Fstart     TWindowCsrAndReg
	Fcurrent   TWindowCsrAndReg
	Fend       TWindowCsrAndReg
}

type TWindowCsrAndReg = struct {
	Fcsr int32
	Freg int32
}

// C documentation
//
//	/*
//	** Context object passed through sqlite3WalkExprList() to
//	** selectWindowRewriteExprCb() by selectWindowRewriteEList().
//	*/
type TWindowRewrite = struct {
	FpWin       uintptr
	FpSrc       uintptr
	FpSub       uintptr
	FpTab       uintptr
	FpSubSelect uintptr
}

type TWith = struct {
	FnCte   int32
	FbView  int32
	FpOuter uintptr
}

type T_ht = struct {
	Fcount uint32
	Fchain uintptr
}

type TabResult = TTabResult

type Table = TTable

type TableLock = TTableLock

// C documentation
//
//	/*
//	** Used to pass information from the analyzer reader through to the
//	** callback routine.
//	*/
type TanalysisInfo = struct {
	Fdb        uintptr
	FzDatabase uintptr
}

// C documentation
//
//	/* A bitfield type for use inside of structures.  Always follow with :N where
//	** N is the number of bits.
//	*/
type Tbft = uint32

type Tclockid_t = int32

/*
** A structure defining how to do GLOB-style comparisons.
 */
type TcompareInfo = struct {
	FmatchAll Tu8
	FmatchOne Tu8
	FmatchSet Tu8
	FnoCase   Tu8
}

type Tdiv_t = struct {
	Fquot int32
	Frem  int32
}

type Tdouble_t = float64

// C documentation
//
//	/*
//	** An "etByte" is an 8-bit unsigned value.
//	*/
type TetByte = uint8

// C documentation
//
//	/*************************************************************************
//	** FTS5 EXTENSION REGISTRATION API
//	*/
type Tfts5_api = struct {
	FiVersion            int32
	FxCreateTokenizer    uintptr
	FxFindTokenizer      uintptr
	FxCreateFunction     uintptr
	FxCreateTokenizer_v2 uintptr
	FxFindTokenizer_v2   uintptr
}

type Tfts5_extension_function = uintptr

// C documentation
//
//	/*
//	** New code should use the fts5_tokenizer_v2 type to define tokenizer
//	** implementations. The following type is included for legacy applications
//	** that still use it.
//	*/
type Tfts5_tokenizer = struct {
	FxCreate   uintptr
	FxDelete   uintptr
	FxTokenize uintptr
}

type Tfts5_tokenizer_v2 = struct {
	FiVersion  int32
	FxCreate   uintptr
	FxDelete   uintptr
	FxTokenize uintptr
}

/* The state of the parser is completely contained in an instance of
** the following structure */
type Tfts5yyParser = struct {
	Ffts5yytos      uintptr
	FpParse         uintptr
	Ffts5yystackEnd uintptr
	Ffts5yystack    uintptr
	Ffts5yystk0     [100]Tfts5yyStackEntry
}

/* The following structure represents a single element of the
** parser's stack.  Information stored includes:
**
**   +  The state number for the parser at this level of the stack.
**
**   +  The value of the token stored at this level of the stack.
**      (In other words, the "major" token.)
**
**   +  The semantic value stored at this level of the stack.  This is
**      the information used by the action routines in the grammar.
**      It is sometimes called the "minor" token.
**
** After the "shift" half of a SHIFTREDUCE action, the stateno field
** actually contains the reduce action for the second half of the
** SHIFTREDUCE.
 */
type Tfts5yyStackEntry = struct {
	Fstateno uint8
	Fmajor   uint8
	Fminor   Tfts5YYMINORTYPE
}

// C documentation
//
//	/*
//	** Each page of the wal-index mapping contains a hash-table made up of
//	** an array of HASHTABLE_NSLOT elements of the following type.
//	*/
type Tht_slot = uint16

/* 2-byte unsigned integer */
type Ti16 = int16

// C documentation
//
//	/*
//	** Integers of known sizes.  These typedefs might change for architectures
//	** where the sizes very.  Preprocessor macros are available so that the
//	** types can be conveniently redefined at compile-type.  Like this:
//	**
//	**         cc '-DUINTPTR_TYPE=long long int' ...
//	*/
type Ti64 = int64

/* 1-byte unsigned integer */
type Ti8 = int8

type Tint16_t = int16

type Tint32_t = int32

type Tint64_t = int64

type Tint8_t = int8

type Tint_fast32_t = int32

type Tint_fast64_t = int64

type Tint_least16_t = int16

type Tint_least32_t = int32

type Tint_least64_t = int64

type Tint_least8_t = int8

type Tintmax_t = int64

type Toff_t = int64

type Token = TToken

type TokenCtx = TTokenCtx

type TokendataSetupCtx = TTokendataSetupCtx

type Trbu_vfs = struct {
	Fbase     Tsqlite3_vfs
	FpRealVfs uintptr
	Fmutex    uintptr
	FpRbu     uintptr
	FpMain    uintptr
	FpMainRbu uintptr
}

type TrigEvent = TTrigEvent

type Trigger = TTrigger

type TriggerPrg = TTriggerPrg

type TriggerStep = TTriggerStep

type TrigramTokenizer = TTrigramTokenizer

type TsColMap = struct {
	FiFrom int32
	FzCol  uintptr
}

// C documentation
//
//	/*
//	** The following object holds the list of automatically loaded
//	** extensions.
//	**
//	** This list is shared across threads.  The SQLITE_MUTEX_STATIC_MAIN
//	** mutex must be held while accessing this list.
//	*/
type Tsqlite3AutoExtList = struct {
	FnExt Tu32
	FaExt uintptr
}

type Tsqlite3InitInfo = struct {
	FnewTnum       TPgno
	FiDb           Tu8
	Fbusy          Tu8
	F__ccgo_align3 [2]byte
	F__ccgo8       uint8
	FazInit        uintptr
}

// C documentation
//
//	/* All threads share a single random number generator.
//	** This structure is the current state of the generator.
//	*/
type Tsqlite3PrngType = struct {
	Fs   [16]Tu32
	Fout [64]Tu8
	Fn   Tu8
}

type Tsqlite3StatType = struct {
	FnowValue [10]Tsqlite3StatValueType
	FmxValue  [10]Tsqlite3StatValueType
}

// C documentation
//
//	/*
//	** CAPI3REF: Loadable Extension Thunk
//	**
//	** A pointer to the opaque sqlite3_api_routines structure is passed as
//	** the third parameter to entry points of [loadable extensions].  This
//	** structure must be typedefed in order to work around compiler warnings
//	** on some platforms.
//	*/
type Tsqlite3_api_routines = struct {
	Faggregate_context      uintptr
	Faggregate_count        uintptr
	Fbind_blob              uintptr
	Fbind_double            uintptr
	Fbind_int               uintptr
	Fbind_int64             uintptr
	Fbind_null              uintptr
	Fbind_parameter_count   uintptr
	Fbind_parameter_index   uintptr
	Fbind_parameter_name    uintptr
	Fbind_text              uintptr
	Fbind_text16            uintptr
	Fbind_value             uintptr
	Fbusy_handler           uintptr
	Fbusy_timeout           uintptr
	Fchanges                uintptr
	Fclose1                 uintptr
	Fcollation_needed       uintptr
	Fcollation_needed16     uintptr
	Fcolumn_blob            uintptr
	Fcolumn_bytes           uintptr
	Fcolumn_bytes16         uintptr
	Fcolumn_count           uintptr
	Fcolumn_database_name   uintptr
	Fcolumn_database_name16 uintptr
	Fcolumn_decltype        uintptr
	Fcolumn_decltype16      uintptr
	Fcolumn_double          uintptr
	Fcolumn_int             uintptr
	Fcolumn_int64           uintptr
	Fcolumn_name            uintptr
	Fcolumn_name16          uintptr
	Fcolumn_origin_name     uintptr
	Fcolumn_origin_name16   uintptr
	Fcolumn_table_name      uintptr
	Fcolumn_table_name16    uintptr
	Fcolumn_text            uintptr
	Fcolumn_text16          uintptr
	Fcolumn_type            uintptr
	Fcolumn_value           uintptr
	Fcommit_hook            uintptr
	Fcomplete               uintptr
	Fcomplete16             uintptr
	Fcreate_collation       uintptr
	Fcreate_collation16     uintptr
	Fcreate_function        uintptr
	Fcreate_function16      uintptr
	Fcreate_module          uintptr
	Fdata_count             uintptr
	Fdb_handle              uintptr
	Fdeclare_vtab           uintptr
	Fenable_shared_cache    uintptr
	Ferrcode                uintptr
	Ferrmsg                 uintptr
	Ferrmsg16               uintptr
	Fexec                   uintptr
	Fexpired                uintptr
	Ffinalize               uintptr
	Ffree                   uintptr
	Ffree_table             uintptr
	Fget_autocommit         uintptr
	Fget_auxdata            uintptr
	Fget_table              uintptr
	Fglobal_recover         uintptr
	Finterruptx             uintptr
	Flast_insert_rowid      uintptr
	Flibversion             uintptr
	Flibversion_number      uintptr
	Fmalloc                 uintptr
	Fmprintf                uintptr
	Fopen                   uintptr
	Fopen16                 uintptr
	Fprepare                uintptr
	Fprepare16              uintptr
	Fprofile                uintptr
	Fprogress_handler       uintptr
	Frealloc                uintptr
	Freset                  uintptr
	Fresult_blob            uintptr
	Fresult_double          uintptr
	Fresult_error           uintptr
	Fresult_error16         uintptr
	Fresult_int             uintptr
	Fresult_int64           uintptr
	Fresult_null            uintptr
	Fresult_text            uintptr
	Fresult_text16          uintptr
	Fresult_text16be        uintptr
	Fresult_text16le        uintptr
	Fresult_value           uintptr
	Frollback_hook          uintptr
	Fset_authorizer         uintptr
	Fset_auxdata            uintptr
	Fxsnprintf              uintptr
	Fstep                   uintptr
	Ftable_column_metadata  uintptr
	Fthread_cleanup         uintptr
	Ftotal_changes          uintptr
	Ftrace                  uintptr
	Ftransfer_bindings      uintptr
	Fupdate_hook            uintptr
	Fuser_data              uintptr
	Fvalue_blob             uintptr
	Fvalue_bytes            uintptr
	Fvalue_bytes16          uintptr
	Fvalue_double           uintptr
	Fvalue_int              uintptr
	Fvalue_int64            uintptr
	Fvalue_numeric_type     uintptr
	Fvalue_text             uintptr
	Fvalue_text16           uintptr
	Fvalue_text16be         uintptr
	Fvalue_text16le         uintptr
	Fvalue_type             uintptr
	Fvmprintf               uintptr
	Foverload_function      uintptr
	Fprepare_v2             uintptr
	Fprepare16_v2           uintptr
	Fclear_bindings         uintptr
	Fcreate_module_v2       uintptr
	Fbind_zeroblob          uintptr
	Fblob_bytes             uintptr
	Fblob_close             uintptr
	Fblob_open              uintptr
	Fblob_read              uintptr
	Fblob_write             uintptr
	Fcreate_collation_v2    uintptr
	Ffile_control           uintptr
	Fmemory_highwater       uintptr
	Fmemory_used            uintptr
	Fmutex_alloc            uintptr
	Fmutex_enter            uintptr
	Fmutex_free             uintptr
	Fmutex_leave            uintptr
	Fmutex_try              uintptr
	Fopen_v2                uintptr
	Frelease_memory         uintptr
	Fresult_error_nomem     uintptr
	Fresult_error_toobig    uintptr
	Fsleep                  uintptr
	Fsoft_heap_limit        uintptr
	Fvfs_find               uintptr
	Fvfs_register           uintptr
	Fvfs_unregister         uintptr
	Fxthreadsafe            uintptr
	Fresult_zeroblob        uintptr
	Fresult_error_code      uintptr
	Ftest_control           uintptr
	Frandomness             uintptr
	Fcontext_db_handle      uintptr
	Fextended_result_codes  uintptr
	Flimit                  uintptr
	Fnext_stmt              uintptr
	Fsql                    uintptr
	Fstatus                 uintptr
	Fbackup_finish          uintptr
	Fbackup_init            uintptr
	Fbackup_pagecount       uintptr
	Fbackup_remaining       uintptr
	Fbackup_step            uintptr
	Fcompileoption_get      uintptr
	Fcompileoption_used     uintptr
	Fcreate_function_v2     uintptr
	Fdb_config              uintptr
	Fdb_mutex               uintptr
	Fdb_status              uintptr
	Fextended_errcode       uintptr
	Flog                    uintptr
	Fsoft_heap_limit64      uintptr
	Fsourceid               uintptr
	Fstmt_status            uintptr
	Fstrnicmp               uintptr
	Funlock_notify          uintptr
	Fwal_autocheckpoint     uintptr
	Fwal_checkpoint         uintptr
	Fwal_hook               uintptr
	Fblob_reopen            uintptr
	Fvtab_config            uintptr
	Fvtab_on_conflict       uintptr
	Fclose_v2               uintptr
	Fdb_filename            uintptr
	Fdb_readonly            uintptr
	Fdb_release_memory      uintptr
	Ferrstr                 uintptr
	Fstmt_busy              uintptr
	Fstmt_readonly          uintptr
	Fstricmp                uintptr
	Furi_boolean            uintptr
	Furi_int64              uintptr
	Furi_parameter          uintptr
	Fxvsnprintf             uintptr
	Fwal_checkpoint_v2      uintptr
	Fauto_extension         uintptr
	Fbind_blob64            uintptr
	Fbind_text64            uintptr
	Fcancel_auto_extension  uintptr
	Fload_extension         uintptr
	Fmalloc64               uintptr
	Fmsize                  uintptr
	Frealloc64              uintptr
	Freset_auto_extension   uintptr
	Fresult_blob64          uintptr
	Fresult_text64          uintptr
	Fstrglob                uintptr
	Fvalue_dup              uintptr
	Fvalue_free             uintptr
	Fresult_zeroblob64      uintptr
	Fbind_zeroblob64        uintptr
	Fvalue_subtype          uintptr
	Fresult_subtype         uintptr
	Fstatus64               uintptr
	Fstrlike                uintptr
	Fdb_cacheflush          uintptr
	Fsystem_errno           uintptr
	Ftrace_v2               uintptr
	Fexpanded_sql           uintptr
	Fset_last_insert_rowid  uintptr
	Fprepare_v3             uintptr
	Fprepare16_v3           uintptr
	Fbind_pointer           uintptr
	Fresult_pointer         uintptr
	Fvalue_pointer          uintptr
	Fvtab_nochange          uintptr
	Fvalue_nochange         uintptr
	Fvtab_collation         uintptr
	Fkeyword_count          uintptr
	Fkeyword_name           uintptr
	Fkeyword_check          uintptr
	Fstr_new                uintptr
	Fstr_finish             uintptr
	Fstr_appendf            uintptr
	Fstr_vappendf           uintptr
	Fstr_append             uintptr
	Fstr_appendall          uintptr
	Fstr_appendchar         uintptr
	Fstr_reset              uintptr
	Fstr_errcode            uintptr
	Fstr_length             uintptr
	Fstr_value              uintptr
	Fcreate_window_function uintptr
	Fnormalized_sql         uintptr
	Fstmt_isexplain         uintptr
	Fvalue_frombind         uintptr
	Fdrop_modules           uintptr
	Fhard_heap_limit64      uintptr
	Furi_key                uintptr
	Ffilename_database      uintptr
	Ffilename_journal       uintptr
	Ffilename_wal           uintptr
	Fcreate_filename        uintptr
	Ffree_filename          uintptr
	Fdatabase_file_object   uintptr
	Ftxn_state              uintptr
	Fchanges64              uintptr
	Ftotal_changes64        uintptr
	Fautovacuum_pages       uintptr
	Ferror_offset           uintptr
	Fvtab_rhs_value         uintptr
	Fvtab_distinct          uintptr
	Fvtab_in                uintptr
	Fvtab_in_first          uintptr
	Fvtab_in_next           uintptr
	Fdeserialize            uintptr
	Fserialize              uintptr
	Fdb_name                uintptr
	Fvalue_encoding         uintptr
	Fis_interrupted         uintptr
	Fstmt_explain           uintptr
	Fget_clientdata         uintptr
	Fset_clientdata         uintptr
	Fsetlk_timeout          uintptr
	Fset_errmsg             uintptr
	Fdb_status64            uintptr
	Fstr_truncate           uintptr
	Fstr_free               uintptr
	Fcarray_bind            uintptr
	Fcarray_bind_v2         uintptr
}

// C documentation
//
//	/*
//	** CAPI3REF: Online Backup Object
//	**
//	** The sqlite3_backup object records state information about an ongoing
//	** online backup operation.  ^The sqlite3_backup object is created by
//	** a call to [sqlite3_backup_init()] and is destroyed by a call to
//	** [sqlite3_backup_finish()].
//	**
//	** See Also: [Using the SQLite Online Backup API]
//	*/
type Tsqlite3_backup = struct {
	FpDestDb     uintptr
	FzDestDb     uintptr
	FpDest       uintptr
	FiDestSchema Tu32
	FbDestLocked int32
	FiNext       TPgno
	FpSrcDb      uintptr
	FpSrc        uintptr
	Frc          int32
	FnRemaining  TPgno
	FnPagecount  TPgno
	FisAttached  int32
	FpNext       uintptr
}

// C documentation
//
//	/*
//	** The type for a callback function.
//	** This is legacy and deprecated.  It is included for historical
//	** compatibility and is not documented.
//	*/
type Tsqlite3_callback = uintptr

// C documentation
//
//	/*
//	** CAPI3REF: Changegroup Handle
//	**
//	** A changegroup is an object used to combine two or more
//	** [changesets] or [patchsets]
//	*/
type Tsqlite3_changegroup = struct {
	Frc     int32
	FbPatch int32
	FpList  uintptr
	Frec    TSessionBuffer
	Fdb     uintptr
	FzDb    uintptr
	Fcd     TChangeData
}

// C documentation
//
//	/*
//	** CAPI3REF: Changeset Iterator Handle
//	**
//	** An instance of this object acts as a cursor for iterating
//	** over the elements of a [changeset] or [patchset].
//	*/
type Tsqlite3_changeset_iter = struct {
	Fin         TSessionInput
	Ftblhdr     TSessionBuffer
	FbPatchset  int32
	FbInvert    int32
	FbSkipEmpty int32
	Frc         int32
	FpConflict  uintptr
	FzTab       uintptr
	FnCol       int32
	Fop         int32
	FbIndirect  int32
	FabPK       uintptr
	FapValue    uintptr
}

// C documentation
//
//	/*
//	** CAPI3REF: SQL Function Context Object
//	**
//	** The context in which an SQL function executes is stored in an
//	** sqlite3_context object.  ^A pointer to an sqlite3_context object
//	** is always the first parameter to [application-defined SQL functions].
//	** The application-defined SQL function implementation will pass this
//	** pointer through into calls to [sqlite3_result_int | sqlite3_result()],
//	** [sqlite3_aggregate_context()], [sqlite3_user_data()],
//	** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],
//	** and/or [sqlite3_set_auxdata()].
//	*/
type Tsqlite3_context = struct {
	FpOut     uintptr
	FpFunc    uintptr
	FpMem     uintptr
	FpVdbe    uintptr
	FiOp      int32
	FisError  int32
	Fenc      Tu8
	FskipFlag Tu8
	Fargc     Tu16
}

// C documentation
//
//	/*
//	** CAPI3REF: Constants Defining Special Destructor Behavior
//	**
//	** These are special values for the destructor that is passed in as the
//	** final argument to routines like [sqlite3_result_blob()].  ^If the destructor
//	** argument is SQLITE_STATIC, it means that the content pointer is constant
//	** and will never change.  It does not need to be destroyed.  ^The
//	** SQLITE_TRANSIENT value means that the content will likely change in
//	** the near future and that SQLite should make its own private copy of
//	** the content before returning.
//	**
//	** The typedef is necessary to work around problems in certain
//	** C++ compilers.
//	*/
type Tsqlite3_destructor_type = uintptr

// C documentation
//
//	/*
//	** CAPI3REF: OS Interface Open File Handle
//	**
//	** An [sqlite3_file] object represents an open file in the
//	** [sqlite3_vfs | OS interface layer].  Individual OS interface
//	** implementations will
//	** want to subclass this object by appending additional fields
//	** for their own use.  The pMethods entry is a pointer to an
//	** [sqlite3_io_methods] object that defines methods for performing
//	** I/O operations on the open file.
//	*/
type Tsqlite3_file = struct {
	FpMethods uintptr
}

// C documentation
//
//	/*
//	** CAPI3REF: File Name
//	**
//	** Type [sqlite3_filename] is used by SQLite to pass filenames to the
//	** xOpen method of a [VFS]. It may be cast to (const char*) and treated
//	** as a normal, nul-terminated, UTF-8 buffer containing the filename, but
//	** may also be passed to special APIs such as:
//	**
//	** <ul>
//	** <li>  sqlite3_filename_database()
//	** <li>  sqlite3_filename_journal()
//	** <li>  sqlite3_filename_wal()
//	** <li>  sqlite3_uri_parameter()
//	** <li>  sqlite3_uri_boolean()
//	** <li>  sqlite3_uri_int64()
//	** <li>  sqlite3_uri_key()
//	** </ul>
//	*/
type Tsqlite3_filename = uintptr

type Tsqlite3_index_constraint = struct {
	FiColumn     int32
	Fop          uint8
	Fusable      uint8
	FiTermOffset int32
}

type Tsqlite3_index_constraint_usage = struct {
	FargvIndex int32
	Fomit      uint8
}

type Tsqlite3_index_orderby = struct {
	FiColumn int32
	Fdesc    uint8
}

type Tsqlite3_int64 = int64

// C documentation
//
//	/*
//	** CAPI3REF: OS Interface File Virtual Methods Object
//	**
//	** Every file opened by the [sqlite3_vfs.xOpen] method populates an
//	** [sqlite3_file] object (or, more commonly, a subclass of the
//	** [sqlite3_file] object) with a pointer to an instance of this object.
//	** This object defines the methods used to perform various operations
//	** against the open file represented by the [sqlite3_file] object.
//	**
//	** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element
//	** to a non-NULL pointer, then the sqlite3_io_methods.xClose method
//	** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed.  The
//	** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen]
//	** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element
//	** to NULL.
//	**
//	** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or
//	** [SQLITE_SYNC_FULL].  The first choice is the normal fsync().
//	** The second choice is a Mac OS X style fullsync.  The [SQLITE_SYNC_DATAONLY]
//	** flag may be ORed in to indicate that only the data of the file
//	** and not its inode needs to be synced.
//	**
//	** The integer values to xLock() and xUnlock() are one of
//	** <ul>
//	** <li> [SQLITE_LOCK_NONE],
//	** <li> [SQLITE_LOCK_SHARED],
//	** <li> [SQLITE_LOCK_RESERVED],
//	** <li> [SQLITE_LOCK_PENDING], or
//	** <li> [SQLITE_LOCK_EXCLUSIVE].
//	** </ul>
//	** xLock() upgrades the database file lock.  In other words, xLock() moves the
//	** database file lock in the direction NONE toward EXCLUSIVE. The argument to
//	** xLock() is always one of SHARED, RESERVED, PENDING, or EXCLUSIVE, never
//	** SQLITE_LOCK_NONE.  If the database file lock is already at or above the
//	** requested lock, then the call to xLock() is a no-op.
//	** xUnlock() downgrades the database file lock to either SHARED or NONE.
//	** If the lock is already at or below the requested lock state, then the call
//	** to xUnlock() is a no-op.
//	** The xCheckReservedLock() method checks whether any database connection,
//	** either in this process or in some other process, is holding a RESERVED,
//	** PENDING, or EXCLUSIVE lock on the file.  It returns, via its output
//	** pointer parameter, true if such a lock exists and false otherwise.
//	**
//	** The xFileControl() method is a generic interface that allows custom
//	** VFS implementations to directly control an open file using the
//	** [sqlite3_file_control()] interface.  The second "op" argument is an
//	** integer opcode.  The third argument is a generic pointer intended to
//	** point to a structure that may contain arguments or space in which to
//	** write return values.  Potential uses for xFileControl() might be
//	** functions to enable blocking locks with timeouts, to change the
//	** locking strategy (for example to use dot-file locks), to inquire
//	** about the status of a lock, or to break stale locks.  The SQLite
//	** core reserves all opcodes less than 100 for its own use.
//	** A [file control opcodes | list of opcodes] less than 100 is available.
//	** Applications that define a custom xFileControl method should use opcodes
//	** greater than 100 to avoid conflicts.  VFS implementations should
//	** return [SQLITE_NOTFOUND] for file control opcodes that they do not
//	** recognize.
//	**
//	** The xSectorSize() method returns the sector size of the
//	** device that underlies the file.  The sector size is the
//	** minimum write that can be performed without disturbing
//	** other bytes in the file.  The xDeviceCharacteristics()
//	** method returns a bit vector describing behaviors of the
//	** underlying device:
//	**
//	** <ul>
//	** <li> [SQLITE_IOCAP_ATOMIC]
//	** <li> [SQLITE_IOCAP_ATOMIC512]
//	** <li> [SQLITE_IOCAP_ATOMIC1K]
//	** <li> [SQLITE_IOCAP_ATOMIC2K]
//	** <li> [SQLITE_IOCAP_ATOMIC4K]
//	** <li> [SQLITE_IOCAP_ATOMIC8K]
//	** <li> [SQLITE_IOCAP_ATOMIC16K]
//	** <li> [SQLITE_IOCAP_ATOMIC32K]
//	** <li> [SQLITE_IOCAP_ATOMIC64K]
//	** <li> [SQLITE_IOCAP_SAFE_APPEND]
//	** <li> [SQLITE_IOCAP_SEQUENTIAL]
//	** <li> [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN]
//	** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]
//	** <li> [SQLITE_IOCAP_IMMUTABLE]
//	** <li> [SQLITE_IOCAP_BATCH_ATOMIC]
//	** <li> [SQLITE_IOCAP_SUBPAGE_READ]
//	** </ul>
//	**
//	** The SQLITE_IOCAP_ATOMIC property means that all writes of
//	** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values
//	** mean that writes of blocks that are nnn bytes in size and
//	** are aligned to an address which is an integer multiple of
//	** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means
//	** that when data is appended to a file, the data is appended
//	** first then the size of the file is extended, never the other
//	** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that
//	** information is written to disk in the same order as calls
//	** to xWrite().
//	**
//	** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill
//	** in the unread portions of the buffer with zeros.  A VFS that
//	** fails to zero-fill short reads might seem to work.  However,
//	** failure to zero-fill short reads will eventually lead to
//	** database corruption.
//	*/
type Tsqlite3_io_methods = struct {
	FiVersion               int32
	FxClose                 uintptr
	FxRead                  uintptr
	FxWrite                 uintptr
	FxTruncate              uintptr
	FxSync                  uintptr
	FxFileSize              uintptr
	FxLock                  uintptr
	FxUnlock                uintptr
	FxCheckReservedLock     uintptr
	FxFileControl           uintptr
	FxSectorSize            uintptr
	FxDeviceCharacteristics uintptr
	FxShmMap                uintptr
	FxShmLock               uintptr
	FxShmBarrier            uintptr
	FxShmUnmap              uintptr
	FxFetch                 uintptr
	FxUnfetch               uintptr
}

// C documentation
//
//	/*
//	** This is the function signature used for all extension entry points.  It
//	** is also defined in the file "loadext.c".
//	*/
type Tsqlite3_loadext_entry = uintptr

// C documentation
//
//	/*
//	** CAPI3REF: Memory Allocation Routines
//	**
//	** An instance of this object defines the interface between SQLite
//	** and low-level memory allocation routines.
//	**
//	** This object is used in only one place in the SQLite interface.
//	** A pointer to an instance of this object is the argument to
//	** [sqlite3_config()] when the configuration option is
//	** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC].
//	** By creating an instance of this object
//	** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])
//	** during configuration, an application can specify an alternative
//	** memory allocation subsystem for SQLite to use for all of its
//	** dynamic memory needs.
//	**
//	** Note that SQLite comes with several [built-in memory allocators]
//	** that are perfectly adequate for the overwhelming majority of applications
//	** and that this object is only useful to a tiny minority of applications
//	** with specialized memory allocation requirements.  This object is
//	** also used during testing of SQLite in order to specify an alternative
//	** memory allocator that simulates memory out-of-memory conditions in
//	** order to verify that SQLite recovers gracefully from such
//	** conditions.
//	**
//	** The xMalloc, xRealloc, and xFree methods must work like the
//	** malloc(), realloc() and free() functions from the standard C library.
//	** ^SQLite guarantees that the second argument to
//	** xRealloc is always a value returned by a prior call to xRoundup.
//	**
//	** xSize should return the allocated size of a memory allocation
//	** previously obtained from xMalloc or xRealloc.  The allocated size
//	** is always at least as big as the requested size but may be larger.
//	**
//	** The xRoundup method returns what would be the allocated size of
//	** a memory allocation given a particular requested size.  Most memory
//	** allocators round up memory allocations at least to the next multiple
//	** of 8.  Some allocators round up to a larger multiple or to a power of 2.
//	** Every memory allocation request coming in through [sqlite3_malloc()]
//	** or [sqlite3_realloc()] first calls xRoundup.  If xRoundup returns 0,
//	** that causes the corresponding memory allocation to fail.
//	**
//	** The xInit method initializes the memory allocator.  For example,
//	** it might allocate any required mutexes or initialize internal data
//	** structures.  The xShutdown method is invoked (indirectly) by
//	** [sqlite3_shutdown()] and should deallocate any resources acquired
//	** by xInit.  The pAppData pointer is used as the only parameter to
//	** xInit and xShutdown.
//	**
//	** SQLite holds the [SQLITE_MUTEX_STATIC_MAIN] mutex when it invokes
//	** the xInit method, so the xInit method need not be threadsafe.  The
//	** xShutdown method is only called from [sqlite3_shutdown()] so it does
//	** not need to be threadsafe either.  For all other methods, SQLite
//	** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the
//	** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which
//	** it is by default) and so the methods are automatically serialized.
//	** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other
//	** methods must be threadsafe or else make their own arrangements for
//	** serialization.
//	**
//	** SQLite will never invoke xInit() more than once without an intervening
//	** call to xShutdown().
//	*/
type Tsqlite3_mem_methods = struct {
	FxMalloc   uintptr
	FxFree     uintptr
	FxRealloc  uintptr
	FxSize     uintptr
	FxRoundup  uintptr
	FxInit     uintptr
	FxShutdown uintptr
	FpAppData  uintptr
}

type Tsqlite3_module = struct {
	FiVersion      int32
	FxCreate       uintptr
	FxConnect      uintptr
	FxBestIndex    uintptr
	FxDisconnect   uintptr
	FxDestroy      uintptr
	FxOpen         uintptr
	FxClose        uintptr
	FxFilter       uintptr
	FxNext         uintptr
	FxEof          uintptr
	FxColumn       uintptr
	FxRowid        uintptr
	FxUpdate       uintptr
	FxBegin        uintptr
	FxSync         uintptr
	FxCommit       uintptr
	FxRollback     uintptr
	FxFindFunction uintptr
	FxRename       uintptr
	FxSavepoint    uintptr
	FxRelease      uintptr
	FxRollbackTo   uintptr
	FxShadowName   uintptr
	FxIntegrity    uintptr
}

// C documentation
//
//	/*
//	** CAPI3REF: Mutex Methods Object
//	**
//	** An instance of this structure defines the low-level routines
//	** used to allocate and use mutexes.
//	**
//	** Usually, the default mutex implementations provided by SQLite are
//	** sufficient, however the application has the option of substituting a custom
//	** implementation for specialized deployments or systems for which SQLite
//	** does not provide a suitable implementation. In this case, the application
//	** creates and populates an instance of this structure to pass
//	** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.
//	** Additionally, an instance of this structure can be used as an
//	** output variable when querying the system for the current mutex
//	** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.
//	**
//	** ^The xMutexInit method defined by this structure is invoked as
//	** part of system initialization by the sqlite3_initialize() function.
//	** ^The xMutexInit routine is called by SQLite exactly once for each
//	** effective call to [sqlite3_initialize()].
//	**
//	** ^The xMutexEnd method defined by this structure is invoked as
//	** part of system shutdown by the sqlite3_shutdown() function. The
//	** implementation of this method is expected to release all outstanding
//	** resources obtained by the mutex methods implementation, especially
//	** those obtained by the xMutexInit method.  ^The xMutexEnd()
//	** interface is invoked exactly once for each call to [sqlite3_shutdown()].
//	**
//	** ^(The remaining seven methods defined by this structure (xMutexAlloc,
//	** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and
//	** xMutexNotheld) implement the following interfaces (respectively):
//	**
//	** <ul>
//	**   <li>  [sqlite3_mutex_alloc()] </li>
//	**   <li>  [sqlite3_mutex_free()] </li>
//	**   <li>  [sqlite3_mutex_enter()] </li>
//	**   <li>  [sqlite3_mutex_try()] </li>
//	**   <li>  [sqlite3_mutex_leave()] </li>
//	**   <li>  [sqlite3_mutex_held()] </li>
//	**   <li>  [sqlite3_mutex_notheld()] </li>
//	** </ul>)^
//	**
//	** The only difference is that the public sqlite3_XXX functions enumerated
//	** above silently ignore any invocations that pass a NULL pointer instead
//	** of a valid mutex handle. The implementations of the methods defined
//	** by this structure are not required to handle this case. The results
//	** of passing a NULL pointer instead of a valid mutex handle are undefined
//	** (i.e. it is acceptable to provide an implementation that segfaults if
//	** it is passed a NULL pointer).
//	**
//	** The xMutexInit() method must be threadsafe.  It must be harmless to
//	** invoke xMutexInit() multiple times within the same process and without
//	** intervening calls to xMutexEnd().  Second and subsequent calls to
//	** xMutexInit() must be no-ops.
//	**
//	** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
//	** and its associates).  Similarly, xMutexAlloc() must not use SQLite memory
//	** allocation for a static mutex.  ^However xMutexAlloc() may use SQLite
//	** memory allocation for a fast or recursive mutex.
//	**
//	** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
//	** called, but only if the prior call to xMutexInit returned SQLITE_OK.
//	** If xMutexInit fails in any way, it is expected to clean up after itself
//	** prior to returning.
//	*/
type Tsqlite3_mutex_methods = struct {
	FxMutexInit    uintptr
	FxMutexEnd     uintptr
	FxMutexAlloc   uintptr
	FxMutexFree    uintptr
	FxMutexEnter   uintptr
	FxMutexTry     uintptr
	FxMutexLeave   uintptr
	FxMutexHeld    uintptr
	FxMutexNotheld uintptr
}

// C documentation
//
//	/*
//	** This is the obsolete pcache_methods object that has now been replaced
//	** by sqlite3_pcache_methods2.  This object is not used by SQLite.  It is
//	** retained in the header file for backwards compatibility only.
//	*/
type Tsqlite3_pcache_methods = struct {
	FpArg       uintptr
	FxInit      uintptr
	FxShutdown  uintptr
	FxCreate    uintptr
	FxCachesize uintptr
	FxPagecount uintptr
	FxFetch     uintptr
	FxUnpin     uintptr
	FxRekey     uintptr
	FxTruncate  uintptr
	FxDestroy   uintptr
}

// C documentation
//
//	/*
//	** CAPI3REF: Application Defined Page Cache.
//	** KEYWORDS: {page cache}
//	**
//	** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can
//	** register an alternative page cache implementation by passing in an
//	** instance of the sqlite3_pcache_methods2 structure.)^
//	** In many applications, most of the heap memory allocated by
//	** SQLite is used for the page cache.
//	** By implementing a
//	** custom page cache using this API, an application can better control
//	** the amount of memory consumed by SQLite, the way in which
//	** that memory is allocated and released, and the policies used to
//	** determine exactly which parts of a database file are cached and for
//	** how long.
//	**
//	** The alternative page cache mechanism is an
//	** extreme measure that is only needed by the most demanding applications.
//	** The built-in page cache is recommended for most uses.
//	**
//	** ^(The contents of the sqlite3_pcache_methods2 structure are copied to an
//	** internal buffer by SQLite within the call to [sqlite3_config].  Hence
//	** the application may discard the parameter after the call to
//	** [sqlite3_config()] returns.)^
//	**
//	** [[the xInit() page cache method]]
//	** ^(The xInit() method is called once for each effective
//	** call to [sqlite3_initialize()])^
//	** (usually only once during the lifetime of the process). ^(The xInit()
//	** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^
//	** The intent of the xInit() method is to set up global data structures
//	** required by the custom page cache implementation.
//	** ^(If the xInit() method is NULL, then the
//	** built-in default page cache is used instead of the application defined
//	** page cache.)^
//	**
//	** [[the xShutdown() page cache method]]
//	** ^The xShutdown() method is called by [sqlite3_shutdown()].
//	** It can be used to clean up
//	** any outstanding resources before process shutdown, if required.
//	** ^The xShutdown() method may be NULL.
//	**
//	** ^SQLite automatically serializes calls to the xInit method,
//	** so the xInit method need not be threadsafe.  ^The
//	** xShutdown method is only called from [sqlite3_shutdown()] so it does
//	** not need to be threadsafe either.  All other methods must be threadsafe
//	** in multithreaded applications.
//	**
//	** ^SQLite will never invoke xInit() more than once without an intervening
//	** call to xShutdown().
//	**
//	** [[the xCreate() page cache methods]]
//	** ^SQLite invokes the xCreate() method to construct a new cache instance.
//	** SQLite will typically create one cache instance for each open database file,
//	** though this is not guaranteed. ^The
//	** first parameter, szPage, is the size in bytes of the pages that must
//	** be allocated by the cache.  ^szPage will always be a power of two.  ^The
//	** second parameter szExtra is a number of bytes of extra storage
//	** associated with each page cache entry.  ^The szExtra parameter will be
//	** a number less than 250.  SQLite will use the
//	** extra szExtra bytes on each page to store metadata about the underlying
//	** database page on disk.  The value passed into szExtra depends
//	** on the SQLite version, the target platform, and how SQLite was compiled.
//	** ^The third argument to xCreate(), bPurgeable, is true if the cache being
//	** created will be used to cache database pages of a file stored on disk, or
//	** false if it is used for an in-memory database. The cache implementation
//	** does not have to do anything special based upon the value of bPurgeable;
//	** it is purely advisory.  ^On a cache where bPurgeable is false, SQLite will
//	** never invoke xUnpin() except to deliberately delete a page.
//	** ^In other words, calls to xUnpin() on a cache with bPurgeable set to
//	** false will always have the "discard" flag set to true.
//	** ^Hence, a cache created with bPurgeable set to false will
//	** never contain any unpinned pages.
//	**
//	** [[the xCachesize() page cache method]]
//	** ^(The xCachesize() method may be called at any time by SQLite to set the
//	** suggested maximum cache-size (number of pages stored) for the cache
//	** instance passed as the first argument. This is the value configured using
//	** the SQLite "[PRAGMA cache_size]" command.)^  As with the bPurgeable
//	** parameter, the implementation is not required to do anything with this
//	** value; it is advisory only.
//	**
//	** [[the xPagecount() page cache methods]]
//	** The xPagecount() method must return the number of pages currently
//	** stored in the cache, both pinned and unpinned.
//	**
//	** [[the xFetch() page cache methods]]
//	** The xFetch() method locates a page in the cache and returns a pointer to
//	** an sqlite3_pcache_page object associated with that page, or a NULL pointer.
//	** The pBuf element of the returned sqlite3_pcache_page object will be a
//	** pointer to a buffer of szPage bytes used to store the content of a
//	** single database page.  The pExtra element of sqlite3_pcache_page will be
//	** a pointer to the szExtra bytes of extra storage that SQLite has requested
//	** for each entry in the page cache.
//	**
//	** The page to be fetched is determined by the key. ^The minimum key value
//	** is 1.  After it has been retrieved using xFetch, the page is considered
//	** to be "pinned".
//	**
//	** If the requested page is already in the page cache, then the page cache
//	** implementation must return a pointer to the page buffer with its content
//	** intact.  If the requested page is not already in the cache, then the
//	** cache implementation should use the value of the createFlag
//	** parameter to help it determine what action to take:
//	**
//	** <table border=1 width=85% align=center>
//	** <tr><th> createFlag <th> Behavior when page is not already in cache
//	** <tr><td> 0 <td> Do not allocate a new page.  Return NULL.
//	** <tr><td> 1 <td> Allocate a new page if it is easy and convenient to do so.
//	**                 Otherwise return NULL.
//	** <tr><td> 2 <td> Make every effort to allocate a new page.  Only return
//	**                 NULL if allocating a new page is effectively impossible.
//	** </table>
//	**
//	** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1.  SQLite
//	** will only use a createFlag of 2 after a prior call with a createFlag of 1
//	** failed.)^  In between the xFetch() calls, SQLite may
//	** attempt to unpin one or more cache pages by spilling the content of
//	** pinned pages to disk and synching the operating system disk cache.
//	**
//	** [[the xUnpin() page cache method]]
//	** ^xUnpin() is called by SQLite with a pointer to a currently pinned page
//	** as its second argument.  If the third parameter, discard, is non-zero,
//	** then the page must be evicted from the cache.
//	** ^If the discard parameter is
//	** zero, then the page may be discarded or retained at the discretion of the
//	** page cache implementation. ^The page cache implementation
//	** may choose to evict unpinned pages at any time.
//	**
//	** The cache must not perform any reference counting. A single
//	** call to xUnpin() unpins the page regardless of the number of prior calls
//	** to xFetch().
//	**
//	** [[the xRekey() page cache methods]]
//	** The xRekey() method is used to change the key value associated with the
//	** page passed as the second argument. If the cache
//	** previously contains an entry associated with newKey, it must be
//	** discarded. ^Any prior cache entry associated with newKey is guaranteed not
//	** to be pinned.
//	**
//	** When SQLite calls the xTruncate() method, the cache must discard all
//	** existing cache entries with page numbers (keys) greater than or equal
//	** to the value of the iLimit parameter passed to xTruncate(). If any
//	** of these pages are pinned, they become implicitly unpinned, meaning that
//	** they can be safely discarded.
//	**
//	** [[the xDestroy() page cache method]]
//	** ^The xDestroy() method is used to delete a cache allocated by xCreate().
//	** All resources associated with the specified cache should be freed. ^After
//	** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
//	** handle invalid, and will not use it with any other sqlite3_pcache_methods2
//	** functions.
//	**
//	** [[the xShrink() page cache method]]
//	** ^SQLite invokes the xShrink() method when it wants the page cache to
//	** free up as much of heap memory as possible.  The page cache implementation
//	** is not obligated to free any memory, but well-behaved implementations should
//	** do their best.
//	*/
type Tsqlite3_pcache_methods2 = struct {
	FiVersion   int32
	FpArg       uintptr
	FxInit      uintptr
	FxShutdown  uintptr
	FxCreate    uintptr
	FxCachesize uintptr
	FxPagecount uintptr
	FxFetch     uintptr
	FxUnpin     uintptr
	FxRekey     uintptr
	FxTruncate  uintptr
	FxDestroy   uintptr
	FxShrink    uintptr
}

// C documentation
//
//	/*
//	** CAPI3REF: Custom Page Cache Object
//	**
//	** The sqlite3_pcache_page object represents a single page in the
//	** page cache.  The page cache will allocate instances of this
//	** object.  Various methods of the page cache use pointers to instances
//	** of this object as parameters or as their return value.
//	**
//	** See [sqlite3_pcache_methods2] for additional information.
//	*/
type Tsqlite3_pcache_page = struct {
	FpBuf   uintptr
	FpExtra uintptr
}

// C documentation
//
//	/*
//	** CAPI3REF: Rebasing changesets
//	** EXPERIMENTAL
//	**
//	** Suppose there is a site hosting a database in state S0. And that
//	** modifications are made that move that database to state S1 and a
//	** changeset recorded (the "local" changeset). Then, a changeset based
//	** on S0 is received from another site (the "remote" changeset) and
//	** applied to the database. The database is then in state
//	** (S1+"remote"), where the exact state depends on any conflict
//	** resolution decisions (OMIT or REPLACE) made while applying "remote".
//	** Rebasing a changeset is to update it to take those conflict
//	** resolution decisions into account, so that the same conflicts
//	** do not have to be resolved elsewhere in the network.
//	**
//	** For example, if both the local and remote changesets contain an
//	** INSERT of the same key on "CREATE TABLE t1(a PRIMARY KEY, b)":
//	**
//	**   local:  INSERT INTO t1 VALUES(1, 'v1');
//	**   remote: INSERT INTO t1 VALUES(1, 'v2');
//	**
//	** and the conflict resolution is REPLACE, then the INSERT change is
//	** removed from the local changeset (it was overridden). Or, if the
//	** conflict resolution was "OMIT", then the local changeset is modified
//	** to instead contain:
//	**
//	**           UPDATE t1 SET b = 'v2' WHERE a=1;
//	**
//	** Changes within the local changeset are rebased as follows:
//	**
//	** <dl>
//	** <dt>Local INSERT<dd>
//	**   This may only conflict with a remote INSERT. If the conflict
//	**   resolution was OMIT, then add an UPDATE change to the rebased
//	**   changeset. Or, if the conflict resolution was REPLACE, add
//	**   nothing to the rebased changeset.
//	**
//	** <dt>Local DELETE<dd>
//	**   This may conflict with a remote UPDATE or DELETE. In both cases the
//	**   only possible resolution is OMIT. If the remote operation was a
//	**   DELETE, then add no change to the rebased changeset. If the remote
//	**   operation was an UPDATE, then the old.* fields of change are updated
//	**   to reflect the new.* values in the UPDATE.
//	**
//	** <dt>Local UPDATE<dd>
//	**   This may conflict with a remote UPDATE or DELETE. If it conflicts
//	**   with a DELETE, and the conflict resolution was OMIT, then the update
//	**   is changed into an INSERT. Any undefined values in the new.* record
//	**   from the update change are filled in using the old.* values from
//	**   the conflicting DELETE. Or, if the conflict resolution was REPLACE,
//	**   the UPDATE change is simply omitted from the rebased changeset.
//	**
//	**   If conflict is with a remote UPDATE and the resolution is OMIT, then
//	**   the old.* values are rebased using the new.* values in the remote
//	**   change. Or, if the resolution is REPLACE, then the change is copied
//	**   into the rebased changeset with updates to columns also updated by
//	**   the conflicting remote UPDATE removed. If this means no columns would
//	**   be updated, the change is omitted.
//	** </dl>
//	**
//	** A local change may be rebased against multiple remote changes
//	** simultaneously. If a single key is modified by multiple remote
//	** changesets, they are combined as follows before the local changeset
//	** is rebased:
//	**
//	** <ul>
//	**    <li> If there has been one or more REPLACE resolutions on a
//	**         key, it is rebased according to a REPLACE.
//	**
//	**    <li> If there have been no REPLACE resolutions on a key, then
//	**         the local changeset is rebased according to the most recent
//	**         of the OMIT resolutions.
//	** </ul>
//	**
//	** Note that conflict resolutions from multiple remote changesets are
//	** combined on a per-field basis, not per-row. This means that in the
//	** case of multiple remote UPDATE operations, some fields of a single
//	** local change may be rebased for REPLACE while others are rebased for
//	** OMIT.
//	**
//	** In order to rebase a local changeset, the remote changeset must first
//	** be applied to the local database using sqlite3changeset_apply_v2() and
//	** the buffer of rebase information captured. Then:
//	**
//	** <ol>
//	**   <li> An sqlite3_rebaser object is created by calling
//	**        sqlite3rebaser_create().
//	**   <li> The new object is configured with the rebase buffer obtained from
//	**        sqlite3changeset_apply_v2() by calling sqlite3rebaser_configure().
//	**        If the local changeset is to be rebased against multiple remote
//	**        changesets, then sqlite3rebaser_configure() should be called
//	**        multiple times, in the same order that the multiple
//	**        sqlite3changeset_apply_v2() calls were made.
//	**   <li> Each local changeset is rebased by calling sqlite3rebaser_rebase().
//	**   <li> The sqlite3_rebaser object is deleted by calling
//	**        sqlite3rebaser_delete().
//	** </ol>
//	*/
type Tsqlite3_rebaser = struct {
	Fgrp Tsqlite3_changegroup
}

// C documentation
//
//	/* The double-precision datatype used by RTree depends on the
//	** SQLITE_RTREE_INT_ONLY compile-time option.
//	*/
type Tsqlite3_rtree_dbl = float64

type Tsqlite3_rtree_geometry = struct {
	FpContext uintptr
	FnParam   int32
	FaParam   uintptr
	FpUser    uintptr
	FxDelUser uintptr
}

// C documentation
//
//	/*
//	** CAPI3REF: Database Snapshot
//	** KEYWORDS: {snapshot} {sqlite3_snapshot}
//	**
//	** An instance of the snapshot object records the state of a [WAL mode]
//	** database for some specific point in history.
//	**
//	** In [WAL mode], multiple [database connections] that are open on the
//	** same database file can each be reading a different historical version
//	** of the database file.  When a [database connection] begins a read
//	** transaction, that connection sees an unchanging copy of the database
//	** as it existed for the point in time when the transaction first started.
//	** Subsequent changes to the database from other connections are not seen
//	** by the reader until a new read transaction is started.
//	**
//	** The sqlite3_snapshot object records state information about an historical
//	** version of the database file so that it is possible to later open a new read
//	** transaction that sees that historical version of the database rather than
//	** the most recent version.
//	*/
type Tsqlite3_snapshot = struct {
	Fhidden [48]uint8
}

// C documentation
//
//	/*
//	** CAPI3REF: Dynamic String Object
//	** KEYWORDS: {dynamic string}
//	**
//	** An instance of the sqlite3_str object contains a dynamically-sized
//	** string under construction.
//	**
//	** The lifecycle of an sqlite3_str object is as follows:
//	** <ol>
//	** <li> ^The sqlite3_str object is created using [sqlite3_str_new()].
//	** <li> ^Text is appended to the sqlite3_str object using various
//	** methods, such as [sqlite3_str_appendf()].
//	** <li> ^The sqlite3_str object is destroyed and the string it created
//	** is returned using the [sqlite3_str_finish()] interface.
//	** </ol>
//	*/
type Tsqlite3_str = struct {
	Fdb          uintptr
	FzText       uintptr
	FnAlloc      Tu32
	FmxAlloc     Tu32
	FnChar       Tu32
	FaccError    Tu8
	FprintfFlags Tu8
}

type Tsqlite3_syscall_ptr = uintptr

type Tsqlite3_uint64 = uint64

// C documentation
//
//	/*
//	** CAPI3REF: OS Interface Object
//	**
//	** An instance of the sqlite3_vfs object defines the interface between
//	** the SQLite core and the underlying operating system.  The "vfs"
//	** in the name of the object stands for "virtual file system".  See
//	** the [VFS | VFS documentation] for further information.
//	**
//	** The VFS interface is sometimes extended by adding new methods onto
//	** the end.  Each time such an extension occurs, the iVersion field
//	** is incremented.  The iVersion value started out as 1 in
//	** SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2
//	** with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased
//	** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6].  Additional fields
//	** may be appended to the sqlite3_vfs object and the iVersion value
//	** may increase again in future versions of SQLite.
//	** Note that due to an oversight, the structure
//	** of the sqlite3_vfs object changed in the transition from
//	** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0]
//	** and yet the iVersion field was not increased.
//	**
//	** The szOsFile field is the size of the subclassed [sqlite3_file]
//	** structure used by this VFS.  mxPathname is the maximum length of
//	** a pathname in this VFS.
//	**
//	** Registered sqlite3_vfs objects are kept on a linked list formed by
//	** the pNext pointer.  The [sqlite3_vfs_register()]
//	** and [sqlite3_vfs_unregister()] interfaces manage this list
//	** in a thread-safe way.  The [sqlite3_vfs_find()] interface
//	** searches the list.  Neither the application code nor the VFS
//	** implementation should use the pNext pointer.
//	**
//	** The pNext field is the only field in the sqlite3_vfs
//	** structure that SQLite will ever modify.  SQLite will only access
//	** or modify this field while holding a particular static mutex.
//	** The application should never modify anything within the sqlite3_vfs
//	** object once the object has been registered.
//	**
//	** The zName field holds the name of the VFS module.  The name must
//	** be unique across all VFS modules.
//	**
//	** [[sqlite3_vfs.xOpen]]
//	** ^SQLite guarantees that the zFilename parameter to xOpen
//	** is either a NULL pointer or string obtained
//	** from xFullPathname() with an optional suffix added.
//	** ^If a suffix is added to the zFilename parameter, it will
//	** consist of a single "-" character followed by no more than
//	** 11 alphanumeric and/or "-" characters.
//	** ^SQLite further guarantees that
//	** the string will be valid and unchanged until xClose() is
//	** called. Because of the previous sentence,
//	** the [sqlite3_file] can safely store a pointer to the
//	** filename if it needs to remember the filename for some reason.
//	** If the zFilename parameter to xOpen is a NULL pointer then xOpen
//	** must invent its own temporary name for the file.  ^Whenever the
//	** xFilename parameter is NULL it will also be the case that the
//	** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].
//	**
//	** The flags argument to xOpen() includes all bits set in
//	** the flags argument to [sqlite3_open_v2()].  Or if [sqlite3_open()]
//	** or [sqlite3_open16()] is used, then flags includes at least
//	** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE].
//	** If xOpen() opens a file read-only then it sets *pOutFlags to
//	** include [SQLITE_OPEN_READONLY].  Other bits in *pOutFlags may be set.
//	**
//	** ^(SQLite will also add one of the following flags to the xOpen()
//	** call, depending on the object being opened:
//	**
//	** <ul>
//	** <li>  [SQLITE_OPEN_MAIN_DB]
//	** <li>  [SQLITE_OPEN_MAIN_JOURNAL]
//	** <li>  [SQLITE_OPEN_TEMP_DB]
//	** <li>  [SQLITE_OPEN_TEMP_JOURNAL]
//	** <li>  [SQLITE_OPEN_TRANSIENT_DB]
//	** <li>  [SQLITE_OPEN_SUBJOURNAL]
//	** <li>  [SQLITE_OPEN_SUPER_JOURNAL]
//	** <li>  [SQLITE_OPEN_WAL]
//	** </ul>)^
//	**
//	** The file I/O implementation can use the object type flags to
//	** change the way it deals with files.  For example, an application
//	** that does not care about crash recovery or rollback might make
//	** the open of a journal file a no-op.  Writes to this journal would
//	** also be no-ops, and any attempt to read the journal would return
//	** SQLITE_IOERR.  Or the implementation might recognize that a database
//	** file will be doing page-aligned sector reads and writes in a random
//	** order and set up its I/O subsystem accordingly.
//	**
//	** SQLite might also add one of the following flags to the xOpen method:
//	**
//	** <ul>
//	** <li> [SQLITE_OPEN_DELETEONCLOSE]
//	** <li> [SQLITE_OPEN_EXCLUSIVE]
//	** </ul>
//	**
//	** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be
//	** deleted when it is closed.  ^The [SQLITE_OPEN_DELETEONCLOSE]
//	** will be set for TEMP databases and their journals, transient
//	** databases, and subjournals.
//	**
//	** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction
//	** with the [SQLITE_OPEN_CREATE] flag, which are both directly
//	** analogous to the O_EXCL and O_CREAT flags of the POSIX open()
//	** API.  The SQLITE_OPEN_EXCLUSIVE flag, when paired with the
//	** SQLITE_OPEN_CREATE, is used to indicate that file should always
//	** be created, and that it is an error if it already exists.
//	** It is <i>not</i> used to indicate the file should be opened
//	** for exclusive access.
//	**
//	** ^At least szOsFile bytes of memory are allocated by SQLite
//	** to hold the [sqlite3_file] structure passed as the third
//	** argument to xOpen.  The xOpen method does not have to
//	** allocate the structure; it should just fill it in.  Note that
//	** the xOpen method must set the sqlite3_file.pMethods to either
//	** a valid [sqlite3_io_methods] object or to NULL.  xOpen must do
//	** this even if the open fails.  SQLite expects that the sqlite3_file.pMethods
//	** element will be valid after xOpen returns regardless of the success
//	** or failure of the xOpen call.
//	**
//	** [[sqlite3_vfs.xAccess]]
//	** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]
//	** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to
//	** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]
//	** to test whether a file is at least readable.  The SQLITE_ACCESS_READ
//	** flag is never actually used and is not implemented in the built-in
//	** VFSes of SQLite.  The file is named by the second argument and can be a
//	** directory. The xAccess method returns [SQLITE_OK] on success or some
//	** non-zero error code if there is an I/O error or if the name of
//	** the file given in the second argument is illegal.  If SQLITE_OK
//	** is returned, then non-zero or zero is written into *pResOut to indicate
//	** whether or not the file is accessible.
//	**
//	** ^SQLite will always allocate at least mxPathname+1 bytes for the
//	** output buffer xFullPathname.  The exact size of the output buffer
//	** is also passed as a parameter to both  methods. If the output buffer
//	** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is
//	** handled as a fatal error by SQLite, vfs implementations should endeavor
//	** to prevent this by setting mxPathname to a sufficiently large value.
//	**
//	** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()
//	** interfaces are not strictly a part of the filesystem, but they are
//	** included in the VFS structure for completeness.
//	** The xRandomness() function attempts to return nBytes bytes
//	** of good-quality randomness into zOut.  The return value is
//	** the actual number of bytes of randomness obtained.
//	** The xSleep() method causes the calling thread to sleep for at
//	** least the number of microseconds given.  ^The xCurrentTime()
//	** method returns a Julian Day Number for the current date and time as
//	** a floating point value.
//	** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
//	** Day Number multiplied by 86400000 (the number of milliseconds in
//	** a 24-hour day).
//	** ^SQLite will use the xCurrentTimeInt64() method to get the current
//	** date and time if that method is available (if iVersion is 2 or
//	** greater and the function pointer is not NULL) and will fall back
//	** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
//	**
//	** ^The xSetSystemCall(), xGetSystemCall(), and xNextSystemCall() interfaces
//	** are not used by the SQLite core.  These optional interfaces are provided
//	** by some VFSes to facilitate testing of the VFS code. By overriding
//	** system calls with functions under its control, a test program can
//	** simulate faults and error conditions that would otherwise be difficult
//	** or impossible to induce.  The set of system calls that can be overridden
//	** varies from one VFS to another, and from one version of the same VFS to the
//	** next.  Applications that use these interfaces must be prepared for any
//	** or all of these interfaces to be NULL or for their behavior to change
//	** from one release to the next.  Applications must not attempt to access
//	** any of these methods if the iVersion of the VFS is less than 3.
//	*/
type Tsqlite3_vfs = struct {
	FiVersion          int32
	FszOsFile          int32
	FmxPathname        int32
	FpNext             uintptr
	FzName             uintptr
	FpAppData          uintptr
	FxOpen             uintptr
	FxDelete           uintptr
	FxAccess           uintptr
	FxFullPathname     uintptr
	FxDlOpen           uintptr
	FxDlError          uintptr
	FxDlSym            uintptr
	FxDlClose          uintptr
	FxRandomness       uintptr
	FxSleep            uintptr
	FxCurrentTime      uintptr
	FxGetLastError     uintptr
	FxCurrentTimeInt64 uintptr
	FxSetSystemCall    uintptr
	FxGetSystemCall    uintptr
	FxNextSystemCall   uintptr
}

// C documentation
//
//	/*
//	** Structures used by the virtual table interface
//	*/
type Tsqlite3_vtab = struct {
	FpModule uintptr
	FnRef    int32
	FzErrMsg uintptr
}

type Tsqlite3_vtab_cursor = struct {
	FpVtab uintptr
}

// C documentation
//
//	/*
//	** typedef for the authorization callback function.
//	*/
type Tsqlite3_xauth = uintptr

// C documentation
//
//	/*
//	** CAPI3REF: 64-Bit Integer Types
//	** KEYWORDS: sqlite_int64 sqlite_uint64
//	**
//	** Because there is no cross-platform way to specify 64-bit integer types
//	** SQLite includes typedefs for 64-bit signed and unsigned integers.
//	**
//	** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.
//	** The sqlite_int64 and sqlite_uint64 types are supported for backwards
//	** compatibility only.
//	**
//	** ^The sqlite3_int64 and sqlite_int64 types can store integer values
//	** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The
//	** sqlite3_uint64 and sqlite_uint64 types can store integer values
//	** between 0 and +18446744073709551615 inclusive.
//	*/
type Tsqlite_int64 = int64

type Tsqlite_uint64 = uint64

// C documentation
//
//	/*
//	** The datatype used to store estimates of the number of rows in a
//	** table or index.
//	*/
type TtRowcnt = uint64

type Ttimezone = struct {
	Ftz_minuteswest int32
	Ftz_dsttime     int32
}

/* 4-byte unsigned integer */
type Tu16 = uint16

/* 8-byte unsigned integer */
type Tu32 = uint32

/* 8-byte signed integer */
type Tu64 = uint64

/* 2-byte signed integer */
type Tu8 = uint8

type Tu_char = uint8

type Tu_int = uint32

type Tu_short = uint16

type Tuint16_t = uint16

type Tuint32_t = uint32

type Tuint64_t = uint64

type Tuint8_t = uint8

type Tuint_fast32_t = uint32

type Tuint_fast64_t = uint64

type Tuint_least16_t = uint16

type Tuint_least32_t = uint32

type Tuint_least64_t = uint64

type Tuint_least8_t = uint8

type Tuintmax_t = uint64

type Tuseconds_t = uint32

type Tva_list = uintptr

// C documentation
//
//	/*
//	** The yDbMask datatype for the bitmask of all attached databases.
//	*/
type TyDbMask = uint32

// C documentation
//
//	/*
//	** The datatype ynVar is a signed integer, either 16-bit or 32-bit.
//	** Usually it is 16-bits.  But if SQLITE_MAX_VARIABLE_NUMBER is greater
//	** than 32767 we have to make it 32-bit.  16-bit is preferred because
//	** it uses less memory in the Expr object, which is a big memory user
//	** in systems with lots of prepared statements.  And few applications
//	** need more than about 10 or 20 variables.  But some extreme users want
//	** to have prepared statements with over 32766 variables, and for them
//	** the option is available (at compile-time).
//	*/
type TynVar = int16

/* The state of the parser is completely contained in an instance of
** the following structure */
type TyyParser = struct {
	Fyytos      uintptr
	FpParse     uintptr
	FyystackEnd uintptr
	Fyystack    uintptr
	Fyystk0     [50]TyyStackEntry
}

/* The following structure represents a single element of the
** parser's stack.  Information stored includes:
**
**   +  The state number for the parser at this level of the stack.
**
**   +  The value of the token stored at this level of the stack.
**      (In other words, the "major" token.)
**
**   +  The semantic value stored at this level of the stack.  This is
**      the information used by the action routines in the grammar.
**      It is sometimes called the "minor" token.
**
** After the "shift" half of a SHIFTREDUCE action, the stateno field
** actually contains the reduce action for the second half of the
** SHIFTREDUCE.
 */
type TyyStackEntry = struct {
	Fstateno uint16
	Fmajor   uint16
	Fminor   TYYMINORTYPE
}

const UINT16_MAX = 65535

const UINT32_MAX = 4294967295

const UINT64_MAX = 18446744073709551615

const UINT8_MAX = 255

const UINTMAX_MAX = 18446744073709551615

const UINT_FAST32_MAX = 4294967295

const UINT_FAST64_MAX = 18446744073709551615

const UINT_LEAST16_MAX = 65535

const UINT_LEAST32_MAX = 4294967295

const UINT_LEAST64_MAX = 18446744073709551615

const UINT_LEAST8_MAX = 255

const UNKNOWN_LOCK = 5

type Unicode61Tokenizer = TUnicode61Tokenizer

/* Values for eRemoveDiacritic (must match internals of fts5_unicode2.c) */

type UnpackedRecord = TUnpackedRecord

const UpperToLower = 0

type Upsert = TUpsert

const VDBE_DISPLAY_P4 = 1

const VDBE_HALT_STATE = 3

const VDBE_INIT_STATE = 0

const VDBE_READY_STATE = 1

const VDBE_RUN_STATE = 2

type VList = TVList

/************** End of os.h **************************************************/
/************** Continuing where we left off in sqliteInt.h ******************/
/************** Include pager.h in the middle of sqliteInt.h *****************/
/************** Begin file pager.h *******************************************/
/*
** 2001 September 15
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This header file defines the interface that the sqlite page cache
** subsystem.  The page cache subsystem reads and writes a file a page
** at a time and provides a journal for rollback.
 */

/*
** Default maximum size for persistent journal files. A negative
** value means no limit. This value may be overridden using the
** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit".
 */

type VTable = TVTable

type ValueList = TValueList

/************** End of vdbeInt.h *********************************************/
/************** Continuing where we left off in status.c *********************/

type ValueNewStat4Ctx = TValueNewStat4Ctx

type Vdbe = TVdbe

type VdbeCursor = TVdbeCursor

type VdbeFrame = TVdbeFrame

/*
** The size (in bytes) of an sqlite3_context object that holds N
** argv[] arguments.
 */

type VdbeOp = TVdbeOp

type VdbeOpList = TVdbeOpList

type VdbeSorter = TVdbeSorter

type VdbeTxtBlbCache = TVdbeTxtBlbCache

/* Types of VDBE cursors */

const ViewCanHaveRowid = 0

type VtabCtx = TVtabCtx

const WALINDEX_HDR_SIZE = 0

const WALINDEX_MAX_VERSION = 3007000

const WALINDEX_PGSZ = 0

const WAL_ALL_BUT_WRITE = 1

const WAL_CKPT_LOCK = 1

const WAL_EXCLUSIVE_MODE = 1

const WAL_FRAME_HDRSIZE = 24

const WAL_HDRSIZE = 32

const WAL_HEAPMEMORY_MODE = 2

const WAL_LOCK_CKPT = 1

const WAL_LOCK_READ0 = 3

const WAL_LOCK_WRITE = 0

const WAL_MAGIC = 931071618

const WAL_MAX_VERSION = 3007000

const WAL_NORMAL_MODE = 0

const WAL_NREADER = 5

const WAL_RDONLY = 1

const WAL_RDWR = 0

const WAL_RECOVER_LOCK = 2

const WAL_RETRY = -1

const WAL_RETRY_BLOCKED_MASK = 0

const WAL_RETRY_PROTOCOL_LIMIT = 100

const WAL_SAVEPOINT_NDATA = 4

const WAL_SHM_RDONLY = 2

const WAL_WRITE_LOCK = 0

const WHERE_AGG_DISTINCT = 1024

const WHERE_AUTO_INDEX = 16384

const WHERE_BIGNULL_SORT = 524288

const WHERE_BLOOMFILTER = 4194304

const WHERE_BOTH_LIMIT = 48

const WHERE_BTM_LIMIT = 32

const WHERE_COLUMN_EQ = 1

const WHERE_COLUMN_IN = 4

const WHERE_COLUMN_NULL = 8

const WHERE_COLUMN_RANGE = 2

const WHERE_CONSTRAINT = 15

const WHERE_COROUTINE = 33554432

const WHERE_DISTINCTBY = 128

const WHERE_DISTINCT_NOOP = 0

const WHERE_DISTINCT_ORDERED = 2

const WHERE_DISTINCT_UNIQUE = 1

const WHERE_DISTINCT_UNORDERED = 3

const WHERE_DUPLICATES_OK = 16

const WHERE_EXPRIDX = 67108864

const WHERE_GROUPBY = 64

const WHERE_IDX_ONLY = 64

const WHERE_INDEXED = 512

const WHERE_IN_ABLE = 2048

const WHERE_IN_EARLYOUT = 262144

const WHERE_IN_SEEKSCAN = 1048576

const WHERE_IPK = 256

const WHERE_KEEP_ALL_JOINS = 8192

const WHERE_MULTI_OR = 8192

const WHERE_OMIT_OFFSET = 16777216

const WHERE_ONEPASS_DESIRED = 4

const WHERE_ONEPASS_MULTIROW = 8

const WHERE_ONEROW = 4096

const WHERE_ORDERBY_LIMIT = 2048

const WHERE_ORDERBY_MAX = 2

const WHERE_ORDERBY_MIN = 1

const WHERE_ORDERBY_NORMAL = 0

const WHERE_OR_SUBCLAUSE = 32

const WHERE_PARTIALIDX = 131072

const WHERE_RIGHT_JOIN = 4096

const WHERE_SELFCULL = 8388608

const WHERE_SKIPSCAN = 32768

const WHERE_SORTBYGROUP = 512

const WHERE_TOP_LIMIT = 16

const WHERE_TRANSCONS = 2097152

const WHERE_UNQ_WANTED = 65536

const WHERE_USE_LIMIT = 16384

const WHERE_VIRTUALTABLE = 1024

const WHERE_WANT_DISTINCT = 256

const WINDOW_AGGINVERSE = 2

const WINDOW_AGGSTEP = 3

const WINDOW_ENDING_INT = 1

const WINDOW_ENDING_NUM = 4

const WINDOW_NTH_VALUE_INT = 2

const WINDOW_RETURN_ROW = 1

const WINDOW_STARTING_INT = 0

const WINDOW_STARTING_NUM = 3

const WO_ALL = 16383

const WO_AND = 1024

const WO_AUX = 64

const WO_EQ = 2

const WO_EQUIV = 2048

const WO_GE = 32

const WO_GT = 4

const WO_IN = 1

const WO_IS = 128

const WO_ISNULL = 256

const WO_LE = 8

const WO_LT = 16

const WO_NOOP = 4096

const WO_OR = 512

const WO_ROWVAL = 8192

const WO_SINGLE = 511

const WRC_Abort = 2

const WRC_Continue = 0

const WRC_Prune = 1

const WRITE_LOCK = 2

type Wal = TWal

/************** End of wal.h *************************************************/
/************** Continuing where we left off in pager.c **********************/

/******************* NOTES ON THE DESIGN OF THE PAGER ************************
**
** This comment block describes invariants that hold when using a rollback
** journal.  These invariants do not apply for journal_mode=WAL,
** journal_mode=MEMORY, or journal_mode=OFF.
**
** Within this comment block, a page is deemed to have been synced
** automatically as soon as it is written when PRAGMA synchronous=OFF.
** Otherwise, the page is not synced until the xSync method of the VFS
** is called successfully on the file containing the page.
**
** Definition:  A page of the database file is said to be "overwriteable" if
** one or more of the following are true about the page:
**
**     (a)  The original content of the page as it was at the beginning of
**          the transaction has been written into the rollback journal and
**          synced.
**
**     (b)  The page was a freelist leaf page at the start of the transaction.
**
**     (c)  The page number is greater than the largest page that existed in
**          the database file at the start of the transaction.
**
** (1) A page of the database file is never overwritten unless one of the
**     following are true:
**
**     (a) The page and all other pages on the same sector are overwriteable.
**
**     (b) The atomic page write optimization is enabled, and the entire
**         transaction other than the update of the transaction sequence
**         number consists of a single page change.
**
** (2) The content of a page written into the rollback journal exactly matches
**     both the content in the database when the rollback journal was written
**     and the content in the database at the beginning of the current
**     transaction.
**
** (3) Writes to the database file are an integer multiple of the page size
**     in length and are aligned on a page boundary.
**
** (4) Reads from the database file are either aligned on a page boundary and
**     an integer multiple of the page size in length or are taken from the
**     first 100 bytes of the database file.
**
** (5) All writes to the database file are synced prior to the rollback journal
**     being deleted, truncated, or zeroed.
**
** (6) If a super-journal file is used, then all writes to the database file
**     are synced prior to the super-journal being deleted.
**
** Definition: Two databases (or the same database at two points it time)
** are said to be "logically equivalent" if they give the same answer to
** all queries.  Note in particular the content of freelist leaf
** pages can be changed arbitrarily without affecting the logical equivalence
** of the database.
**
** (7) At any time, if any subset, including the empty set and the total set,
**     of the unsynced changes to a rollback journal are removed and the
**     journal is rolled back, the resulting database file will be logically
**     equivalent to the database file at the beginning of the transaction.
**
** (8) When a transaction is rolled back, the xTruncate method of the VFS
**     is called to restore the database file to the same size it was at
**     the beginning of the transaction.  (In some VFSes, the xTruncate
**     method is a no-op, but that does not change the fact the SQLite will
**     invoke it.)
**
** (9) Whenever the database file is modified, at least one bit in the range
**     of bytes from 24 through 39 inclusive will be changed prior to releasing
**     the EXCLUSIVE lock, thus signaling other connections on the same
**     database to flush their caches.
**
** (10) The pattern of bits in bytes 24 through 39 shall not repeat in less
**      than one billion transactions.
**
** (11) A database file is well-formed at the beginning and at the conclusion
**      of every transaction.
**
** (12) An EXCLUSIVE lock is held on the database file when writing to
**      the database file.
**
** (13) A SHARED lock is held on the database file while reading any
**      content out of the database file.
**
******************************************************************************/

/*
** Macros for troubleshooting.  Normally turned off
 */

/*
** The following two macros are used within the PAGERTRACE() macros above
** to print out file-descriptors.
**
** PAGERID() takes a pointer to a Pager struct as its argument. The
** associated file-descriptor is returned. FILEHANDLEID() takes an sqlite3_file
** struct as its argument.
 */

/*
** The Pager.eState variable stores the current 'state' of a pager. A
** pager may be in any one of the seven states shown in the following
** state diagram.
**
**                            OPEN <------+------+
**                              |         |      |
**                              V         |      |
**               +---------> READER-------+      |
**               |              |                |
**               |              V                |
**               |<-------WRITER_LOCKED------> ERROR
**               |              |                ^
**               |              V                |
**               |<------WRITER_CACHEMOD-------->|
**               |              |                |
**               |              V                |
**               |<-------WRITER_DBMOD---------->|
**               |              |                |
**               |              V                |
**               +<------WRITER_FINISHED-------->+
**
**
** List of state transitions and the C [function] that performs each:
**
**   OPEN              -> READER              [sqlite3PagerSharedLock]
**   READER            -> OPEN                [pager_unlock]
**
**   READER            -> WRITER_LOCKED       [sqlite3PagerBegin]
**   WRITER_LOCKED     -> WRITER_CACHEMOD     [pager_open_journal]
**   WRITER_CACHEMOD   -> WRITER_DBMOD        [syncJournal]
**   WRITER_DBMOD      -> WRITER_FINISHED     [sqlite3PagerCommitPhaseOne]
**   WRITER_***        -> READER              [pager_end_transaction]
**
**   WRITER_***        -> ERROR               [pager_error]
**   ERROR             -> OPEN                [pager_unlock]
**
**
**  OPEN:
**
**    The pager starts up in this state. Nothing is guaranteed in this
**    state - the file may or may not be locked and the database size is
**    unknown. The database may not be read or written.
**
**    * No read or write transaction is active.
**    * Any lock, or no lock at all, may be held on the database file.
**    * The dbSize, dbOrigSize and dbFileSize variables may not be trusted.
**
**  READER:
**
**    In this state all the requirements for reading the database in
**    rollback (non-WAL) mode are met. Unless the pager is (or recently
**    was) in exclusive-locking mode, a user-level read transaction is
**    open. The database size is known in this state.
**
**    A connection running with locking_mode=normal enters this state when
**    it opens a read-transaction on the database and returns to state
**    OPEN after the read-transaction is completed. However a connection
**    running in locking_mode=exclusive (including temp databases) remains in
**    this state even after the read-transaction is closed. The only way
**    a locking_mode=exclusive connection can transition from READER to OPEN
**    is via the ERROR state (see below).
**
**    * A read transaction may be active (but a write-transaction cannot).
**    * A SHARED or greater lock is held on the database file.
**    * The dbSize variable may be trusted (even if a user-level read
**      transaction is not active). The dbOrigSize and dbFileSize variables
**      may not be trusted at this point.
**    * If the database is a WAL database, then the WAL connection is open.
**    * Even if a read-transaction is not open, it is guaranteed that
**      there is no hot-journal in the file-system.
**
**  WRITER_LOCKED:
**
**    The pager moves to this state from READER when a write-transaction
**    is first opened on the database. In WRITER_LOCKED state, all locks
**    required to start a write-transaction are held, but no actual
**    modifications to the cache or database have taken place.
**
**    In rollback mode, a RESERVED or (if the transaction was opened with
**    BEGIN EXCLUSIVE) EXCLUSIVE lock is obtained on the database file when
**    moving to this state, but the journal file is not written to or opened
**    to in this state. If the transaction is committed or rolled back while
**    in WRITER_LOCKED state, all that is required is to unlock the database
**    file.
**
**    IN WAL mode, WalBeginWriteTransaction() is called to lock the log file.
**    If the connection is running with locking_mode=exclusive, an attempt
**    is made to obtain an EXCLUSIVE lock on the database file.
**
**    * A write transaction is active.
**    * If the connection is open in rollback-mode, a RESERVED or greater
**      lock is held on the database file.
**    * If the connection is open in WAL-mode, a WAL write transaction
**      is open (i.e. sqlite3WalBeginWriteTransaction() has been successfully
**      called).
**    * The dbSize, dbOrigSize and dbFileSize variables are all valid.
**    * The contents of the pager cache have not been modified.
**    * The journal file may or may not be open.
**    * Nothing (not even the first header) has been written to the journal.
**
**  WRITER_CACHEMOD:
**
**    A pager moves from WRITER_LOCKED state to this state when a page is
**    first modified by the upper layer. In rollback mode the journal file
**    is opened (if it is not already open) and a header written to the
**    start of it. The database file on disk has not been modified.
**
**    * A write transaction is active.
**    * A RESERVED or greater lock is held on the database file.
**    * The journal file is open and the first header has been written
**      to it, but the header has not been synced to disk.
**    * The contents of the page cache have been modified.
**
**  WRITER_DBMOD:
**
**    The pager transitions from WRITER_CACHEMOD into WRITER_DBMOD state
**    when it modifies the contents of the database file. WAL connections
**    never enter this state (since they do not modify the database file,
**    just the log file).
**
**    * A write transaction is active.
**    * An EXCLUSIVE or greater lock is held on the database file.
**    * The journal file is open and the first header has been written
**      and synced to disk.
**    * The contents of the page cache have been modified (and possibly
**      written to disk).
**
**  WRITER_FINISHED:
**
**    It is not possible for a WAL connection to enter this state.
**
**    A rollback-mode pager changes to WRITER_FINISHED state from WRITER_DBMOD
**    state after the entire transaction has been successfully written into the
**    database file. In this state the transaction may be committed simply
**    by finalizing the journal file. Once in WRITER_FINISHED state, it is
**    not possible to modify the database further. At this point, the upper
**    layer must either commit or rollback the transaction.
**
**    * A write transaction is active.
**    * An EXCLUSIVE or greater lock is held on the database file.
**    * All writing and syncing of journal and database data has finished.
**      If no error occurred, all that remains is to finalize the journal to
**      commit the transaction. If an error did occur, the caller will need
**      to rollback the transaction.
**
**  ERROR:
**
**    The ERROR state is entered when an IO or disk-full error (including
**    SQLITE_IOERR_NOMEM) occurs at a point in the code that makes it
**    difficult to be sure that the in-memory pager state (cache contents,
**    db size etc.) are consistent with the contents of the file-system.
**
**    Temporary pager files may enter the ERROR state, but in-memory pagers
**    cannot.
**
**    For example, if an IO error occurs while performing a rollback,
**    the contents of the page-cache may be left in an inconsistent state.
**    At this point it would be dangerous to change back to READER state
**    (as usually happens after a rollback). Any subsequent readers might
**    report database corruption (due to the inconsistent cache), and if
**    they upgrade to writers, they may inadvertently corrupt the database
**    file. To avoid this hazard, the pager switches into the ERROR state
**    instead of READER following such an error.
**
**    Once it has entered the ERROR state, any attempt to use the pager
**    to read or write data returns an error. Eventually, once all
**    outstanding transactions have been abandoned, the pager is able to
**    transition back to OPEN state, discarding the contents of the
**    page-cache and any other in-memory state at the same time. Everything
**    is reloaded from disk (and, if necessary, hot-journal rollback performed)
**    when a read-transaction is next opened on the pager (transitioning
**    the pager into READER state). At that point the system has recovered
**    from the error.
**
**    Specifically, the pager jumps into the ERROR state if:
**
**      1. An error occurs while attempting a rollback. This happens in
**         function sqlite3PagerRollback().
**
**      2. An error occurs while attempting to finalize a journal file
**         following a commit in function sqlite3PagerCommitPhaseTwo().
**
**      3. An error occurs while attempting to write to the journal or
**         database file in function pagerStress() in order to free up
**         memory.
**
**    In other cases, the error is returned to the b-tree layer. The b-tree
**    layer then attempts a rollback operation. If the error condition
**    persists, the pager enters the ERROR state via condition (1) above.
**
**    Condition (3) is necessary because it can be triggered by a read-only
**    statement executed within a transaction. In this case, if the error
**    code were simply returned to the user, the b-tree layer would not
**    automatically attempt a rollback, as it assumes that an error in a
**    read-only statement cannot leave the pager in an internally inconsistent
**    state.
**
**    * The Pager.errCode variable is set to something other than SQLITE_OK.
**    * There are one or more outstanding references to pages (after the
**      last reference is dropped the pager should move back to OPEN state).
**    * The pager is not an in-memory pager.
**
**
** Notes:
**
**   * A pager is never in WRITER_DBMOD or WRITER_FINISHED state if the
**     connection is open in WAL mode. A WAL connection is always in one
**     of the first four states.
**
**   * Normally, a connection open in exclusive mode is never in PAGER_OPEN
**     state. There are two exceptions: immediately after exclusive-mode has
**     been turned on (and before any read or write transactions are
**     executed), and when the pager is leaving the "error state".
**
**   * See also: assert_pager_state().
 */

/*
** The Pager.eLock variable is almost always set to one of the
** following locking-states, according to the lock currently held on
** the database file: NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK.
** This variable is kept up to date as locks are taken and released by
** the pagerLockDb() and pagerUnlockDb() wrappers.
**
** If the VFS xLock() or xUnlock() returns an error other than SQLITE_BUSY
** (i.e. one of the SQLITE_IOERR subtypes), it is not clear whether or not
** the operation was successful. In these circumstances pagerLockDb() and
** pagerUnlockDb() take a conservative approach - eLock is always updated
** when unlocking the file, and only updated when locking the file if the
** VFS call is successful. This way, the Pager.eLock variable may be set
** to a less exclusive (lower) value than the lock that is actually held
** at the system level, but it is never set to a more exclusive value.
**
** This is usually safe. If an xUnlock fails or appears to fail, there may
** be a few redundant xLock() calls or a lock may be held for longer than
** required, but nothing really goes wrong.
**
** The exception is when the database file is unlocked as the pager moves
** from ERROR to OPEN state. At this point there may be a hot-journal file
** in the file-system that needs to be rolled back (as part of an OPEN->SHARED
** transition, by the same pager or any other). If the call to xUnlock()
** fails at this point and the pager is left holding an EXCLUSIVE lock, this
** can confuse the call to xCheckReservedLock() call made later as part
** of hot-journal detection.
**
** xCheckReservedLock() is defined as returning true "if there is a RESERVED
** lock held by this process or any others". So xCheckReservedLock may
** return true because the caller itself is holding an EXCLUSIVE lock (but
** doesn't know it because of a previous error in xUnlock). If this happens
** a hot-journal may be mistaken for a journal being created by an active
** transaction in another process, causing SQLite to read from the database
** without rolling it back.
**
** To work around this, if a call to xUnlock() fails when unlocking the
** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It
** is only changed back to a real locking state after a successful call
** to xLock(EXCLUSIVE). Also, the code to do the OPEN->SHARED state transition
** omits the check for a hot-journal if Pager.eLock is set to UNKNOWN_LOCK
** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE
** lock on the database file before attempting to roll it back. See function
** PagerSharedLock() for more detail.
**
** Pager.eLock may only be set to UNKNOWN_LOCK when the pager is in
** PAGER_OPEN state.
 */

/*
** The maximum allowed sector size. 64KiB. If the xSectorsize() method
** returns a value larger than this, then MAX_SECTOR_SIZE is used instead.
** This could conceivably cause corruption following a power failure on
** such a system. This is currently an undocumented limit.
 */

type WalCkptInfo = TWalCkptInfo

/*
** Candidate values for Wal.exclusiveMode.
 */

/*
** Possible values for WAL.readOnly
 */

type WalHashLoc = TWalHashLoc

type WalIndexHdr = TWalIndexHdr

type WalIterator = TWalIterator

type WalSegment = TWalSegment

type WalWriter = TWalWriter

type Walker = TWalker

type WhereAndInfo = TWhereAndInfo

type WhereClause = TWhereClause

type WhereConst = TWhereConst

type WhereInfo = TWhereInfo

type WhereLevel = TWhereLevel

type WhereLoop = TWhereLoop

type WhereLoopBuilder = TWhereLoopBuilder

type WhereMaskSet = TWhereMaskSet

type WhereMemBlock = TWhereMemBlock

type WhereOrCost = TWhereOrCost

type WhereOrInfo = TWhereOrInfo

type WhereOrSet = TWhereOrSet

type WherePath = TWherePath

type WhereRightJoin = TWhereRightJoin

/*
** Bitmasks for the operators on WhereTerm objects.  These are all
** operators that are of interest to the query planner.  An
** OR-ed combination of these values can be used when searching for
** particular WhereTerms within a WhereClause.
**
** Value constraints:
**     WO_EQ    == SQLITE_INDEX_CONSTRAINT_EQ
**     WO_LT    == SQLITE_INDEX_CONSTRAINT_LT
**     WO_LE    == SQLITE_INDEX_CONSTRAINT_LE
**     WO_GT    == SQLITE_INDEX_CONSTRAINT_GT
**     WO_GE    == SQLITE_INDEX_CONSTRAINT_GE
 */

/*
** These are definitions of bits in the WhereLoop.wsFlags field.
** The particular combination of bits in each WhereLoop help to
** determine the algorithm that WhereLoop represents.
 */

/************** End of whereInt.h ********************************************/
/************** Continuing where we left off in wherecode.c ******************/

type WhereScan = TWhereScan

type WhereTerm = TWhereTerm

type Window = TWindow

type WindowCodeArg = TWindowCodeArg

type WindowCsrAndReg = TWindowCsrAndReg

type WindowRewrite = TWindowRewrite

type With = TWith

const XN_EXPR = -2

const XN_ROWID = -1

// C documentation
//
//	/*
//	** Return the number of times the Step function of an aggregate has been
//	** called.
//	**
//	** This function is deprecated.  Do not use it for new code.  It is
//	** provide only to avoid breaking legacy code.  New aggregate function
//	** implementations should keep their own counts within their aggregate
//	** context.
//	*/
func Xsqlite3_aggregate_count(tls *libc.TLS, p uintptr) (r int32) {
	return (*TMem)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(p)).FpMem)).Fn
}

// C documentation
//
//	/*
//	** Register a function to be invoked prior to each autovacuum that
//	** determines the number of pages to vacuum.
//	*/
func Xsqlite3_autovacuum_pages(tls *libc.TLS, db uintptr, __ccgo_fp_xCallback uintptr, pArg uintptr, __ccgo_fp_xDestructor uintptr) (r int32) {
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	if (*Tsqlite3)(unsafe.Pointer(db)).FxAutovacDestr != 0 {
		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxAutovacDestr})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpAutovacPagesArg)
	}
	(*Tsqlite3)(unsafe.Pointer(db)).FxAutovacPages = __ccgo_fp_xCallback
	(*Tsqlite3)(unsafe.Pointer(db)).FpAutovacPagesArg = pArg
	(*Tsqlite3)(unsafe.Pointer(db)).FxAutovacDestr = __ccgo_fp_xDestructor
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Bind a blob value to an SQL statement variable.
//	*/
func Xsqlite3_bind_blob(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData int32, __ccgo_fp_xDel uintptr) (r int32) {
	return _bindText(tls, pStmt, i, zData, int64(nData), __ccgo_fp_xDel, uint8(0))
}

func Xsqlite3_bind_int(tls *libc.TLS, p uintptr, i int32, iValue int32) (r int32) {
	return Xsqlite3_bind_int64(tls, p, i, int64(iValue))
}

// C documentation
//
//	/*
//	** Return the number of wildcards that can be potentially bound to.
//	** This routine is added to support DBD::SQLite.
//	*/
func Xsqlite3_bind_parameter_count(tls *libc.TLS, pStmt uintptr) (r int32) {
	var p uintptr
	var v1 int32
	_, _ = p, v1
	p = pStmt
	if p != 0 {
		v1 = int32((*TVdbe)(unsafe.Pointer(p)).FnVar)
	} else {
		v1 = 0
	}
	return v1
}

func Xsqlite3_bind_parameter_index(tls *libc.TLS, pStmt uintptr, zName uintptr) (r int32) {
	return _sqlite3VdbeParameterIndex(tls, pStmt, zName, _sqlite3Strlen30(tls, zName))
}

// C documentation
//
//	/*
//	** Return the name of a wildcard parameter.  Return NULL if the index
//	** is out of range or if the wildcard is unnamed.
//	**
//	** The result is always UTF-8.
//	*/
func Xsqlite3_bind_parameter_name(tls *libc.TLS, pStmt uintptr, i int32) (r uintptr) {
	var p uintptr
	_ = p
	p = pStmt
	if p == uintptr(0) {
		return uintptr(0)
	}
	return _sqlite3VListNumToName(tls, (*TVdbe)(unsafe.Pointer(p)).FpVList, i)
}

func Xsqlite3_bind_text(tls *libc.TLS, pStmt uintptr, i int32, zData uintptr, nData int32, __ccgo_fp_xDel uintptr) (r int32) {
	return _bindText(tls, pStmt, i, zData, int64(nData), __ccgo_fp_xDel, uint8(SQLITE_UTF8))
}

// C documentation
//
//	/*
//	** Query a blob handle for the size of the data.
//	**
//	** The Incrblob.nByte field is fixed for the lifetime of the Incrblob
//	** so no mutex is required for access.
//	*/
func Xsqlite3_blob_bytes(tls *libc.TLS, pBlob uintptr) (r int32) {
	var p uintptr
	var v1 int32
	_, _ = p, v1
	p = pBlob
	if p != 0 && (*TIncrblob)(unsafe.Pointer(p)).FpStmt != 0 {
		v1 = (*TIncrblob)(unsafe.Pointer(p)).FnByte
	} else {
		v1 = 0
	}
	return v1
}

// C documentation
//
//	/*
//	** Close a blob handle that was previously created using
//	** sqlite3_blob_open().
//	*/
func Xsqlite3_blob_close(tls *libc.TLS, pBlob uintptr) (r int32) {
	var db, p, pStmt uintptr
	var rc int32
	_, _, _, _ = db, p, pStmt, rc
	p = pBlob
	if p != 0 {
		pStmt = (*TIncrblob)(unsafe.Pointer(p)).FpStmt
		db = (*TIncrblob)(unsafe.Pointer(p)).Fdb
		Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
		_sqlite3DbFree(tls, db, p)
		Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
		rc = Xsqlite3_finalize(tls, pStmt)
	} else {
		rc = SQLITE_OK
	}
	return rc
}

// C documentation
//
//	/*
//	** Read data from a blob handle.
//	*/
func Xsqlite3_blob_read(tls *libc.TLS, pBlob uintptr, z uintptr, n int32, iOffset int32) (r int32) {
	return _blobReadWrite(tls, pBlob, z, n, iOffset, __ccgo_fp(_sqlite3BtreePayloadChecked))
}

// C documentation
//
//	/*
//	** Write data to a blob handle.
//	*/
func Xsqlite3_blob_write(tls *libc.TLS, pBlob uintptr, z uintptr, n int32, iOffset int32) (r int32) {
	return _blobReadWrite(tls, pBlob, z, n, iOffset, __ccgo_fp(_sqlite3BtreePutData))
}

// C documentation
//
//	/*
//	** This routine sets the busy callback for an Sqlite database to the
//	** given callback function with the given argument.
//	*/
func Xsqlite3_busy_handler(tls *libc.TLS, db uintptr, __ccgo_fp_xBusy uintptr, pArg uintptr) (r int32) {
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	(*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FxBusyHandler = __ccgo_fp_xBusy
	(*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FpBusyArg = pArg
	(*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0
	(*Tsqlite3)(unsafe.Pointer(db)).FbusyTimeout = 0
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** This routine installs a default busy handler that waits for the
//	** specified number of milliseconds before returning 0.
//	*/
func Xsqlite3_busy_timeout(tls *libc.TLS, db uintptr, ms int32) (r int32) {
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	if ms > 0 {
		Xsqlite3_busy_handler(tls, db, __ccgo_fp(_sqliteDefaultBusyCallback), db)
		(*Tsqlite3)(unsafe.Pointer(db)).FbusyTimeout = ms
	} else {
		Xsqlite3_busy_handler(tls, db, uintptr(0), uintptr(0))
	}
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return SQLITE_OK
}

func Xsqlite3_changes(tls *libc.TLS, db uintptr) (r int32) {
	return int32(Xsqlite3_changes64(tls, db))
}

// C documentation
//
//	/*
//	** Return the number of changes in the most recent call to sqlite3_exec().
//	*/
func Xsqlite3_changes64(tls *libc.TLS, db uintptr) (r Tsqlite3_int64) {
	var iRet Ti64
	_ = iRet
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	iRet = (*Tsqlite3)(unsafe.Pointer(db)).FnChange
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return iRet
}

// C documentation
//
//	/*
//	** Two variations on the public interface for closing a database
//	** connection. The sqlite3_close() version returns SQLITE_BUSY and
//	** leaves the connection open if there are unfinalized prepared
//	** statements or unfinished sqlite3_backups.  The sqlite3_close_v2()
//	** version forces the connection to become a zombie if there are
//	** unclosed resources, and arranges for deallocation when the last
//	** prepare statement or sqlite3_backup closes.
//	*/
func Xsqlite3_close(tls *libc.TLS, db uintptr) (r int32) {
	return _sqlite3Close(tls, db, 0)
}

func Xsqlite3_close_v2(tls *libc.TLS, db uintptr) (r int32) {
	return _sqlite3Close(tls, db, int32(1))
}

// C documentation
//
//	/*
//	** Register a collation sequence factory callback with the database handle
//	** db. Replace any previously installed collation sequence factory.
//	*/
func Xsqlite3_collation_needed(tls *libc.TLS, db uintptr, pCollNeededArg uintptr, __ccgo_fp_xCollNeeded uintptr) (r int32) {
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	(*Tsqlite3)(unsafe.Pointer(db)).FxCollNeeded = __ccgo_fp_xCollNeeded
	(*Tsqlite3)(unsafe.Pointer(db)).FxCollNeeded16 = uintptr(0)
	(*Tsqlite3)(unsafe.Pointer(db)).FpCollNeededArg = pCollNeededArg
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Register a collation sequence factory callback with the database handle
//	** db. Replace any previously installed collation sequence factory.
//	*/
func Xsqlite3_collation_needed16(tls *libc.TLS, db uintptr, pCollNeededArg uintptr, __ccgo_fp_xCollNeeded16 uintptr) (r int32) {
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	(*Tsqlite3)(unsafe.Pointer(db)).FxCollNeeded = uintptr(0)
	(*Tsqlite3)(unsafe.Pointer(db)).FxCollNeeded16 = __ccgo_fp_xCollNeeded16
	(*Tsqlite3)(unsafe.Pointer(db)).FpCollNeededArg = pCollNeededArg
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return SQLITE_OK
}

// C documentation
//
//	/**************************** sqlite3_column_  *******************************
//	** The following routines are used to access elements of the current row
//	** in the result set.
//	*/
func Xsqlite3_column_blob(tls *libc.TLS, pStmt uintptr, i int32) (r uintptr) {
	var val uintptr
	_ = val
	val = Xsqlite3_value_blob(tls, _columnMem(tls, pStmt, i))
	/* Even though there is no encoding conversion, value_blob() might
	 ** need to call malloc() to expand the result of a zeroblob()
	 ** expression.
	 */
	_columnMallocFailure(tls, pStmt)
	return val
}

func Xsqlite3_column_bytes(tls *libc.TLS, pStmt uintptr, i int32) (r int32) {
	var val int32
	_ = val
	val = Xsqlite3_value_bytes(tls, _columnMem(tls, pStmt, i))
	_columnMallocFailure(tls, pStmt)
	return val
}

func Xsqlite3_column_bytes16(tls *libc.TLS, pStmt uintptr, i int32) (r int32) {
	var val int32
	_ = val
	val = Xsqlite3_value_bytes16(tls, _columnMem(tls, pStmt, i))
	_columnMallocFailure(tls, pStmt)
	return val
}

// C documentation
//
//	/*
//	** Return the name of the database from which a result column derives.
//	** NULL is returned if the result column is an expression or constant or
//	** anything else which is not an unambiguous reference to a database column.
//	*/
func Xsqlite3_column_database_name(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) {
	return _columnName(tls, pStmt, N, 0, int32(COLNAME_DATABASE))
}

func Xsqlite3_column_database_name16(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) {
	return _columnName(tls, pStmt, N, int32(1), int32(COLNAME_DATABASE))
}

// C documentation
//
//	/*
//	** Return the column declaration type (if applicable) of the 'i'th column
//	** of the result set of SQL statement pStmt.
//	*/
func Xsqlite3_column_decltype(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) {
	return _columnName(tls, pStmt, N, 0, int32(COLNAME_DECLTYPE))
}

func Xsqlite3_column_decltype16(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) {
	return _columnName(tls, pStmt, N, int32(1), int32(COLNAME_DECLTYPE))
}

func Xsqlite3_column_double(tls *libc.TLS, pStmt uintptr, i int32) (r float64) {
	var val float64
	_ = val
	val = Xsqlite3_value_double(tls, _columnMem(tls, pStmt, i))
	_columnMallocFailure(tls, pStmt)
	return val
}

func Xsqlite3_column_int(tls *libc.TLS, pStmt uintptr, i int32) (r int32) {
	var val int32
	_ = val
	val = Xsqlite3_value_int(tls, _columnMem(tls, pStmt, i))
	_columnMallocFailure(tls, pStmt)
	return val
}

func Xsqlite3_column_int64(tls *libc.TLS, pStmt uintptr, i int32) (r Tsqlite_int64) {
	var val Tsqlite_int64
	_ = val
	val = Xsqlite3_value_int64(tls, _columnMem(tls, pStmt, i))
	_columnMallocFailure(tls, pStmt)
	return val
}

// C documentation
//
//	/*
//	** Return the name of the Nth column of the result set returned by SQL
//	** statement pStmt.
//	*/
func Xsqlite3_column_name(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) {
	return _columnName(tls, pStmt, N, 0, COLNAME_NAME)
}

func Xsqlite3_column_name16(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) {
	return _columnName(tls, pStmt, N, int32(1), COLNAME_NAME)
}

/*
** Constraint:  If you have ENABLE_COLUMN_METADATA then you must
** not define OMIT_DECLTYPE.
 */

// C documentation
//
//	/*
//	** Return the name of the table column from which a result column derives.
//	** NULL is returned if the result column is an expression or constant or
//	** anything else which is not an unambiguous reference to a database column.
//	*/
func Xsqlite3_column_origin_name(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) {
	return _columnName(tls, pStmt, N, 0, int32(COLNAME_COLUMN))
}

func Xsqlite3_column_origin_name16(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) {
	return _columnName(tls, pStmt, N, int32(1), int32(COLNAME_COLUMN))
}

// C documentation
//
//	/*
//	** Return the name of the table from which a result column derives.
//	** NULL is returned if the result column is an expression or constant or
//	** anything else which is not an unambiguous reference to a database column.
//	*/
func Xsqlite3_column_table_name(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) {
	return _columnName(tls, pStmt, N, 0, int32(COLNAME_TABLE))
}

func Xsqlite3_column_table_name16(tls *libc.TLS, pStmt uintptr, N int32) (r uintptr) {
	return _columnName(tls, pStmt, N, int32(1), int32(COLNAME_TABLE))
}

func Xsqlite3_column_text(tls *libc.TLS, pStmt uintptr, i int32) (r uintptr) {
	var val uintptr
	_ = val
	val = Xsqlite3_value_text(tls, _columnMem(tls, pStmt, i))
	_columnMallocFailure(tls, pStmt)
	return val
}

func Xsqlite3_column_text16(tls *libc.TLS, pStmt uintptr, i int32) (r uintptr) {
	var val uintptr
	_ = val
	val = Xsqlite3_value_text16(tls, _columnMem(tls, pStmt, i))
	_columnMallocFailure(tls, pStmt)
	return val
}

func Xsqlite3_column_type(tls *libc.TLS, pStmt uintptr, i int32) (r int32) {
	var iType int32
	_ = iType
	iType = Xsqlite3_value_type(tls, _columnMem(tls, pStmt, i))
	_columnMallocFailure(tls, pStmt)
	return iType
}

// C documentation
//
//	/*
//	** Register a function to be invoked when a transaction commits.
//	** If the invoked function returns non-zero, then the commit becomes a
//	** rollback.
//	*/
func Xsqlite3_commit_hook(tls *libc.TLS, db uintptr, __ccgo_fp_xCallback uintptr, pArg uintptr) (r uintptr) {
	var pOld uintptr
	_ = pOld
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	pOld = (*Tsqlite3)(unsafe.Pointer(db)).FpCommitArg
	(*Tsqlite3)(unsafe.Pointer(db)).FxCommitCallback = __ccgo_fp_xCallback
	(*Tsqlite3)(unsafe.Pointer(db)).FpCommitArg = pArg
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return pOld
}

// C documentation
//
//	/*
//	** Extract the user data from a sqlite3_context structure and return a
//	** pointer to it.
//	**
//	** IMPLEMENTATION-OF: R-46798-50301 The sqlite3_context_db_handle() interface
//	** returns a copy of the pointer to the database connection (the 1st
//	** parameter) of the sqlite3_create_function() and
//	** sqlite3_create_function16() routines that originally registered the
//	** application defined function.
//	*/
func Xsqlite3_context_db_handle(tls *libc.TLS, p uintptr) (r uintptr) {
	return (*TMem)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(p)).FpOut)).Fdb
}

// C documentation
//
//	/*
//	** Register a new collation sequence with the database handle db.
//	*/
func Xsqlite3_create_collation(tls *libc.TLS, db uintptr, zName uintptr, enc int32, pCtx uintptr, __ccgo_fp_xCompare uintptr) (r int32) {
	return Xsqlite3_create_collation_v2(tls, db, zName, enc, pCtx, __ccgo_fp_xCompare, uintptr(0))
}

// C documentation
//
//	/*
//	** Create new user functions.
//	*/
func Xsqlite3_create_function(tls *libc.TLS, db uintptr, zFunc uintptr, nArg int32, enc int32, p uintptr, __ccgo_fp_xSFunc uintptr, __ccgo_fp_xStep uintptr, __ccgo_fp_xFinal uintptr) (r int32) {
	return _createFunctionApi(tls, db, zFunc, nArg, enc, p, __ccgo_fp_xSFunc, __ccgo_fp_xStep, __ccgo_fp_xFinal, uintptr(0), uintptr(0), uintptr(0))
}

func Xsqlite3_create_function_v2(tls *libc.TLS, db uintptr, zFunc uintptr, nArg int32, enc int32, p uintptr, __ccgo_fp_xSFunc uintptr, __ccgo_fp_xStep uintptr, __ccgo_fp_xFinal uintptr, __ccgo_fp_xDestroy uintptr) (r int32) {
	return _createFunctionApi(tls, db, zFunc, nArg, enc, p, __ccgo_fp_xSFunc, __ccgo_fp_xStep, __ccgo_fp_xFinal, uintptr(0), uintptr(0), __ccgo_fp_xDestroy)
}

// C documentation
//
//	/*
//	** External API function used to create a new virtual-table module.
//	*/
func Xsqlite3_create_module(tls *libc.TLS, db uintptr, zName uintptr, pModule uintptr, pAux uintptr) (r int32) {
	return _createModule(tls, db, zName, pModule, pAux, uintptr(0))
}

// C documentation
//
//	/*
//	** External API function used to create a new virtual-table module.
//	*/
func Xsqlite3_create_module_v2(tls *libc.TLS, db uintptr, zName uintptr, pModule uintptr, pAux uintptr, __ccgo_fp_xDestroy uintptr) (r int32) {
	return _createModule(tls, db, zName, pModule, pAux, __ccgo_fp_xDestroy)
}

func Xsqlite3_create_window_function(tls *libc.TLS, db uintptr, zFunc uintptr, nArg int32, enc int32, p uintptr, __ccgo_fp_xStep uintptr, __ccgo_fp_xFinal uintptr, __ccgo_fp_xValue uintptr, __ccgo_fp_xInverse uintptr, __ccgo_fp_xDestroy uintptr) (r int32) {
	return _createFunctionApi(tls, db, zFunc, nArg, enc, p, uintptr(0), __ccgo_fp_xStep, __ccgo_fp_xFinal, __ccgo_fp_xValue, __ccgo_fp_xInverse, __ccgo_fp_xDestroy)
}

// C documentation
//
//	/*
//	** If the following global variable points to a string which is the
//	** name of a directory, then that directory will be used to store
//	** all database files specified with a relative pathname.
//	**
//	** See also the "PRAGMA data_store_directory" SQL command.
//	*/
var Xsqlite3_data_directory uintptr

/*
** When compiling the test fixture or with debugging enabled (on Win32),
** this variable being set to non-zero will cause OSTRACE macros to emit
** extra diagnostic information.
 */

// C documentation
//
//	/*
//	** Return the filename of the database associated with a database
//	** connection.
//	*/
func Xsqlite3_db_filename(tls *libc.TLS, db uintptr, zDbName uintptr) (r uintptr) {
	var pBt, v1 uintptr
	_, _ = pBt, v1
	pBt = _sqlite3DbNameToBtree(tls, db, zDbName)
	if pBt != 0 {
		v1 = _sqlite3BtreeGetFilename(tls, pBt)
	} else {
		v1 = uintptr(0)
	}
	return v1
}

// C documentation
//
//	/*
//	** Return the sqlite3* database handle to which the prepared statement given
//	** in the argument belongs.  This is the same database handle that was
//	** the first argument to the sqlite3_prepare() that was used to create
//	** the statement in the first place.
//	*/
func Xsqlite3_db_handle(tls *libc.TLS, pStmt uintptr) (r uintptr) {
	var v1 uintptr
	_ = v1
	if pStmt != 0 {
		v1 = (*TVdbe)(unsafe.Pointer(pStmt)).Fdb
	} else {
		v1 = uintptr(0)
	}
	return v1
}

// C documentation
//
//	/*
//	** Return the mutex associated with a database connection.
//	*/
func Xsqlite3_db_mutex(tls *libc.TLS, db uintptr) (r uintptr) {
	return (*Tsqlite3)(unsafe.Pointer(db)).Fmutex
}

// C documentation
//
//	/*
//	** Return 1 if database is read-only or 0 if read/write.  Return -1 if
//	** no such database exists.
//	*/
func Xsqlite3_db_readonly(tls *libc.TLS, db uintptr, zDbName uintptr) (r int32) {
	var pBt uintptr
	var v1 int32
	_, _ = pBt, v1
	pBt = _sqlite3DbNameToBtree(tls, db, zDbName)
	if pBt != 0 {
		v1 = _sqlite3BtreeIsReadonly(tls, pBt)
	} else {
		v1 = -int32(1)
	}
	return v1
}

// C documentation
//
//	/*
//	** 32-bit variant of sqlite3_db_status64()
//	*/
func Xsqlite3_db_status(tls *libc.TLS, db uintptr, op int32, pCurrent uintptr, pHighwtr uintptr, resetFlag int32) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* C at bp+0 */ Tsqlite3_int64
	var _ /* H at bp+8 */ Tsqlite3_int64
	_ = rc
	**(**Tsqlite3_int64)(__ccgo_up(bp)) = 0
	**(**Tsqlite3_int64)(__ccgo_up(bp + 8)) = 0
	rc = Xsqlite3_db_status64(tls, db, op, bp, bp+8, resetFlag)
	if rc == 0 {
		**(**int32)(__ccgo_up(pCurrent)) = int32(**(**Tsqlite3_int64)(__ccgo_up(bp)) & int64(0x7fffffff))
		**(**int32)(__ccgo_up(pHighwtr)) = int32(**(**Tsqlite3_int64)(__ccgo_up(bp + 8)) & int64(0x7fffffff))
	}
	return rc
}

// C documentation
//
//	/*
//	** Enable or disable the shared pager and schema features.
//	**
//	** This routine has no effect on existing database connections.
//	** The shared cache setting effects only future calls to
//	** sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2().
//	*/
func Xsqlite3_enable_shared_cache(tls *libc.TLS, enable int32) (r int32) {
	_sqlite3Config.FsharedCacheEnabled = enable
	return SQLITE_OK
}

/*
** Implementation of the SQLITE_CORRUPT_PAGE() macro. Takes a single
** (MemPage*) as an argument. The (MemPage*) must not be NULL.
**
** If SQLITE_DEBUG is not defined, then this macro is equivalent to
** SQLITE_CORRUPT_BKPT. Or, if SQLITE_DEBUG is set, then the log message
** normally produced as a side-effect of SQLITE_CORRUPT_BKPT is augmented
** with the page number and filename associated with the (MemPage*).
 */

/* Default value for SHARED_LOCK_TRACE macro if shared-cache is disabled
** or if the lock tracking is disabled.  This is always the value for
** release builds.
 */

// C documentation
//
//	/*
//	** Return the most recent error code generated by an SQLite routine. If NULL is
//	** passed to this function, we assume a malloc() failed during sqlite3_open().
//	*/
func Xsqlite3_errcode(tls *libc.TLS, db uintptr) (r int32) {
	var iRet int32
	_ = iRet
	if !(db != 0) {
		return int32(SQLITE_NOMEM)
	}
	if !(_sqlite3SafetyCheckSickOrOk(tls, db) != 0) {
		return _sqlite3MisuseError(tls, int32(190200))
	}
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
		iRet = int32(SQLITE_NOMEM)
	} else {
		iRet = (*Tsqlite3)(unsafe.Pointer(db)).FerrCode & (*Tsqlite3)(unsafe.Pointer(db)).FerrMask
	}
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return iRet
}

// C documentation
//
//	/*
//	** Return UTF-8 encoded English language explanation of the most recent
//	** error.
//	*/
func Xsqlite3_errmsg(tls *libc.TLS, db uintptr) (r uintptr) {
	var z, v1 uintptr
	_, _ = z, v1
	if !(db != 0) {
		return _sqlite3ErrStr(tls, int32(SQLITE_NOMEM))
	}
	if !(_sqlite3SafetyCheckSickOrOk(tls, db) != 0) {
		return _sqlite3ErrStr(tls, _sqlite3MisuseError(tls, int32(190094)))
	}
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
		z = _sqlite3ErrStr(tls, int32(SQLITE_NOMEM))
	} else {
		if (*Tsqlite3)(unsafe.Pointer(db)).FerrCode != 0 {
			v1 = Xsqlite3_value_text(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr)
		} else {
			v1 = uintptr(0)
		}
		z = v1
		if z == uintptr(0) {
			z = _sqlite3ErrStr(tls, (*Tsqlite3)(unsafe.Pointer(db)).FerrCode)
		}
	}
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return z
}

// C documentation
//
//	/*
//	** Return UTF-16 encoded English language explanation of the most recent
//	** error.
//	*/
func Xsqlite3_errmsg16(tls *libc.TLS, db uintptr) (r uintptr) {
	var z uintptr
	_ = z
	if !(db != 0) {
		return uintptr(unsafe.Pointer(&_outOfMem))
	}
	if !(_sqlite3SafetyCheckSickOrOk(tls, db) != 0) {
		return uintptr(unsafe.Pointer(&_misuse))
	}
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
		z = uintptr(unsafe.Pointer(&_outOfMem))
	} else {
		z = Xsqlite3_value_text16(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr)
		if z == uintptr(0) {
			_sqlite3ErrorWithMsg(tls, db, (*Tsqlite3)(unsafe.Pointer(db)).FerrCode, _sqlite3ErrStr(tls, (*Tsqlite3)(unsafe.Pointer(db)).FerrCode), 0)
			z = Xsqlite3_value_text16(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr)
		}
		/* A malloc() may have failed within the call to sqlite3_value_text16()
		 ** above. If this is the case, then the db->mallocFailed flag needs to
		 ** be cleared before returning. Do this directly, instead of via
		 ** sqlite3ApiExit(), to avoid setting the database handle error message.
		 */
		_sqlite3OomClear(tls, db)
	}
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return z
}

// C documentation
//
//	/*
//	** Return the byte offset of the most recent error
//	*/
func Xsqlite3_error_offset(tls *libc.TLS, db uintptr) (r int32) {
	var iOffset int32
	_ = iOffset
	iOffset = -int32(1)
	if db != 0 && _sqlite3SafetyCheckSickOrOk(tls, db) != 0 {
		Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
		if (*Tsqlite3)(unsafe.Pointer(db)).FerrCode != 0 {
			iOffset = (*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset
		}
		Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	}
	return iOffset
}

// C documentation
//
//	/*
//	** Return a string that describes the kind of error specified in the
//	** argument.  For now, this simply calls the internal sqlite3ErrStr()
//	** function.
//	*/
func Xsqlite3_errstr(tls *libc.TLS, rc int32) (r uintptr) {
	return _sqlite3ErrStr(tls, rc)
}

// C documentation
//
//	/*
//	** Return the SQL associated with a prepared statement with
//	** bound parameters expanded.  Space to hold the returned string is
//	** obtained from sqlite3_malloc().  The caller is responsible for
//	** freeing the returned string by passing it to sqlite3_free().
//	**
//	** The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of
//	** expanded bound parameters.
//	*/
func Xsqlite3_expanded_sql(tls *libc.TLS, pStmt uintptr) (r uintptr) {
	var p, z, zSql uintptr
	_, _, _ = p, z, zSql
	z = uintptr(0)
	zSql = Xsqlite3_sql(tls, pStmt)
	if zSql != 0 {
		p = pStmt
		Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
		z = _sqlite3VdbeExpandSql(tls, p, zSql)
		Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
	}
	return z
}

func Xsqlite3_extended_errcode(tls *libc.TLS, db uintptr) (r int32) {
	var iRet int32
	_ = iRet
	if !(db != 0) {
		return int32(SQLITE_NOMEM)
	}
	if !(_sqlite3SafetyCheckSickOrOk(tls, db) != 0) {
		return _sqlite3MisuseError(tls, int32(190215))
	}
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
		iRet = int32(SQLITE_NOMEM)
	} else {
		iRet = (*Tsqlite3)(unsafe.Pointer(db)).FerrCode
	}
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return iRet
}

// C documentation
//
//	/*
//	** Invoke the xFileControl method on a particular database.
//	*/
func Xsqlite3_file_control(tls *libc.TLS, db uintptr, zDbName uintptr, op int32, pArg uintptr) (r int32) {
	var fd, pBtree, pPager uintptr
	var iNew, nSave, rc int32
	_, _, _, _, _, _ = fd, iNew, nSave, pBtree, pPager, rc
	rc = int32(SQLITE_ERROR)
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	pBtree = _sqlite3DbNameToBtree(tls, db, zDbName)
	if pBtree != 0 {
		_sqlite3BtreeEnter(tls, pBtree)
		pPager = _sqlite3BtreePager(tls, pBtree)
		fd = _sqlite3PagerFile(tls, pPager)
		if op == int32(SQLITE_FCNTL_FILE_POINTER) {
			**(**uintptr)(__ccgo_up(pArg)) = fd
			rc = SQLITE_OK
		} else {
			if op == int32(SQLITE_FCNTL_VFS_POINTER) {
				**(**uintptr)(__ccgo_up(pArg)) = _sqlite3PagerVfs(tls, pPager)
				rc = SQLITE_OK
			} else {
				if op == int32(SQLITE_FCNTL_JOURNAL_POINTER) {
					**(**uintptr)(__ccgo_up(pArg)) = _sqlite3PagerJrnlFile(tls, pPager)
					rc = SQLITE_OK
				} else {
					if op == int32(SQLITE_FCNTL_DATA_VERSION) {
						**(**uint32)(__ccgo_up(pArg)) = _sqlite3PagerDataVersion(tls, pPager)
						rc = SQLITE_OK
					} else {
						if op == int32(SQLITE_FCNTL_RESERVE_BYTES) {
							iNew = **(**int32)(__ccgo_up(pArg))
							**(**int32)(__ccgo_up(pArg)) = _sqlite3BtreeGetRequestedReserve(tls, pBtree)
							if iNew >= 0 && iNew <= int32(255) {
								_sqlite3BtreeSetPageSize(tls, pBtree, 0, iNew, 0)
							}
							rc = SQLITE_OK
						} else {
							if op == int32(SQLITE_FCNTL_RESET_CACHE) {
								_sqlite3BtreeClearCache(tls, pBtree)
								rc = SQLITE_OK
							} else {
								nSave = (*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy
								rc = _sqlite3OsFileControl(tls, fd, op, pArg)
								(*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = nSave
							}
						}
					}
				}
			}
		}
		_sqlite3BtreeLeave(tls, pBtree)
	}
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return rc
}

// C documentation
//
//	/*
//	** Translate a filename that was handed to a VFS routine into the corresponding
//	** database, journal, or WAL file.
//	**
//	** It is an error to pass this routine a filename string that was not
//	** passed into the VFS from the SQLite core.  Doing so is similar to
//	** passing free() a pointer that was not obtained from malloc() - it is
//	** an error that we cannot easily detect but that will likely cause memory
//	** corruption.
//	*/
func Xsqlite3_filename_database(tls *libc.TLS, zFilename uintptr) (r uintptr) {
	if zFilename == uintptr(0) {
		return uintptr(0)
	}
	return _databaseName(tls, zFilename)
}

func Xsqlite3_filename_wal(tls *libc.TLS, zFilename uintptr) (r uintptr) {
	zFilename = Xsqlite3_filename_journal(tls, zFilename)
	if zFilename != 0 {
		zFilename = zFilename + uintptr(_sqlite3Strlen30(tls, zFilename)+int32(1))
	}
	return zFilename
}

// C documentation
//
//	/*
//	** The following routine destroys a virtual machine that is created by
//	** the sqlite3_compile() routine. The integer returned is an SQLITE_
//	** success/failure code that describes the result of executing the virtual
//	** machine.
//	**
//	** This routine sets the error code and string returned by
//	** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
//	*/
func Xsqlite3_finalize(tls *libc.TLS, pStmt uintptr) (r int32) {
	var db, v uintptr
	var rc int32
	_, _, _ = db, rc, v
	if pStmt == uintptr(0) {
		/* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL
		 ** pointer is a harmless no-op. */
		rc = SQLITE_OK
	} else {
		v = pStmt
		db = (*TVdbe)(unsafe.Pointer(v)).Fdb
		if _vdbeSafety(tls, v) != 0 {
			return _sqlite3MisuseError(tls, int32(93797))
		}
		Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
		if (*TVdbe)(unsafe.Pointer(v)).FstartTime > 0 {
			_invokeProfileCallback(tls, db, v)
		}
		rc = _sqlite3VdbeReset(tls, v)
		_sqlite3VdbeDelete(tls, v)
		rc = _sqlite3ApiExit(tls, db, rc)
		_sqlite3LeaveMutexAndCloseZombie(tls, db)
	}
	return rc
}

// C documentation
//
//	/*
//	** Free memory previously obtained from sqlite3Malloc().
//	*/
func Xsqlite3_free(tls *libc.TLS, p uintptr) {
	if p == uintptr(0) {
		return
	} /* IMP: R-49053-54554 */
	if _sqlite3Config.FbMemstat != 0 {
		Xsqlite3_mutex_enter(tls, _mem0.Fmutex)
		_sqlite3StatusDown(tls, SQLITE_STATUS_MEMORY_USED, _sqlite3MallocSize(tls, p))
		_sqlite3StatusDown(tls, int32(SQLITE_STATUS_MALLOC_COUNT), int32(1))
		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxFree})))(tls, p)
		Xsqlite3_mutex_leave(tls, _mem0.Fmutex)
	} else {
		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxFree})))(tls, p)
	}
}

// C documentation
//
//	/*
//	** Free memory obtained from sqlite3_create_filename().  It is a severe
//	** error to call this routine with any parameter other than a pointer
//	** previously obtained from sqlite3_create_filename() or a NULL pointer.
//	*/
func Xsqlite3_free_filename(tls *libc.TLS, p uintptr) {
	if p == uintptr(0) {
		return
	}
	p = _databaseName(tls, p)
	Xsqlite3_free(tls, p-uintptr(4))
}

// C documentation
//
//	/*
//	** Return the auxiliary data pointer, if any, for the iArg'th argument to
//	** the user-function defined by pCtx.
//	**
//	** The left-most argument is 0.
//	**
//	** Undocumented behavior:  If iArg is negative then access a cache of
//	** auxiliary data pointers that is available to all functions within a
//	** single prepared statement.  The iArg values must match.
//	*/
func Xsqlite3_get_auxdata(tls *libc.TLS, pCtx uintptr, iArg int32) (r uintptr) {
	var pAuxData uintptr
	_ = pAuxData
	if (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe == uintptr(0) {
		return uintptr(0)
	}
	pAuxData = (*TVdbe)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpVdbe)).FpAuxData
	for {
		if !(pAuxData != 0) {
			break
		}
		if (*TAuxData)(unsafe.Pointer(pAuxData)).FiAuxArg == iArg && ((*TAuxData)(unsafe.Pointer(pAuxData)).FiAuxOp == (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FiOp || iArg < 0) {
			return (*TAuxData)(unsafe.Pointer(pAuxData)).FpAux
		}
		goto _1
	_1:
		;
		pAuxData = (*TAuxData)(unsafe.Pointer(pAuxData)).FpNextAux
	}
	return uintptr(0)
}

// C documentation
//
//	/*
//	** This function is now an anachronism. It used to be used to recover from a
//	** malloc() failure, but SQLite now does this automatically.
//	*/
func Xsqlite3_global_recover(tls *libc.TLS) (r int32) {
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Set the hard heap-size limit for the library. An argument of zero
//	** disables the hard heap limit.  A negative argument is a no-op used
//	** to obtain the return value without affecting the hard heap limit.
//	**
//	** The return value is the value of the hard heap limit just prior to
//	** calling this interface.
//	**
//	** Setting the hard heap limit will also activate the soft heap limit
//	** and constrain the soft heap limit to be no more than the hard heap
//	** limit.
//	*/
func Xsqlite3_hard_heap_limit64(tls *libc.TLS, n Tsqlite3_int64) (r Tsqlite3_int64) {
	var priorLimit Tsqlite3_int64
	var rc int32
	_, _ = priorLimit, rc
	rc = Xsqlite3_initialize(tls)
	if rc != 0 {
		return int64(-int32(1))
	}
	Xsqlite3_mutex_enter(tls, _mem0.Fmutex)
	priorLimit = _mem0.FhardLimit
	if n >= 0 {
		_mem0.FhardLimit = n
		if n < _mem0.FalarmThreshold || _mem0.FalarmThreshold == 0 {
			_mem0.FalarmThreshold = n
		}
	}
	Xsqlite3_mutex_leave(tls, _mem0.Fmutex)
	return priorLimit
}

func Xsqlite3_keyword_check(tls *libc.TLS, zName uintptr, nName int32) (r int32) {
	return libc.BoolInt32(int32(TK_ID) != _sqlite3KeywordCode(tls, zName, nName))
}

/************** End of keywordhash.h *****************************************/
/************** Continuing where we left off in tokenize.c *******************/

/*
** If X is a character that can be used in an identifier then
** IdChar(X) will be true.  Otherwise it is false.
**
** For ASCII, any character with the high-order bit set is
** allowed in an identifier.  For 7-bit characters,
** sqlite3IsIdChar[X] must be 1.
**
** For EBCDIC, the rules are more complex but have the same
** end result.
**
** Ticket #1066.  the SQL standard does not allow '$' in the
** middle of identifiers.  But many SQL implementations do.
** SQLite will allow '$' in identifiers for compatibility.
** But the feature is undocumented.
 */

func Xsqlite3_keyword_count(tls *libc.TLS) (r int32) {
	return int32(SQLITE_N_KEYWORD)
}

// C documentation
//
//	/*
//	** Return the ROWID of the most recent insert
//	*/
func Xsqlite3_last_insert_rowid(tls *libc.TLS, db uintptr) (r Tsqlite_int64) {
	var iRet Ti64
	_ = iRet
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	iRet = (*Tsqlite3)(unsafe.Pointer(db)).FlastRowid
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return iRet
}

// C documentation
//
//	/* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns
//	** a pointer to the to the sqlite3_version[] string constant.
//	*/
func Xsqlite3_libversion(tls *libc.TLS) (r uintptr) {
	return uintptr(unsafe.Pointer(&Xsqlite3_version))
}

/* IMPLEMENTATION-OF: R-25063-23286 The sqlite3_sourceid() function returns a
** pointer to a string constant whose value is the same as the
** SQLITE_SOURCE_ID C preprocessor macro. Except if SQLite is built using
** an edited copy of the amalgamation, then the last four characters of
** the hash might be different from SQLITE_SOURCE_ID.
 */
/* SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } */

// C documentation
//
//	/* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function
//	** returns an integer equal to SQLITE_VERSION_NUMBER.
//	*/
func Xsqlite3_libversion_number(tls *libc.TLS) (r int32) {
	return int32(SQLITE_VERSION_NUMBER)
}

func Xsqlite3_load_extension(tls *libc.TLS, db uintptr, zFile uintptr, zProc uintptr, pzErrMsg uintptr) (r int32) {
	var rc int32
	_ = rc
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	rc = _sqlite3LoadExtension(tls, db, zFile, zProc, pzErrMsg)
	rc = _sqlite3ApiExit(tls, db, rc)
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return rc
}

// C documentation
//
//	/*
//	** Format and write a message to the log if logging is enabled.
//	*/
func Xsqlite3_log(tls *libc.TLS, iErrCode int32, zFormat uintptr, va uintptr) {
	var ap Tva_list
	_ = ap /* Vararg list */
	if _sqlite3Config.FxLog != 0 {
		ap = va
		_renderLogMsg(tls, iErrCode, zFormat, ap)
		_ = ap
	}
}

func Xsqlite3_malloc64(tls *libc.TLS, n Tsqlite3_uint64) (r uintptr) {
	if Xsqlite3_initialize(tls) != 0 {
		return uintptr(0)
	}
	return _sqlite3Malloc(tls, n)
}

// C documentation
//
//	/*
//	** Deprecated external interface.  It used to set an alarm callback
//	** that was invoked when memory usage grew too large.  Now it is a
//	** no-op.
//	*/
func Xsqlite3_memory_alarm(tls *libc.TLS, __ccgo_fp_xCallback uintptr, pArg uintptr, iThreshold Tsqlite3_int64) (r int32) {
	_ = __ccgo_fp_xCallback
	_ = pArg
	_ = iThreshold
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Return the maximum amount of memory that has ever been
//	** checked out since either the beginning of this process
//	** or since the most recent reset.
//	*/
func Xsqlite3_memory_highwater(tls *libc.TLS, resetFlag int32) (r Tsqlite3_int64) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var _ /* mx at bp+8 */ Tsqlite3_int64
	var _ /* res at bp+0 */ Tsqlite3_int64
	Xsqlite3_status64(tls, SQLITE_STATUS_MEMORY_USED, bp, bp+8, resetFlag)
	return **(**Tsqlite3_int64)(__ccgo_up(bp + 8))
}

// C documentation
//
//	/*
//	** Return the amount of memory currently checked out.
//	*/
func Xsqlite3_memory_used(tls *libc.TLS) (r Tsqlite3_int64) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var _ /* mx at bp+8 */ Tsqlite3_int64
	var _ /* res at bp+0 */ Tsqlite3_int64
	Xsqlite3_status64(tls, SQLITE_STATUS_MEMORY_USED, bp, bp+8, 0)
	return **(**Tsqlite3_int64)(__ccgo_up(bp))
}

// C documentation
//
//	/*
//	** Print into memory obtained from sqlite3_malloc()().  Omit the internal
//	** %-conversion extensions.
//	*/
func Xsqlite3_mprintf(tls *libc.TLS, zFormat uintptr, va uintptr) (r uintptr) {
	var ap Tva_list
	var z uintptr
	_, _ = ap, z
	if Xsqlite3_initialize(tls) != 0 {
		return uintptr(0)
	}
	ap = va
	z = Xsqlite3_vmprintf(tls, zFormat, ap)
	_ = ap
	return z
}

// C documentation
//
//	/*
//	** Retrieve a pointer to a static mutex or allocate a new dynamic one.
//	*/
func Xsqlite3_mutex_alloc(tls *libc.TLS, id int32) (r uintptr) {
	if id <= int32(SQLITE_MUTEX_RECURSIVE) && Xsqlite3_initialize(tls) != 0 {
		return uintptr(0)
	}
	if id > int32(SQLITE_MUTEX_RECURSIVE) && _sqlite3MutexInit(tls) != 0 {
		return uintptr(0)
	}
	return (*(*func(*libc.TLS, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fmutex.FxMutexAlloc})))(tls, id)
}

// C documentation
//
//	/*
//	** Obtain the mutex p. If some other thread already has the mutex, block
//	** until it can be obtained.
//	*/
func Xsqlite3_mutex_enter(tls *libc.TLS, p uintptr) {
	if p != 0 {
		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fmutex.FxMutexEnter})))(tls, p)
	}
}

// C documentation
//
//	/*
//	** Free a dynamic mutex.
//	*/
func Xsqlite3_mutex_free(tls *libc.TLS, p uintptr) {
	if p != 0 {
		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fmutex.FxMutexFree})))(tls, p)
	}
}

// C documentation
//
//	/*
//	** The sqlite3_mutex_leave() routine exits a mutex that was previously
//	** entered by the same thread.  The behavior is undefined if the mutex
//	** is not currently entered. If a NULL pointer is passed as an argument
//	** this function is a no-op.
//	*/
func Xsqlite3_mutex_leave(tls *libc.TLS, p uintptr) {
	if p != 0 {
		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fmutex.FxMutexLeave})))(tls, p)
	}
}

/************** End of mutex.c ***********************************************/
/************** Begin file mutex_noop.c **************************************/
/*
** 2008 October 07
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains the C functions that implement mutexes.
**
** This implementation in this file does not provide any mutual
** exclusion and is thus suitable for use only in applications
** that use SQLite in a single thread.  The routines defined
** here are place-holders.  Applications can substitute working
** mutex routines at start-time using the
**
**     sqlite3_config(SQLITE_CONFIG_MUTEX,...)
**
** interface.
**
** If compiled with SQLITE_DEBUG, then additional logic is inserted
** that does error checking on mutexes to make sure they are being
** called correctly.
 */
/* #include "sqliteInt.h" */

// C documentation
//
//	/*
//	** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another
//	** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY.
//	*/
func Xsqlite3_mutex_try(tls *libc.TLS, p uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = SQLITE_OK
	if p != 0 {
		return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fmutex.FxMutexTry})))(tls, p)
	}
	return rc
}

// C documentation
//
//	/*
//	** Return a pointer to the next prepared statement after pStmt associated
//	** with database connection pDb.  If pStmt is NULL, return the first
//	** prepared statement for the database connection.  Return NULL if there
//	** are no more.
//	*/
func Xsqlite3_next_stmt(tls *libc.TLS, pDb uintptr, pStmt uintptr) (r uintptr) {
	var pNext uintptr
	_ = pNext
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(pDb)).Fmutex)
	if pStmt == uintptr(0) {
		pNext = (*Tsqlite3)(unsafe.Pointer(pDb)).FpVdbe
	} else {
		pNext = (*TVdbe)(unsafe.Pointer(pStmt)).FpVNext
	}
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(pDb)).Fmutex)
	return pNext
}

// C documentation
//
//	/*
//	** Two versions of the official API.  Legacy and new use.  In the legacy
//	** version, the original SQL text is not saved in the prepared statement
//	** and so if a schema change occurs, SQLITE_SCHEMA is returned by
//	** sqlite3_step().  In the new version, the original SQL text is retained
//	** and the statement is automatically recompiled if an schema change
//	** occurs.
//	*/
func Xsqlite3_prepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, ppStmt uintptr, pzTail uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = _sqlite3LockAndPrepare(tls, db, zSql, nBytes, uint32(0), uintptr(0), ppStmt, pzTail)
	/* VERIFY: F13021 */
	return rc
}

// C documentation
//
//	/*
//	** Two versions of the official API.  Legacy and new use.  In the legacy
//	** version, the original SQL text is not saved in the prepared statement
//	** and so if a schema change occurs, SQLITE_SCHEMA is returned by
//	** sqlite3_step().  In the new version, the original SQL text is retained
//	** and the statement is automatically recompiled if an schema change
//	** occurs.
//	*/
func Xsqlite3_prepare16(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, ppStmt uintptr, pzTail uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = _sqlite3Prepare16(tls, db, zSql, nBytes, uint32(0), ppStmt, pzTail)
	/* VERIFY: F13021 */
	return rc
}

func Xsqlite3_prepare16_v2(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, ppStmt uintptr, pzTail uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = _sqlite3Prepare16(tls, db, zSql, nBytes, uint32(SQLITE_PREPARE_SAVESQL), ppStmt, pzTail)
	/* VERIFY: F13021 */
	return rc
}

func Xsqlite3_prepare16_v3(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags uint32, ppStmt uintptr, pzTail uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = _sqlite3Prepare16(tls, db, zSql, nBytes, uint32(SQLITE_PREPARE_SAVESQL)|prepFlags&uint32(SQLITE_PREPARE_MASK), ppStmt, pzTail)
	/* VERIFY: F13021 */
	return rc
}

/************** End of prepare.c *********************************************/
/************** Begin file select.c ******************************************/
/*
** 2001 September 15
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
 */
/* #include "sqliteInt.h" */

func Xsqlite3_prepare_v2(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, ppStmt uintptr, pzTail uintptr) (r int32) {
	var rc int32
	_ = rc
	/* EVIDENCE-OF: R-37923-12173 The sqlite3_prepare_v2() interface works
	 ** exactly the same as sqlite3_prepare_v3() with a zero prepFlags
	 ** parameter.
	 **
	 ** Proof in that the 5th parameter to sqlite3LockAndPrepare is 0 */
	rc = _sqlite3LockAndPrepare(tls, db, zSql, nBytes, uint32(SQLITE_PREPARE_SAVESQL), uintptr(0), ppStmt, pzTail)
	return rc
}

func Xsqlite3_prepare_v3(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags uint32, ppStmt uintptr, pzTail uintptr) (r int32) {
	var rc int32
	_ = rc
	/* EVIDENCE-OF: R-56861-42673 sqlite3_prepare_v3() differs from
	 ** sqlite3_prepare_v2() only in having the extra prepFlags parameter,
	 ** which is a bit array consisting of zero or more of the
	 ** SQLITE_PREPARE_* flags.
	 **
	 ** Proof by comparison to the implementation of sqlite3_prepare_v2()
	 ** directly above. */
	rc = _sqlite3LockAndPrepare(tls, db, zSql, nBytes, uint32(SQLITE_PREPARE_SAVESQL)|prepFlags&uint32(SQLITE_PREPARE_MASK), uintptr(0), ppStmt, pzTail)
	return rc
}

// C documentation
//
//	/*
//	** This function is designed to be called from within a pre-update callback
//	** only.
//	*/
func Xsqlite3_preupdate_blobwrite(tls *libc.TLS, db uintptr) (r int32) {
	var p uintptr
	var v1 int32
	_, _ = p, v1
	p = (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdate
	if p != 0 {
		v1 = (*TPreUpdate)(unsafe.Pointer(p)).FiBlobWrite
	} else {
		v1 = -int32(1)
	}
	return v1
}

// C documentation
//
//	/*
//	** This function is designed to be called from within a pre-update callback
//	** only. It returns zero if the change that caused the callback was made
//	** immediately by a user SQL statement. Or, if the change was made by a
//	** trigger program, it returns the number of trigger programs currently
//	** on the stack (1 for a top-level trigger, 2 for a trigger fired by a
//	** top-level trigger etc.).
//	**
//	** For the purposes of the previous paragraph, a foreign key CASCADE, SET NULL
//	** or SET DEFAULT action is considered a trigger.
//	*/
func Xsqlite3_preupdate_depth(tls *libc.TLS, db uintptr) (r int32) {
	var p uintptr
	var v1 int32
	_, _ = p, v1
	p = (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdate
	if p != 0 {
		v1 = (*TVdbe)(unsafe.Pointer((*TPreUpdate)(unsafe.Pointer(p)).Fv)).FnFrame
	} else {
		v1 = 0
	}
	return v1
}

// C documentation
//
//	/*
//	** Register a callback to be invoked each time a row is updated,
//	** inserted or deleted using this database connection.
//	*/
func Xsqlite3_preupdate_hook(tls *libc.TLS, db uintptr, __ccgo_fp_xCallback uintptr, pArg uintptr) (r uintptr) {
	var pRet uintptr
	_ = pRet
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	pRet = (*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdateArg
	(*Tsqlite3)(unsafe.Pointer(db)).FxPreUpdateCallback = __ccgo_fp_xCallback
	(*Tsqlite3)(unsafe.Pointer(db)).FpPreUpdateArg = pArg
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return pRet
}

func Xsqlite3_realloc64(tls *libc.TLS, pOld uintptr, n Tsqlite3_uint64) (r uintptr) {
	if Xsqlite3_initialize(tls) != 0 {
		return uintptr(0)
	}
	return _sqlite3Realloc(tls, pOld, n)
}

// C documentation
//
//	/*
//	** Attempt to release up to n bytes of non-essential memory currently
//	** held by SQLite. An example of non-essential memory is memory used to
//	** cache database pages that are not currently in use.
//	*/
func Xsqlite3_release_memory(tls *libc.TLS, n int32) (r int32) {
	return _sqlite3PcacheReleaseMemory(tls, n)
}

/*
** Default value of the hard heap limit.  0 means "no limit".
 */

// C documentation
//
//	/*
//	** Terminate the current execution of an SQL statement and reset it
//	** back to its starting state so that it can be reused. A success code from
//	** the prior execution is returned.
//	**
//	** This routine sets the error code and string returned by
//	** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
//	*/
func Xsqlite3_reset(tls *libc.TLS, pStmt uintptr) (r int32) {
	var db, v uintptr
	var rc int32
	_, _, _ = db, rc, v
	if pStmt == uintptr(0) {
		rc = SQLITE_OK
	} else {
		v = pStmt
		db = (*TVdbe)(unsafe.Pointer(v)).Fdb
		Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
		if (*TVdbe)(unsafe.Pointer(v)).FstartTime > 0 {
			_invokeProfileCallback(tls, db, v)
		}
		rc = _sqlite3VdbeReset(tls, v)
		_sqlite3VdbeRewind(tls, v)
		rc = _sqlite3ApiExit(tls, db, rc)
		Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	}
	return rc
}

// C documentation
//
//	/*
//	** Reset the automatic extension loading mechanism.
//	*/
func Xsqlite3_reset_auto_extension(tls *libc.TLS) {
	var mutex uintptr
	_ = mutex
	if Xsqlite3_initialize(tls) == SQLITE_OK {
		mutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN))
		Xsqlite3_mutex_enter(tls, mutex)
		Xsqlite3_free(tls, _sqlite3Autoext.FaExt)
		_sqlite3Autoext.FaExt = uintptr(0)
		_sqlite3Autoext.FnExt = uint32(0)
		Xsqlite3_mutex_leave(tls, mutex)
	}
}

func Xsqlite3_result_blob(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, __ccgo_fp_xDel uintptr) {
	_setResultStrOrError(tls, pCtx, z, n, uint8(0), __ccgo_fp_xDel)
}

func Xsqlite3_result_double(tls *libc.TLS, pCtx uintptr, rVal float64) {
	_sqlite3VdbeMemSetDouble(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut, rVal)
}

func Xsqlite3_result_error(tls *libc.TLS, pCtx uintptr, z uintptr, n int32) {
	(*Tsqlite3_context)(unsafe.Pointer(pCtx)).FisError = int32(SQLITE_ERROR)
	_sqlite3VdbeMemSetStr(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut, z, int64(n), uint8(SQLITE_UTF8), uintptr(-libc.Int32FromInt32(1)))
}

// C documentation
//
//	/* An SQLITE_NOMEM error. */
func Xsqlite3_result_error_nomem(tls *libc.TLS, pCtx uintptr) {
	_sqlite3VdbeMemSetNull(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut)
	(*Tsqlite3_context)(unsafe.Pointer(pCtx)).FisError = int32(SQLITE_NOMEM)
	_sqlite3OomFault(tls, (*TMem)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut)).Fdb)
}

func Xsqlite3_result_int(tls *libc.TLS, pCtx uintptr, iVal int32) {
	_sqlite3VdbeMemSetInt64(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut, int64(iVal))
}

func Xsqlite3_result_int64(tls *libc.TLS, pCtx uintptr, iVal Ti64) {
	_sqlite3VdbeMemSetInt64(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut, iVal)
}

func Xsqlite3_result_null(tls *libc.TLS, pCtx uintptr) {
	_sqlite3VdbeMemSetNull(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut)
}

func Xsqlite3_result_pointer(tls *libc.TLS, pCtx uintptr, pPtr uintptr, zPType uintptr, __ccgo_fp_xDestructor uintptr) {
	var pOut uintptr
	_ = pOut
	pOut = (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut
	_sqlite3VdbeMemRelease(tls, pOut)
	(*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Null)
	_sqlite3VdbeMemSetPointer(tls, pOut, pPtr, zPType, __ccgo_fp_xDestructor)
}

func Xsqlite3_result_text(tls *libc.TLS, pCtx uintptr, z uintptr, n int32, __ccgo_fp_xDel uintptr) {
	_setResultStrOrError(tls, pCtx, z, n, uint8(SQLITE_UTF8), __ccgo_fp_xDel)
}

// C documentation
//
//	/*
//	** Register a callback to be invoked each time a transaction is rolled
//	** back by this database connection.
//	*/
func Xsqlite3_rollback_hook(tls *libc.TLS, db uintptr, __ccgo_fp_xCallback uintptr, pArg uintptr) (r uintptr) {
	var pRet uintptr
	_ = pRet
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	pRet = (*Tsqlite3)(unsafe.Pointer(db)).FpRollbackArg
	(*Tsqlite3)(unsafe.Pointer(db)).FxRollbackCallback = __ccgo_fp_xCallback
	(*Tsqlite3)(unsafe.Pointer(db)).FpRollbackArg = pArg
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return pRet
}

// C documentation
//
//	/*
//	** Set or clear the access authorization function.
//	**
//	** The access authorization function is be called during the compilation
//	** phase to verify that the user has read and/or write access permission on
//	** various fields of the database.  The first argument to the auth function
//	** is a copy of the 3rd argument to this routine.  The second argument
//	** to the auth function is one of these constants:
//	**
//	**       SQLITE_CREATE_INDEX
//	**       SQLITE_CREATE_TABLE
//	**       SQLITE_CREATE_TEMP_INDEX
//	**       SQLITE_CREATE_TEMP_TABLE
//	**       SQLITE_CREATE_TEMP_TRIGGER
//	**       SQLITE_CREATE_TEMP_VIEW
//	**       SQLITE_CREATE_TRIGGER
//	**       SQLITE_CREATE_VIEW
//	**       SQLITE_DELETE
//	**       SQLITE_DROP_INDEX
//	**       SQLITE_DROP_TABLE
//	**       SQLITE_DROP_TEMP_INDEX
//	**       SQLITE_DROP_TEMP_TABLE
//	**       SQLITE_DROP_TEMP_TRIGGER
//	**       SQLITE_DROP_TEMP_VIEW
//	**       SQLITE_DROP_TRIGGER
//	**       SQLITE_DROP_VIEW
//	**       SQLITE_INSERT
//	**       SQLITE_PRAGMA
//	**       SQLITE_READ
//	**       SQLITE_SELECT
//	**       SQLITE_TRANSACTION
//	**       SQLITE_UPDATE
//	**
//	** The third and fourth arguments to the auth function are the name of
//	** the table and the column that are being accessed.  The auth function
//	** should return either SQLITE_OK, SQLITE_DENY, or SQLITE_IGNORE.  If
//	** SQLITE_OK is returned, it means that access is allowed.  SQLITE_DENY
//	** means that the SQL statement will never-run - the sqlite3_exec() call
//	** will return with an error.  SQLITE_IGNORE means that the SQL statement
//	** should run but attempts to read the specified column will return NULL
//	** and attempts to write the column will be ignored.
//	**
//	** Setting the auth function to NULL disables this hook.  The default
//	** setting of the auth function is NULL.
//	*/
func Xsqlite3_set_authorizer(tls *libc.TLS, db uintptr, __ccgo_fp_xAuth uintptr, pArg uintptr) (r int32) {
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	(*Tsqlite3)(unsafe.Pointer(db)).FxAuth = __ccgo_fp_xAuth
	(*Tsqlite3)(unsafe.Pointer(db)).FpAuthArg = pArg
	_sqlite3ExpirePreparedStatements(tls, db, int32(1))
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Set the value returned by the sqlite3_last_insert_rowid() API function.
//	*/
func Xsqlite3_set_last_insert_rowid(tls *libc.TLS, db uintptr, iRowid Tsqlite3_int64) {
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	(*Tsqlite3)(unsafe.Pointer(db)).FlastRowid = iRowid
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
}

// C documentation
//
//	/*
//	** Set the setlk timeout value.
//	*/
func Xsqlite3_setlk_timeout(tls *libc.TLS, db uintptr, ms int32, flags int32) (r int32) {
	if ms < -int32(1) {
		return int32(SQLITE_RANGE)
	}
	_ = db
	_ = flags
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Sleep for a little while.  Return the amount of time slept.
//	*/
func Xsqlite3_sleep(tls *libc.TLS, ms int32) (r int32) {
	var pVfs uintptr
	var rc, v1 int32
	_, _, _ = pVfs, rc, v1
	pVfs = Xsqlite3_vfs_find(tls, uintptr(0))
	if pVfs == uintptr(0) {
		return 0
	}
	/* This function works in milliseconds, but the underlying OsSleep()
	 ** API uses microseconds. Hence the 1000's.
	 */
	if ms < 0 {
		v1 = 0
	} else {
		v1 = int32(1000) * ms
	}
	rc = _sqlite3OsSleep(tls, pVfs, v1) / int32(1000)
	return rc
}

// C documentation
//
//	/*
//	** Return a +ve value if snapshot p1 is newer than p2. A -ve value if
//	** p1 is older than p2 and zero if p1 and p2 are the same snapshot.
//	*/
func Xsqlite3_snapshot_cmp(tls *libc.TLS, p1 uintptr, p2 uintptr) (r int32) {
	var pHdr1, pHdr2 uintptr
	_, _ = pHdr1, pHdr2
	pHdr1 = p1
	pHdr2 = p2
	/* aSalt[0] is a copy of the value stored in the wal file header. It
	 ** is incremented each time the wal file is restarted.  */
	if **(**Tu32)(__ccgo_up(pHdr1 + 32)) < **(**Tu32)(__ccgo_up(pHdr2 + 32)) {
		return -int32(1)
	}
	if **(**Tu32)(__ccgo_up(pHdr1 + 32)) > **(**Tu32)(__ccgo_up(pHdr2 + 32)) {
		return +libc.Int32FromInt32(1)
	}
	if (*TWalIndexHdr)(unsafe.Pointer(pHdr1)).FmxFrame < (*TWalIndexHdr)(unsafe.Pointer(pHdr2)).FmxFrame {
		return -int32(1)
	}
	if (*TWalIndexHdr)(unsafe.Pointer(pHdr1)).FmxFrame > (*TWalIndexHdr)(unsafe.Pointer(pHdr2)).FmxFrame {
		return +libc.Int32FromInt32(1)
	}
	return 0
}

// C documentation
//
//	/*
//	** Free a snapshot handle obtained from sqlite3_snapshot_get().
//	*/
func Xsqlite3_snapshot_free(tls *libc.TLS, pSnapshot uintptr) {
	Xsqlite3_free(tls, pSnapshot)
}

func Xsqlite3_soft_heap_limit(tls *libc.TLS, n int32) {
	if n < 0 {
		n = 0
	}
	Xsqlite3_soft_heap_limit64(tls, int64(n))
}

// C documentation
//
//	/*
//	** Return the SQL associated with a prepared statement
//	*/
func Xsqlite3_sql(tls *libc.TLS, pStmt uintptr) (r uintptr) {
	var p, v1 uintptr
	_, _ = p, v1
	p = pStmt
	if p != 0 {
		v1 = (*TVdbe)(unsafe.Pointer(p)).FzSql
	} else {
		v1 = uintptr(0)
	}
	return v1
}

func Xsqlite3_status(tls *libc.TLS, op int32, pCurrent uintptr, pHighwater uintptr, resetFlag int32) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* iCur at bp+0 */ Tsqlite3_int64
	var _ /* iHwtr at bp+8 */ Tsqlite3_int64
	_ = rc
	**(**Tsqlite3_int64)(__ccgo_up(bp)) = 0
	**(**Tsqlite3_int64)(__ccgo_up(bp + 8)) = 0
	rc = Xsqlite3_status64(tls, op, bp, bp+8, resetFlag)
	if rc == 0 {
		**(**int32)(__ccgo_up(pCurrent)) = int32(**(**Tsqlite3_int64)(__ccgo_up(bp)))
		**(**int32)(__ccgo_up(pHighwater)) = int32(**(**Tsqlite3_int64)(__ccgo_up(bp + 8)))
	}
	return rc
}

// C documentation
//
//	/*
//	** This is the top-level implementation of sqlite3_step().  Call
//	** sqlite3Step() to do most of the work.  If a schema error occurs,
//	** call sqlite3Reprepare() and try again.
//	*/
func Xsqlite3_step(tls *libc.TLS, pStmt uintptr) (r int32) {
	var cnt, rc, savedPc, v1, v2 int32
	var db, v, zErr uintptr
	var v3 bool
	_, _, _, _, _, _, _, _, _ = cnt, db, rc, savedPc, v, zErr, v1, v2, v3
	rc = SQLITE_OK /* Result from sqlite3Step() */
	v = pStmt      /* the prepared statement */
	cnt = 0        /* The database connection */
	if _vdbeSafetyNotNull(tls, v) != 0 {
		return _sqlite3MisuseError(tls, int32(94609))
	}
	db = (*TVdbe)(unsafe.Pointer(v)).Fdb
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	for {
		v1 = _sqlite3Step(tls, v)
		rc = v1
		if v3 = v1 == int32(SQLITE_SCHEMA); v3 {
			v2 = cnt
			cnt = cnt + 1
		}
		if !(v3 && v2 < int32(SQLITE_MAX_SCHEMA_RETRY)) {
			break
		}
		savedPc = (*TVdbe)(unsafe.Pointer(v)).Fpc
		rc = _sqlite3Reprepare(tls, v)
		if rc != SQLITE_OK {
			/* This case occurs after failing to recompile an sql statement.
			 ** The error message from the SQL compiler has already been loaded
			 ** into the database handle. This block copies the error message
			 ** from the database handle into the statement and sets the statement
			 ** program counter to 0 to ensure that when the statement is
			 ** finalized or reset the parser error message is available via
			 ** sqlite3_errmsg() and sqlite3_errcode().
			 */
			zErr = Xsqlite3_value_text(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr)
			_sqlite3DbFree(tls, db, (*TVdbe)(unsafe.Pointer(v)).FzErrMsg)
			if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
				(*TVdbe)(unsafe.Pointer(v)).FzErrMsg = _sqlite3DbStrDup(tls, db, zErr)
				v1 = _sqlite3ApiExit(tls, db, rc)
				rc = v1
				(*TVdbe)(unsafe.Pointer(v)).Frc = v1
			} else {
				(*TVdbe)(unsafe.Pointer(v)).FzErrMsg = uintptr(0)
				v1 = libc.Int32FromInt32(SQLITE_NOMEM)
				rc = v1
				(*TVdbe)(unsafe.Pointer(v)).Frc = v1
			}
			break
		}
		Xsqlite3_reset(tls, pStmt)
		if savedPc >= 0 {
			/* Setting minWriteFileFormat to 254 is a signal to the OP_Init and
			 ** OP_Trace opcodes to *not* perform SQLITE_TRACE_STMT because it has
			 ** already been done once on a prior invocation that failed due to
			 ** SQLITE_SCHEMA.   tag-20220401a  */
			(*TVdbe)(unsafe.Pointer(v)).FminWriteFileFormat = uint8(254)
		}
	}
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return rc
}

// C documentation
//
//	/*
//	** Append the complete text of zero-terminated string z[] to the p string.
//	*/
func Xsqlite3_str_appendall(tls *libc.TLS, p uintptr, z uintptr) {
	Xsqlite3_str_append(tls, p, z, _sqlite3Strlen30(tls, z))
}

// C documentation
//
//	/*
//	** variable-argument wrapper around sqlite3_str_vappendf(). The bFlags argument
//	** can contain the bit SQLITE_PRINTF_INTERNAL enable internal formats.
//	*/
func Xsqlite3_str_appendf(tls *libc.TLS, p uintptr, zFormat uintptr, va uintptr) {
	var ap Tva_list
	_ = ap
	ap = va
	Xsqlite3_str_vappendf(tls, p, zFormat, ap)
	_ = ap
}

/*****************************************************************************
** Reference counted string/blob storage
*****************************************************************************/

// C documentation
//
//	/* Finalize a string created using sqlite3_str_new().
//	*/
func Xsqlite3_str_finish(tls *libc.TLS, p uintptr) (r uintptr) {
	var z uintptr
	_ = z
	if p != uintptr(0) && p != uintptr(unsafe.Pointer(&_sqlite3OomStr)) {
		z = _sqlite3StrAccumFinish(tls, p)
		Xsqlite3_free(tls, p)
	} else {
		z = uintptr(0)
	}
	return z
}

// C documentation
//
//	/*
//	** Destroy a dynamically allocate sqlite3_str object and all
//	** of its content, all in one call.
//	*/
func Xsqlite3_str_free(tls *libc.TLS, p uintptr) {
	if p != uintptr(0) && p != uintptr(unsafe.Pointer(&_sqlite3OomStr)) {
		Xsqlite3_str_reset(tls, p)
		Xsqlite3_free(tls, p)
	}
}

// C documentation
//
//	/*
//	** The sqlite3_strglob() interface.  Return 0 on a match (like strcmp()) and
//	** non-zero if there is no match.
//	*/
func Xsqlite3_strglob(tls *libc.TLS, zGlobPattern uintptr, zString uintptr) (r int32) {
	if zString == uintptr(0) {
		return libc.BoolInt32(zGlobPattern != uintptr(0))
	} else {
		if zGlobPattern == uintptr(0) {
			return int32(1)
		} else {
			return _patternCompare(tls, zGlobPattern, zString, uintptr(unsafe.Pointer(&_globInfo)), uint32('['))
		}
	}
	return r
}

// C documentation
//
//	/*
//	** Some systems have stricmp().  Others have strcasecmp().  Because
//	** there is no consistency, we will define our own.
//	**
//	** IMPLEMENTATION-OF: R-30243-02494 The sqlite3_stricmp() and
//	** sqlite3_strnicmp() APIs allow applications and extensions to compare
//	** the contents of two buffers containing UTF-8 strings in a
//	** case-independent fashion, using the same definition of "case
//	** independence" that SQLite uses internally when comparing identifiers.
//	*/
func Xsqlite3_stricmp(tls *libc.TLS, zLeft uintptr, zRight uintptr) (r int32) {
	var v1 int32
	_ = v1
	if zLeft == uintptr(0) {
		if zRight != 0 {
			v1 = -int32(1)
		} else {
			v1 = 0
		}
		return v1
	} else {
		if zRight == uintptr(0) {
			return int32(1)
		}
	}
	return _sqlite3StrICmp(tls, zLeft, zRight)
}

// C documentation
//
//	/*
//	** The sqlite3_strlike() interface.  Return 0 on a match and non-zero for
//	** a miss - like strcmp().
//	*/
func Xsqlite3_strlike(tls *libc.TLS, zPattern uintptr, zStr uintptr, esc uint32) (r int32) {
	if zStr == uintptr(0) {
		return libc.BoolInt32(zPattern != uintptr(0))
	} else {
		if zPattern == uintptr(0) {
			return int32(1)
		} else {
			return _patternCompare(tls, zPattern, zStr, uintptr(unsafe.Pointer(&_likeInfoNorm)), esc)
		}
	}
	return r
}

/*
** Count the number of times that the LIKE operator (or GLOB which is
** just a variation of LIKE) gets called.  This is used for testing
** only.
 */

func Xsqlite3_system_errno(tls *libc.TLS, db uintptr) (r int32) {
	var iRet int32
	_ = iRet
	iRet = 0
	if db != 0 {
		Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
		iRet = (*Tsqlite3)(unsafe.Pointer(db)).FiSysErrno
		Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	}
	return iRet
}

// C documentation
//
//	/*
//	** This is a convenience routine that makes sure that all thread-specific
//	** data for this thread has been deallocated.
//	**
//	** SQLite no longer uses thread-specific data so this routine is now a
//	** no-op.  It is retained for historical compatibility.
//	*/
func Xsqlite3_thread_cleanup(tls *libc.TLS) {
}

// C documentation
//
//	/* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns
//	** zero if and only if SQLite was compiled with mutexing code omitted due to
//	** the SQLITE_THREADSAFE compile-time option being set to 0.
//	*/
func Xsqlite3_threadsafe(tls *libc.TLS) (r int32) {
	return int32(SQLITE_THREADSAFE)
}

func Xsqlite3_total_changes(tls *libc.TLS, db uintptr) (r int32) {
	return int32(Xsqlite3_total_changes64(tls, db))
}

// C documentation
//
//	/*
//	** Return the number of changes since the database handle was opened.
//	*/
func Xsqlite3_total_changes64(tls *libc.TLS, db uintptr) (r Tsqlite3_int64) {
	var iRet Ti64
	_ = iRet
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	iRet = (*Tsqlite3)(unsafe.Pointer(db)).FnTotalChange
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return iRet
}

// C documentation
//
//	/*
//	** Register a callback to be invoked each time a row is updated,
//	** inserted or deleted using this database connection.
//	*/
func Xsqlite3_update_hook(tls *libc.TLS, db uintptr, __ccgo_fp_xCallback uintptr, pArg uintptr) (r uintptr) {
	var pRet uintptr
	_ = pRet
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	pRet = (*Tsqlite3)(unsafe.Pointer(db)).FpUpdateArg
	(*Tsqlite3)(unsafe.Pointer(db)).FxUpdateCallback = __ccgo_fp_xCallback
	(*Tsqlite3)(unsafe.Pointer(db)).FpUpdateArg = pArg
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return pRet
}

// C documentation
//
//	/*
//	** Return a 64-bit integer value for a query parameter.
//	*/
func Xsqlite3_uri_int64(tls *libc.TLS, zFilename uintptr, zParam uintptr, bDflt Tsqlite3_int64) (r Tsqlite3_int64) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var z uintptr
	var _ /* v at bp+0 */ Tsqlite3_int64
	_ = z
	z = Xsqlite3_uri_parameter(tls, zFilename, zParam)
	if z != 0 && _sqlite3DecOrHexToI64(tls, z, bp) == 0 {
		bDflt = **(**Tsqlite3_int64)(__ccgo_up(bp))
	}
	return bDflt
}

// C documentation
//
//	/*
//	** This is a utility routine, useful to VFS implementations, that checks
//	** to see if a database file was a URI that contained a specific query
//	** parameter, and if so obtains the value of the query parameter.
//	**
//	** The zFilename argument is the filename pointer passed into the xOpen()
//	** method of a VFS implementation.  The zParam argument is the name of the
//	** query parameter we seek.  This routine returns the value of the zParam
//	** parameter if it exists.  If the parameter does not exist, this routine
//	** returns a NULL pointer.
//	*/
func Xsqlite3_uri_parameter(tls *libc.TLS, zFilename uintptr, zParam uintptr) (r uintptr) {
	if zFilename == uintptr(0) || zParam == uintptr(0) {
		return uintptr(0)
	}
	zFilename = _databaseName(tls, zFilename)
	return _uriParameter(tls, zFilename, zParam)
}

// C documentation
//
//	/*
//	** Extract the user data from a sqlite3_context structure and return a
//	** pointer to it.
//	*/
func Xsqlite3_user_data(tls *libc.TLS, p uintptr) (r uintptr) {
	return (*TFuncDef)(unsafe.Pointer((*Tsqlite3_context)(unsafe.Pointer(p)).FpFunc)).FpUserData
}

func Xsqlite3_value_bytes(tls *libc.TLS, pVal uintptr) (r int32) {
	return _sqlite3ValueBytes(tls, pVal, uint8(SQLITE_UTF8))
}

func Xsqlite3_value_double(tls *libc.TLS, pVal uintptr) (r float64) {
	return _sqlite3VdbeRealValue(tls, pVal)
}

// C documentation
//
//	/* Destroy an sqlite3_value object previously obtained from
//	** sqlite3_value_dup().
//	*/
func Xsqlite3_value_free(tls *libc.TLS, pOld uintptr) {
	_sqlite3ValueFree(tls, pOld)
}

func Xsqlite3_value_int(tls *libc.TLS, pVal uintptr) (r int32) {
	return int32(_sqlite3VdbeIntValue(tls, pVal))
}

func Xsqlite3_value_int64(tls *libc.TLS, pVal uintptr) (r Tsqlite_int64) {
	return _sqlite3VdbeIntValue(tls, pVal)
}

// C documentation
//
//	/*
//	** Try to convert the type of a function argument or a result column
//	** into a numeric representation.  Use either INTEGER or REAL whichever
//	** is appropriate.  But only do the conversion if it is possible without
//	** loss of information and return the revised type of the argument.
//	*/
func Xsqlite3_value_numeric_type(tls *libc.TLS, pVal uintptr) (r int32) {
	var eType int32
	var pMem uintptr
	_, _ = eType, pMem
	eType = Xsqlite3_value_type(tls, pVal)
	if eType == int32(SQLITE_TEXT) {
		pMem = pVal
		Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer((*TMem)(unsafe.Pointer(pMem)).Fdb)).Fmutex)
		_applyNumericAffinity(tls, pMem, 0)
		Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*TMem)(unsafe.Pointer(pMem)).Fdb)).Fmutex)
		eType = Xsqlite3_value_type(tls, pVal)
	}
	return eType
}

func Xsqlite3_value_text(tls *libc.TLS, pVal uintptr) (r uintptr) {
	return _sqlite3ValueText(tls, pVal, uint8(SQLITE_UTF8))
}

func Xsqlite3_value_text16be(tls *libc.TLS, pVal uintptr) (r uintptr) {
	return _sqlite3ValueText(tls, pVal, uint8(SQLITE_UTF16BE))
}

func Xsqlite3_value_text16le(tls *libc.TLS, pVal uintptr) (r uintptr) {
	return _sqlite3ValueText(tls, pVal, uint8(SQLITE_UTF16LE))
}

// C documentation
//
//	/*
//	** Locate a VFS by name.  If no name is given, simply return the
//	** first VFS on the list.
//	*/
func Xsqlite3_vfs_find(tls *libc.TLS, zVfs uintptr) (r uintptr) {
	var mutex, pVfs uintptr
	var rc int32
	_, _, _ = mutex, pVfs, rc
	pVfs = uintptr(0)
	rc = Xsqlite3_initialize(tls)
	if rc != 0 {
		return uintptr(0)
	}
	mutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN))
	Xsqlite3_mutex_enter(tls, mutex)
	pVfs = _vfsList
	for {
		if !(pVfs != 0) {
			break
		}
		if zVfs == uintptr(0) {
			break
		}
		if libc.Xstrcmp(tls, zVfs, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FzName) == 0 {
			break
		}
		goto _1
	_1:
		;
		pVfs = (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext
	}
	Xsqlite3_mutex_leave(tls, mutex)
	return pVfs
}

// C documentation
//
//	/*
//	** Register a VFS with the system.  It is harmless to register the same
//	** VFS multiple times.  The new VFS becomes the default if makeDflt is
//	** true.
//	*/
func Xsqlite3_vfs_register(tls *libc.TLS, pVfs uintptr, makeDflt int32) (r int32) {
	var mutex uintptr
	var rc int32
	_, _ = mutex, rc
	rc = Xsqlite3_initialize(tls)
	if rc != 0 {
		return rc
	}
	mutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN))
	Xsqlite3_mutex_enter(tls, mutex)
	_vfsUnlink(tls, pVfs)
	if makeDflt != 0 || _vfsList == uintptr(0) {
		(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext = _vfsList
		_vfsList = pVfs
	} else {
		(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext = (*Tsqlite3_vfs)(unsafe.Pointer(_vfsList)).FpNext
		(*Tsqlite3_vfs)(unsafe.Pointer(_vfsList)).FpNext = pVfs
	}
	Xsqlite3_mutex_leave(tls, mutex)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Unregister a VFS so that it is no longer accessible.
//	*/
func Xsqlite3_vfs_unregister(tls *libc.TLS, pVfs uintptr) (r int32) {
	var mutex uintptr
	var rc int32
	_, _ = mutex, rc
	rc = Xsqlite3_initialize(tls)
	if rc != 0 {
		return rc
	}
	mutex = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN))
	Xsqlite3_mutex_enter(tls, mutex)
	_vfsUnlink(tls, pVfs)
	Xsqlite3_mutex_leave(tls, mutex)
	return SQLITE_OK
}

/************** End of os.c **************************************************/
/************** Begin file fault.c *******************************************/
/*
** 2008 Jan 22
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains code to support the concept of "benign"
** malloc failures (when the xMalloc() or xRealloc() method of the
** sqlite3_mem_methods structure fails to allocate a block of memory
** and returns 0).
**
** Most malloc failures are non-benign. After they occur, SQLite
** abandons the current operation and returns an error code (usually
** SQLITE_NOMEM) to the user. However, sometimes a fault is not necessarily
** fatal. For example, if a malloc fails while resizing a hash table, this
** is completely recoverable simply by not carrying out the resize. The
** hash table will continue to function normally.  So a malloc failure
** during a hash table resize is a benign fault.
 */

/* #include "sqliteInt.h" */

// C documentation
//
//	/*
//	** Set the iterator value pVal to point to the first value in the set.
//	** Set (*ppOut) to point to this value before returning.
//	*/
func Xsqlite3_vtab_in_first(tls *libc.TLS, pVal uintptr, ppOut uintptr) (r int32) {
	return _valueFromValueList(tls, pVal, ppOut, 0)
}

// C documentation
//
//	/*
//	** Set the iterator value pVal to point to the next value in the set.
//	** Set (*ppOut) to point to this value before returning.
//	*/
func Xsqlite3_vtab_in_next(tls *libc.TLS, pVal uintptr, ppOut uintptr) (r int32) {
	return _valueFromValueList(tls, pVal, ppOut, int32(1))
}

// C documentation
//
//	/*
//	** If this routine is invoked from within an xColumn method of a virtual
//	** table, then it returns true if and only if the the call is during an
//	** UPDATE operation and the value of the column will not be modified
//	** by the UPDATE.
//	**
//	** If this routine is called from any context other than within the
//	** xColumn method of a virtual table, then the return value is meaningless
//	** and arbitrary.
//	**
//	** Virtual table implements might use this routine to optimize their
//	** performance by substituting a NULL result, or some other light-weight
//	** value, as a signal to the xUpdate routine that the column is unchanged.
//	*/
func Xsqlite3_vtab_nochange(tls *libc.TLS, p uintptr) (r int32) {
	return Xsqlite3_value_nochange(tls, (*Tsqlite3_context)(unsafe.Pointer(p)).FpOut)
}

// C documentation
//
//	/*
//	** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points
//	** to contains a zero-length string, all attached databases are
//	** checkpointed.
//	*/
func Xsqlite3_wal_checkpoint(tls *libc.TLS, db uintptr, zDb uintptr) (r int32) {
	/* EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to
	 ** sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). */
	return Xsqlite3_wal_checkpoint_v2(tls, db, zDb, SQLITE_CHECKPOINT_PASSIVE, uintptr(0), uintptr(0))
}

// C documentation
//
//	/*
//	** Register a callback to be invoked each time a transaction is written
//	** into the write-ahead-log by this database connection.
//	*/
func Xsqlite3_wal_hook(tls *libc.TLS, db uintptr, __ccgo_fp_xCallback uintptr, pArg uintptr) (r uintptr) {
	var pRet uintptr
	_ = pRet
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	pRet = (*Tsqlite3)(unsafe.Pointer(db)).FpWalArg
	(*Tsqlite3)(unsafe.Pointer(db)).FxWalCallback = __ccgo_fp_xCallback
	(*Tsqlite3)(unsafe.Pointer(db)).FpWalArg = pArg
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return pRet
}

// C documentation
//
//	/*
//	** Add the changeset currently stored in buffer pData, size nData bytes,
//	** to changeset-group p.
//	*/
func Xsqlite3changegroup_add(tls *libc.TLS, pGrp uintptr, nData int32, pData uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* pIter at bp+0 */ uintptr
	_ = rc /* Return code */
	rc = Xsqlite3changeset_start(tls, bp, nData, pData)
	if rc == SQLITE_OK {
		rc = _sessionChangesetToHash(tls, **(**uintptr)(__ccgo_up(bp)), pGrp, 0)
	}
	Xsqlite3changeset_finalize(tls, **(**uintptr)(__ccgo_up(bp)))
	return rc
}

// C documentation
//
//	/*
//	** Add a single change to a changeset-group.
//	*/
func Xsqlite3changegroup_add_change(tls *libc.TLS, pGrp uintptr, pIter uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = SQLITE_OK
	if (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FiCurrent == (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FiNext || (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Frc != SQLITE_OK || (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbInvert != 0 {
		/* Iterator does not point to any valid entry or is an INVERT iterator. */
		rc = int32(SQLITE_ERROR)
	} else {
		(*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fin.FbNoDiscard = int32(1)
		rc = _sessionOneChangeIterToHash(tls, pGrp, pIter, 0)
	}
	return rc
}

// C documentation
//
//	/*
//	** Streaming versions of changegroup_add().
//	*/
func Xsqlite3changegroup_add_strm(tls *libc.TLS, pGrp uintptr, __ccgo_fp_xInput uintptr, pIn uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* pIter at bp+0 */ uintptr
	_ = rc /* Return code */
	rc = Xsqlite3changeset_start_strm(tls, bp, __ccgo_fp_xInput, pIn)
	if rc == SQLITE_OK {
		rc = _sessionChangesetToHash(tls, **(**uintptr)(__ccgo_up(bp)), pGrp, 0)
	}
	Xsqlite3changeset_finalize(tls, **(**uintptr)(__ccgo_up(bp)))
	return rc
}

// C documentation
//
//	/*
//	** Configure the change currently under construction with a real value.
//	*/
func Xsqlite3changegroup_change_double(tls *libc.TLS, pGrp uintptr, bNew int32, iCol int32, fVal float64) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc, v1 int32
	var _ /* pBuf at bp+0 */ uintptr
	_, _ = rc, v1
	rc = SQLITE_OK
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
	v1 = _checkChangeParams(tls, pGrp, bNew, iCol, int64(9), bp)
	rc = v1
	if SQLITE_OK != v1 {
		return rc
	}
	**(**Tu8)(__ccgo_up((*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf)) = uint8(SQLITE_FLOAT)
	_sessionPutDouble(tls, (*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf+1, fVal)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Configure the change currently under construction with an integer value.
//	*/
func Xsqlite3changegroup_change_int64(tls *libc.TLS, pGrp uintptr, bNew int32, iCol int32, iVal Tsqlite3_int64) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc, v1 int32
	var _ /* pBuf at bp+0 */ uintptr
	_, _ = rc, v1
	rc = SQLITE_OK
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
	v1 = _checkChangeParams(tls, pGrp, bNew, iCol, int64(9), bp)
	rc = v1
	if SQLITE_OK != v1 {
		return rc
	}
	**(**Tu8)(__ccgo_up((*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf)) = uint8(SQLITE_INTEGER)
	_sessionPutI64(tls, (*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf+1, iVal)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Configure the change currently under construction with a null value.
//	*/
func Xsqlite3changegroup_change_null(tls *libc.TLS, pGrp uintptr, bNew int32, iCol int32) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc, v1 int32
	var _ /* pBuf at bp+0 */ uintptr
	_, _ = rc, v1
	rc = SQLITE_OK
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
	v1 = _checkChangeParams(tls, pGrp, bNew, iCol, int64(1), bp)
	rc = v1
	if SQLITE_OK != v1 {
		return rc
	}
	**(**Tu8)(__ccgo_up((*TSessionBuffer)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FaBuf)) = uint8(SQLITE_NULL)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Configure a changegroup object.
//	*/
func Xsqlite3changegroup_config(tls *libc.TLS, pGrp uintptr, op int32, pArg uintptr) (r int32) {
	var arg, rc int32
	_, _ = arg, rc
	rc = SQLITE_OK
	switch op {
	case int32(SQLITE_CHANGEGROUP_CONFIG_PATCHSET):
		arg = **(**int32)(__ccgo_up(pArg))
		if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FpList == uintptr(0) && arg >= 0 {
			(*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch = libc.BoolInt32(arg > 0)
		}
		**(**int32)(__ccgo_up(pArg)) = (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FbPatch
	default:
		rc = int32(SQLITE_MISUSE)
		break
	}
	return rc
}

// C documentation
//
//	/*
//	** Obtain a buffer containing a changeset representing the concatenation
//	** of all changesets added to the group so far.
//	*/
func Xsqlite3changegroup_output(tls *libc.TLS, pGrp uintptr, pnData uintptr, ppData uintptr) (r int32) {
	return _sessionChangegroupOutput(tls, pGrp, uintptr(0), uintptr(0), pnData, ppData)
}

// C documentation
//
//	/*
//	** Streaming versions of changegroup_output().
//	*/
func Xsqlite3changegroup_output_strm(tls *libc.TLS, pGrp uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr) (r int32) {
	return _sessionChangegroupOutput(tls, pGrp, __ccgo_fp_xOutput, pOut, uintptr(0), uintptr(0))
}

// C documentation
//
//	/*
//	** Apply the changeset passed via pChangeset/nChangeset to the main database
//	** attached to handle "db". Invoke the supplied conflict handler callback
//	** to resolve any conflicts encountered while applying the change.
//	*/
func Xsqlite3changeset_apply(tls *libc.TLS, db uintptr, nChangeset int32, pChangeset uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr) (r int32) {
	return _sessionChangesetApplyV23(tls, db, nChangeset, pChangeset, uintptr(0), uintptr(0), __ccgo_fp_xFilter, uintptr(0), __ccgo_fp_xConflict, pCtx, uintptr(0), uintptr(0), 0)
}

func Xsqlite3changeset_apply_strm(tls *libc.TLS, db uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr) (r int32) {
	return _sessionChangesetApplyV23(tls, db, 0, uintptr(0), __ccgo_fp_xInput, pIn, __ccgo_fp_xFilter, uintptr(0), __ccgo_fp_xConflict, pCtx, uintptr(0), uintptr(0), 0)
}

// C documentation
//
//	/*
//	** Apply the changeset passed via pChangeset/nChangeset to the main
//	** database attached to handle "db".
//	*/
func Xsqlite3changeset_apply_v2(tls *libc.TLS, db uintptr, nChangeset int32, pChangeset uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) (r int32) {
	return _sessionChangesetApplyV23(tls, db, nChangeset, pChangeset, uintptr(0), uintptr(0), __ccgo_fp_xFilter, uintptr(0), __ccgo_fp_xConflict, pCtx, ppRebase, pnRebase, flags)
}

func Xsqlite3changeset_apply_v2_strm(tls *libc.TLS, db uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) (r int32) {
	return _sessionChangesetApplyV23(tls, db, 0, uintptr(0), __ccgo_fp_xInput, pIn, __ccgo_fp_xFilter, uintptr(0), __ccgo_fp_xConflict, pCtx, ppRebase, pnRebase, flags)
}

// C documentation
//
//	/*
//	** Apply the changeset passed via pChangeset/nChangeset to the main
//	** database attached to handle "db".
//	*/
func Xsqlite3changeset_apply_v3(tls *libc.TLS, db uintptr, nChangeset int32, pChangeset uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) (r int32) {
	return _sessionChangesetApplyV23(tls, db, nChangeset, pChangeset, uintptr(0), uintptr(0), uintptr(0), __ccgo_fp_xFilter, __ccgo_fp_xConflict, pCtx, ppRebase, pnRebase, flags)
}

// C documentation
//
//	/*
//	** Apply the changeset passed via xInput/pIn to the main database
//	** attached to handle "db". Invoke the supplied conflict handler callback
//	** to resolve any conflicts encountered while applying the change.
//	*/
func Xsqlite3changeset_apply_v3_strm(tls *libc.TLS, db uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) (r int32) {
	return _sessionChangesetApplyV23(tls, db, 0, uintptr(0), __ccgo_fp_xInput, pIn, uintptr(0), __ccgo_fp_xFilter, __ccgo_fp_xConflict, pCtx, ppRebase, pnRebase, flags)
}

// C documentation
//
//	/*
//	** Combine two changesets together.
//	*/
func Xsqlite3changeset_concat(tls *libc.TLS, nLeft int32, pLeft uintptr, nRight int32, pRight uintptr, pnOut uintptr, ppOut uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* pGrp at bp+0 */ uintptr
	_ = rc
	rc = Xsqlite3changegroup_new(tls, bp)
	if rc == SQLITE_OK {
		rc = Xsqlite3changegroup_add(tls, **(**uintptr)(__ccgo_up(bp)), nLeft, pLeft)
	}
	if rc == SQLITE_OK {
		rc = Xsqlite3changegroup_add(tls, **(**uintptr)(__ccgo_up(bp)), nRight, pRight)
	}
	if rc == SQLITE_OK {
		rc = Xsqlite3changegroup_output(tls, **(**uintptr)(__ccgo_up(bp)), pnOut, ppOut)
	}
	Xsqlite3changegroup_delete(tls, **(**uintptr)(__ccgo_up(bp)))
	return rc
}

// C documentation
//
//	/*
//	** Streaming version of sqlite3changeset_concat().
//	*/
func Xsqlite3changeset_concat_strm(tls *libc.TLS, __ccgo_fp_xInputA uintptr, pInA uintptr, __ccgo_fp_xInputB uintptr, pInB uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* pGrp at bp+0 */ uintptr
	_ = rc
	rc = Xsqlite3changegroup_new(tls, bp)
	if rc == SQLITE_OK {
		rc = Xsqlite3changegroup_add_strm(tls, **(**uintptr)(__ccgo_up(bp)), __ccgo_fp_xInputA, pInA)
	}
	if rc == SQLITE_OK {
		rc = Xsqlite3changegroup_add_strm(tls, **(**uintptr)(__ccgo_up(bp)), __ccgo_fp_xInputB, pInB)
	}
	if rc == SQLITE_OK {
		rc = Xsqlite3changegroup_output_strm(tls, **(**uintptr)(__ccgo_up(bp)), __ccgo_fp_xOutput, pOut)
	}
	Xsqlite3changegroup_delete(tls, **(**uintptr)(__ccgo_up(bp)))
	return rc
}

// C documentation
//
//	/*
//	** This function may only be called with a changeset iterator that has been
//	** passed to an SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT
//	** conflict-handler function. Otherwise, SQLITE_MISUSE is returned.
//	**
//	** If successful, *ppValue is set to point to an sqlite3_value structure
//	** containing the iVal'th value of the conflicting record.
//	**
//	** If value iVal is out-of-range or some other error occurs, an SQLite error
//	** code is returned. Otherwise, SQLITE_OK.
//	*/
func Xsqlite3changeset_conflict(tls *libc.TLS, pIter uintptr, iVal int32, ppValue uintptr) (r int32) {
	if !((*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FpConflict != 0) {
		return int32(SQLITE_MISUSE)
	}
	if iVal < 0 || iVal >= (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol {
		return int32(SQLITE_RANGE)
	}
	**(**uintptr)(__ccgo_up(ppValue)) = Xsqlite3_column_value(tls, (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FpConflict, iVal)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** This function may only be called with an iterator passed to an
//	** SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case
//	** it sets the output variable to the total number of known foreign key
//	** violations in the destination database and returns SQLITE_OK.
//	**
//	** In all other cases this function returns SQLITE_MISUSE.
//	*/
func Xsqlite3changeset_fk_conflicts(tls *libc.TLS, pIter uintptr, pnOut uintptr) (r int32) {
	if (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FpConflict != 0 || (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FapValue != 0 {
		return int32(SQLITE_MISUSE)
	}
	**(**int32)(__ccgo_up(pnOut)) = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Advance an iterator created by sqlite3changeset_start() to the next
//	** change in the changeset. This function may return SQLITE_ROW, SQLITE_DONE
//	** or SQLITE_CORRUPT.
//	**
//	** This function may not be called on iterators passed to a conflict handler
//	** callback by changeset_apply().
//	*/
func Xsqlite3changeset_next(tls *libc.TLS, p uintptr) (r int32) {
	return _sessionChangesetNext(tls, p, uintptr(0), uintptr(0), uintptr(0))
}

// C documentation
//
//	/*
//	** The following function extracts information on the current change
//	** from a changeset iterator. It may only be called after changeset_next()
//	** has returned SQLITE_ROW.
//	*/
func Xsqlite3changeset_op(tls *libc.TLS, pIter uintptr, pzTab uintptr, pnCol uintptr, pOp uintptr, pbIndirect uintptr) (r int32) {
	**(**int32)(__ccgo_up(pOp)) = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).Fop
	**(**int32)(__ccgo_up(pnCol)) = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol
	**(**uintptr)(__ccgo_up(pzTab)) = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FzTab
	if pbIndirect != 0 {
		**(**int32)(__ccgo_up(pbIndirect)) = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FbIndirect
	}
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Return information regarding the PRIMARY KEY and number of columns in
//	** the database table affected by the change that pIter currently points
//	** to. This function may only be called after changeset_next() returns
//	** SQLITE_ROW.
//	*/
func Xsqlite3changeset_pk(tls *libc.TLS, pIter uintptr, pabPK uintptr, pnCol uintptr) (r int32) {
	**(**uintptr)(__ccgo_up(pabPK)) = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FabPK
	if pnCol != 0 {
		**(**int32)(__ccgo_up(pnCol)) = (*Tsqlite3_changeset_iter)(unsafe.Pointer(pIter)).FnCol
	}
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Create an iterator used to iterate through the contents of a changeset.
//	*/
func Xsqlite3changeset_start(tls *libc.TLS, pp uintptr, nChangeset int32, pChangeset uintptr) (r int32) {
	return _sessionChangesetStart(tls, pp, uintptr(0), uintptr(0), nChangeset, pChangeset, 0, 0)
}

// C documentation
//
//	/*
//	** Streaming version of sqlite3changeset_start().
//	*/
func Xsqlite3changeset_start_strm(tls *libc.TLS, pp uintptr, __ccgo_fp_xInput uintptr, pIn uintptr) (r int32) {
	return _sessionChangesetStart(tls, pp, __ccgo_fp_xInput, pIn, 0, uintptr(0), 0, 0)
}

func Xsqlite3changeset_start_v2(tls *libc.TLS, pp uintptr, nChangeset int32, pChangeset uintptr, flags int32) (r int32) {
	var bInvert int32
	_ = bInvert
	bInvert = libc.BoolInt32(!!(flags&libc.Int32FromInt32(SQLITE_CHANGESETSTART_INVERT) != 0))
	return _sessionChangesetStart(tls, pp, uintptr(0), uintptr(0), nChangeset, pChangeset, bInvert, 0)
}

func Xsqlite3changeset_start_v2_strm(tls *libc.TLS, pp uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, flags int32) (r int32) {
	var bInvert int32
	_ = bInvert
	bInvert = libc.BoolInt32(!!(flags&libc.Int32FromInt32(SQLITE_CHANGESETSTART_INVERT) != 0))
	return _sessionChangesetStart(tls, pp, __ccgo_fp_xInput, pIn, 0, uintptr(0), bInvert, 0)
}

// C documentation
//
//	/*
//	** Return permyriadage progress indications for the two main stages of
//	** an RBU update.
//	*/
func Xsqlite3rbu_bp_progress(tls *libc.TLS, p uintptr, pnOne uintptr, pnTwo uintptr) {
	var MAX_PROGRESS int32
	_ = MAX_PROGRESS
	MAX_PROGRESS = int32(10000)
	switch (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage {
	case int32(RBU_STAGE_OAL):
		if (*Tsqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep > 0 {
			**(**int32)(__ccgo_up(pnOne)) = int32(int64(MAX_PROGRESS) * (*Tsqlite3rbu)(unsafe.Pointer(p)).FnProgress / (*Tsqlite3rbu)(unsafe.Pointer(p)).FnPhaseOneStep)
		} else {
			**(**int32)(__ccgo_up(pnOne)) = -int32(1)
		}
		**(**int32)(__ccgo_up(pnTwo)) = 0
	case int32(RBU_STAGE_MOVE):
		**(**int32)(__ccgo_up(pnOne)) = MAX_PROGRESS
		**(**int32)(__ccgo_up(pnTwo)) = 0
	case int32(RBU_STAGE_CKPT):
		**(**int32)(__ccgo_up(pnOne)) = MAX_PROGRESS
		**(**int32)(__ccgo_up(pnTwo)) = int32(int64(MAX_PROGRESS) * int64((*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep) / int64((*Tsqlite3rbu)(unsafe.Pointer(p)).FnFrame))
	case int32(RBU_STAGE_DONE):
		**(**int32)(__ccgo_up(pnOne)) = MAX_PROGRESS
		**(**int32)(__ccgo_up(pnTwo)) = MAX_PROGRESS
	default:
	}
}

// C documentation
//
//	/*
//	** Return the database handle used by pRbu.
//	*/
func Xsqlite3rbu_db(tls *libc.TLS, pRbu uintptr, bRbu int32) (r uintptr) {
	var db, v1 uintptr
	_, _ = db, v1
	db = uintptr(0)
	if pRbu != 0 {
		if bRbu != 0 {
			v1 = (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FdbRbu
		} else {
			v1 = (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FdbMain
		}
		db = v1
	}
	return db
}

// C documentation
//
//	/*
//	** Deregister and destroy an RBU vfs created by an earlier call to
//	** sqlite3rbu_create_vfs().
//	*/
func Xsqlite3rbu_destroy_vfs(tls *libc.TLS, zName uintptr) {
	var pVfs uintptr
	_ = pVfs
	pVfs = Xsqlite3_vfs_find(tls, zName)
	if pVfs != 0 && (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxOpen == __ccgo_fp(_rbuVfsOpen) {
		Xsqlite3_mutex_free(tls, (*Trbu_vfs)(unsafe.Pointer(pVfs)).Fmutex)
		Xsqlite3_vfs_unregister(tls, pVfs)
		Xsqlite3_free(tls, pVfs)
	}
}

// C documentation
//
//	/*
//	** Open and return a new RBU handle.
//	*/
func Xsqlite3rbu_open(tls *libc.TLS, zTarget uintptr, zRbu uintptr, zState uintptr) (r uintptr) {
	if zTarget == uintptr(0) || zRbu == uintptr(0) {
		return _rbuMisuseError(tls)
	}
	return _openRbuHandle(tls, zTarget, zRbu, zState)
}

// C documentation
//
//	/*
//	** Return the total number of key-value operations (inserts, deletes or
//	** updates) that have been performed on the target database since the
//	** current RBU update was started.
//	*/
func Xsqlite3rbu_progress(tls *libc.TLS, pRbu uintptr) (r Tsqlite3_int64) {
	return (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FnProgress
}

func Xsqlite3rbu_rename_handler(tls *libc.TLS, pRbu uintptr, pArg uintptr, __ccgo_fp_xRename uintptr) {
	if __ccgo_fp_xRename != 0 {
		(*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FxRename = __ccgo_fp_xRename
		(*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FpRenameArg = pArg
	} else {
		(*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FxRename = __ccgo_fp(_xDefaultRename)
		(*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FpRenameArg = uintptr(0)
	}
}

/**************************************************************************
** Beginning of RBU VFS shim methods. The VFS shim modifies the behaviour
** of a standard VFS in the following ways:
**
** 1. Whenever the first page of a main database file is read or
**    written, the value of the change-counter cookie is stored in
**    rbu_file.iCookie. Similarly, the value of the "write-version"
**    database header field is stored in rbu_file.iWriteVer. This ensures
**    that the values are always trustworthy within an open transaction.
**
** 2. Whenever an SQLITE_OPEN_WAL file is opened, the (rbu_file.pWalFd)
**    member variable of the associated database file descriptor is set
**    to point to the new file. A mutex protected linked list of all main
**    db fds opened using a particular RBU VFS is maintained at
**    rbu_vfs.pMain to facilitate this.
**
** 3. Using a new file-control "SQLITE_FCNTL_RBU", a main db rbu_file
**    object can be marked as the target database of an RBU update. This
**    turns on the following extra special behaviour:
**
** 3a. If xAccess() is called to check if there exists a *-wal file
**     associated with an RBU target database currently in RBU_STAGE_OAL
**     stage (preparing the *-oal file), the following special handling
**     applies:
**
**      * if the *-wal file does exist, return SQLITE_CANTOPEN. An RBU
**        target database may not be in wal mode already.
**
**      * if the *-wal file does not exist, set the output parameter to
**        non-zero (to tell SQLite that it does exist) anyway.
**
**     Then, when xOpen() is called to open the *-wal file associated with
**     the RBU target in RBU_STAGE_OAL stage, instead of opening the *-wal
**     file, the rbu vfs opens the corresponding *-oal file instead.
**
** 3b. The *-shm pages returned by xShmMap() for a target db file in
**     RBU_STAGE_OAL mode are actually stored in heap memory. This is to
**     avoid creating a *-shm file on disk. Additionally, xShmLock() calls
**     are no-ops on target database files in RBU_STAGE_OAL mode. This is
**     because assert() statements in some VFS implementations fail if
**     xShmLock() is called before xShmMap().
**
** 3c. If an EXCLUSIVE lock is attempted on a target database file in any
**     mode except RBU_STAGE_DONE (all work completed and checkpointed), it
**     fails with an SQLITE_BUSY error. This is to stop RBU connections
**     from automatically checkpointing a *-wal (or *-oal) file from within
**     sqlite3_close().
**
** 3d. In RBU_STAGE_CAPTURE mode, all xRead() calls on the wal file, and
**     all xWrite() calls on the target database file perform no IO.
**     Instead the frame and page numbers that would be read and written
**     are recorded. Additionally, successful attempts to obtain exclusive
**     xShmLock() WRITER, CHECKPOINTER and READ0 locks on the target
**     database file are recorded. xShmLock() calls to unlock the same
**     locks are no-ops (so that once obtained, these locks are never
**     relinquished). Finally, calls to xSync() on the target database
**     file fail with SQLITE_NOTICE errors.
 */

// C documentation
//
//	/*
//	** Return the current state of the RBU vacuum or update operation.
//	*/
func Xsqlite3rbu_state(tls *libc.TLS, p uintptr) (r int32) {
	var aRes [6]int32
	_ = aRes
	aRes = [6]int32{
		1: int32(SQLITE_RBU_STATE_OAL),
		2: int32(SQLITE_RBU_STATE_MOVE),
		4: int32(SQLITE_RBU_STATE_CHECKPOINT),
		5: int32(SQLITE_RBU_STATE_DONE),
	}
	if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != int32(SQLITE_DONE) {
		return int32(SQLITE_RBU_STATE_ERROR)
	} else {
		return aRes[(*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage]
	}
	return r
}

func Xsqlite3rbu_temp_size(tls *libc.TLS, pRbu uintptr) (r Tsqlite3_int64) {
	return (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FszTemp
}

/**************************************************************************/

/************** End of sqlite3rbu.c ******************************************/
/************** Begin file dbstat.c ******************************************/
/*
** 2010 July 12
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file contains an implementation of the "dbstat" virtual table.
**
** The dbstat virtual table is used to extract low-level storage
** information from an SQLite database in order to implement the
** "sqlite3_analyzer" utility.  See the ../tool/spaceanal.tcl script
** for an example implementation.
**
** Additional information is available on the "dbstat.html" page of the
** official SQLite documentation.
 */

/* #include "sqliteInt.h"   ** Requires access to internal data structures ** */

/*
** The pager and btree modules arrange objects in memory so that there are
** always approximately 200 bytes of addressable memory following each page
** buffer. This way small buffer overreads caused by corrupt database pages
** do not cause undefined behaviour. This module pads each page buffer
** by the following number of bytes for the same purpose.
 */

// C documentation
//
//	/*
//	** Configure the aggregate temp file size limit for this RBU handle.
//	*/
func Xsqlite3rbu_temp_size_limit(tls *libc.TLS, pRbu uintptr, n Tsqlite3_int64) (r Tsqlite3_int64) {
	if n >= 0 {
		(*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FszTempLimit = n
	}
	return (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FszTempLimit
}

// C documentation
//
//	/*
//	** Call this one or more times to configure a rebaser.
//	*/
func Xsqlite3rebaser_configure(tls *libc.TLS, p uintptr, nRebase int32, pRebase uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* pIter at bp+0 */ uintptr
	_ = rc
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Return code */
	rc = Xsqlite3changeset_start(tls, bp, nRebase, pRebase)
	if rc == SQLITE_OK {
		rc = _sessionChangesetToHash(tls, **(**uintptr)(__ccgo_up(bp)), p, int32(1))
	}
	Xsqlite3changeset_finalize(tls, **(**uintptr)(__ccgo_up(bp)))
	return rc
}

// C documentation
//
//	/*
//	** Destroy a rebaser object
//	*/
func Xsqlite3rebaser_delete(tls *libc.TLS, p uintptr) {
	if p != 0 {
		_sessionDeleteTable(tls, uintptr(0), (*Tsqlite3_rebaser)(unsafe.Pointer(p)).Fgrp.FpList)
		Xsqlite3_free(tls, (*Tsqlite3_rebaser)(unsafe.Pointer(p)).Fgrp.Frec.FaBuf)
		Xsqlite3_free(tls, p)
	}
}

// C documentation
//
//	/*
//	** Rebase a changeset according to current rebaser configuration
//	*/
func Xsqlite3rebaser_rebase(tls *libc.TLS, p uintptr, nIn int32, pIn uintptr, pnOut uintptr, ppOut uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* pIter at bp+0 */ uintptr
	_ = rc
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Iterator to skip through input */
	rc = Xsqlite3changeset_start(tls, bp, nIn, pIn)
	if rc == SQLITE_OK {
		rc = _sessionRebase(tls, p, **(**uintptr)(__ccgo_up(bp)), uintptr(0), uintptr(0), pnOut, ppOut)
		Xsqlite3changeset_finalize(tls, **(**uintptr)(__ccgo_up(bp)))
	}
	return rc
}

// C documentation
//
//	/*
//	** Rebase a changeset according to current rebaser configuration
//	*/
func Xsqlite3rebaser_rebase_strm(tls *libc.TLS, p uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* pIter at bp+0 */ uintptr
	_ = rc
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0) /* Iterator to skip through input */
	rc = Xsqlite3changeset_start_strm(tls, bp, __ccgo_fp_xInput, pIn)
	if rc == SQLITE_OK {
		rc = _sessionRebase(tls, p, **(**uintptr)(__ccgo_up(bp)), __ccgo_fp_xOutput, pOut, uintptr(0), uintptr(0))
		Xsqlite3changeset_finalize(tls, **(**uintptr)(__ccgo_up(bp)))
	}
	return rc
}

// C documentation
//
//	/*
//	** Obtain a changeset object containing all changes recorded by the
//	** session object passed as the first argument.
//	**
//	** It is the responsibility of the caller to eventually free the buffer
//	** using sqlite3_free().
//	*/
func Xsqlite3session_changeset(tls *libc.TLS, pSession uintptr, pnChangeset uintptr, ppChangeset uintptr) (r int32) {
	var rc int32
	_ = rc
	if pnChangeset == uintptr(0) || ppChangeset == uintptr(0) {
		return int32(SQLITE_MISUSE)
	}
	rc = _sessionGenerateChangeset(tls, pSession, 0, uintptr(0), uintptr(0), pnChangeset, ppChangeset)
	return rc
}

// C documentation
//
//	/*
//	** Return the maximum size of sqlite3session_changeset() output.
//	*/
func Xsqlite3session_changeset_size(tls *libc.TLS, pSession uintptr) (r Tsqlite3_int64) {
	return (*Tsqlite3_session)(unsafe.Pointer(pSession)).FnMaxChangesetSize
}

// C documentation
//
//	/*
//	** Streaming version of sqlite3session_changeset().
//	*/
func Xsqlite3session_changeset_strm(tls *libc.TLS, pSession uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr) (r int32) {
	if __ccgo_fp_xOutput == uintptr(0) {
		return int32(SQLITE_MISUSE)
	}
	return _sessionGenerateChangeset(tls, pSession, 0, __ccgo_fp_xOutput, pOut, uintptr(0), uintptr(0))
}

// C documentation
//
//	/*
//	** Global configuration
//	*/
func Xsqlite3session_config(tls *libc.TLS, op int32, pArg uintptr) (r int32) {
	var pInt uintptr
	var rc int32
	_, _ = pInt, rc
	rc = SQLITE_OK
	switch op {
	case int32(SQLITE_SESSION_CONFIG_STRMSIZE):
		pInt = pArg
		if **(**int32)(__ccgo_up(pInt)) > 0 {
			_sessions_strm_chunk_size = **(**int32)(__ccgo_up(pInt))
		}
		**(**int32)(__ccgo_up(pInt)) = _sessions_strm_chunk_size
	default:
		rc = int32(SQLITE_MISUSE)
		break
	}
	return rc
}

// C documentation
//
//	/*
//	** Enable or disable the session object passed as the first argument.
//	*/
func Xsqlite3session_enable(tls *libc.TLS, pSession uintptr, bEnable int32) (r int32) {
	var ret int32
	_ = ret
	Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb))
	if bEnable >= 0 {
		(*Tsqlite3_session)(unsafe.Pointer(pSession)).FbEnable = bEnable
	}
	ret = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbEnable
	Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb))
	return ret
}

// C documentation
//
//	/*
//	** Enable or disable the session object passed as the first argument.
//	*/
func Xsqlite3session_indirect(tls *libc.TLS, pSession uintptr, bIndirect int32) (r int32) {
	var ret int32
	_ = ret
	Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb))
	if bIndirect >= 0 {
		(*Tsqlite3_session)(unsafe.Pointer(pSession)).FbIndirect = bIndirect
	}
	ret = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbIndirect
	Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb))
	return ret
}

// C documentation
//
//	/*
//	** Return true if there have been no changes to monitored tables recorded
//	** by the session object passed as the only argument.
//	*/
func Xsqlite3session_isempty(tls *libc.TLS, pSession uintptr) (r int32) {
	var pTab uintptr
	var ret int32
	_, _ = pTab, ret
	ret = 0
	Xsqlite3_mutex_enter(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb))
	pTab = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpTable
	for {
		if !(pTab != 0 && ret == 0) {
			break
		}
		ret = libc.BoolInt32((*TSessionTable)(unsafe.Pointer(pTab)).FnEntry > 0)
		goto _1
	_1:
		;
		pTab = (*TSessionTable)(unsafe.Pointer(pTab)).FpNext
	}
	Xsqlite3_mutex_leave(tls, Xsqlite3_db_mutex(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb))
	return libc.BoolInt32(ret == 0)
}

// C documentation
//
//	/*
//	** Return the amount of heap memory in use.
//	*/
func Xsqlite3session_memory_used(tls *libc.TLS, pSession uintptr) (r Tsqlite3_int64) {
	return (*Tsqlite3_session)(unsafe.Pointer(pSession)).FnMalloc
}

// C documentation
//
//	/*
//	** Configure the session object passed as the first argument.
//	*/
func Xsqlite3session_object_config(tls *libc.TLS, pSession uintptr, op int32, pArg uintptr) (r int32) {
	var iArg, iArg1, rc int32
	_, _, _ = iArg, iArg1, rc
	rc = SQLITE_OK
	switch op {
	case int32(SQLITE_SESSION_OBJCONFIG_SIZE):
		iArg = **(**int32)(__ccgo_up(pArg))
		if iArg >= 0 {
			if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpTable != 0 {
				rc = int32(SQLITE_MISUSE)
			} else {
				(*Tsqlite3_session)(unsafe.Pointer(pSession)).FbEnableSize = libc.BoolInt32(iArg != 0)
			}
		}
		**(**int32)(__ccgo_up(pArg)) = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbEnableSize
	case int32(SQLITE_SESSION_OBJCONFIG_ROWID):
		iArg1 = **(**int32)(__ccgo_up(pArg))
		if iArg1 >= 0 {
			if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpTable != 0 {
				rc = int32(SQLITE_MISUSE)
			} else {
				(*Tsqlite3_session)(unsafe.Pointer(pSession)).FbImplicitPK = libc.BoolInt32(iArg1 != 0)
			}
		}
		**(**int32)(__ccgo_up(pArg)) = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbImplicitPK
	default:
		rc = int32(SQLITE_MISUSE)
	}
	return rc
}

// C documentation
//
//	/*
//	** Obtain a patchset object containing all changes recorded by the
//	** session object passed as the first argument.
//	**
//	** It is the responsibility of the caller to eventually free the buffer
//	** using sqlite3_free().
//	*/
func Xsqlite3session_patchset(tls *libc.TLS, pSession uintptr, pnPatchset uintptr, ppPatchset uintptr) (r int32) {
	if pnPatchset == uintptr(0) || ppPatchset == uintptr(0) {
		return int32(SQLITE_MISUSE)
	}
	return _sessionGenerateChangeset(tls, pSession, int32(1), uintptr(0), uintptr(0), pnPatchset, ppPatchset)
}

// C documentation
//
//	/*
//	** Streaming version of sqlite3session_patchset().
//	*/
func Xsqlite3session_patchset_strm(tls *libc.TLS, pSession uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr) (r int32) {
	if __ccgo_fp_xOutput == uintptr(0) {
		return int32(SQLITE_MISUSE)
	}
	return _sessionGenerateChangeset(tls, pSession, int32(1), __ccgo_fp_xOutput, pOut, uintptr(0), uintptr(0))
}

// C documentation
//
//	/*
//	** Set a table filter on a Session Object.
//	*/
func Xsqlite3session_table_filter(tls *libc.TLS, pSession uintptr, __ccgo_fp_xFilter uintptr, pCtx uintptr) {
	(*Tsqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach = int32(1)
	(*Tsqlite3_session)(unsafe.Pointer(pSession)).FpFilterCtx = pCtx
	(*Tsqlite3_session)(unsafe.Pointer(pSession)).FxTableFilter = __ccgo_fp_xFilter
}

const YYGROWABLESTACK = 1

const YYMALLOCARGTYPE = 0

type YYMINORTYPE = TYYMINORTYPE

/************* End control #defines *******************************************/

/* Define the yytestcase() macro to be a no-op if is not already defined
** otherwise.
**
** Applications can choose to define yytestcase() in the %include section
** to a macro that can assist in verifying code coverage.  For production
** code the yytestcase() macro should be turned off.  But it is useful
** for testing.
 */

/* Macro to determine if stack space has the ability to grow using
** heap memory.
 */

/* Guarantee a minimum number of initial stack slots.
 */

const YYNOCODE = 322

const YYNOERRORRECOVERY = 1

const YYNRULE = 412

const YYNRULE_WITH_ACTION = 348

const YYNSTATE = 600

const YYNTOKEN = 187

const YYPARSEFREENEVERNULL = 1

const YYSTACKDEPTH = 50

const YYWILDCARD = 102

const YY_ACCEPT_ACTION = 1280

const YY_ACTTAB_COUNT = 2379

const YY_ERROR_ACTION = 1279

const YY_MAX_DSTRCTR = 319

const YY_MAX_REDUCE = 1693

const YY_MAX_SHIFT = 599

const YY_MAX_SHIFTREDUCE = 1278

const YY_MIN_DSTRCTR = 206

const YY_MIN_REDUCE = 1282

const YY_MIN_SHIFTREDUCE = 867

const YY_NO_ACTION = 1281

const YY_REDUCE_COUNT = 423

const YY_REDUCE_MAX = 1825

const YY_REDUCE_MIN = -303

const YY_SHIFT_COUNT = 599

const YY_SHIFT_MAX = 2215

const YY_SHIFT_MIN = 0

// C documentation
//
//	/*
//	** A cell with the same content as pCell has just been inserted into
//	** the node pNode. This function updates the bounding box cells in
//	** all ancestor elements.
//	*/
func _AdjustTree(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr) (r int32) {
	bp := tls.Alloc(64)
	defer tls.Free(64)
	var cnt, rc int32
	var p, pParent uintptr
	var _ /* cell at bp+0 */ TRtreeCell
	var _ /* iCell at bp+48 */ int32
	_, _, _, _ = cnt, p, pParent, rc
	p = pNode
	cnt = 0
	for (*TRtreeNode)(unsafe.Pointer(p)).FpParent != 0 {
		pParent = (*TRtreeNode)(unsafe.Pointer(p)).FpParent
		cnt = cnt + 1
		if cnt > int32(100) {
			return libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<<libc.Int32FromInt32(8)
		}
		rc = _nodeParentIndex(tls, pRtree, p, bp+48)
		if rc != SQLITE_OK {
			return libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<<libc.Int32FromInt32(8)
		}
		_nodeGetCell(tls, pRtree, pParent, **(**int32)(__ccgo_up(bp + 48)), bp)
		if !(_cellContains(tls, pRtree, bp, pCell) != 0) {
			_cellUnion(tls, pRtree, bp, pCell)
			_nodeOverwriteCell(tls, pRtree, pParent, bp, **(**int32)(__ccgo_up(bp + 48)))
		}
		p = pParent
	}
	return SQLITE_OK
}

const _FILE_OFFSET_BITS = 64

const _IOFBF = 0

const _LARGEFILE64_SOURCE = 1

const _LARGEFILE_SOURCE = 1

const _LARGE_FILE = 1

// C documentation
//
//	/*
//	** Table of methods for MemJournal sqlite3_file object.
//	*/
var _MemJournalMethods = Tsqlite3_io_methods{
	FiVersion: int32(1),
}

const __ATOMIC_ACQUIRE = 2

const __ATOMIC_ACQ_REL = 4

const __ATOMIC_CONSUME = 1

const __ATOMIC_RELAXED = 0

const __ATOMIC_RELEASE = 3

const __ATOMIC_SEQ_CST = 5

const __CCGO__ = 1

const __CHAR_BIT__ = 8

const __DBL_DECIMAL_DIG__ = 17

const __DBL_DIG__ = 15

const __DBL_HAS_DENORM__ = 1

const __DBL_HAS_INFINITY__ = 1

const __DBL_HAS_QUIET_NAN__ = 1

const __DBL_MANT_DIG__ = 53

const __DBL_MAX_10_EXP__ = 308

const __DBL_MAX_EXP__ = 1024

const __DBL_MIN_10_EXP__ = -307

const __DBL_MIN_EXP__ = -1021

const __FINITE_MATH_ONLY__ = 0

const __FLT_DECIMAL_DIG__ = 9

const __FLT_DENORM_MIN__ = 0

const __FLT_DIG__ = 6

const __FLT_EPSILON__ = 0

const __FLT_HAS_DENORM__ = 1

const __FLT_HAS_INFINITY__ = 1

const __FLT_HAS_QUIET_NAN__ = 1

const __FLT_MANT_DIG__ = 24

const __FLT_MAX_10_EXP__ = 38

const __FLT_MAX_EXP__ = 128

const __FLT_MAX__ = 0

const __FLT_MIN_10_EXP__ = -37

const __FLT_MIN_EXP__ = -125

const __FLT_NORM_MAX__ = 0

const __FLT_RADIX__ = 2

const __FUNCTION__ = 0

const __GCC_ATOMIC_CHAR32_T_LOCK_FREE = 2

const __GCC_ATOMIC_INT_LOCK_FREE = 2

const __GCC_ATOMIC_LONG_LOCK_FREE = 2

const __GCC_ATOMIC_POINTER_LOCK_FREE = 2

const __GCC_ATOMIC_TEST_AND_SET_TRUEVAL = 1

const __GCC_ATOMIC_WCHAR_T_LOCK_FREE = 2

const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 = 1

const __GNUC_STDC_INLINE__ = 1

const __INT16_MAX__ = 32767

const __INT32_MAX__ = 2147483647

const __INT32_TYPE__ = 0

const __INT64_MAX__ = 9223372036854775807

const __INT8_MAX__ = 127

const __INTMAX_MAX__ = 9223372036854775807

const __INTMAX_WIDTH__ = 64

const __INT_FAST64_MAX__ = 9223372036854775807

const __INT_FAST64_WIDTH__ = 64

const __INT_LEAST16_MAX__ = 32767

const __INT_LEAST16_WIDTH__ = 16

const __INT_LEAST32_MAX__ = 2147483647

const __INT_LEAST32_TYPE__ = 0

const __INT_LEAST32_WIDTH__ = 32

const __INT_LEAST64_MAX__ = 9223372036854775807

const __INT_LEAST64_WIDTH__ = 64

const __INT_LEAST8_MAX__ = 127

const __INT_LEAST8_WIDTH__ = 8

const __INT_MAX__ = 2147483647

const __INT_WIDTH__ = 32

const __LDBL_DENORM_MIN__ = 0

const __LDBL_EPSILON__ = 0

const __LDBL_HAS_DENORM__ = 1

const __LDBL_HAS_INFINITY__ = 1

const __LDBL_HAS_QUIET_NAN__ = 1

const __LDBL_MAX__ = 0

const __LDBL_NORM_MAX__ = 0

const __LONG_LONG_MAX__ = 9223372036854775807

const __NO_INLINE__ = 1

const __ORDER_BIG_ENDIAN__ = 4321

const __ORDER_LITTLE_ENDIAN__ = 1234

const __ORDER_PDP_ENDIAN__ = 3412

const __PRAGMA_REDEFINE_EXTNAME = 1

const __PRETTY_FUNCTION__ = 0

const __SCHAR_MAX__ = 127

const __SHRT_MAX__ = 32767

const __SHRT_WIDTH__ = 16

const __SIG_ATOMIC_MAX__ = 2147483647

const __SIG_ATOMIC_WIDTH__ = 32

const __SIZEOF_DOUBLE__ = 8

const __SIZEOF_FLOAT__ = 4

const __SIZEOF_INT__ = 4

const __SIZEOF_LONG_DOUBLE__ = 8

const __SIZEOF_LONG_LONG__ = 8

const __SIZEOF_SHORT__ = 2

const __SQLITESESSION_H_ = 1

const __STDC_HOSTED__ = 1

const __STDC_UTF_16__ = 1

const __STDC_UTF_32__ = 1

const __STDC_VERSION__ = 201710

const __STDC__ = 1

const __UINT16_MAX__ = 65535

const __UINT32_MAX__ = 4294967295

const __UINT64_MAX__ = 18446744073709551615

const __UINT8_MAX__ = 255

const __UINTMAX_MAX__ = 18446744073709551615

const __UINT_FAST64_MAX__ = 18446744073709551615

const __UINT_LEAST16_MAX__ = 65535

const __UINT_LEAST32_MAX__ = 4294967295

const __UINT_LEAST64_MAX__ = 18446744073709551615

const __UINT_LEAST8_MAX__ = 255

func __ccgo_fp(f interface{}) uintptr {
	type iface [2]uintptr
	return (*iface)(unsafe.Pointer(&f))[1]
}

var __ccgo_ts = (*reflect.StringHeader)(unsafe.Pointer(&__ccgo_ts1)).Data

func __ccgo_up(n uintptr) unsafe.Pointer {
	return unsafe.Pointer(&n)
}

var _a = [8]TLogEst{
	1: int16(2),
	2: int16(3),
	3: int16(5),
	4: int16(6),
	5: int16(7),
	6: int16(8),
	7: int16(9),
}

// C documentation
//
//	/*
//	** For tokenizers with no "unicode" modifier, the set of token characters
//	** is the same as the set of ASCII range alphanumeric characters.
//	*/
var _aAsciiTokenChar = [128]uint8{
	48:  uint8(1),
	49:  uint8(1),
	50:  uint8(1),
	51:  uint8(1),
	52:  uint8(1),
	53:  uint8(1),
	54:  uint8(1),
	55:  uint8(1),
	56:  uint8(1),
	57:  uint8(1),
	65:  uint8(1),
	66:  uint8(1),
	67:  uint8(1),
	68:  uint8(1),
	69:  uint8(1),
	70:  uint8(1),
	71:  uint8(1),
	72:  uint8(1),
	73:  uint8(1),
	74:  uint8(1),
	75:  uint8(1),
	76:  uint8(1),
	77:  uint8(1),
	78:  uint8(1),
	79:  uint8(1),
	80:  uint8(1),
	81:  uint8(1),
	82:  uint8(1),
	83:  uint8(1),
	84:  uint8(1),
	85:  uint8(1),
	86:  uint8(1),
	87:  uint8(1),
	88:  uint8(1),
	89:  uint8(1),
	90:  uint8(1),
	97:  uint8(1),
	98:  uint8(1),
	99:  uint8(1),
	100: uint8(1),
	101: uint8(1),
	102: uint8(1),
	103: uint8(1),
	104: uint8(1),
	105: uint8(1),
	106: uint8(1),
	107: uint8(1),
	108: uint8(1),
	109: uint8(1),
	110: uint8(1),
	111: uint8(1),
	112: uint8(1),
	113: uint8(1),
	114: uint8(1),
	115: uint8(1),
	116: uint8(1),
	117: uint8(1),
	118: uint8(1),
	119: uint8(1),
	120: uint8(1),
	121: uint8(1),
	122: uint8(1),
}

var _aCode = [4]Tu8{
	0: uint8(SQLITE_CREATE_TABLE),
	1: uint8(SQLITE_CREATE_TEMP_TABLE),
	2: uint8(SQLITE_CREATE_VIEW),
	3: uint8(SQLITE_CREATE_TEMP_VIEW),
}

/* This array determines which meta meta values are preserved in the
 ** vacuum.  Even entries are the meta value number and odd entries
 ** are an increment to apply to the meta value after the vacuum.
 ** The increment is used to increase the schema cookie so that other
 ** connections to the same database will know to reread the schema.
 */
var _aCopy = [10]uint8{
	0: uint8(BTREE_SCHEMA_VERSION),
	1: uint8(1),
	2: uint8(BTREE_DEFAULT_CACHE_SIZE),
	4: uint8(BTREE_TEXT_ENCODING),
	6: uint8(BTREE_USER_VERSION),
	8: uint8(BTREE_APPLICATION_ID),
}

var _aEditType = [3]Tu8{
	0: uint8(JEDIT_INS),
	1: uint8(JEDIT_SET),
	2: uint8(JEDIT_AINS),
}

var _aEnc = [3]Tu8{
	0: uint8(SQLITE_UTF16BE),
	1: uint8(SQLITE_UTF16LE),
	2: uint8(SQLITE_UTF8),
}

var _aEndOp = [4]Tu8{
	0: uint8(OP_IdxGE),
	1: uint8(OP_IdxGT),
	2: uint8(OP_IdxLE),
	3: uint8(OP_IdxLT),
}

/* Each entry in the following array defines a rule for folding a range
 ** of codepoints to lower case. The rule applies to a range of nRange
 ** codepoints starting at codepoint iCode.
 **
 ** If the least significant bit in flags is clear, then the rule applies
 ** to all nRange codepoints (i.e. all nRange codepoints are upper case and
 ** need to be folded). Or, if it is set, then the rule only applies to
 ** every second codepoint in the range, starting with codepoint C.
 **
 ** The 7 most significant bits in flags are an index into the aiOff[]
 ** array. If a specific codepoint C does require folding, then its lower
 ** case equivalent is ((C + aiOff[flags>>1]) & 0xFFFF).
 **
 ** The contents of this array are generated by parsing the CaseFolding.txt
 ** file distributed as part of the "Unicode Character Database". See
 ** http://www.unicode.org for details.
 */
var _aEntry = [163]struct {
	FiCode  uint16
	Fflags  uint8
	FnRange uint8
}{
	0: {
		FiCode:  uint16(65),
		Fflags:  uint8(14),
		FnRange: uint8(26),
	},
	1: {
		FiCode:  uint16(181),
		Fflags:  uint8(64),
		FnRange: uint8(1),
	},
	2: {
		FiCode:  uint16(192),
		Fflags:  uint8(14),
		FnRange: uint8(23),
	},
	3: {
		FiCode:  uint16(216),
		Fflags:  uint8(14),
		FnRange: uint8(7),
	},
	4: {
		FiCode:  uint16(256),
		Fflags:  uint8(1),
		FnRange: uint8(48),
	},
	5: {
		FiCode:  uint16(306),
		Fflags:  uint8(1),
		FnRange: uint8(6),
	},
	6: {
		FiCode:  uint16(313),
		Fflags:  uint8(1),
		FnRange: uint8(16),
	},
	7: {
		FiCode:  uint16(330),
		Fflags:  uint8(1),
		FnRange: uint8(46),
	},
	8: {
		FiCode:  uint16(376),
		Fflags:  uint8(116),
		FnRange: uint8(1),
	},
	9: {
		FiCode:  uint16(377),
		Fflags:  uint8(1),
		FnRange: uint8(6),
	},
	10: {
		FiCode:  uint16(383),
		Fflags:  uint8(104),
		FnRange: uint8(1),
	},
	11: {
		FiCode:  uint16(385),
		Fflags:  uint8(50),
		FnRange: uint8(1),
	},
	12: {
		FiCode:  uint16(386),
		Fflags:  uint8(1),
		FnRange: uint8(4),
	},
	13: {
		FiCode:  uint16(390),
		Fflags:  uint8(44),
		FnRange: uint8(1),
	},
	14: {
		FiCode:  uint16(391),
		FnRange: uint8(1),
	},
	15: {
		FiCode:  uint16(393),
		Fflags:  uint8(42),
		FnRange: uint8(2),
	},
	16: {
		FiCode:  uint16(395),
		FnRange: uint8(1),
	},
	17: {
		FiCode:  uint16(398),
		Fflags:  uint8(32),
		FnRange: uint8(1),
	},
	18: {
		FiCode:  uint16(399),
		Fflags:  uint8(38),
		FnRange: uint8(1),
	},
	19: {
		FiCode:  uint16(400),
		Fflags:  uint8(40),
		FnRange: uint8(1),
	},
	20: {
		FiCode:  uint16(401),
		FnRange: uint8(1),
	},
	21: {
		FiCode:  uint16(403),
		Fflags:  uint8(42),
		FnRange: uint8(1),
	},
	22: {
		FiCode:  uint16(404),
		Fflags:  uint8(46),
		FnRange: uint8(1),
	},
	23: {
		FiCode:  uint16(406),
		Fflags:  uint8(52),
		FnRange: uint8(1),
	},
	24: {
		FiCode:  uint16(407),
		Fflags:  uint8(48),
		FnRange: uint8(1),
	},
	25: {
		FiCode:  uint16(408),
		FnRange: uint8(1),
	},
	26: {
		FiCode:  uint16(412),
		Fflags:  uint8(52),
		FnRange: uint8(1),
	},
	27: {
		FiCode:  uint16(413),
		Fflags:  uint8(54),
		FnRange: uint8(1),
	},
	28: {
		FiCode:  uint16(415),
		Fflags:  uint8(56),
		FnRange: uint8(1),
	},
	29: {
		FiCode:  uint16(416),
		Fflags:  uint8(1),
		FnRange: uint8(6),
	},
	30: {
		FiCode:  uint16(422),
		Fflags:  uint8(60),
		FnRange: uint8(1),
	},
	31: {
		FiCode:  uint16(423),
		FnRange: uint8(1),
	},
	32: {
		FiCode:  uint16(425),
		Fflags:  uint8(60),
		FnRange: uint8(1),
	},
	33: {
		FiCode:  uint16(428),
		FnRange: uint8(1),
	},
	34: {
		FiCode:  uint16(430),
		Fflags:  uint8(60),
		FnRange: uint8(1),
	},
	35: {
		FiCode:  uint16(431),
		FnRange: uint8(1),
	},
	36: {
		FiCode:  uint16(433),
		Fflags:  uint8(58),
		FnRange: uint8(2),
	},
	37: {
		FiCode:  uint16(435),
		Fflags:  uint8(1),
		FnRange: uint8(4),
	},
	38: {
		FiCode:  uint16(439),
		Fflags:  uint8(62),
		FnRange: uint8(1),
	},
	39: {
		FiCode:  uint16(440),
		FnRange: uint8(1),
	},
	40: {
		FiCode:  uint16(444),
		FnRange: uint8(1),
	},
	41: {
		FiCode:  uint16(452),
		Fflags:  uint8(2),
		FnRange: uint8(1),
	},
	42: {
		FiCode:  uint16(453),
		FnRange: uint8(1),
	},
	43: {
		FiCode:  uint16(455),
		Fflags:  uint8(2),
		FnRange: uint8(1),
	},
	44: {
		FiCode:  uint16(456),
		FnRange: uint8(1),
	},
	45: {
		FiCode:  uint16(458),
		Fflags:  uint8(2),
		FnRange: uint8(1),
	},
	46: {
		FiCode:  uint16(459),
		Fflags:  uint8(1),
		FnRange: uint8(18),
	},
	47: {
		FiCode:  uint16(478),
		Fflags:  uint8(1),
		FnRange: uint8(18),
	},
	48: {
		FiCode:  uint16(497),
		Fflags:  uint8(2),
		FnRange: uint8(1),
	},
	49: {
		FiCode:  uint16(498),
		Fflags:  uint8(1),
		FnRange: uint8(4),
	},
	50: {
		FiCode:  uint16(502),
		Fflags:  uint8(122),
		FnRange: uint8(1),
	},
	51: {
		FiCode:  uint16(503),
		Fflags:  uint8(134),
		FnRange: uint8(1),
	},
	52: {
		FiCode:  uint16(504),
		Fflags:  uint8(1),
		FnRange: uint8(40),
	},
	53: {
		FiCode:  uint16(544),
		Fflags:  uint8(110),
		FnRange: uint8(1),
	},
	54: {
		FiCode:  uint16(546),
		Fflags:  uint8(1),
		FnRange: uint8(18),
	},
	55: {
		FiCode:  uint16(570),
		Fflags:  uint8(70),
		FnRange: uint8(1),
	},
	56: {
		FiCode:  uint16(571),
		FnRange: uint8(1),
	},
	57: {
		FiCode:  uint16(573),
		Fflags:  uint8(108),
		FnRange: uint8(1),
	},
	58: {
		FiCode:  uint16(574),
		Fflags:  uint8(68),
		FnRange: uint8(1),
	},
	59: {
		FiCode:  uint16(577),
		FnRange: uint8(1),
	},
	60: {
		FiCode:  uint16(579),
		Fflags:  uint8(106),
		FnRange: uint8(1),
	},
	61: {
		FiCode:  uint16(580),
		Fflags:  uint8(28),
		FnRange: uint8(1),
	},
	62: {
		FiCode:  uint16(581),
		Fflags:  uint8(30),
		FnRange: uint8(1),
	},
	63: {
		FiCode:  uint16(582),
		Fflags:  uint8(1),
		FnRange: uint8(10),
	},
	64: {
		FiCode:  uint16(837),
		Fflags:  uint8(36),
		FnRange: uint8(1),
	},
	65: {
		FiCode:  uint16(880),
		Fflags:  uint8(1),
		FnRange: uint8(4),
	},
	66: {
		FiCode:  uint16(886),
		FnRange: uint8(1),
	},
	67: {
		FiCode:  uint16(902),
		Fflags:  uint8(18),
		FnRange: uint8(1),
	},
	68: {
		FiCode:  uint16(904),
		Fflags:  uint8(16),
		FnRange: uint8(3),
	},
	69: {
		FiCode:  uint16(908),
		Fflags:  uint8(26),
		FnRange: uint8(1),
	},
	70: {
		FiCode:  uint16(910),
		Fflags:  uint8(24),
		FnRange: uint8(2),
	},
	71: {
		FiCode:  uint16(913),
		Fflags:  uint8(14),
		FnRange: uint8(17),
	},
	72: {
		FiCode:  uint16(931),
		Fflags:  uint8(14),
		FnRange: uint8(9),
	},
	73: {
		FiCode:  uint16(962),
		FnRange: uint8(1),
	},
	74: {
		FiCode:  uint16(975),
		Fflags:  uint8(4),
		FnRange: uint8(1),
	},
	75: {
		FiCode:  uint16(976),
		Fflags:  uint8(140),
		FnRange: uint8(1),
	},
	76: {
		FiCode:  uint16(977),
		Fflags:  uint8(142),
		FnRange: uint8(1),
	},
	77: {
		FiCode:  uint16(981),
		Fflags:  uint8(146),
		FnRange: uint8(1),
	},
	78: {
		FiCode:  uint16(982),
		Fflags:  uint8(144),
		FnRange: uint8(1),
	},
	79: {
		FiCode:  uint16(984),
		Fflags:  uint8(1),
		FnRange: uint8(24),
	},
	80: {
		FiCode:  uint16(1008),
		Fflags:  uint8(136),
		FnRange: uint8(1),
	},
	81: {
		FiCode:  uint16(1009),
		Fflags:  uint8(138),
		FnRange: uint8(1),
	},
	82: {
		FiCode:  uint16(1012),
		Fflags:  uint8(130),
		FnRange: uint8(1),
	},
	83: {
		FiCode:  uint16(1013),
		Fflags:  uint8(128),
		FnRange: uint8(1),
	},
	84: {
		FiCode:  uint16(1015),
		FnRange: uint8(1),
	},
	85: {
		FiCode:  uint16(1017),
		Fflags:  uint8(152),
		FnRange: uint8(1),
	},
	86: {
		FiCode:  uint16(1018),
		FnRange: uint8(1),
	},
	87: {
		FiCode:  uint16(1021),
		Fflags:  uint8(110),
		FnRange: uint8(3),
	},
	88: {
		FiCode:  uint16(1024),
		Fflags:  uint8(34),
		FnRange: uint8(16),
	},
	89: {
		FiCode:  uint16(1040),
		Fflags:  uint8(14),
		FnRange: uint8(32),
	},
	90: {
		FiCode:  uint16(1120),
		Fflags:  uint8(1),
		FnRange: uint8(34),
	},
	91: {
		FiCode:  uint16(1162),
		Fflags:  uint8(1),
		FnRange: uint8(54),
	},
	92: {
		FiCode:  uint16(1216),
		Fflags:  uint8(6),
		FnRange: uint8(1),
	},
	93: {
		FiCode:  uint16(1217),
		Fflags:  uint8(1),
		FnRange: uint8(14),
	},
	94: {
		FiCode:  uint16(1232),
		Fflags:  uint8(1),
		FnRange: uint8(88),
	},
	95: {
		FiCode:  uint16(1329),
		Fflags:  uint8(22),
		FnRange: uint8(38),
	},
	96: {
		FiCode:  uint16(4256),
		Fflags:  uint8(66),
		FnRange: uint8(38),
	},
	97: {
		FiCode:  uint16(4295),
		Fflags:  uint8(66),
		FnRange: uint8(1),
	},
	98: {
		FiCode:  uint16(4301),
		Fflags:  uint8(66),
		FnRange: uint8(1),
	},
	99: {
		FiCode:  uint16(7680),
		Fflags:  uint8(1),
		FnRange: uint8(150),
	},
	100: {
		FiCode:  uint16(7835),
		Fflags:  uint8(132),
		FnRange: uint8(1),
	},
	101: {
		FiCode:  uint16(7838),
		Fflags:  uint8(96),
		FnRange: uint8(1),
	},
	102: {
		FiCode:  uint16(7840),
		Fflags:  uint8(1),
		FnRange: uint8(96),
	},
	103: {
		FiCode:  uint16(7944),
		Fflags:  uint8(150),
		FnRange: uint8(8),
	},
	104: {
		FiCode:  uint16(7960),
		Fflags:  uint8(150),
		FnRange: uint8(6),
	},
	105: {
		FiCode:  uint16(7976),
		Fflags:  uint8(150),
		FnRange: uint8(8),
	},
	106: {
		FiCode:  uint16(7992),
		Fflags:  uint8(150),
		FnRange: uint8(8),
	},
	107: {
		FiCode:  uint16(8008),
		Fflags:  uint8(150),
		FnRange: uint8(6),
	},
	108: {
		FiCode:  uint16(8025),
		Fflags:  uint8(151),
		FnRange: uint8(8),
	},
	109: {
		FiCode:  uint16(8040),
		Fflags:  uint8(150),
		FnRange: uint8(8),
	},
	110: {
		FiCode:  uint16(8072),
		Fflags:  uint8(150),
		FnRange: uint8(8),
	},
	111: {
		FiCode:  uint16(8088),
		Fflags:  uint8(150),
		FnRange: uint8(8),
	},
	112: {
		FiCode:  uint16(8104),
		Fflags:  uint8(150),
		FnRange: uint8(8),
	},
	113: {
		FiCode:  uint16(8120),
		Fflags:  uint8(150),
		FnRange: uint8(2),
	},
	114: {
		FiCode:  uint16(8122),
		Fflags:  uint8(126),
		FnRange: uint8(2),
	},
	115: {
		FiCode:  uint16(8124),
		Fflags:  uint8(148),
		FnRange: uint8(1),
	},
	116: {
		FiCode:  uint16(8126),
		Fflags:  uint8(100),
		FnRange: uint8(1),
	},
	117: {
		FiCode:  uint16(8136),
		Fflags:  uint8(124),
		FnRange: uint8(4),
	},
	118: {
		FiCode:  uint16(8140),
		Fflags:  uint8(148),
		FnRange: uint8(1),
	},
	119: {
		FiCode:  uint16(8152),
		Fflags:  uint8(150),
		FnRange: uint8(2),
	},
	120: {
		FiCode:  uint16(8154),
		Fflags:  uint8(120),
		FnRange: uint8(2),
	},
	121: {
		FiCode:  uint16(8168),
		Fflags:  uint8(150),
		FnRange: uint8(2),
	},
	122: {
		FiCode:  uint16(8170),
		Fflags:  uint8(118),
		FnRange: uint8(2),
	},
	123: {
		FiCode:  uint16(8172),
		Fflags:  uint8(152),
		FnRange: uint8(1),
	},
	124: {
		FiCode:  uint16(8184),
		Fflags:  uint8(112),
		FnRange: uint8(2),
	},
	125: {
		FiCode:  uint16(8186),
		Fflags:  uint8(114),
		FnRange: uint8(2),
	},
	126: {
		FiCode:  uint16(8188),
		Fflags:  uint8(148),
		FnRange: uint8(1),
	},
	127: {
		FiCode:  uint16(8486),
		Fflags:  uint8(98),
		FnRange: uint8(1),
	},
	128: {
		FiCode:  uint16(8490),
		Fflags:  uint8(92),
		FnRange: uint8(1),
	},
	129: {
		FiCode:  uint16(8491),
		Fflags:  uint8(94),
		FnRange: uint8(1),
	},
	130: {
		FiCode:  uint16(8498),
		Fflags:  uint8(12),
		FnRange: uint8(1),
	},
	131: {
		FiCode:  uint16(8544),
		Fflags:  uint8(8),
		FnRange: uint8(16),
	},
	132: {
		FiCode:  uint16(8579),
		FnRange: uint8(1),
	},
	133: {
		FiCode:  uint16(9398),
		Fflags:  uint8(10),
		FnRange: uint8(26),
	},
	134: {
		FiCode:  uint16(11264),
		Fflags:  uint8(22),
		FnRange: uint8(47),
	},
	135: {
		FiCode:  uint16(11360),
		FnRange: uint8(1),
	},
	136: {
		FiCode:  uint16(11362),
		Fflags:  uint8(88),
		FnRange: uint8(1),
	},
	137: {
		FiCode:  uint16(11363),
		Fflags:  uint8(102),
		FnRange: uint8(1),
	},
	138: {
		FiCode:  uint16(11364),
		Fflags:  uint8(90),
		FnRange: uint8(1),
	},
	139: {
		FiCode:  uint16(11367),
		Fflags:  uint8(1),
		FnRange: uint8(6),
	},
	140: {
		FiCode:  uint16(11373),
		Fflags:  uint8(84),
		FnRange: uint8(1),
	},
	141: {
		FiCode:  uint16(11374),
		Fflags:  uint8(86),
		FnRange: uint8(1),
	},
	142: {
		FiCode:  uint16(11375),
		Fflags:  uint8(80),
		FnRange: uint8(1),
	},
	143: {
		FiCode:  uint16(11376),
		Fflags:  uint8(82),
		FnRange: uint8(1),
	},
	144: {
		FiCode:  uint16(11378),
		FnRange: uint8(1),
	},
	145: {
		FiCode:  uint16(11381),
		FnRange: uint8(1),
	},
	146: {
		FiCode:  uint16(11390),
		Fflags:  uint8(78),
		FnRange: uint8(2),
	},
	147: {
		FiCode:  uint16(11392),
		Fflags:  uint8(1),
		FnRange: uint8(100),
	},
	148: {
		FiCode:  uint16(11499),
		Fflags:  uint8(1),
		FnRange: uint8(4),
	},
	149: {
		FiCode:  uint16(11506),
		FnRange: uint8(1),
	},
	150: {
		FiCode:  uint16(42560),
		Fflags:  uint8(1),
		FnRange: uint8(46),
	},
	151: {
		FiCode:  uint16(42624),
		Fflags:  uint8(1),
		FnRange: uint8(24),
	},
	152: {
		FiCode:  uint16(42786),
		Fflags:  uint8(1),
		FnRange: uint8(14),
	},
	153: {
		FiCode:  uint16(42802),
		Fflags:  uint8(1),
		FnRange: uint8(62),
	},
	154: {
		FiCode:  uint16(42873),
		Fflags:  uint8(1),
		FnRange: uint8(4),
	},
	155: {
		FiCode:  uint16(42877),
		Fflags:  uint8(76),
		FnRange: uint8(1),
	},
	156: {
		FiCode:  uint16(42878),
		Fflags:  uint8(1),
		FnRange: uint8(10),
	},
	157: {
		FiCode:  uint16(42891),
		FnRange: uint8(1),
	},
	158: {
		FiCode:  uint16(42893),
		Fflags:  uint8(74),
		FnRange: uint8(1),
	},
	159: {
		FiCode:  uint16(42896),
		Fflags:  uint8(1),
		FnRange: uint8(4),
	},
	160: {
		FiCode:  uint16(42912),
		Fflags:  uint8(1),
		FnRange: uint8(10),
	},
	161: {
		FiCode:  uint16(42922),
		Fflags:  uint8(72),
		FnRange: uint8(1),
	},
	162: {
		FiCode:  uint16(65313),
		Fflags:  uint8(14),
		FnRange: uint8(26),
	},
}

var _aFts5UnicodeBlock = [17]Tu16{
	1:  uint16(1471),
	2:  uint16(1753),
	3:  uint16(1760),
	4:  uint16(1760),
	5:  uint16(1760),
	6:  uint16(1760),
	7:  uint16(1760),
	8:  uint16(1760),
	9:  uint16(1760),
	10: uint16(1760),
	11: uint16(1760),
	12: uint16(1760),
	13: uint16(1760),
	14: uint16(1760),
	15: uint16(1763),
	16: uint16(1765),
}

var _aFts5UnicodeData = [1765]Tu16{
	0:    uint16(1025),
	1:    uint16(61),
	2:    uint16(117),
	3:    uint16(55),
	4:    uint16(117),
	5:    uint16(54),
	6:    uint16(50),
	7:    uint16(53),
	8:    uint16(57),
	9:    uint16(53),
	10:   uint16(49),
	11:   uint16(85),
	12:   uint16(333),
	13:   uint16(85),
	14:   uint16(121),
	15:   uint16(85),
	16:   uint16(841),
	17:   uint16(54),
	18:   uint16(53),
	19:   uint16(50),
	20:   uint16(56),
	21:   uint16(48),
	22:   uint16(56),
	23:   uint16(837),
	24:   uint16(54),
	25:   uint16(57),
	26:   uint16(50),
	27:   uint16(57),
	28:   uint16(1057),
	29:   uint16(61),
	30:   uint16(53),
	31:   uint16(151),
	32:   uint16(58),
	33:   uint16(53),
	34:   uint16(56),
	35:   uint16(58),
	36:   uint16(39),
	37:   uint16(52),
	38:   uint16(57),
	39:   uint16(34),
	40:   uint16(58),
	41:   uint16(56),
	42:   uint16(58),
	43:   uint16(57),
	44:   uint16(79),
	45:   uint16(56),
	46:   uint16(37),
	47:   uint16(85),
	48:   uint16(56),
	49:   uint16(47),
	50:   uint16(39),
	51:   uint16(51),
	52:   uint16(111),
	53:   uint16(53),
	54:   uint16(745),
	55:   uint16(57),
	56:   uint16(233),
	57:   uint16(773),
	58:   uint16(57),
	59:   uint16(261),
	60:   uint16(1822),
	61:   uint16(37),
	62:   uint16(542),
	63:   uint16(37),
	64:   uint16(1534),
	65:   uint16(222),
	66:   uint16(69),
	67:   uint16(73),
	68:   uint16(37),
	69:   uint16(126),
	70:   uint16(126),
	71:   uint16(73),
	72:   uint16(69),
	73:   uint16(137),
	74:   uint16(37),
	75:   uint16(73),
	76:   uint16(37),
	77:   uint16(105),
	78:   uint16(101),
	79:   uint16(73),
	80:   uint16(37),
	81:   uint16(73),
	82:   uint16(37),
	83:   uint16(190),
	84:   uint16(158),
	85:   uint16(37),
	86:   uint16(126),
	87:   uint16(126),
	88:   uint16(73),
	89:   uint16(37),
	90:   uint16(126),
	91:   uint16(94),
	92:   uint16(37),
	93:   uint16(39),
	94:   uint16(94),
	95:   uint16(69),
	96:   uint16(135),
	97:   uint16(41),
	98:   uint16(40),
	99:   uint16(37),
	100:  uint16(41),
	101:  uint16(40),
	102:  uint16(37),
	103:  uint16(41),
	104:  uint16(40),
	105:  uint16(37),
	106:  uint16(542),
	107:  uint16(37),
	108:  uint16(606),
	109:  uint16(37),
	110:  uint16(41),
	111:  uint16(40),
	112:  uint16(37),
	113:  uint16(126),
	114:  uint16(73),
	115:  uint16(37),
	116:  uint16(1886),
	117:  uint16(197),
	118:  uint16(73),
	119:  uint16(37),
	120:  uint16(73),
	121:  uint16(69),
	122:  uint16(126),
	123:  uint16(105),
	124:  uint16(37),
	125:  uint16(286),
	126:  uint16(2181),
	127:  uint16(39),
	128:  uint16(869),
	129:  uint16(582),
	130:  uint16(152),
	131:  uint16(390),
	132:  uint16(472),
	133:  uint16(166),
	134:  uint16(248),
	135:  uint16(38),
	136:  uint16(56),
	137:  uint16(38),
	138:  uint16(568),
	139:  uint16(3596),
	140:  uint16(158),
	141:  uint16(38),
	142:  uint16(56),
	143:  uint16(94),
	144:  uint16(38),
	145:  uint16(101),
	146:  uint16(53),
	147:  uint16(88),
	148:  uint16(41),
	149:  uint16(53),
	150:  uint16(105),
	151:  uint16(41),
	152:  uint16(73),
	153:  uint16(37),
	154:  uint16(553),
	155:  uint16(297),
	156:  uint16(1125),
	157:  uint16(94),
	158:  uint16(37),
	159:  uint16(105),
	160:  uint16(101),
	161:  uint16(798),
	162:  uint16(133),
	163:  uint16(94),
	164:  uint16(57),
	165:  uint16(126),
	166:  uint16(94),
	167:  uint16(37),
	168:  uint16(1641),
	169:  uint16(1541),
	170:  uint16(1118),
	171:  uint16(58),
	172:  uint16(172),
	173:  uint16(75),
	174:  uint16(1790),
	175:  uint16(478),
	176:  uint16(37),
	177:  uint16(2846),
	178:  uint16(1225),
	179:  uint16(38),
	180:  uint16(213),
	181:  uint16(1253),
	182:  uint16(53),
	183:  uint16(49),
	184:  uint16(55),
	185:  uint16(1452),
	186:  uint16(49),
	187:  uint16(44),
	188:  uint16(53),
	189:  uint16(76),
	190:  uint16(53),
	191:  uint16(76),
	192:  uint16(53),
	193:  uint16(44),
	194:  uint16(871),
	195:  uint16(103),
	196:  uint16(85),
	197:  uint16(162),
	198:  uint16(121),
	199:  uint16(85),
	200:  uint16(55),
	201:  uint16(85),
	202:  uint16(90),
	203:  uint16(364),
	204:  uint16(53),
	205:  uint16(85),
	206:  uint16(1031),
	207:  uint16(38),
	208:  uint16(327),
	209:  uint16(684),
	210:  uint16(333),
	211:  uint16(149),
	212:  uint16(71),
	213:  uint16(44),
	214:  uint16(3175),
	215:  uint16(53),
	216:  uint16(39),
	217:  uint16(236),
	218:  uint16(34),
	219:  uint16(58),
	220:  uint16(204),
	221:  uint16(70),
	222:  uint16(76),
	223:  uint16(58),
	224:  uint16(140),
	225:  uint16(71),
	226:  uint16(333),
	227:  uint16(103),
	228:  uint16(90),
	229:  uint16(39),
	230:  uint16(469),
	231:  uint16(34),
	232:  uint16(39),
	233:  uint16(44),
	234:  uint16(967),
	235:  uint16(876),
	236:  uint16(2855),
	237:  uint16(364),
	238:  uint16(39),
	239:  uint16(333),
	240:  uint16(1063),
	241:  uint16(300),
	242:  uint16(70),
	243:  uint16(58),
	244:  uint16(117),
	245:  uint16(38),
	246:  uint16(711),
	247:  uint16(140),
	248:  uint16(38),
	249:  uint16(300),
	250:  uint16(38),
	251:  uint16(108),
	252:  uint16(38),
	253:  uint16(172),
	254:  uint16(501),
	255:  uint16(807),
	256:  uint16(108),
	257:  uint16(53),
	258:  uint16(39),
	259:  uint16(359),
	260:  uint16(876),
	261:  uint16(108),
	262:  uint16(42),
	263:  uint16(1735),
	264:  uint16(44),
	265:  uint16(42),
	266:  uint16(44),
	267:  uint16(39),
	268:  uint16(106),
	269:  uint16(268),
	270:  uint16(138),
	271:  uint16(44),
	272:  uint16(74),
	273:  uint16(39),
	274:  uint16(236),
	275:  uint16(327),
	276:  uint16(76),
	277:  uint16(85),
	278:  uint16(333),
	279:  uint16(53),
	280:  uint16(38),
	281:  uint16(199),
	282:  uint16(231),
	283:  uint16(44),
	284:  uint16(74),
	285:  uint16(263),
	286:  uint16(71),
	287:  uint16(711),
	288:  uint16(231),
	289:  uint16(39),
	290:  uint16(135),
	291:  uint16(44),
	292:  uint16(39),
	293:  uint16(106),
	294:  uint16(140),
	295:  uint16(74),
	296:  uint16(74),
	297:  uint16(44),
	298:  uint16(39),
	299:  uint16(42),
	300:  uint16(71),
	301:  uint16(103),
	302:  uint16(76),
	303:  uint16(333),
	304:  uint16(71),
	305:  uint16(87),
	306:  uint16(207),
	307:  uint16(58),
	308:  uint16(55),
	309:  uint16(76),
	310:  uint16(42),
	311:  uint16(199),
	312:  uint16(71),
	313:  uint16(711),
	314:  uint16(231),
	315:  uint16(71),
	316:  uint16(71),
	317:  uint16(71),
	318:  uint16(44),
	319:  uint16(106),
	320:  uint16(76),
	321:  uint16(76),
	322:  uint16(108),
	323:  uint16(44),
	324:  uint16(135),
	325:  uint16(39),
	326:  uint16(333),
	327:  uint16(76),
	328:  uint16(103),
	329:  uint16(44),
	330:  uint16(76),
	331:  uint16(42),
	332:  uint16(295),
	333:  uint16(103),
	334:  uint16(711),
	335:  uint16(231),
	336:  uint16(71),
	337:  uint16(167),
	338:  uint16(44),
	339:  uint16(39),
	340:  uint16(106),
	341:  uint16(172),
	342:  uint16(76),
	343:  uint16(42),
	344:  uint16(74),
	345:  uint16(44),
	346:  uint16(39),
	347:  uint16(71),
	348:  uint16(76),
	349:  uint16(333),
	350:  uint16(53),
	351:  uint16(55),
	352:  uint16(44),
	353:  uint16(74),
	354:  uint16(263),
	355:  uint16(71),
	356:  uint16(711),
	357:  uint16(231),
	358:  uint16(71),
	359:  uint16(167),
	360:  uint16(44),
	361:  uint16(39),
	362:  uint16(42),
	363:  uint16(44),
	364:  uint16(42),
	365:  uint16(140),
	366:  uint16(74),
	367:  uint16(74),
	368:  uint16(44),
	369:  uint16(44),
	370:  uint16(42),
	371:  uint16(71),
	372:  uint16(103),
	373:  uint16(76),
	374:  uint16(333),
	375:  uint16(58),
	376:  uint16(39),
	377:  uint16(207),
	378:  uint16(44),
	379:  uint16(39),
	380:  uint16(199),
	381:  uint16(103),
	382:  uint16(135),
	383:  uint16(71),
	384:  uint16(39),
	385:  uint16(71),
	386:  uint16(71),
	387:  uint16(103),
	388:  uint16(391),
	389:  uint16(74),
	390:  uint16(44),
	391:  uint16(74),
	392:  uint16(106),
	393:  uint16(106),
	394:  uint16(44),
	395:  uint16(39),
	396:  uint16(42),
	397:  uint16(333),
	398:  uint16(111),
	399:  uint16(218),
	400:  uint16(55),
	401:  uint16(58),
	402:  uint16(106),
	403:  uint16(263),
	404:  uint16(103),
	405:  uint16(743),
	406:  uint16(327),
	407:  uint16(167),
	408:  uint16(39),
	409:  uint16(108),
	410:  uint16(138),
	411:  uint16(108),
	412:  uint16(140),
	413:  uint16(76),
	414:  uint16(71),
	415:  uint16(71),
	416:  uint16(76),
	417:  uint16(333),
	418:  uint16(239),
	419:  uint16(58),
	420:  uint16(74),
	421:  uint16(263),
	422:  uint16(103),
	423:  uint16(743),
	424:  uint16(327),
	425:  uint16(167),
	426:  uint16(44),
	427:  uint16(39),
	428:  uint16(42),
	429:  uint16(44),
	430:  uint16(170),
	431:  uint16(44),
	432:  uint16(74),
	433:  uint16(74),
	434:  uint16(76),
	435:  uint16(74),
	436:  uint16(39),
	437:  uint16(71),
	438:  uint16(76),
	439:  uint16(333),
	440:  uint16(71),
	441:  uint16(74),
	442:  uint16(263),
	443:  uint16(103),
	444:  uint16(1319),
	445:  uint16(39),
	446:  uint16(106),
	447:  uint16(140),
	448:  uint16(106),
	449:  uint16(106),
	450:  uint16(44),
	451:  uint16(39),
	452:  uint16(42),
	453:  uint16(71),
	454:  uint16(76),
	455:  uint16(333),
	456:  uint16(207),
	457:  uint16(58),
	458:  uint16(199),
	459:  uint16(74),
	460:  uint16(583),
	461:  uint16(775),
	462:  uint16(295),
	463:  uint16(39),
	464:  uint16(231),
	465:  uint16(44),
	466:  uint16(106),
	467:  uint16(108),
	468:  uint16(44),
	469:  uint16(266),
	470:  uint16(74),
	471:  uint16(53),
	472:  uint16(1543),
	473:  uint16(44),
	474:  uint16(71),
	475:  uint16(236),
	476:  uint16(55),
	477:  uint16(199),
	478:  uint16(38),
	479:  uint16(268),
	480:  uint16(53),
	481:  uint16(333),
	482:  uint16(85),
	483:  uint16(71),
	484:  uint16(39),
	485:  uint16(71),
	486:  uint16(39),
	487:  uint16(39),
	488:  uint16(135),
	489:  uint16(231),
	490:  uint16(103),
	491:  uint16(39),
	492:  uint16(39),
	493:  uint16(71),
	494:  uint16(135),
	495:  uint16(44),
	496:  uint16(71),
	497:  uint16(204),
	498:  uint16(76),
	499:  uint16(39),
	500:  uint16(167),
	501:  uint16(38),
	502:  uint16(204),
	503:  uint16(333),
	504:  uint16(135),
	505:  uint16(39),
	506:  uint16(122),
	507:  uint16(501),
	508:  uint16(58),
	509:  uint16(53),
	510:  uint16(122),
	511:  uint16(76),
	512:  uint16(218),
	513:  uint16(333),
	514:  uint16(335),
	515:  uint16(58),
	516:  uint16(44),
	517:  uint16(58),
	518:  uint16(44),
	519:  uint16(58),
	520:  uint16(44),
	521:  uint16(54),
	522:  uint16(50),
	523:  uint16(54),
	524:  uint16(50),
	525:  uint16(74),
	526:  uint16(263),
	527:  uint16(1159),
	528:  uint16(460),
	529:  uint16(42),
	530:  uint16(172),
	531:  uint16(53),
	532:  uint16(76),
	533:  uint16(167),
	534:  uint16(364),
	535:  uint16(1164),
	536:  uint16(282),
	537:  uint16(44),
	538:  uint16(218),
	539:  uint16(90),
	540:  uint16(181),
	541:  uint16(154),
	542:  uint16(85),
	543:  uint16(1383),
	544:  uint16(74),
	545:  uint16(140),
	546:  uint16(42),
	547:  uint16(204),
	548:  uint16(42),
	549:  uint16(76),
	550:  uint16(74),
	551:  uint16(76),
	552:  uint16(39),
	553:  uint16(333),
	554:  uint16(213),
	555:  uint16(199),
	556:  uint16(74),
	557:  uint16(76),
	558:  uint16(135),
	559:  uint16(108),
	560:  uint16(39),
	561:  uint16(106),
	562:  uint16(71),
	563:  uint16(234),
	564:  uint16(103),
	565:  uint16(140),
	566:  uint16(423),
	567:  uint16(44),
	568:  uint16(74),
	569:  uint16(76),
	570:  uint16(202),
	571:  uint16(44),
	572:  uint16(39),
	573:  uint16(42),
	574:  uint16(333),
	575:  uint16(106),
	576:  uint16(44),
	577:  uint16(90),
	578:  uint16(1225),
	579:  uint16(41),
	580:  uint16(41),
	581:  uint16(1383),
	582:  uint16(53),
	583:  uint16(38),
	584:  uint16(10631),
	585:  uint16(135),
	586:  uint16(231),
	587:  uint16(39),
	588:  uint16(135),
	589:  uint16(1319),
	590:  uint16(135),
	591:  uint16(1063),
	592:  uint16(135),
	593:  uint16(231),
	594:  uint16(39),
	595:  uint16(135),
	596:  uint16(487),
	597:  uint16(1831),
	598:  uint16(135),
	599:  uint16(2151),
	600:  uint16(108),
	601:  uint16(309),
	602:  uint16(655),
	603:  uint16(519),
	604:  uint16(346),
	605:  uint16(2727),
	606:  uint16(49),
	607:  uint16(19847),
	608:  uint16(85),
	609:  uint16(551),
	610:  uint16(61),
	611:  uint16(839),
	612:  uint16(54),
	613:  uint16(50),
	614:  uint16(2407),
	615:  uint16(117),
	616:  uint16(110),
	617:  uint16(423),
	618:  uint16(135),
	619:  uint16(108),
	620:  uint16(583),
	621:  uint16(108),
	622:  uint16(85),
	623:  uint16(583),
	624:  uint16(76),
	625:  uint16(423),
	626:  uint16(103),
	627:  uint16(76),
	628:  uint16(1671),
	629:  uint16(76),
	630:  uint16(42),
	631:  uint16(236),
	632:  uint16(266),
	633:  uint16(44),
	634:  uint16(74),
	635:  uint16(364),
	636:  uint16(117),
	637:  uint16(38),
	638:  uint16(117),
	639:  uint16(55),
	640:  uint16(39),
	641:  uint16(44),
	642:  uint16(333),
	643:  uint16(335),
	644:  uint16(213),
	645:  uint16(49),
	646:  uint16(149),
	647:  uint16(108),
	648:  uint16(61),
	649:  uint16(333),
	650:  uint16(1127),
	651:  uint16(38),
	652:  uint16(1671),
	653:  uint16(1319),
	654:  uint16(44),
	655:  uint16(39),
	656:  uint16(2247),
	657:  uint16(935),
	658:  uint16(108),
	659:  uint16(138),
	660:  uint16(76),
	661:  uint16(106),
	662:  uint16(74),
	663:  uint16(44),
	664:  uint16(202),
	665:  uint16(108),
	666:  uint16(58),
	667:  uint16(85),
	668:  uint16(333),
	669:  uint16(967),
	670:  uint16(167),
	671:  uint16(1415),
	672:  uint16(554),
	673:  uint16(231),
	674:  uint16(74),
	675:  uint16(333),
	676:  uint16(47),
	677:  uint16(1114),
	678:  uint16(743),
	679:  uint16(76),
	680:  uint16(106),
	681:  uint16(85),
	682:  uint16(1703),
	683:  uint16(42),
	684:  uint16(44),
	685:  uint16(42),
	686:  uint16(236),
	687:  uint16(44),
	688:  uint16(42),
	689:  uint16(44),
	690:  uint16(74),
	691:  uint16(268),
	692:  uint16(202),
	693:  uint16(332),
	694:  uint16(44),
	695:  uint16(333),
	696:  uint16(333),
	697:  uint16(245),
	698:  uint16(38),
	699:  uint16(213),
	700:  uint16(140),
	701:  uint16(42),
	702:  uint16(1511),
	703:  uint16(44),
	704:  uint16(42),
	705:  uint16(172),
	706:  uint16(42),
	707:  uint16(44),
	708:  uint16(170),
	709:  uint16(44),
	710:  uint16(74),
	711:  uint16(231),
	712:  uint16(333),
	713:  uint16(245),
	714:  uint16(346),
	715:  uint16(300),
	716:  uint16(314),
	717:  uint16(76),
	718:  uint16(42),
	719:  uint16(967),
	720:  uint16(42),
	721:  uint16(140),
	722:  uint16(74),
	723:  uint16(76),
	724:  uint16(42),
	725:  uint16(44),
	726:  uint16(74),
	727:  uint16(71),
	728:  uint16(333),
	729:  uint16(1415),
	730:  uint16(44),
	731:  uint16(42),
	732:  uint16(76),
	733:  uint16(106),
	734:  uint16(44),
	735:  uint16(42),
	736:  uint16(108),
	737:  uint16(74),
	738:  uint16(149),
	739:  uint16(1159),
	740:  uint16(266),
	741:  uint16(268),
	742:  uint16(74),
	743:  uint16(76),
	744:  uint16(181),
	745:  uint16(333),
	746:  uint16(103),
	747:  uint16(333),
	748:  uint16(967),
	749:  uint16(198),
	750:  uint16(85),
	751:  uint16(277),
	752:  uint16(108),
	753:  uint16(53),
	754:  uint16(428),
	755:  uint16(42),
	756:  uint16(236),
	757:  uint16(135),
	758:  uint16(44),
	759:  uint16(135),
	760:  uint16(74),
	761:  uint16(44),
	762:  uint16(71),
	763:  uint16(1413),
	764:  uint16(2022),
	765:  uint16(421),
	766:  uint16(38),
	767:  uint16(1093),
	768:  uint16(1190),
	769:  uint16(1260),
	770:  uint16(140),
	771:  uint16(4830),
	772:  uint16(261),
	773:  uint16(3166),
	774:  uint16(261),
	775:  uint16(265),
	776:  uint16(197),
	777:  uint16(201),
	778:  uint16(261),
	779:  uint16(265),
	780:  uint16(261),
	781:  uint16(265),
	782:  uint16(197),
	783:  uint16(201),
	784:  uint16(261),
	785:  uint16(41),
	786:  uint16(41),
	787:  uint16(41),
	788:  uint16(94),
	789:  uint16(229),
	790:  uint16(265),
	791:  uint16(453),
	792:  uint16(261),
	793:  uint16(264),
	794:  uint16(261),
	795:  uint16(264),
	796:  uint16(261),
	797:  uint16(264),
	798:  uint16(165),
	799:  uint16(69),
	800:  uint16(137),
	801:  uint16(40),
	802:  uint16(56),
	803:  uint16(37),
	804:  uint16(120),
	805:  uint16(101),
	806:  uint16(69),
	807:  uint16(137),
	808:  uint16(40),
	809:  uint16(120),
	810:  uint16(133),
	811:  uint16(69),
	812:  uint16(137),
	813:  uint16(120),
	814:  uint16(261),
	815:  uint16(169),
	816:  uint16(120),
	817:  uint16(101),
	818:  uint16(69),
	819:  uint16(137),
	820:  uint16(40),
	821:  uint16(88),
	822:  uint16(381),
	823:  uint16(162),
	824:  uint16(209),
	825:  uint16(85),
	826:  uint16(52),
	827:  uint16(51),
	828:  uint16(54),
	829:  uint16(84),
	830:  uint16(51),
	831:  uint16(54),
	832:  uint16(52),
	833:  uint16(277),
	834:  uint16(59),
	835:  uint16(60),
	836:  uint16(162),
	837:  uint16(61),
	838:  uint16(309),
	839:  uint16(52),
	840:  uint16(51),
	841:  uint16(149),
	842:  uint16(80),
	843:  uint16(117),
	844:  uint16(57),
	845:  uint16(54),
	846:  uint16(50),
	847:  uint16(373),
	848:  uint16(57),
	849:  uint16(53),
	850:  uint16(48),
	851:  uint16(341),
	852:  uint16(61),
	853:  uint16(162),
	854:  uint16(194),
	855:  uint16(47),
	856:  uint16(38),
	857:  uint16(207),
	858:  uint16(121),
	859:  uint16(54),
	860:  uint16(50),
	861:  uint16(38),
	862:  uint16(335),
	863:  uint16(121),
	864:  uint16(54),
	865:  uint16(50),
	866:  uint16(422),
	867:  uint16(855),
	868:  uint16(428),
	869:  uint16(139),
	870:  uint16(44),
	871:  uint16(107),
	872:  uint16(396),
	873:  uint16(90),
	874:  uint16(41),
	875:  uint16(154),
	876:  uint16(41),
	877:  uint16(90),
	878:  uint16(37),
	879:  uint16(105),
	880:  uint16(69),
	881:  uint16(105),
	882:  uint16(37),
	883:  uint16(58),
	884:  uint16(41),
	885:  uint16(90),
	886:  uint16(57),
	887:  uint16(169),
	888:  uint16(218),
	889:  uint16(41),
	890:  uint16(58),
	891:  uint16(41),
	892:  uint16(58),
	893:  uint16(41),
	894:  uint16(58),
	895:  uint16(137),
	896:  uint16(58),
	897:  uint16(37),
	898:  uint16(137),
	899:  uint16(37),
	900:  uint16(135),
	901:  uint16(37),
	902:  uint16(90),
	903:  uint16(69),
	904:  uint16(73),
	905:  uint16(185),
	906:  uint16(94),
	907:  uint16(101),
	908:  uint16(58),
	909:  uint16(57),
	910:  uint16(90),
	911:  uint16(37),
	912:  uint16(58),
	913:  uint16(527),
	914:  uint16(1134),
	915:  uint16(94),
	916:  uint16(142),
	917:  uint16(47),
	918:  uint16(185),
	919:  uint16(186),
	920:  uint16(89),
	921:  uint16(154),
	922:  uint16(57),
	923:  uint16(90),
	924:  uint16(57),
	925:  uint16(90),
	926:  uint16(57),
	927:  uint16(250),
	928:  uint16(57),
	929:  uint16(1018),
	930:  uint16(89),
	931:  uint16(90),
	932:  uint16(57),
	933:  uint16(58),
	934:  uint16(57),
	935:  uint16(1018),
	936:  uint16(8601),
	937:  uint16(282),
	938:  uint16(153),
	939:  uint16(666),
	940:  uint16(89),
	941:  uint16(250),
	942:  uint16(54),
	943:  uint16(50),
	944:  uint16(2618),
	945:  uint16(57),
	946:  uint16(986),
	947:  uint16(825),
	948:  uint16(1306),
	949:  uint16(217),
	950:  uint16(602),
	951:  uint16(1274),
	952:  uint16(378),
	953:  uint16(1935),
	954:  uint16(2522),
	955:  uint16(719),
	956:  uint16(5882),
	957:  uint16(57),
	958:  uint16(314),
	959:  uint16(57),
	960:  uint16(1754),
	961:  uint16(281),
	962:  uint16(3578),
	963:  uint16(57),
	964:  uint16(4634),
	965:  uint16(3322),
	966:  uint16(54),
	967:  uint16(50),
	968:  uint16(54),
	969:  uint16(50),
	970:  uint16(54),
	971:  uint16(50),
	972:  uint16(54),
	973:  uint16(50),
	974:  uint16(54),
	975:  uint16(50),
	976:  uint16(54),
	977:  uint16(50),
	978:  uint16(54),
	979:  uint16(50),
	980:  uint16(975),
	981:  uint16(1434),
	982:  uint16(185),
	983:  uint16(54),
	984:  uint16(50),
	985:  uint16(1017),
	986:  uint16(54),
	987:  uint16(50),
	988:  uint16(54),
	989:  uint16(50),
	990:  uint16(54),
	991:  uint16(50),
	992:  uint16(54),
	993:  uint16(50),
	994:  uint16(54),
	995:  uint16(50),
	996:  uint16(537),
	997:  uint16(8218),
	998:  uint16(4217),
	999:  uint16(54),
	1000: uint16(50),
	1001: uint16(54),
	1002: uint16(50),
	1003: uint16(54),
	1004: uint16(50),
	1005: uint16(54),
	1006: uint16(50),
	1007: uint16(54),
	1008: uint16(50),
	1009: uint16(54),
	1010: uint16(50),
	1011: uint16(54),
	1012: uint16(50),
	1013: uint16(54),
	1014: uint16(50),
	1015: uint16(54),
	1016: uint16(50),
	1017: uint16(54),
	1018: uint16(50),
	1019: uint16(54),
	1020: uint16(50),
	1021: uint16(2041),
	1022: uint16(54),
	1023: uint16(50),
	1024: uint16(54),
	1025: uint16(50),
	1026: uint16(1049),
	1027: uint16(54),
	1028: uint16(50),
	1029: uint16(8281),
	1030: uint16(1562),
	1031: uint16(697),
	1032: uint16(90),
	1033: uint16(217),
	1034: uint16(346),
	1035: uint16(1513),
	1036: uint16(1509),
	1037: uint16(126),
	1038: uint16(73),
	1039: uint16(69),
	1040: uint16(254),
	1041: uint16(105),
	1042: uint16(37),
	1043: uint16(94),
	1044: uint16(37),
	1045: uint16(94),
	1046: uint16(165),
	1047: uint16(70),
	1048: uint16(105),
	1049: uint16(37),
	1050: uint16(3166),
	1051: uint16(37),
	1052: uint16(218),
	1053: uint16(158),
	1054: uint16(108),
	1055: uint16(94),
	1056: uint16(149),
	1057: uint16(47),
	1058: uint16(85),
	1059: uint16(1221),
	1060: uint16(37),
	1061: uint16(37),
	1062: uint16(1799),
	1063: uint16(38),
	1064: uint16(53),
	1065: uint16(44),
	1066: uint16(743),
	1067: uint16(231),
	1068: uint16(231),
	1069: uint16(231),
	1070: uint16(231),
	1071: uint16(231),
	1072: uint16(231),
	1073: uint16(231),
	1074: uint16(231),
	1075: uint16(1036),
	1076: uint16(85),
	1077: uint16(52),
	1078: uint16(51),
	1079: uint16(52),
	1080: uint16(51),
	1081: uint16(117),
	1082: uint16(52),
	1083: uint16(51),
	1084: uint16(53),
	1085: uint16(52),
	1086: uint16(51),
	1087: uint16(309),
	1088: uint16(49),
	1089: uint16(85),
	1090: uint16(49),
	1091: uint16(53),
	1092: uint16(52),
	1093: uint16(51),
	1094: uint16(85),
	1095: uint16(52),
	1096: uint16(51),
	1097: uint16(54),
	1098: uint16(50),
	1099: uint16(54),
	1100: uint16(50),
	1101: uint16(54),
	1102: uint16(50),
	1103: uint16(54),
	1104: uint16(50),
	1105: uint16(181),
	1106: uint16(38),
	1107: uint16(341),
	1108: uint16(81),
	1109: uint16(858),
	1110: uint16(2874),
	1111: uint16(6874),
	1112: uint16(410),
	1113: uint16(61),
	1114: uint16(117),
	1115: uint16(58),
	1116: uint16(38),
	1117: uint16(39),
	1118: uint16(46),
	1119: uint16(54),
	1120: uint16(50),
	1121: uint16(54),
	1122: uint16(50),
	1123: uint16(54),
	1124: uint16(50),
	1125: uint16(54),
	1126: uint16(50),
	1127: uint16(54),
	1128: uint16(50),
	1129: uint16(90),
	1130: uint16(54),
	1131: uint16(50),
	1132: uint16(54),
	1133: uint16(50),
	1134: uint16(54),
	1135: uint16(50),
	1136: uint16(54),
	1137: uint16(50),
	1138: uint16(49),
	1139: uint16(54),
	1140: uint16(82),
	1141: uint16(58),
	1142: uint16(302),
	1143: uint16(140),
	1144: uint16(74),
	1145: uint16(49),
	1146: uint16(166),
	1147: uint16(90),
	1148: uint16(110),
	1149: uint16(38),
	1150: uint16(39),
	1151: uint16(53),
	1152: uint16(90),
	1153: uint16(2759),
	1154: uint16(76),
	1155: uint16(88),
	1156: uint16(70),
	1157: uint16(39),
	1158: uint16(49),
	1159: uint16(2887),
	1160: uint16(53),
	1161: uint16(102),
	1162: uint16(39),
	1163: uint16(1319),
	1164: uint16(3015),
	1165: uint16(90),
	1166: uint16(143),
	1167: uint16(346),
	1168: uint16(871),
	1169: uint16(1178),
	1170: uint16(519),
	1171: uint16(1018),
	1172: uint16(335),
	1173: uint16(986),
	1174: uint16(271),
	1175: uint16(58),
	1176: uint16(495),
	1177: uint16(1050),
	1178: uint16(335),
	1179: uint16(1274),
	1180: uint16(495),
	1181: uint16(2042),
	1182: uint16(8218),
	1183: uint16(39),
	1184: uint16(39),
	1185: uint16(2074),
	1186: uint16(39),
	1187: uint16(39),
	1188: uint16(679),
	1189: uint16(38),
	1190: uint16(36583),
	1191: uint16(1786),
	1192: uint16(1287),
	1193: uint16(198),
	1194: uint16(85),
	1195: uint16(8583),
	1196: uint16(38),
	1197: uint16(117),
	1198: uint16(519),
	1199: uint16(333),
	1200: uint16(71),
	1201: uint16(1502),
	1202: uint16(39),
	1203: uint16(44),
	1204: uint16(107),
	1205: uint16(53),
	1206: uint16(332),
	1207: uint16(53),
	1208: uint16(38),
	1209: uint16(798),
	1210: uint16(44),
	1211: uint16(2247),
	1212: uint16(334),
	1213: uint16(76),
	1214: uint16(213),
	1215: uint16(760),
	1216: uint16(294),
	1217: uint16(88),
	1218: uint16(478),
	1219: uint16(69),
	1220: uint16(2014),
	1221: uint16(38),
	1222: uint16(261),
	1223: uint16(190),
	1224: uint16(350),
	1225: uint16(38),
	1226: uint16(88),
	1227: uint16(158),
	1228: uint16(158),
	1229: uint16(382),
	1230: uint16(70),
	1231: uint16(37),
	1232: uint16(231),
	1233: uint16(44),
	1234: uint16(103),
	1235: uint16(44),
	1236: uint16(135),
	1237: uint16(44),
	1238: uint16(743),
	1239: uint16(74),
	1240: uint16(76),
	1241: uint16(42),
	1242: uint16(154),
	1243: uint16(207),
	1244: uint16(90),
	1245: uint16(55),
	1246: uint16(58),
	1247: uint16(1671),
	1248: uint16(149),
	1249: uint16(74),
	1250: uint16(1607),
	1251: uint16(522),
	1252: uint16(44),
	1253: uint16(85),
	1254: uint16(333),
	1255: uint16(588),
	1256: uint16(199),
	1257: uint16(117),
	1258: uint16(39),
	1259: uint16(333),
	1260: uint16(903),
	1261: uint16(268),
	1262: uint16(85),
	1263: uint16(743),
	1264: uint16(364),
	1265: uint16(74),
	1266: uint16(53),
	1267: uint16(935),
	1268: uint16(108),
	1269: uint16(42),
	1270: uint16(1511),
	1271: uint16(44),
	1272: uint16(74),
	1273: uint16(140),
	1274: uint16(74),
	1275: uint16(44),
	1276: uint16(138),
	1277: uint16(437),
	1278: uint16(38),
	1279: uint16(333),
	1280: uint16(85),
	1281: uint16(1319),
	1282: uint16(204),
	1283: uint16(74),
	1284: uint16(76),
	1285: uint16(74),
	1286: uint16(76),
	1287: uint16(103),
	1288: uint16(44),
	1289: uint16(263),
	1290: uint16(44),
	1291: uint16(42),
	1292: uint16(333),
	1293: uint16(149),
	1294: uint16(519),
	1295: uint16(38),
	1296: uint16(199),
	1297: uint16(122),
	1298: uint16(39),
	1299: uint16(42),
	1300: uint16(1543),
	1301: uint16(44),
	1302: uint16(39),
	1303: uint16(108),
	1304: uint16(71),
	1305: uint16(76),
	1306: uint16(167),
	1307: uint16(76),
	1308: uint16(39),
	1309: uint16(44),
	1310: uint16(39),
	1311: uint16(71),
	1312: uint16(38),
	1313: uint16(85),
	1314: uint16(359),
	1315: uint16(42),
	1316: uint16(76),
	1317: uint16(74),
	1318: uint16(85),
	1319: uint16(39),
	1320: uint16(70),
	1321: uint16(42),
	1322: uint16(44),
	1323: uint16(199),
	1324: uint16(199),
	1325: uint16(199),
	1326: uint16(231),
	1327: uint16(231),
	1328: uint16(1127),
	1329: uint16(74),
	1330: uint16(44),
	1331: uint16(74),
	1332: uint16(44),
	1333: uint16(74),
	1334: uint16(53),
	1335: uint16(42),
	1336: uint16(44),
	1337: uint16(333),
	1338: uint16(39),
	1339: uint16(39),
	1340: uint16(743),
	1341: uint16(1575),
	1342: uint16(36),
	1343: uint16(68),
	1344: uint16(68),
	1345: uint16(36),
	1346: uint16(63),
	1347: uint16(63),
	1348: uint16(11719),
	1349: uint16(3399),
	1350: uint16(229),
	1351: uint16(165),
	1352: uint16(39),
	1353: uint16(44),
	1354: uint16(327),
	1355: uint16(57),
	1356: uint16(423),
	1357: uint16(167),
	1358: uint16(39),
	1359: uint16(71),
	1360: uint16(71),
	1361: uint16(3463),
	1362: uint16(536),
	1363: uint16(11623),
	1364: uint16(54),
	1365: uint16(50),
	1366: uint16(2055),
	1367: uint16(1735),
	1368: uint16(391),
	1369: uint16(55),
	1370: uint16(58),
	1371: uint16(524),
	1372: uint16(245),
	1373: uint16(54),
	1374: uint16(50),
	1375: uint16(53),
	1376: uint16(236),
	1377: uint16(53),
	1378: uint16(81),
	1379: uint16(80),
	1380: uint16(54),
	1381: uint16(50),
	1382: uint16(54),
	1383: uint16(50),
	1384: uint16(54),
	1385: uint16(50),
	1386: uint16(54),
	1387: uint16(50),
	1388: uint16(54),
	1389: uint16(50),
	1390: uint16(54),
	1391: uint16(50),
	1392: uint16(54),
	1393: uint16(50),
	1394: uint16(54),
	1395: uint16(50),
	1396: uint16(85),
	1397: uint16(54),
	1398: uint16(50),
	1399: uint16(149),
	1400: uint16(112),
	1401: uint16(117),
	1402: uint16(149),
	1403: uint16(49),
	1404: uint16(54),
	1405: uint16(50),
	1406: uint16(54),
	1407: uint16(50),
	1408: uint16(54),
	1409: uint16(50),
	1410: uint16(117),
	1411: uint16(57),
	1412: uint16(49),
	1413: uint16(121),
	1414: uint16(53),
	1415: uint16(55),
	1416: uint16(85),
	1417: uint16(167),
	1418: uint16(4327),
	1419: uint16(34),
	1420: uint16(117),
	1421: uint16(55),
	1422: uint16(117),
	1423: uint16(54),
	1424: uint16(50),
	1425: uint16(53),
	1426: uint16(57),
	1427: uint16(53),
	1428: uint16(49),
	1429: uint16(85),
	1430: uint16(333),
	1431: uint16(85),
	1432: uint16(121),
	1433: uint16(85),
	1434: uint16(841),
	1435: uint16(54),
	1436: uint16(53),
	1437: uint16(50),
	1438: uint16(56),
	1439: uint16(48),
	1440: uint16(56),
	1441: uint16(837),
	1442: uint16(54),
	1443: uint16(57),
	1444: uint16(50),
	1445: uint16(57),
	1446: uint16(54),
	1447: uint16(50),
	1448: uint16(53),
	1449: uint16(54),
	1450: uint16(50),
	1451: uint16(85),
	1452: uint16(327),
	1453: uint16(38),
	1454: uint16(1447),
	1455: uint16(70),
	1456: uint16(999),
	1457: uint16(199),
	1458: uint16(199),
	1459: uint16(199),
	1460: uint16(103),
	1461: uint16(87),
	1462: uint16(57),
	1463: uint16(56),
	1464: uint16(58),
	1465: uint16(87),
	1466: uint16(58),
	1467: uint16(153),
	1468: uint16(90),
	1469: uint16(98),
	1470: uint16(90),
	1471: uint16(391),
	1472: uint16(839),
	1473: uint16(615),
	1474: uint16(71),
	1475: uint16(487),
	1476: uint16(455),
	1477: uint16(3943),
	1478: uint16(117),
	1479: uint16(1455),
	1480: uint16(314),
	1481: uint16(1710),
	1482: uint16(143),
	1483: uint16(570),
	1484: uint16(47),
	1485: uint16(410),
	1486: uint16(1466),
	1487: uint16(44),
	1488: uint16(935),
	1489: uint16(1575),
	1490: uint16(999),
	1491: uint16(143),
	1492: uint16(551),
	1493: uint16(46),
	1494: uint16(263),
	1495: uint16(46),
	1496: uint16(967),
	1497: uint16(53),
	1498: uint16(1159),
	1499: uint16(263),
	1500: uint16(53),
	1501: uint16(174),
	1502: uint16(1289),
	1503: uint16(1285),
	1504: uint16(2503),
	1505: uint16(333),
	1506: uint16(199),
	1507: uint16(39),
	1508: uint16(1415),
	1509: uint16(71),
	1510: uint16(39),
	1511: uint16(743),
	1512: uint16(53),
	1513: uint16(271),
	1514: uint16(711),
	1515: uint16(207),
	1516: uint16(53),
	1517: uint16(839),
	1518: uint16(53),
	1519: uint16(1799),
	1520: uint16(71),
	1521: uint16(39),
	1522: uint16(108),
	1523: uint16(76),
	1524: uint16(140),
	1525: uint16(135),
	1526: uint16(103),
	1527: uint16(871),
	1528: uint16(108),
	1529: uint16(44),
	1530: uint16(271),
	1531: uint16(309),
	1532: uint16(935),
	1533: uint16(79),
	1534: uint16(53),
	1535: uint16(1735),
	1536: uint16(245),
	1537: uint16(711),
	1538: uint16(271),
	1539: uint16(615),
	1540: uint16(271),
	1541: uint16(2343),
	1542: uint16(1007),
	1543: uint16(42),
	1544: uint16(44),
	1545: uint16(42),
	1546: uint16(1703),
	1547: uint16(492),
	1548: uint16(245),
	1549: uint16(655),
	1550: uint16(333),
	1551: uint16(76),
	1552: uint16(42),
	1553: uint16(1447),
	1554: uint16(106),
	1555: uint16(140),
	1556: uint16(74),
	1557: uint16(76),
	1558: uint16(85),
	1559: uint16(34),
	1560: uint16(149),
	1561: uint16(807),
	1562: uint16(333),
	1563: uint16(108),
	1564: uint16(1159),
	1565: uint16(172),
	1566: uint16(42),
	1567: uint16(268),
	1568: uint16(333),
	1569: uint16(149),
	1570: uint16(76),
	1571: uint16(42),
	1572: uint16(1543),
	1573: uint16(106),
	1574: uint16(300),
	1575: uint16(74),
	1576: uint16(135),
	1577: uint16(149),
	1578: uint16(333),
	1579: uint16(1383),
	1580: uint16(44),
	1581: uint16(42),
	1582: uint16(44),
	1583: uint16(74),
	1584: uint16(204),
	1585: uint16(42),
	1586: uint16(44),
	1587: uint16(333),
	1588: uint16(28135),
	1589: uint16(3182),
	1590: uint16(149),
	1591: uint16(34279),
	1592: uint16(18215),
	1593: uint16(2215),
	1594: uint16(39),
	1595: uint16(1482),
	1596: uint16(140),
	1597: uint16(422),
	1598: uint16(71),
	1599: uint16(7898),
	1600: uint16(1274),
	1601: uint16(1946),
	1602: uint16(74),
	1603: uint16(108),
	1604: uint16(122),
	1605: uint16(202),
	1606: uint16(258),
	1607: uint16(268),
	1608: uint16(90),
	1609: uint16(236),
	1610: uint16(986),
	1611: uint16(140),
	1612: uint16(1562),
	1613: uint16(2138),
	1614: uint16(108),
	1615: uint16(58),
	1616: uint16(2810),
	1617: uint16(591),
	1618: uint16(841),
	1619: uint16(837),
	1620: uint16(841),
	1621: uint16(229),
	1622: uint16(581),
	1623: uint16(841),
	1624: uint16(837),
	1625: uint16(41),
	1626: uint16(73),
	1627: uint16(41),
	1628: uint16(73),
	1629: uint16(137),
	1630: uint16(265),
	1631: uint16(133),
	1632: uint16(37),
	1633: uint16(229),
	1634: uint16(357),
	1635: uint16(841),
	1636: uint16(837),
	1637: uint16(73),
	1638: uint16(137),
	1639: uint16(265),
	1640: uint16(233),
	1641: uint16(837),
	1642: uint16(73),
	1643: uint16(137),
	1644: uint16(169),
	1645: uint16(41),
	1646: uint16(233),
	1647: uint16(837),
	1648: uint16(841),
	1649: uint16(837),
	1650: uint16(841),
	1651: uint16(837),
	1652: uint16(841),
	1653: uint16(837),
	1654: uint16(841),
	1655: uint16(837),
	1656: uint16(841),
	1657: uint16(837),
	1658: uint16(841),
	1659: uint16(901),
	1660: uint16(809),
	1661: uint16(57),
	1662: uint16(805),
	1663: uint16(57),
	1664: uint16(197),
	1665: uint16(809),
	1666: uint16(57),
	1667: uint16(805),
	1668: uint16(57),
	1669: uint16(197),
	1670: uint16(809),
	1671: uint16(57),
	1672: uint16(805),
	1673: uint16(57),
	1674: uint16(197),
	1675: uint16(809),
	1676: uint16(57),
	1677: uint16(805),
	1678: uint16(57),
	1679: uint16(197),
	1680: uint16(809),
	1681: uint16(57),
	1682: uint16(805),
	1683: uint16(57),
	1684: uint16(197),
	1685: uint16(94),
	1686: uint16(1613),
	1687: uint16(135),
	1688: uint16(871),
	1689: uint16(71),
	1690: uint16(39),
	1691: uint16(39),
	1692: uint16(327),
	1693: uint16(135),
	1694: uint16(39),
	1695: uint16(39),
	1696: uint16(39),
	1697: uint16(39),
	1698: uint16(39),
	1699: uint16(39),
	1700: uint16(103),
	1701: uint16(71),
	1702: uint16(39),
	1703: uint16(39),
	1704: uint16(39),
	1705: uint16(39),
	1706: uint16(39),
	1707: uint16(39),
	1708: uint16(71),
	1709: uint16(39),
	1710: uint16(135),
	1711: uint16(231),
	1712: uint16(135),
	1713: uint16(135),
	1714: uint16(39),
	1715: uint16(327),
	1716: uint16(551),
	1717: uint16(103),
	1718: uint16(167),
	1719: uint16(551),
	1720: uint16(89),
	1721: uint16(1434),
	1722: uint16(3226),
	1723: uint16(506),
	1724: uint16(474),
	1725: uint16(506),
	1726: uint16(506),
	1727: uint16(367),
	1728: uint16(1018),
	1729: uint16(1946),
	1730: uint16(1402),
	1731: uint16(954),
	1732: uint16(1402),
	1733: uint16(314),
	1734: uint16(90),
	1735: uint16(1082),
	1736: uint16(218),
	1737: uint16(2266),
	1738: uint16(666),
	1739: uint16(1210),
	1740: uint16(186),
	1741: uint16(570),
	1742: uint16(2042),
	1743: uint16(58),
	1744: uint16(5850),
	1745: uint16(154),
	1746: uint16(2010),
	1747: uint16(154),
	1748: uint16(794),
	1749: uint16(2266),
	1750: uint16(378),
	1751: uint16(2266),
	1752: uint16(3738),
	1753: uint16(39),
	1754: uint16(39),
	1755: uint16(39),
	1756: uint16(39),
	1757: uint16(39),
	1758: uint16(39),
	1759: uint16(17351),
	1760: uint16(34),
	1761: uint16(3074),
	1762: uint16(7692),
	1763: uint16(63),
	1764: uint16(63),
}

var _aFts5UnicodeMap = [1765]Tu16{
	1:    uint16(32),
	2:    uint16(33),
	3:    uint16(36),
	4:    uint16(37),
	5:    uint16(40),
	6:    uint16(41),
	7:    uint16(42),
	8:    uint16(43),
	9:    uint16(44),
	10:   uint16(45),
	11:   uint16(46),
	12:   uint16(48),
	13:   uint16(58),
	14:   uint16(60),
	15:   uint16(63),
	16:   uint16(65),
	17:   uint16(91),
	18:   uint16(92),
	19:   uint16(93),
	20:   uint16(94),
	21:   uint16(95),
	22:   uint16(96),
	23:   uint16(97),
	24:   uint16(123),
	25:   uint16(124),
	26:   uint16(125),
	27:   uint16(126),
	28:   uint16(127),
	29:   uint16(160),
	30:   uint16(161),
	31:   uint16(162),
	32:   uint16(166),
	33:   uint16(167),
	34:   uint16(168),
	35:   uint16(169),
	36:   uint16(170),
	37:   uint16(171),
	38:   uint16(172),
	39:   uint16(173),
	40:   uint16(174),
	41:   uint16(175),
	42:   uint16(176),
	43:   uint16(177),
	44:   uint16(178),
	45:   uint16(180),
	46:   uint16(181),
	47:   uint16(182),
	48:   uint16(184),
	49:   uint16(185),
	50:   uint16(186),
	51:   uint16(187),
	52:   uint16(188),
	53:   uint16(191),
	54:   uint16(192),
	55:   uint16(215),
	56:   uint16(216),
	57:   uint16(223),
	58:   uint16(247),
	59:   uint16(248),
	60:   uint16(256),
	61:   uint16(312),
	62:   uint16(313),
	63:   uint16(329),
	64:   uint16(330),
	65:   uint16(377),
	66:   uint16(383),
	67:   uint16(385),
	68:   uint16(387),
	69:   uint16(388),
	70:   uint16(391),
	71:   uint16(394),
	72:   uint16(396),
	73:   uint16(398),
	74:   uint16(402),
	75:   uint16(403),
	76:   uint16(405),
	77:   uint16(406),
	78:   uint16(409),
	79:   uint16(412),
	80:   uint16(414),
	81:   uint16(415),
	82:   uint16(417),
	83:   uint16(418),
	84:   uint16(423),
	85:   uint16(427),
	86:   uint16(428),
	87:   uint16(431),
	88:   uint16(434),
	89:   uint16(436),
	90:   uint16(437),
	91:   uint16(440),
	92:   uint16(442),
	93:   uint16(443),
	94:   uint16(444),
	95:   uint16(446),
	96:   uint16(448),
	97:   uint16(452),
	98:   uint16(453),
	99:   uint16(454),
	100:  uint16(455),
	101:  uint16(456),
	102:  uint16(457),
	103:  uint16(458),
	104:  uint16(459),
	105:  uint16(460),
	106:  uint16(461),
	107:  uint16(477),
	108:  uint16(478),
	109:  uint16(496),
	110:  uint16(497),
	111:  uint16(498),
	112:  uint16(499),
	113:  uint16(500),
	114:  uint16(503),
	115:  uint16(505),
	116:  uint16(506),
	117:  uint16(564),
	118:  uint16(570),
	119:  uint16(572),
	120:  uint16(573),
	121:  uint16(575),
	122:  uint16(577),
	123:  uint16(580),
	124:  uint16(583),
	125:  uint16(584),
	126:  uint16(592),
	127:  uint16(660),
	128:  uint16(661),
	129:  uint16(688),
	130:  uint16(706),
	131:  uint16(710),
	132:  uint16(722),
	133:  uint16(736),
	134:  uint16(741),
	135:  uint16(748),
	136:  uint16(749),
	137:  uint16(750),
	138:  uint16(751),
	139:  uint16(768),
	140:  uint16(880),
	141:  uint16(884),
	142:  uint16(885),
	143:  uint16(886),
	144:  uint16(890),
	145:  uint16(891),
	146:  uint16(894),
	147:  uint16(900),
	148:  uint16(902),
	149:  uint16(903),
	150:  uint16(904),
	151:  uint16(908),
	152:  uint16(910),
	153:  uint16(912),
	154:  uint16(913),
	155:  uint16(931),
	156:  uint16(940),
	157:  uint16(975),
	158:  uint16(977),
	159:  uint16(978),
	160:  uint16(981),
	161:  uint16(984),
	162:  uint16(1008),
	163:  uint16(1012),
	164:  uint16(1014),
	165:  uint16(1015),
	166:  uint16(1018),
	167:  uint16(1020),
	168:  uint16(1021),
	169:  uint16(1072),
	170:  uint16(1120),
	171:  uint16(1154),
	172:  uint16(1155),
	173:  uint16(1160),
	174:  uint16(1162),
	175:  uint16(1217),
	176:  uint16(1231),
	177:  uint16(1232),
	178:  uint16(1329),
	179:  uint16(1369),
	180:  uint16(1370),
	181:  uint16(1377),
	182:  uint16(1417),
	183:  uint16(1418),
	184:  uint16(1423),
	185:  uint16(1425),
	186:  uint16(1470),
	187:  uint16(1471),
	188:  uint16(1472),
	189:  uint16(1473),
	190:  uint16(1475),
	191:  uint16(1476),
	192:  uint16(1478),
	193:  uint16(1479),
	194:  uint16(1488),
	195:  uint16(1520),
	196:  uint16(1523),
	197:  uint16(1536),
	198:  uint16(1542),
	199:  uint16(1545),
	200:  uint16(1547),
	201:  uint16(1548),
	202:  uint16(1550),
	203:  uint16(1552),
	204:  uint16(1563),
	205:  uint16(1566),
	206:  uint16(1568),
	207:  uint16(1600),
	208:  uint16(1601),
	209:  uint16(1611),
	210:  uint16(1632),
	211:  uint16(1642),
	212:  uint16(1646),
	213:  uint16(1648),
	214:  uint16(1649),
	215:  uint16(1748),
	216:  uint16(1749),
	217:  uint16(1750),
	218:  uint16(1757),
	219:  uint16(1758),
	220:  uint16(1759),
	221:  uint16(1765),
	222:  uint16(1767),
	223:  uint16(1769),
	224:  uint16(1770),
	225:  uint16(1774),
	226:  uint16(1776),
	227:  uint16(1786),
	228:  uint16(1789),
	229:  uint16(1791),
	230:  uint16(1792),
	231:  uint16(1807),
	232:  uint16(1808),
	233:  uint16(1809),
	234:  uint16(1810),
	235:  uint16(1840),
	236:  uint16(1869),
	237:  uint16(1958),
	238:  uint16(1969),
	239:  uint16(1984),
	240:  uint16(1994),
	241:  uint16(2027),
	242:  uint16(2036),
	243:  uint16(2038),
	244:  uint16(2039),
	245:  uint16(2042),
	246:  uint16(2048),
	247:  uint16(2070),
	248:  uint16(2074),
	249:  uint16(2075),
	250:  uint16(2084),
	251:  uint16(2085),
	252:  uint16(2088),
	253:  uint16(2089),
	254:  uint16(2096),
	255:  uint16(2112),
	256:  uint16(2137),
	257:  uint16(2142),
	258:  uint16(2208),
	259:  uint16(2210),
	260:  uint16(2276),
	261:  uint16(2304),
	262:  uint16(2307),
	263:  uint16(2308),
	264:  uint16(2362),
	265:  uint16(2363),
	266:  uint16(2364),
	267:  uint16(2365),
	268:  uint16(2366),
	269:  uint16(2369),
	270:  uint16(2377),
	271:  uint16(2381),
	272:  uint16(2382),
	273:  uint16(2384),
	274:  uint16(2385),
	275:  uint16(2392),
	276:  uint16(2402),
	277:  uint16(2404),
	278:  uint16(2406),
	279:  uint16(2416),
	280:  uint16(2417),
	281:  uint16(2418),
	282:  uint16(2425),
	283:  uint16(2433),
	284:  uint16(2434),
	285:  uint16(2437),
	286:  uint16(2447),
	287:  uint16(2451),
	288:  uint16(2474),
	289:  uint16(2482),
	290:  uint16(2486),
	291:  uint16(2492),
	292:  uint16(2493),
	293:  uint16(2494),
	294:  uint16(2497),
	295:  uint16(2503),
	296:  uint16(2507),
	297:  uint16(2509),
	298:  uint16(2510),
	299:  uint16(2519),
	300:  uint16(2524),
	301:  uint16(2527),
	302:  uint16(2530),
	303:  uint16(2534),
	304:  uint16(2544),
	305:  uint16(2546),
	306:  uint16(2548),
	307:  uint16(2554),
	308:  uint16(2555),
	309:  uint16(2561),
	310:  uint16(2563),
	311:  uint16(2565),
	312:  uint16(2575),
	313:  uint16(2579),
	314:  uint16(2602),
	315:  uint16(2610),
	316:  uint16(2613),
	317:  uint16(2616),
	318:  uint16(2620),
	319:  uint16(2622),
	320:  uint16(2625),
	321:  uint16(2631),
	322:  uint16(2635),
	323:  uint16(2641),
	324:  uint16(2649),
	325:  uint16(2654),
	326:  uint16(2662),
	327:  uint16(2672),
	328:  uint16(2674),
	329:  uint16(2677),
	330:  uint16(2689),
	331:  uint16(2691),
	332:  uint16(2693),
	333:  uint16(2703),
	334:  uint16(2707),
	335:  uint16(2730),
	336:  uint16(2738),
	337:  uint16(2741),
	338:  uint16(2748),
	339:  uint16(2749),
	340:  uint16(2750),
	341:  uint16(2753),
	342:  uint16(2759),
	343:  uint16(2761),
	344:  uint16(2763),
	345:  uint16(2765),
	346:  uint16(2768),
	347:  uint16(2784),
	348:  uint16(2786),
	349:  uint16(2790),
	350:  uint16(2800),
	351:  uint16(2801),
	352:  uint16(2817),
	353:  uint16(2818),
	354:  uint16(2821),
	355:  uint16(2831),
	356:  uint16(2835),
	357:  uint16(2858),
	358:  uint16(2866),
	359:  uint16(2869),
	360:  uint16(2876),
	361:  uint16(2877),
	362:  uint16(2878),
	363:  uint16(2879),
	364:  uint16(2880),
	365:  uint16(2881),
	366:  uint16(2887),
	367:  uint16(2891),
	368:  uint16(2893),
	369:  uint16(2902),
	370:  uint16(2903),
	371:  uint16(2908),
	372:  uint16(2911),
	373:  uint16(2914),
	374:  uint16(2918),
	375:  uint16(2928),
	376:  uint16(2929),
	377:  uint16(2930),
	378:  uint16(2946),
	379:  uint16(2947),
	380:  uint16(2949),
	381:  uint16(2958),
	382:  uint16(2962),
	383:  uint16(2969),
	384:  uint16(2972),
	385:  uint16(2974),
	386:  uint16(2979),
	387:  uint16(2984),
	388:  uint16(2990),
	389:  uint16(3006),
	390:  uint16(3008),
	391:  uint16(3009),
	392:  uint16(3014),
	393:  uint16(3018),
	394:  uint16(3021),
	395:  uint16(3024),
	396:  uint16(3031),
	397:  uint16(3046),
	398:  uint16(3056),
	399:  uint16(3059),
	400:  uint16(3065),
	401:  uint16(3066),
	402:  uint16(3073),
	403:  uint16(3077),
	404:  uint16(3086),
	405:  uint16(3090),
	406:  uint16(3114),
	407:  uint16(3125),
	408:  uint16(3133),
	409:  uint16(3134),
	410:  uint16(3137),
	411:  uint16(3142),
	412:  uint16(3146),
	413:  uint16(3157),
	414:  uint16(3160),
	415:  uint16(3168),
	416:  uint16(3170),
	417:  uint16(3174),
	418:  uint16(3192),
	419:  uint16(3199),
	420:  uint16(3202),
	421:  uint16(3205),
	422:  uint16(3214),
	423:  uint16(3218),
	424:  uint16(3242),
	425:  uint16(3253),
	426:  uint16(3260),
	427:  uint16(3261),
	428:  uint16(3262),
	429:  uint16(3263),
	430:  uint16(3264),
	431:  uint16(3270),
	432:  uint16(3271),
	433:  uint16(3274),
	434:  uint16(3276),
	435:  uint16(3285),
	436:  uint16(3294),
	437:  uint16(3296),
	438:  uint16(3298),
	439:  uint16(3302),
	440:  uint16(3313),
	441:  uint16(3330),
	442:  uint16(3333),
	443:  uint16(3342),
	444:  uint16(3346),
	445:  uint16(3389),
	446:  uint16(3390),
	447:  uint16(3393),
	448:  uint16(3398),
	449:  uint16(3402),
	450:  uint16(3405),
	451:  uint16(3406),
	452:  uint16(3415),
	453:  uint16(3424),
	454:  uint16(3426),
	455:  uint16(3430),
	456:  uint16(3440),
	457:  uint16(3449),
	458:  uint16(3450),
	459:  uint16(3458),
	460:  uint16(3461),
	461:  uint16(3482),
	462:  uint16(3507),
	463:  uint16(3517),
	464:  uint16(3520),
	465:  uint16(3530),
	466:  uint16(3535),
	467:  uint16(3538),
	468:  uint16(3542),
	469:  uint16(3544),
	470:  uint16(3570),
	471:  uint16(3572),
	472:  uint16(3585),
	473:  uint16(3633),
	474:  uint16(3634),
	475:  uint16(3636),
	476:  uint16(3647),
	477:  uint16(3648),
	478:  uint16(3654),
	479:  uint16(3655),
	480:  uint16(3663),
	481:  uint16(3664),
	482:  uint16(3674),
	483:  uint16(3713),
	484:  uint16(3716),
	485:  uint16(3719),
	486:  uint16(3722),
	487:  uint16(3725),
	488:  uint16(3732),
	489:  uint16(3737),
	490:  uint16(3745),
	491:  uint16(3749),
	492:  uint16(3751),
	493:  uint16(3754),
	494:  uint16(3757),
	495:  uint16(3761),
	496:  uint16(3762),
	497:  uint16(3764),
	498:  uint16(3771),
	499:  uint16(3773),
	500:  uint16(3776),
	501:  uint16(3782),
	502:  uint16(3784),
	503:  uint16(3792),
	504:  uint16(3804),
	505:  uint16(3840),
	506:  uint16(3841),
	507:  uint16(3844),
	508:  uint16(3859),
	509:  uint16(3860),
	510:  uint16(3861),
	511:  uint16(3864),
	512:  uint16(3866),
	513:  uint16(3872),
	514:  uint16(3882),
	515:  uint16(3892),
	516:  uint16(3893),
	517:  uint16(3894),
	518:  uint16(3895),
	519:  uint16(3896),
	520:  uint16(3897),
	521:  uint16(3898),
	522:  uint16(3899),
	523:  uint16(3900),
	524:  uint16(3901),
	525:  uint16(3902),
	526:  uint16(3904),
	527:  uint16(3913),
	528:  uint16(3953),
	529:  uint16(3967),
	530:  uint16(3968),
	531:  uint16(3973),
	532:  uint16(3974),
	533:  uint16(3976),
	534:  uint16(3981),
	535:  uint16(3993),
	536:  uint16(4030),
	537:  uint16(4038),
	538:  uint16(4039),
	539:  uint16(4046),
	540:  uint16(4048),
	541:  uint16(4053),
	542:  uint16(4057),
	543:  uint16(4096),
	544:  uint16(4139),
	545:  uint16(4141),
	546:  uint16(4145),
	547:  uint16(4146),
	548:  uint16(4152),
	549:  uint16(4153),
	550:  uint16(4155),
	551:  uint16(4157),
	552:  uint16(4159),
	553:  uint16(4160),
	554:  uint16(4170),
	555:  uint16(4176),
	556:  uint16(4182),
	557:  uint16(4184),
	558:  uint16(4186),
	559:  uint16(4190),
	560:  uint16(4193),
	561:  uint16(4194),
	562:  uint16(4197),
	563:  uint16(4199),
	564:  uint16(4206),
	565:  uint16(4209),
	566:  uint16(4213),
	567:  uint16(4226),
	568:  uint16(4227),
	569:  uint16(4229),
	570:  uint16(4231),
	571:  uint16(4237),
	572:  uint16(4238),
	573:  uint16(4239),
	574:  uint16(4240),
	575:  uint16(4250),
	576:  uint16(4253),
	577:  uint16(4254),
	578:  uint16(4256),
	579:  uint16(4295),
	580:  uint16(4301),
	581:  uint16(4304),
	582:  uint16(4347),
	583:  uint16(4348),
	584:  uint16(4349),
	585:  uint16(4682),
	586:  uint16(4688),
	587:  uint16(4696),
	588:  uint16(4698),
	589:  uint16(4704),
	590:  uint16(4746),
	591:  uint16(4752),
	592:  uint16(4786),
	593:  uint16(4792),
	594:  uint16(4800),
	595:  uint16(4802),
	596:  uint16(4808),
	597:  uint16(4824),
	598:  uint16(4882),
	599:  uint16(4888),
	600:  uint16(4957),
	601:  uint16(4960),
	602:  uint16(4969),
	603:  uint16(4992),
	604:  uint16(5008),
	605:  uint16(5024),
	606:  uint16(5120),
	607:  uint16(5121),
	608:  uint16(5741),
	609:  uint16(5743),
	610:  uint16(5760),
	611:  uint16(5761),
	612:  uint16(5787),
	613:  uint16(5788),
	614:  uint16(5792),
	615:  uint16(5867),
	616:  uint16(5870),
	617:  uint16(5888),
	618:  uint16(5902),
	619:  uint16(5906),
	620:  uint16(5920),
	621:  uint16(5938),
	622:  uint16(5941),
	623:  uint16(5952),
	624:  uint16(5970),
	625:  uint16(5984),
	626:  uint16(5998),
	627:  uint16(6002),
	628:  uint16(6016),
	629:  uint16(6068),
	630:  uint16(6070),
	631:  uint16(6071),
	632:  uint16(6078),
	633:  uint16(6086),
	634:  uint16(6087),
	635:  uint16(6089),
	636:  uint16(6100),
	637:  uint16(6103),
	638:  uint16(6104),
	639:  uint16(6107),
	640:  uint16(6108),
	641:  uint16(6109),
	642:  uint16(6112),
	643:  uint16(6128),
	644:  uint16(6144),
	645:  uint16(6150),
	646:  uint16(6151),
	647:  uint16(6155),
	648:  uint16(6158),
	649:  uint16(6160),
	650:  uint16(6176),
	651:  uint16(6211),
	652:  uint16(6212),
	653:  uint16(6272),
	654:  uint16(6313),
	655:  uint16(6314),
	656:  uint16(6320),
	657:  uint16(6400),
	658:  uint16(6432),
	659:  uint16(6435),
	660:  uint16(6439),
	661:  uint16(6441),
	662:  uint16(6448),
	663:  uint16(6450),
	664:  uint16(6451),
	665:  uint16(6457),
	666:  uint16(6464),
	667:  uint16(6468),
	668:  uint16(6470),
	669:  uint16(6480),
	670:  uint16(6512),
	671:  uint16(6528),
	672:  uint16(6576),
	673:  uint16(6593),
	674:  uint16(6600),
	675:  uint16(6608),
	676:  uint16(6618),
	677:  uint16(6622),
	678:  uint16(6656),
	679:  uint16(6679),
	680:  uint16(6681),
	681:  uint16(6686),
	682:  uint16(6688),
	683:  uint16(6741),
	684:  uint16(6742),
	685:  uint16(6743),
	686:  uint16(6744),
	687:  uint16(6752),
	688:  uint16(6753),
	689:  uint16(6754),
	690:  uint16(6755),
	691:  uint16(6757),
	692:  uint16(6765),
	693:  uint16(6771),
	694:  uint16(6783),
	695:  uint16(6784),
	696:  uint16(6800),
	697:  uint16(6816),
	698:  uint16(6823),
	699:  uint16(6824),
	700:  uint16(6912),
	701:  uint16(6916),
	702:  uint16(6917),
	703:  uint16(6964),
	704:  uint16(6965),
	705:  uint16(6966),
	706:  uint16(6971),
	707:  uint16(6972),
	708:  uint16(6973),
	709:  uint16(6978),
	710:  uint16(6979),
	711:  uint16(6981),
	712:  uint16(6992),
	713:  uint16(7002),
	714:  uint16(7009),
	715:  uint16(7019),
	716:  uint16(7028),
	717:  uint16(7040),
	718:  uint16(7042),
	719:  uint16(7043),
	720:  uint16(7073),
	721:  uint16(7074),
	722:  uint16(7078),
	723:  uint16(7080),
	724:  uint16(7082),
	725:  uint16(7083),
	726:  uint16(7084),
	727:  uint16(7086),
	728:  uint16(7088),
	729:  uint16(7098),
	730:  uint16(7142),
	731:  uint16(7143),
	732:  uint16(7144),
	733:  uint16(7146),
	734:  uint16(7149),
	735:  uint16(7150),
	736:  uint16(7151),
	737:  uint16(7154),
	738:  uint16(7164),
	739:  uint16(7168),
	740:  uint16(7204),
	741:  uint16(7212),
	742:  uint16(7220),
	743:  uint16(7222),
	744:  uint16(7227),
	745:  uint16(7232),
	746:  uint16(7245),
	747:  uint16(7248),
	748:  uint16(7258),
	749:  uint16(7288),
	750:  uint16(7294),
	751:  uint16(7360),
	752:  uint16(7376),
	753:  uint16(7379),
	754:  uint16(7380),
	755:  uint16(7393),
	756:  uint16(7394),
	757:  uint16(7401),
	758:  uint16(7405),
	759:  uint16(7406),
	760:  uint16(7410),
	761:  uint16(7412),
	762:  uint16(7413),
	763:  uint16(7424),
	764:  uint16(7468),
	765:  uint16(7531),
	766:  uint16(7544),
	767:  uint16(7545),
	768:  uint16(7579),
	769:  uint16(7616),
	770:  uint16(7676),
	771:  uint16(7680),
	772:  uint16(7830),
	773:  uint16(7838),
	774:  uint16(7936),
	775:  uint16(7944),
	776:  uint16(7952),
	777:  uint16(7960),
	778:  uint16(7968),
	779:  uint16(7976),
	780:  uint16(7984),
	781:  uint16(7992),
	782:  uint16(8000),
	783:  uint16(8008),
	784:  uint16(8016),
	785:  uint16(8025),
	786:  uint16(8027),
	787:  uint16(8029),
	788:  uint16(8031),
	789:  uint16(8033),
	790:  uint16(8040),
	791:  uint16(8048),
	792:  uint16(8064),
	793:  uint16(8072),
	794:  uint16(8080),
	795:  uint16(8088),
	796:  uint16(8096),
	797:  uint16(8104),
	798:  uint16(8112),
	799:  uint16(8118),
	800:  uint16(8120),
	801:  uint16(8124),
	802:  uint16(8125),
	803:  uint16(8126),
	804:  uint16(8127),
	805:  uint16(8130),
	806:  uint16(8134),
	807:  uint16(8136),
	808:  uint16(8140),
	809:  uint16(8141),
	810:  uint16(8144),
	811:  uint16(8150),
	812:  uint16(8152),
	813:  uint16(8157),
	814:  uint16(8160),
	815:  uint16(8168),
	816:  uint16(8173),
	817:  uint16(8178),
	818:  uint16(8182),
	819:  uint16(8184),
	820:  uint16(8188),
	821:  uint16(8189),
	822:  uint16(8192),
	823:  uint16(8203),
	824:  uint16(8208),
	825:  uint16(8214),
	826:  uint16(8216),
	827:  uint16(8217),
	828:  uint16(8218),
	829:  uint16(8219),
	830:  uint16(8221),
	831:  uint16(8222),
	832:  uint16(8223),
	833:  uint16(8224),
	834:  uint16(8232),
	835:  uint16(8233),
	836:  uint16(8234),
	837:  uint16(8239),
	838:  uint16(8240),
	839:  uint16(8249),
	840:  uint16(8250),
	841:  uint16(8251),
	842:  uint16(8255),
	843:  uint16(8257),
	844:  uint16(8260),
	845:  uint16(8261),
	846:  uint16(8262),
	847:  uint16(8263),
	848:  uint16(8274),
	849:  uint16(8275),
	850:  uint16(8276),
	851:  uint16(8277),
	852:  uint16(8287),
	853:  uint16(8288),
	854:  uint16(8298),
	855:  uint16(8304),
	856:  uint16(8305),
	857:  uint16(8308),
	858:  uint16(8314),
	859:  uint16(8317),
	860:  uint16(8318),
	861:  uint16(8319),
	862:  uint16(8320),
	863:  uint16(8330),
	864:  uint16(8333),
	865:  uint16(8334),
	866:  uint16(8336),
	867:  uint16(8352),
	868:  uint16(8400),
	869:  uint16(8413),
	870:  uint16(8417),
	871:  uint16(8418),
	872:  uint16(8421),
	873:  uint16(8448),
	874:  uint16(8450),
	875:  uint16(8451),
	876:  uint16(8455),
	877:  uint16(8456),
	878:  uint16(8458),
	879:  uint16(8459),
	880:  uint16(8462),
	881:  uint16(8464),
	882:  uint16(8467),
	883:  uint16(8468),
	884:  uint16(8469),
	885:  uint16(8470),
	886:  uint16(8472),
	887:  uint16(8473),
	888:  uint16(8478),
	889:  uint16(8484),
	890:  uint16(8485),
	891:  uint16(8486),
	892:  uint16(8487),
	893:  uint16(8488),
	894:  uint16(8489),
	895:  uint16(8490),
	896:  uint16(8494),
	897:  uint16(8495),
	898:  uint16(8496),
	899:  uint16(8500),
	900:  uint16(8501),
	901:  uint16(8505),
	902:  uint16(8506),
	903:  uint16(8508),
	904:  uint16(8510),
	905:  uint16(8512),
	906:  uint16(8517),
	907:  uint16(8519),
	908:  uint16(8522),
	909:  uint16(8523),
	910:  uint16(8524),
	911:  uint16(8526),
	912:  uint16(8527),
	913:  uint16(8528),
	914:  uint16(8544),
	915:  uint16(8579),
	916:  uint16(8581),
	917:  uint16(8585),
	918:  uint16(8592),
	919:  uint16(8597),
	920:  uint16(8602),
	921:  uint16(8604),
	922:  uint16(8608),
	923:  uint16(8609),
	924:  uint16(8611),
	925:  uint16(8612),
	926:  uint16(8614),
	927:  uint16(8615),
	928:  uint16(8622),
	929:  uint16(8623),
	930:  uint16(8654),
	931:  uint16(8656),
	932:  uint16(8658),
	933:  uint16(8659),
	934:  uint16(8660),
	935:  uint16(8661),
	936:  uint16(8692),
	937:  uint16(8960),
	938:  uint16(8968),
	939:  uint16(8972),
	940:  uint16(8992),
	941:  uint16(8994),
	942:  uint16(9001),
	943:  uint16(9002),
	944:  uint16(9003),
	945:  uint16(9084),
	946:  uint16(9085),
	947:  uint16(9115),
	948:  uint16(9140),
	949:  uint16(9180),
	950:  uint16(9186),
	951:  uint16(9216),
	952:  uint16(9280),
	953:  uint16(9312),
	954:  uint16(9372),
	955:  uint16(9450),
	956:  uint16(9472),
	957:  uint16(9655),
	958:  uint16(9656),
	959:  uint16(9665),
	960:  uint16(9666),
	961:  uint16(9720),
	962:  uint16(9728),
	963:  uint16(9839),
	964:  uint16(9840),
	965:  uint16(9985),
	966:  uint16(10088),
	967:  uint16(10089),
	968:  uint16(10090),
	969:  uint16(10091),
	970:  uint16(10092),
	971:  uint16(10093),
	972:  uint16(10094),
	973:  uint16(10095),
	974:  uint16(10096),
	975:  uint16(10097),
	976:  uint16(10098),
	977:  uint16(10099),
	978:  uint16(10100),
	979:  uint16(10101),
	980:  uint16(10102),
	981:  uint16(10132),
	982:  uint16(10176),
	983:  uint16(10181),
	984:  uint16(10182),
	985:  uint16(10183),
	986:  uint16(10214),
	987:  uint16(10215),
	988:  uint16(10216),
	989:  uint16(10217),
	990:  uint16(10218),
	991:  uint16(10219),
	992:  uint16(10220),
	993:  uint16(10221),
	994:  uint16(10222),
	995:  uint16(10223),
	996:  uint16(10224),
	997:  uint16(10240),
	998:  uint16(10496),
	999:  uint16(10627),
	1000: uint16(10628),
	1001: uint16(10629),
	1002: uint16(10630),
	1003: uint16(10631),
	1004: uint16(10632),
	1005: uint16(10633),
	1006: uint16(10634),
	1007: uint16(10635),
	1008: uint16(10636),
	1009: uint16(10637),
	1010: uint16(10638),
	1011: uint16(10639),
	1012: uint16(10640),
	1013: uint16(10641),
	1014: uint16(10642),
	1015: uint16(10643),
	1016: uint16(10644),
	1017: uint16(10645),
	1018: uint16(10646),
	1019: uint16(10647),
	1020: uint16(10648),
	1021: uint16(10649),
	1022: uint16(10712),
	1023: uint16(10713),
	1024: uint16(10714),
	1025: uint16(10715),
	1026: uint16(10716),
	1027: uint16(10748),
	1028: uint16(10749),
	1029: uint16(10750),
	1030: uint16(11008),
	1031: uint16(11056),
	1032: uint16(11077),
	1033: uint16(11079),
	1034: uint16(11088),
	1035: uint16(11264),
	1036: uint16(11312),
	1037: uint16(11360),
	1038: uint16(11363),
	1039: uint16(11365),
	1040: uint16(11367),
	1041: uint16(11374),
	1042: uint16(11377),
	1043: uint16(11378),
	1044: uint16(11380),
	1045: uint16(11381),
	1046: uint16(11383),
	1047: uint16(11388),
	1048: uint16(11390),
	1049: uint16(11393),
	1050: uint16(11394),
	1051: uint16(11492),
	1052: uint16(11493),
	1053: uint16(11499),
	1054: uint16(11503),
	1055: uint16(11506),
	1056: uint16(11513),
	1057: uint16(11517),
	1058: uint16(11518),
	1059: uint16(11520),
	1060: uint16(11559),
	1061: uint16(11565),
	1062: uint16(11568),
	1063: uint16(11631),
	1064: uint16(11632),
	1065: uint16(11647),
	1066: uint16(11648),
	1067: uint16(11680),
	1068: uint16(11688),
	1069: uint16(11696),
	1070: uint16(11704),
	1071: uint16(11712),
	1072: uint16(11720),
	1073: uint16(11728),
	1074: uint16(11736),
	1075: uint16(11744),
	1076: uint16(11776),
	1077: uint16(11778),
	1078: uint16(11779),
	1079: uint16(11780),
	1080: uint16(11781),
	1081: uint16(11782),
	1082: uint16(11785),
	1083: uint16(11786),
	1084: uint16(11787),
	1085: uint16(11788),
	1086: uint16(11789),
	1087: uint16(11790),
	1088: uint16(11799),
	1089: uint16(11800),
	1090: uint16(11802),
	1091: uint16(11803),
	1092: uint16(11804),
	1093: uint16(11805),
	1094: uint16(11806),
	1095: uint16(11808),
	1096: uint16(11809),
	1097: uint16(11810),
	1098: uint16(11811),
	1099: uint16(11812),
	1100: uint16(11813),
	1101: uint16(11814),
	1102: uint16(11815),
	1103: uint16(11816),
	1104: uint16(11817),
	1105: uint16(11818),
	1106: uint16(11823),
	1107: uint16(11824),
	1108: uint16(11834),
	1109: uint16(11904),
	1110: uint16(11931),
	1111: uint16(12032),
	1112: uint16(12272),
	1113: uint16(12288),
	1114: uint16(12289),
	1115: uint16(12292),
	1116: uint16(12293),
	1117: uint16(12294),
	1118: uint16(12295),
	1119: uint16(12296),
	1120: uint16(12297),
	1121: uint16(12298),
	1122: uint16(12299),
	1123: uint16(12300),
	1124: uint16(12301),
	1125: uint16(12302),
	1126: uint16(12303),
	1127: uint16(12304),
	1128: uint16(12305),
	1129: uint16(12306),
	1130: uint16(12308),
	1131: uint16(12309),
	1132: uint16(12310),
	1133: uint16(12311),
	1134: uint16(12312),
	1135: uint16(12313),
	1136: uint16(12314),
	1137: uint16(12315),
	1138: uint16(12316),
	1139: uint16(12317),
	1140: uint16(12318),
	1141: uint16(12320),
	1142: uint16(12321),
	1143: uint16(12330),
	1144: uint16(12334),
	1145: uint16(12336),
	1146: uint16(12337),
	1147: uint16(12342),
	1148: uint16(12344),
	1149: uint16(12347),
	1150: uint16(12348),
	1151: uint16(12349),
	1152: uint16(12350),
	1153: uint16(12353),
	1154: uint16(12441),
	1155: uint16(12443),
	1156: uint16(12445),
	1157: uint16(12447),
	1158: uint16(12448),
	1159: uint16(12449),
	1160: uint16(12539),
	1161: uint16(12540),
	1162: uint16(12543),
	1163: uint16(12549),
	1164: uint16(12593),
	1165: uint16(12688),
	1166: uint16(12690),
	1167: uint16(12694),
	1168: uint16(12704),
	1169: uint16(12736),
	1170: uint16(12784),
	1171: uint16(12800),
	1172: uint16(12832),
	1173: uint16(12842),
	1174: uint16(12872),
	1175: uint16(12880),
	1176: uint16(12881),
	1177: uint16(12896),
	1178: uint16(12928),
	1179: uint16(12938),
	1180: uint16(12977),
	1181: uint16(12992),
	1182: uint16(13056),
	1183: uint16(13312),
	1184: uint16(19893),
	1185: uint16(19904),
	1186: uint16(19968),
	1187: uint16(40908),
	1188: uint16(40960),
	1189: uint16(40981),
	1190: uint16(40982),
	1191: uint16(42128),
	1192: uint16(42192),
	1193: uint16(42232),
	1194: uint16(42238),
	1195: uint16(42240),
	1196: uint16(42508),
	1197: uint16(42509),
	1198: uint16(42512),
	1199: uint16(42528),
	1200: uint16(42538),
	1201: uint16(42560),
	1202: uint16(42606),
	1203: uint16(42607),
	1204: uint16(42608),
	1205: uint16(42611),
	1206: uint16(42612),
	1207: uint16(42622),
	1208: uint16(42623),
	1209: uint16(42624),
	1210: uint16(42655),
	1211: uint16(42656),
	1212: uint16(42726),
	1213: uint16(42736),
	1214: uint16(42738),
	1215: uint16(42752),
	1216: uint16(42775),
	1217: uint16(42784),
	1218: uint16(42786),
	1219: uint16(42800),
	1220: uint16(42802),
	1221: uint16(42864),
	1222: uint16(42865),
	1223: uint16(42873),
	1224: uint16(42878),
	1225: uint16(42888),
	1226: uint16(42889),
	1227: uint16(42891),
	1228: uint16(42896),
	1229: uint16(42912),
	1230: uint16(43000),
	1231: uint16(43002),
	1232: uint16(43003),
	1233: uint16(43010),
	1234: uint16(43011),
	1235: uint16(43014),
	1236: uint16(43015),
	1237: uint16(43019),
	1238: uint16(43020),
	1239: uint16(43043),
	1240: uint16(43045),
	1241: uint16(43047),
	1242: uint16(43048),
	1243: uint16(43056),
	1244: uint16(43062),
	1245: uint16(43064),
	1246: uint16(43065),
	1247: uint16(43072),
	1248: uint16(43124),
	1249: uint16(43136),
	1250: uint16(43138),
	1251: uint16(43188),
	1252: uint16(43204),
	1253: uint16(43214),
	1254: uint16(43216),
	1255: uint16(43232),
	1256: uint16(43250),
	1257: uint16(43256),
	1258: uint16(43259),
	1259: uint16(43264),
	1260: uint16(43274),
	1261: uint16(43302),
	1262: uint16(43310),
	1263: uint16(43312),
	1264: uint16(43335),
	1265: uint16(43346),
	1266: uint16(43359),
	1267: uint16(43360),
	1268: uint16(43392),
	1269: uint16(43395),
	1270: uint16(43396),
	1271: uint16(43443),
	1272: uint16(43444),
	1273: uint16(43446),
	1274: uint16(43450),
	1275: uint16(43452),
	1276: uint16(43453),
	1277: uint16(43457),
	1278: uint16(43471),
	1279: uint16(43472),
	1280: uint16(43486),
	1281: uint16(43520),
	1282: uint16(43561),
	1283: uint16(43567),
	1284: uint16(43569),
	1285: uint16(43571),
	1286: uint16(43573),
	1287: uint16(43584),
	1288: uint16(43587),
	1289: uint16(43588),
	1290: uint16(43596),
	1291: uint16(43597),
	1292: uint16(43600),
	1293: uint16(43612),
	1294: uint16(43616),
	1295: uint16(43632),
	1296: uint16(43633),
	1297: uint16(43639),
	1298: uint16(43642),
	1299: uint16(43643),
	1300: uint16(43648),
	1301: uint16(43696),
	1302: uint16(43697),
	1303: uint16(43698),
	1304: uint16(43701),
	1305: uint16(43703),
	1306: uint16(43705),
	1307: uint16(43710),
	1308: uint16(43712),
	1309: uint16(43713),
	1310: uint16(43714),
	1311: uint16(43739),
	1312: uint16(43741),
	1313: uint16(43742),
	1314: uint16(43744),
	1315: uint16(43755),
	1316: uint16(43756),
	1317: uint16(43758),
	1318: uint16(43760),
	1319: uint16(43762),
	1320: uint16(43763),
	1321: uint16(43765),
	1322: uint16(43766),
	1323: uint16(43777),
	1324: uint16(43785),
	1325: uint16(43793),
	1326: uint16(43808),
	1327: uint16(43816),
	1328: uint16(43968),
	1329: uint16(44003),
	1330: uint16(44005),
	1331: uint16(44006),
	1332: uint16(44008),
	1333: uint16(44009),
	1334: uint16(44011),
	1335: uint16(44012),
	1336: uint16(44013),
	1337: uint16(44016),
	1338: uint16(44032),
	1339: uint16(55203),
	1340: uint16(55216),
	1341: uint16(55243),
	1342: uint16(55296),
	1343: uint16(56191),
	1344: uint16(56319),
	1345: uint16(57343),
	1346: uint16(57344),
	1347: uint16(63743),
	1348: uint16(63744),
	1349: uint16(64112),
	1350: uint16(64256),
	1351: uint16(64275),
	1352: uint16(64285),
	1353: uint16(64286),
	1354: uint16(64287),
	1355: uint16(64297),
	1356: uint16(64298),
	1357: uint16(64312),
	1358: uint16(64318),
	1359: uint16(64320),
	1360: uint16(64323),
	1361: uint16(64326),
	1362: uint16(64434),
	1363: uint16(64467),
	1364: uint16(64830),
	1365: uint16(64831),
	1366: uint16(64848),
	1367: uint16(64914),
	1368: uint16(65008),
	1369: uint16(65020),
	1370: uint16(65021),
	1371: uint16(65024),
	1372: uint16(65040),
	1373: uint16(65047),
	1374: uint16(65048),
	1375: uint16(65049),
	1376: uint16(65056),
	1377: uint16(65072),
	1378: uint16(65073),
	1379: uint16(65075),
	1380: uint16(65077),
	1381: uint16(65078),
	1382: uint16(65079),
	1383: uint16(65080),
	1384: uint16(65081),
	1385: uint16(65082),
	1386: uint16(65083),
	1387: uint16(65084),
	1388: uint16(65085),
	1389: uint16(65086),
	1390: uint16(65087),
	1391: uint16(65088),
	1392: uint16(65089),
	1393: uint16(65090),
	1394: uint16(65091),
	1395: uint16(65092),
	1396: uint16(65093),
	1397: uint16(65095),
	1398: uint16(65096),
	1399: uint16(65097),
	1400: uint16(65101),
	1401: uint16(65104),
	1402: uint16(65108),
	1403: uint16(65112),
	1404: uint16(65113),
	1405: uint16(65114),
	1406: uint16(65115),
	1407: uint16(65116),
	1408: uint16(65117),
	1409: uint16(65118),
	1410: uint16(65119),
	1411: uint16(65122),
	1412: uint16(65123),
	1413: uint16(65124),
	1414: uint16(65128),
	1415: uint16(65129),
	1416: uint16(65130),
	1417: uint16(65136),
	1418: uint16(65142),
	1419: uint16(65279),
	1420: uint16(65281),
	1421: uint16(65284),
	1422: uint16(65285),
	1423: uint16(65288),
	1424: uint16(65289),
	1425: uint16(65290),
	1426: uint16(65291),
	1427: uint16(65292),
	1428: uint16(65293),
	1429: uint16(65294),
	1430: uint16(65296),
	1431: uint16(65306),
	1432: uint16(65308),
	1433: uint16(65311),
	1434: uint16(65313),
	1435: uint16(65339),
	1436: uint16(65340),
	1437: uint16(65341),
	1438: uint16(65342),
	1439: uint16(65343),
	1440: uint16(65344),
	1441: uint16(65345),
	1442: uint16(65371),
	1443: uint16(65372),
	1444: uint16(65373),
	1445: uint16(65374),
	1446: uint16(65375),
	1447: uint16(65376),
	1448: uint16(65377),
	1449: uint16(65378),
	1450: uint16(65379),
	1451: uint16(65380),
	1452: uint16(65382),
	1453: uint16(65392),
	1454: uint16(65393),
	1455: uint16(65438),
	1456: uint16(65440),
	1457: uint16(65474),
	1458: uint16(65482),
	1459: uint16(65490),
	1460: uint16(65498),
	1461: uint16(65504),
	1462: uint16(65506),
	1463: uint16(65507),
	1464: uint16(65508),
	1465: uint16(65509),
	1466: uint16(65512),
	1467: uint16(65513),
	1468: uint16(65517),
	1469: uint16(65529),
	1470: uint16(65532),
	1472: uint16(13),
	1473: uint16(40),
	1474: uint16(60),
	1475: uint16(63),
	1476: uint16(80),
	1477: uint16(128),
	1478: uint16(256),
	1479: uint16(263),
	1480: uint16(311),
	1481: uint16(320),
	1482: uint16(373),
	1483: uint16(377),
	1484: uint16(394),
	1485: uint16(400),
	1486: uint16(464),
	1487: uint16(509),
	1488: uint16(640),
	1489: uint16(672),
	1490: uint16(768),
	1491: uint16(800),
	1492: uint16(816),
	1493: uint16(833),
	1494: uint16(834),
	1495: uint16(842),
	1496: uint16(896),
	1497: uint16(927),
	1498: uint16(928),
	1499: uint16(968),
	1500: uint16(976),
	1501: uint16(977),
	1502: uint16(1024),
	1503: uint16(1064),
	1504: uint16(1104),
	1505: uint16(1184),
	1506: uint16(2048),
	1507: uint16(2056),
	1508: uint16(2058),
	1509: uint16(2103),
	1510: uint16(2108),
	1511: uint16(2111),
	1512: uint16(2135),
	1513: uint16(2136),
	1514: uint16(2304),
	1515: uint16(2326),
	1516: uint16(2335),
	1517: uint16(2336),
	1518: uint16(2367),
	1519: uint16(2432),
	1520: uint16(2494),
	1521: uint16(2560),
	1522: uint16(2561),
	1523: uint16(2565),
	1524: uint16(2572),
	1525: uint16(2576),
	1526: uint16(2581),
	1527: uint16(2585),
	1528: uint16(2616),
	1529: uint16(2623),
	1530: uint16(2624),
	1531: uint16(2640),
	1532: uint16(2656),
	1533: uint16(2685),
	1534: uint16(2687),
	1535: uint16(2816),
	1536: uint16(2873),
	1537: uint16(2880),
	1538: uint16(2904),
	1539: uint16(2912),
	1540: uint16(2936),
	1541: uint16(3072),
	1542: uint16(3680),
	1543: uint16(4096),
	1544: uint16(4097),
	1545: uint16(4098),
	1546: uint16(4099),
	1547: uint16(4152),
	1548: uint16(4167),
	1549: uint16(4178),
	1550: uint16(4198),
	1551: uint16(4224),
	1552: uint16(4226),
	1553: uint16(4227),
	1554: uint16(4272),
	1555: uint16(4275),
	1556: uint16(4279),
	1557: uint16(4281),
	1558: uint16(4283),
	1559: uint16(4285),
	1560: uint16(4286),
	1561: uint16(4304),
	1562: uint16(4336),
	1563: uint16(4352),
	1564: uint16(4355),
	1565: uint16(4391),
	1566: uint16(4396),
	1567: uint16(4397),
	1568: uint16(4406),
	1569: uint16(4416),
	1570: uint16(4480),
	1571: uint16(4482),
	1572: uint16(4483),
	1573: uint16(4531),
	1574: uint16(4534),
	1575: uint16(4543),
	1576: uint16(4545),
	1577: uint16(4549),
	1578: uint16(4560),
	1579: uint16(5760),
	1580: uint16(5803),
	1581: uint16(5804),
	1582: uint16(5805),
	1583: uint16(5806),
	1584: uint16(5808),
	1585: uint16(5814),
	1586: uint16(5815),
	1587: uint16(5824),
	1588: uint16(8192),
	1589: uint16(9216),
	1590: uint16(9328),
	1591: uint16(12288),
	1592: uint16(26624),
	1593: uint16(28416),
	1594: uint16(28496),
	1595: uint16(28497),
	1596: uint16(28559),
	1597: uint16(28563),
	1598: uint16(45056),
	1599: uint16(53248),
	1600: uint16(53504),
	1601: uint16(53545),
	1602: uint16(53605),
	1603: uint16(53607),
	1604: uint16(53610),
	1605: uint16(53613),
	1606: uint16(53619),
	1607: uint16(53627),
	1608: uint16(53635),
	1609: uint16(53637),
	1610: uint16(53644),
	1611: uint16(53674),
	1612: uint16(53678),
	1613: uint16(53760),
	1614: uint16(53826),
	1615: uint16(53829),
	1616: uint16(54016),
	1617: uint16(54112),
	1618: uint16(54272),
	1619: uint16(54298),
	1620: uint16(54324),
	1621: uint16(54350),
	1622: uint16(54358),
	1623: uint16(54376),
	1624: uint16(54402),
	1625: uint16(54428),
	1626: uint16(54430),
	1627: uint16(54434),
	1628: uint16(54437),
	1629: uint16(54441),
	1630: uint16(54446),
	1631: uint16(54454),
	1632: uint16(54459),
	1633: uint16(54461),
	1634: uint16(54469),
	1635: uint16(54480),
	1636: uint16(54506),
	1637: uint16(54532),
	1638: uint16(54535),
	1639: uint16(54541),
	1640: uint16(54550),
	1641: uint16(54558),
	1642: uint16(54584),
	1643: uint16(54587),
	1644: uint16(54592),
	1645: uint16(54598),
	1646: uint16(54602),
	1647: uint16(54610),
	1648: uint16(54636),
	1649: uint16(54662),
	1650: uint16(54688),
	1651: uint16(54714),
	1652: uint16(54740),
	1653: uint16(54766),
	1654: uint16(54792),
	1655: uint16(54818),
	1656: uint16(54844),
	1657: uint16(54870),
	1658: uint16(54896),
	1659: uint16(54922),
	1660: uint16(54952),
	1661: uint16(54977),
	1662: uint16(54978),
	1663: uint16(55003),
	1664: uint16(55004),
	1665: uint16(55010),
	1666: uint16(55035),
	1667: uint16(55036),
	1668: uint16(55061),
	1669: uint16(55062),
	1670: uint16(55068),
	1671: uint16(55093),
	1672: uint16(55094),
	1673: uint16(55119),
	1674: uint16(55120),
	1675: uint16(55126),
	1676: uint16(55151),
	1677: uint16(55152),
	1678: uint16(55177),
	1679: uint16(55178),
	1680: uint16(55184),
	1681: uint16(55209),
	1682: uint16(55210),
	1683: uint16(55235),
	1684: uint16(55236),
	1685: uint16(55242),
	1686: uint16(55246),
	1687: uint16(60928),
	1688: uint16(60933),
	1689: uint16(60961),
	1690: uint16(60964),
	1691: uint16(60967),
	1692: uint16(60969),
	1693: uint16(60980),
	1694: uint16(60985),
	1695: uint16(60987),
	1696: uint16(60994),
	1697: uint16(60999),
	1698: uint16(61001),
	1699: uint16(61003),
	1700: uint16(61005),
	1701: uint16(61009),
	1702: uint16(61012),
	1703: uint16(61015),
	1704: uint16(61017),
	1705: uint16(61019),
	1706: uint16(61021),
	1707: uint16(61023),
	1708: uint16(61025),
	1709: uint16(61028),
	1710: uint16(61031),
	1711: uint16(61036),
	1712: uint16(61044),
	1713: uint16(61049),
	1714: uint16(61054),
	1715: uint16(61056),
	1716: uint16(61067),
	1717: uint16(61089),
	1718: uint16(61093),
	1719: uint16(61099),
	1720: uint16(61168),
	1721: uint16(61440),
	1722: uint16(61488),
	1723: uint16(61600),
	1724: uint16(61617),
	1725: uint16(61633),
	1726: uint16(61649),
	1727: uint16(61696),
	1728: uint16(61712),
	1729: uint16(61744),
	1730: uint16(61808),
	1731: uint16(61926),
	1732: uint16(61968),
	1733: uint16(62016),
	1734: uint16(62032),
	1735: uint16(62208),
	1736: uint16(62256),
	1737: uint16(62263),
	1738: uint16(62336),
	1739: uint16(62368),
	1740: uint16(62406),
	1741: uint16(62432),
	1742: uint16(62464),
	1743: uint16(62528),
	1744: uint16(62530),
	1745: uint16(62713),
	1746: uint16(62720),
	1747: uint16(62784),
	1748: uint16(62800),
	1749: uint16(62971),
	1750: uint16(63045),
	1751: uint16(63104),
	1752: uint16(63232),
	1754: uint16(42710),
	1755: uint16(42752),
	1756: uint16(46900),
	1757: uint16(46912),
	1758: uint16(47133),
	1759: uint16(63488),
	1760: uint16(1),
	1761: uint16(32),
	1762: uint16(256),
	1764: uint16(65533),
}

// C documentation
//
//	/*
//	** This array defines hard upper bounds on limit values.  The
//	** initializer must be kept in sync with the SQLITE_LIMIT_*
//	** #defines in sqlite3.h.
//	*/
var _aHardLimit = [13]int32{
	0:  int32(SQLITE_MAX_LENGTH),
	1:  int32(SQLITE_MAX_SQL_LENGTH),
	2:  int32(SQLITE_MAX_COLUMN),
	3:  int32(SQLITE_MAX_EXPR_DEPTH),
	4:  int32(SQLITE_MAX_COMPOUND_SELECT),
	5:  int32(SQLITE_MAX_VDBE_OP),
	6:  int32(SQLITE_MAX_FUNCTION_ARG),
	7:  int32(SQLITE_MAX_ATTACHED),
	8:  int32(SQLITE_MAX_LIKE_PATTERN_LENGTH),
	9:  int32(SQLITE_MAX_VARIABLE_NUMBER),
	10: int32(SQLITE_MAX_TRIGGER_DEPTH),
	11: int32(SQLITE_MAX_WORKER_THREADS),
	12: int32(SQLITE_MAX_PARSER_DEPTH),
}

/*
** Make sure the hard limits are set to reasonable values
 */

// C documentation
//
//	/*
//	** Journal files begin with the following magic string.  The data
//	** was obtained from /dev/random.  It is used only as a sanity check.
//	**
//	** Since version 2.8.0, the journal format contains additional sanity
//	** checking information.  If the power fails while the journal is being
//	** written, semi-random garbage data might appear in the journal
//	** file after power is restored.  If an attempt is then made
//	** to roll the journal back, the database could be corrupted.  The additional
//	** sanity checking data is an attempt to discover the garbage in the
//	** journal and ignore it.
//	**
//	** The sanity checking information for the new journal format consists
//	** of a 32-bit checksum on each page of data.  The checksum covers both
//	** the page number and the pPager->pageSize bytes of data for the page.
//	** This cksum is initialized to a 32-bit random value that appears in the
//	** journal file right after the header.  The random initializer is important,
//	** because garbage data that appears at the end of a journal is likely
//	** data that was once in other files that have now been deleted.  If the
//	** garbage data came from an obsolete journal file, the checksums might
//	** be correct.  But by initializing the checksum to random value which
//	** is different for every journal, we minimize that risk.
//	*/
var _aJournalMagic = [8]uint8{
	0: uint8(0xd9),
	1: uint8(0xd5),
	2: uint8(0x05),
	3: uint8(0xf9),
	4: uint8(0x20),
	5: uint8(0xa1),
	6: uint8(0x63),
	7: uint8(0xd7),
}

/*
** The size of the of each page record in the journal is given by
** the following macro.
 */

/*
** The journal header size for this pager. This is usually the same
** size as a single disk sector. See also setSectorSize().
 */

/*
** The macro MEMDB is true if we are dealing with an in-memory database.
** We do this as a macro so that if the SQLITE_OMIT_MEMORYDB macro is set,
** the value of MEMDB will be a constant and the compiler will optimize
** out code that would never execute.
 */

/*
** The macro USEFETCH is true if we are allowed to use the xFetch and xUnfetch
** interfaces to access the database using memory-mapped I/O.
 */

// C documentation
//
//	/* aKWCode[i] is the parser symbol code for the i-th keyword */
var _aKWCode = [148]uint8{
	1:   uint8(TK_REINDEX),
	2:   uint8(TK_INDEXED),
	3:   uint8(TK_INDEX),
	4:   uint8(TK_DESC),
	5:   uint8(TK_ESCAPE),
	6:   uint8(TK_EACH),
	7:   uint8(TK_CHECK),
	8:   uint8(TK_KEY),
	9:   uint8(TK_BEFORE),
	10:  uint8(TK_FOREIGN),
	11:  uint8(TK_FOR),
	12:  uint8(TK_IGNORE),
	13:  uint8(TK_LIKE_KW),
	14:  uint8(TK_EXPLAIN),
	15:  uint8(TK_INSTEAD),
	16:  uint8(TK_ADD),
	17:  uint8(TK_DATABASE),
	18:  uint8(TK_AS),
	19:  uint8(TK_SELECT),
	20:  uint8(TK_TABLE),
	21:  uint8(TK_JOIN_KW),
	22:  uint8(TK_THEN),
	23:  uint8(TK_END),
	24:  uint8(TK_DEFERRABLE),
	25:  uint8(TK_ELSE),
	26:  uint8(TK_EXCLUDE),
	27:  uint8(TK_DELETE),
	28:  uint8(TK_TEMP),
	29:  uint8(TK_TEMP),
	30:  uint8(TK_OR),
	31:  uint8(TK_ISNULL),
	32:  uint8(TK_NULLS),
	33:  uint8(TK_SAVEPOINT),
	34:  uint8(TK_INTERSECT),
	35:  uint8(TK_TIES),
	36:  uint8(TK_NOTNULL),
	37:  uint8(TK_NOT),
	38:  uint8(TK_NO),
	39:  uint8(TK_NULL),
	40:  uint8(TK_LIKE_KW),
	41:  uint8(TK_EXCEPT),
	42:  uint8(TK_TRANSACTION),
	43:  uint8(TK_ACTION),
	44:  uint8(TK_ON),
	45:  uint8(TK_JOIN_KW),
	46:  uint8(TK_ALTER),
	47:  uint8(TK_RAISE),
	48:  uint8(TK_EXCLUSIVE),
	49:  uint8(TK_EXISTS),
	50:  uint8(TK_CONSTRAINT),
	51:  uint8(TK_INTO),
	52:  uint8(TK_OFFSET),
	53:  uint8(TK_OF),
	54:  uint8(TK_SET),
	55:  uint8(TK_TRIGGER),
	56:  uint8(TK_RANGE),
	57:  uint8(TK_GENERATED),
	58:  uint8(TK_DETACH),
	59:  uint8(TK_HAVING),
	60:  uint8(TK_LIKE_KW),
	61:  uint8(TK_BEGIN),
	62:  uint8(TK_JOIN_KW),
	63:  uint8(TK_REFERENCES),
	64:  uint8(TK_UNIQUE),
	65:  uint8(TK_QUERY),
	66:  uint8(TK_WITHOUT),
	67:  uint8(TK_WITH),
	68:  uint8(TK_JOIN_KW),
	69:  uint8(TK_RELEASE),
	70:  uint8(TK_ATTACH),
	71:  uint8(TK_BETWEEN),
	72:  uint8(TK_NOTHING),
	73:  uint8(TK_GROUPS),
	74:  uint8(TK_GROUP),
	75:  uint8(TK_CASCADE),
	76:  uint8(TK_ASC),
	77:  uint8(TK_DEFAULT),
	78:  uint8(TK_CASE),
	79:  uint8(TK_COLLATE),
	80:  uint8(TK_CREATE),
	81:  uint8(TK_CTIME_KW),
	82:  uint8(TK_IMMEDIATE),
	83:  uint8(TK_JOIN),
	84:  uint8(TK_INSERT),
	85:  uint8(TK_MATCH),
	86:  uint8(TK_PLAN),
	87:  uint8(TK_ANALYZE),
	88:  uint8(TK_PRAGMA),
	89:  uint8(TK_MATERIALIZED),
	90:  uint8(TK_DEFERRED),
	91:  uint8(TK_DISTINCT),
	92:  uint8(TK_IS),
	93:  uint8(TK_UPDATE),
	94:  uint8(TK_VALUES),
	95:  uint8(TK_VIRTUAL),
	96:  uint8(TK_ALWAYS),
	97:  uint8(TK_WHEN),
	98:  uint8(TK_WHERE),
	99:  uint8(TK_RECURSIVE),
	100: uint8(TK_ABORT),
	101: uint8(TK_AFTER),
	102: uint8(TK_RENAME),
	103: uint8(TK_AND),
	104: uint8(TK_DROP),
	105: uint8(TK_PARTITION),
	106: uint8(TK_AUTOINCR),
	107: uint8(TK_TO),
	108: uint8(TK_IN),
	109: uint8(TK_CAST),
	110: uint8(TK_COLUMNKW),
	111: uint8(TK_COMMIT),
	112: uint8(TK_CONFLICT),
	113: uint8(TK_JOIN_KW),
	114: uint8(TK_CTIME_KW),
	115: uint8(TK_CTIME_KW),
	116: uint8(TK_CURRENT),
	117: uint8(TK_PRECEDING),
	118: uint8(TK_FAIL),
	119: uint8(TK_LAST),
	120: uint8(TK_FILTER),
	121: uint8(TK_REPLACE),
	122: uint8(TK_FIRST),
	123: uint8(TK_FOLLOWING),
	124: uint8(TK_FROM),
	125: uint8(TK_JOIN_KW),
	126: uint8(TK_LIMIT),
	127: uint8(TK_IF),
	128: uint8(TK_ORDER),
	129: uint8(TK_RESTRICT),
	130: uint8(TK_OTHERS),
	131: uint8(TK_OVER),
	132: uint8(TK_RETURNING),
	133: uint8(TK_JOIN_KW),
	134: uint8(TK_ROLLBACK),
	135: uint8(TK_ROWS),
	136: uint8(TK_ROW),
	137: uint8(TK_UNBOUNDED),
	138: uint8(TK_UNION),
	139: uint8(TK_USING),
	140: uint8(TK_VACUUM),
	141: uint8(TK_VIEW),
	142: uint8(TK_WINDOW),
	143: uint8(TK_DO),
	144: uint8(TK_BY),
	145: uint8(TK_INITIALLY),
	146: uint8(TK_ALL),
	147: uint8(TK_PRIMARY),
}

// C documentation
//
//	/* aKWHash[i] is the hash value for the i-th keyword */
var _aKWHash = [127]uint8{
	0:   uint8(84),
	1:   uint8(92),
	2:   uint8(134),
	3:   uint8(82),
	4:   uint8(105),
	5:   uint8(29),
	8:   uint8(94),
	10:  uint8(85),
	11:  uint8(72),
	13:  uint8(53),
	14:  uint8(35),
	15:  uint8(86),
	16:  uint8(15),
	18:  uint8(42),
	19:  uint8(97),
	20:  uint8(54),
	21:  uint8(89),
	22:  uint8(135),
	23:  uint8(19),
	26:  uint8(140),
	28:  uint8(40),
	29:  uint8(129),
	31:  uint8(22),
	32:  uint8(107),
	34:  uint8(9),
	37:  uint8(123),
	38:  uint8(80),
	40:  uint8(78),
	41:  uint8(6),
	43:  uint8(65),
	44:  uint8(103),
	45:  uint8(147),
	47:  uint8(136),
	48:  uint8(115),
	51:  uint8(48),
	53:  uint8(90),
	54:  uint8(24),
	56:  uint8(17),
	58:  uint8(27),
	59:  uint8(70),
	60:  uint8(23),
	61:  uint8(26),
	62:  uint8(5),
	63:  uint8(60),
	64:  uint8(142),
	65:  uint8(110),
	66:  uint8(122),
	68:  uint8(73),
	69:  uint8(91),
	70:  uint8(71),
	71:  uint8(145),
	72:  uint8(61),
	73:  uint8(120),
	74:  uint8(74),
	76:  uint8(49),
	78:  uint8(11),
	79:  uint8(41),
	81:  uint8(113),
	85:  uint8(109),
	86:  uint8(10),
	87:  uint8(111),
	88:  uint8(116),
	89:  uint8(125),
	90:  uint8(14),
	91:  uint8(50),
	92:  uint8(124),
	94:  uint8(100),
	96:  uint8(18),
	97:  uint8(121),
	98:  uint8(144),
	99:  uint8(56),
	100: uint8(130),
	101: uint8(139),
	102: uint8(88),
	103: uint8(83),
	104: uint8(37),
	105: uint8(30),
	106: uint8(126),
	109: uint8(108),
	110: uint8(51),
	111: uint8(131),
	112: uint8(128),
	114: uint8(34),
	117: uint8(132),
	119: uint8(98),
	120: uint8(38),
	121: uint8(39),
	123: uint8(20),
	124: uint8(45),
	125: uint8(117),
	126: uint8(93),
}

// C documentation
//
//	/* aKWLen[i] is the length (in bytes) of the i-th keyword */
var _aKWLen = [148]uint8{
	1:   uint8(7),
	2:   uint8(7),
	3:   uint8(5),
	4:   uint8(4),
	5:   uint8(6),
	6:   uint8(4),
	7:   uint8(5),
	8:   uint8(3),
	9:   uint8(6),
	10:  uint8(7),
	11:  uint8(3),
	12:  uint8(6),
	13:  uint8(6),
	14:  uint8(7),
	15:  uint8(7),
	16:  uint8(3),
	17:  uint8(8),
	18:  uint8(2),
	19:  uint8(6),
	20:  uint8(5),
	21:  uint8(4),
	22:  uint8(4),
	23:  uint8(3),
	24:  uint8(10),
	25:  uint8(4),
	26:  uint8(7),
	27:  uint8(6),
	28:  uint8(9),
	29:  uint8(4),
	30:  uint8(2),
	31:  uint8(6),
	32:  uint8(5),
	33:  uint8(9),
	34:  uint8(9),
	35:  uint8(4),
	36:  uint8(7),
	37:  uint8(3),
	38:  uint8(2),
	39:  uint8(4),
	40:  uint8(4),
	41:  uint8(6),
	42:  uint8(11),
	43:  uint8(6),
	44:  uint8(2),
	45:  uint8(7),
	46:  uint8(5),
	47:  uint8(5),
	48:  uint8(9),
	49:  uint8(6),
	50:  uint8(10),
	51:  uint8(4),
	52:  uint8(6),
	53:  uint8(2),
	54:  uint8(3),
	55:  uint8(7),
	56:  uint8(5),
	57:  uint8(9),
	58:  uint8(6),
	59:  uint8(6),
	60:  uint8(4),
	61:  uint8(5),
	62:  uint8(5),
	63:  uint8(10),
	64:  uint8(6),
	65:  uint8(5),
	66:  uint8(7),
	67:  uint8(4),
	68:  uint8(5),
	69:  uint8(7),
	70:  uint8(6),
	71:  uint8(7),
	72:  uint8(7),
	73:  uint8(6),
	74:  uint8(5),
	75:  uint8(7),
	76:  uint8(3),
	77:  uint8(7),
	78:  uint8(4),
	79:  uint8(7),
	80:  uint8(6),
	81:  uint8(12),
	82:  uint8(9),
	83:  uint8(4),
	84:  uint8(6),
	85:  uint8(5),
	86:  uint8(4),
	87:  uint8(7),
	88:  uint8(6),
	89:  uint8(12),
	90:  uint8(8),
	91:  uint8(8),
	92:  uint8(2),
	93:  uint8(6),
	94:  uint8(6),
	95:  uint8(7),
	96:  uint8(6),
	97:  uint8(4),
	98:  uint8(5),
	99:  uint8(9),
	100: uint8(5),
	101: uint8(5),
	102: uint8(6),
	103: uint8(3),
	104: uint8(4),
	105: uint8(9),
	106: uint8(13),
	107: uint8(2),
	108: uint8(2),
	109: uint8(4),
	110: uint8(6),
	111: uint8(6),
	112: uint8(8),
	113: uint8(5),
	114: uint8(17),
	115: uint8(12),
	116: uint8(7),
	117: uint8(9),
	118: uint8(4),
	119: uint8(4),
	120: uint8(6),
	121: uint8(7),
	122: uint8(5),
	123: uint8(9),
	124: uint8(4),
	125: uint8(4),
	126: uint8(5),
	127: uint8(2),
	128: uint8(5),
	129: uint8(8),
	130: uint8(6),
	131: uint8(4),
	132: uint8(9),
	133: uint8(5),
	134: uint8(8),
	135: uint8(4),
	136: uint8(3),
	137: uint8(9),
	138: uint8(5),
	139: uint8(5),
	140: uint8(6),
	141: uint8(4),
	142: uint8(6),
	143: uint8(2),
	144: uint8(2),
	145: uint8(9),
	146: uint8(3),
	147: uint8(7),
}

// C documentation
//
//	/* aKWNext[] forms the hash collision chain.  If aKWHash[i]==0
//	** then the i-th keyword has no more hash collisions.  Otherwise,
//	** the next keyword with the same hash is aKWHash[i]-1. */
var _aKWNext = [148]uint8{
	5:   uint8(4),
	7:   uint8(43),
	10:  uint8(106),
	11:  uint8(114),
	15:  uint8(2),
	18:  uint8(143),
	22:  uint8(13),
	27:  uint8(141),
	30:  uint8(119),
	31:  uint8(52),
	34:  uint8(137),
	35:  uint8(12),
	38:  uint8(62),
	40:  uint8(138),
	42:  uint8(133),
	45:  uint8(36),
	48:  uint8(28),
	49:  uint8(77),
	54:  uint8(59),
	56:  uint8(47),
	67:  uint8(69),
	73:  uint8(146),
	74:  uint8(3),
	76:  uint8(58),
	78:  uint8(1),
	79:  uint8(75),
	83:  uint8(31),
	89:  uint8(127),
	91:  uint8(104),
	93:  uint8(64),
	94:  uint8(66),
	95:  uint8(63),
	101: uint8(46),
	103: uint8(16),
	104: uint8(8),
	115: uint8(81),
	116: uint8(101),
	118: uint8(112),
	119: uint8(21),
	120: uint8(7),
	121: uint8(67),
	123: uint8(79),
	124: uint8(96),
	125: uint8(118),
	128: uint8(68),
	131: uint8(99),
	132: uint8(44),
	134: uint8(55),
	136: uint8(76),
	138: uint8(95),
	139: uint8(32),
	140: uint8(33),
	141: uint8(57),
	142: uint8(25),
	144: uint8(102),
	147: uint8(87),
}

// C documentation
//
//	/* aKWOffset[i] is the index into zKWText[] of the start of
//	** the text for the i-th keyword. */
var _aKWOffset = [148]uint16{
	2:   uint16(2),
	3:   uint16(2),
	4:   uint16(8),
	5:   uint16(9),
	6:   uint16(14),
	7:   uint16(16),
	8:   uint16(20),
	9:   uint16(23),
	10:  uint16(25),
	11:  uint16(25),
	12:  uint16(29),
	13:  uint16(33),
	14:  uint16(36),
	15:  uint16(41),
	16:  uint16(46),
	17:  uint16(48),
	18:  uint16(53),
	19:  uint16(54),
	20:  uint16(59),
	21:  uint16(62),
	22:  uint16(65),
	23:  uint16(67),
	24:  uint16(69),
	25:  uint16(78),
	26:  uint16(81),
	27:  uint16(86),
	28:  uint16(90),
	29:  uint16(90),
	30:  uint16(94),
	31:  uint16(99),
	32:  uint16(101),
	33:  uint16(105),
	34:  uint16(111),
	35:  uint16(119),
	36:  uint16(123),
	37:  uint16(123),
	38:  uint16(123),
	39:  uint16(126),
	40:  uint16(129),
	41:  uint16(132),
	42:  uint16(137),
	43:  uint16(142),
	44:  uint16(146),
	45:  uint16(147),
	46:  uint16(152),
	47:  uint16(156),
	48:  uint16(160),
	49:  uint16(168),
	50:  uint16(174),
	51:  uint16(181),
	52:  uint16(184),
	53:  uint16(184),
	54:  uint16(187),
	55:  uint16(189),
	56:  uint16(195),
	57:  uint16(198),
	58:  uint16(206),
	59:  uint16(211),
	60:  uint16(216),
	61:  uint16(219),
	62:  uint16(222),
	63:  uint16(226),
	64:  uint16(236),
	65:  uint16(239),
	66:  uint16(244),
	67:  uint16(244),
	68:  uint16(248),
	69:  uint16(252),
	70:  uint16(259),
	71:  uint16(265),
	72:  uint16(271),
	73:  uint16(277),
	74:  uint16(277),
	75:  uint16(283),
	76:  uint16(284),
	77:  uint16(288),
	78:  uint16(295),
	79:  uint16(299),
	80:  uint16(306),
	81:  uint16(312),
	82:  uint16(324),
	83:  uint16(333),
	84:  uint16(335),
	85:  uint16(341),
	86:  uint16(346),
	87:  uint16(348),
	88:  uint16(355),
	89:  uint16(359),
	90:  uint16(370),
	91:  uint16(377),
	92:  uint16(378),
	93:  uint16(385),
	94:  uint16(391),
	95:  uint16(397),
	96:  uint16(402),
	97:  uint16(408),
	98:  uint16(412),
	99:  uint16(415),
	100: uint16(424),
	101: uint16(429),
	102: uint16(433),
	103: uint16(439),
	104: uint16(441),
	105: uint16(444),
	106: uint16(453),
	107: uint16(455),
	108: uint16(457),
	109: uint16(466),
	110: uint16(470),
	111: uint16(476),
	112: uint16(482),
	113: uint16(490),
	114: uint16(495),
	115: uint16(495),
	116: uint16(495),
	117: uint16(511),
	118: uint16(520),
	119: uint16(523),
	120: uint16(527),
	121: uint16(532),
	122: uint16(539),
	123: uint16(544),
	124: uint16(553),
	125: uint16(557),
	126: uint16(560),
	127: uint16(565),
	128: uint16(567),
	129: uint16(571),
	130: uint16(579),
	131: uint16(585),
	132: uint16(588),
	133: uint16(597),
	134: uint16(602),
	135: uint16(610),
	136: uint16(610),
	137: uint16(614),
	138: uint16(623),
	139: uint16(628),
	140: uint16(633),
	141: uint16(639),
	142: uint16(642),
	143: uint16(645),
	144: uint16(648),
	145: uint16(650),
	146: uint16(655),
	147: uint16(659),
}

var _aKeyword1 = [3]Tu8{
	0: uint8(TK_CREATE),
	1: uint8(TK_TABLE),
}

/* The two values have the same sign. Compare using memcmp(). */
var _aLen = [10]Tu8{
	1: uint8(1),
	2: uint8(2),
	3: uint8(3),
	4: uint8(4),
	5: uint8(6),
	6: uint8(8),
}

/* Whether or not a database might need a super-journal depends upon
 ** its journal mode (among other things).  This matrix determines which
 ** journal modes use a super-journal and which do not */
var _aMJNeeded = [6]Tu8{
	0: uint8(1),
	1: uint8(1),
	3: uint8(1),
}

/*
** This routine checks that the sqlite3.nVdbeActive count variable
** matches the number of vdbe's in the list sqlite3.pVdbe that are
** currently active. An assertion fails if the two counts do not match.
** This is an internal self-check only - it is not an essential processing
** step.
**
** This is a no-op if NDEBUG is defined.
 */

var _aMask = [12]uint8{
	0:  uint8(0x10),
	1:  uint8(0x01),
	2:  uint8(0x01),
	3:  uint8(0x01),
	4:  uint8(0x01),
	5:  uint8(0x01),
	6:  uint8(0x01),
	7:  uint8(0x2),
	8:  uint8(0x01),
	9:  uint8(0x01),
	10: uint8(0x10),
	11: uint8(0x10),
}

/* The aMx[] array translates the 3rd character of each format
 ** spec into a max size:    a   b   c   d   e      f */
var _aMx = [6]Tu16{
	0: uint16(12),
	1: uint16(14),
	2: uint16(24),
	3: uint16(31),
	4: uint16(59),
	5: uint16(14712),
}

var _aNull = [1]Tu8{}

var _aOp1 = [5]int32{
	0: int32(OP_Ge),
	1: int32(OP_Ge),
	2: int32(OP_Gt),
	3: int32(OP_Ge),
	4: int32(OP_Ge),
}

var _aScaleLo = [26]uint32{
	0:  uint32(0x205b896d),
	1:  uint32(0x52064cad),
	2:  uint32(0xaf2af2b8),
	3:  uint32(0x5a7744a7),
	4:  uint32(0xaf39a475),
	5:  uint32(0xbd8d794e),
	6:  uint32(0x547eb47b),
	7:  uint32(0x0cb4a5a3),
	8:  uint32(0x92f34d62),
	9:  uint32(0x3a6a07f9),
	10: uint32(0xfae27299),
	11: uint32(0xaa97e14c),
	12: uint32(0x775ea265),
	13: uint32(0xcccccccc),
	15: uint32(0x999090b6),
	16: uint32(0x69a028bb),
	17: uint32(0xe80e6f48),
	18: uint32(0x5ec05dd0),
	19: uint32(0x14588f14),
	20: uint32(0x8f1668c9),
	21: uint32(0x6d953e2c),
	22: uint32(0x4abdaf10),
	23: uint32(0xbc633b39),
	24: uint32(0x0a862f81),
	25: uint32(0x6c07a2c2),
}

var _aStart = [2]Tu8{
	0: uint8(OP_Rewind),
	1: uint8(OP_Last),
}

/* Case 4: Search using an index.
 **
 ** The WHERE clause may contain zero or more equality
 ** terms ("==" or "IN" or "IS" operators) that refer to the N
 ** left-most columns of the index. It may also contain
 ** inequality constraints (>, <, >= or <=) on the indexed
 ** column that immediately follows the N equalities. Only
 ** the right-most column can be an inequality - the rest must
 ** use the "==", "IN", or "IS" operators. For example, if the
 ** index is on (x,y,z), then the following clauses are all
 ** optimized:
 **
 **    x=5
 **    x=5 AND y=10
 **    x=5 AND y<10
 **    x=5 AND y>5 AND y<10
 **    x=5 AND y=5 AND z<=10
 **
 ** The z<10 term of the following cannot be used, only
 ** the x=5 term:
 **
 **    x=5 AND z<10
 **
 ** N may be zero if there are inequality constraints.
 ** If there are no inequality constraints, then N is at
 ** least one.
 **
 ** This case is also used when there are no WHERE clause
 ** constraints but an index is selected anyway, in order
 ** to force the output order to conform to an ORDER BY.
 */
var _aStartOp = [8]Tu8{
	2: uint8(OP_Rewind),
	3: uint8(OP_Last),
	4: uint8(OP_SeekGT),
	5: uint8(OP_SeekLT),
	6: uint8(OP_SeekGE),
	7: uint8(OP_SeekLE),
}

/* (2) Datatype must be exact for non-ANY columns in STRICT tables*/
var _aStdTypeMask = [6]uint8{
	0: uint8(0x1f),
	1: uint8(0x18),
	2: uint8(0x11),
	3: uint8(0x11),
	4: uint8(0x13),
	5: uint8(0x14),
}

/* Case 6:  There is no usable index.  We must do a complete
 **          scan of the entire table.
 */
var _aStep = [2]Tu8{
	0: uint8(OP_Next),
	1: uint8(OP_Prev),
}

var _aType = [64]Tu8{
	0:  uint8(SQLITE_BLOB),
	1:  uint8(SQLITE_NULL),
	2:  uint8(SQLITE_TEXT),
	3:  uint8(SQLITE_NULL),
	4:  uint8(SQLITE_INTEGER),
	5:  uint8(SQLITE_NULL),
	6:  uint8(SQLITE_INTEGER),
	7:  uint8(SQLITE_NULL),
	8:  uint8(SQLITE_FLOAT),
	9:  uint8(SQLITE_NULL),
	10: uint8(SQLITE_FLOAT),
	11: uint8(SQLITE_NULL),
	12: uint8(SQLITE_INTEGER),
	13: uint8(SQLITE_NULL),
	14: uint8(SQLITE_INTEGER),
	15: uint8(SQLITE_NULL),
	16: uint8(SQLITE_BLOB),
	17: uint8(SQLITE_NULL),
	18: uint8(SQLITE_TEXT),
	19: uint8(SQLITE_NULL),
	20: uint8(SQLITE_INTEGER),
	21: uint8(SQLITE_NULL),
	22: uint8(SQLITE_INTEGER),
	23: uint8(SQLITE_NULL),
	24: uint8(SQLITE_FLOAT),
	25: uint8(SQLITE_NULL),
	26: uint8(SQLITE_FLOAT),
	27: uint8(SQLITE_NULL),
	28: uint8(SQLITE_INTEGER),
	29: uint8(SQLITE_NULL),
	30: uint8(SQLITE_INTEGER),
	31: uint8(SQLITE_NULL),
	32: uint8(SQLITE_FLOAT),
	33: uint8(SQLITE_NULL),
	34: uint8(SQLITE_FLOAT),
	35: uint8(SQLITE_NULL),
	36: uint8(SQLITE_FLOAT),
	37: uint8(SQLITE_NULL),
	38: uint8(SQLITE_FLOAT),
	39: uint8(SQLITE_NULL),
	40: uint8(SQLITE_FLOAT),
	41: uint8(SQLITE_NULL),
	42: uint8(SQLITE_FLOAT),
	43: uint8(SQLITE_NULL),
	44: uint8(SQLITE_FLOAT),
	45: uint8(SQLITE_NULL),
	46: uint8(SQLITE_FLOAT),
	47: uint8(SQLITE_NULL),
	48: uint8(SQLITE_BLOB),
	49: uint8(SQLITE_NULL),
	50: uint8(SQLITE_TEXT),
	51: uint8(SQLITE_NULL),
	52: uint8(SQLITE_FLOAT),
	53: uint8(SQLITE_NULL),
	54: uint8(SQLITE_FLOAT),
	55: uint8(SQLITE_NULL),
	56: uint8(SQLITE_FLOAT),
	57: uint8(SQLITE_NULL),
	58: uint8(SQLITE_FLOAT),
	59: uint8(SQLITE_NULL),
	60: uint8(SQLITE_FLOAT),
	61: uint8(SQLITE_NULL),
	62: uint8(SQLITE_FLOAT),
	63: uint8(SQLITE_NULL),
}

/* Lookup table for finding the upper 4 bits of the first byte of the
 ** expanded aIns[], based on the size of the expanded aIns[] header:
 **
 **                             2     3  4     5  6  7  8     9 */
var _aType1 = [8]Tu8{
	0: uint8(0xc0),
	1: uint8(0xd0),
	3: uint8(0xe0),
	7: uint8(0xf0),
}

/*                10,  9,  8,  7,  6 */
var _aVal = [5]TLogEst{
	0: int16(33),
	1: int16(32),
	2: int16(30),
	3: int16(28),
	4: int16(26),
}

var _aZero = [4]Tu32{}

// C documentation
//
//	/*
//	** Deallocate a single AggInfo object
//	*/
func _agginfoFree(tls *libc.TLS, db uintptr, pArg uintptr) {
	var p uintptr
	_ = p
	p = pArg
	_sqlite3DbFree(tls, db, (*TAggInfo)(unsafe.Pointer(p)).FaCol)
	_sqlite3DbFree(tls, db, (*TAggInfo)(unsafe.Pointer(p)).FaFunc)
	_sqlite3DbFreeNN(tls, db, p)
}

var _aiClass = [256]uint8{
	0:   uint8(29),
	1:   uint8(28),
	2:   uint8(28),
	3:   uint8(28),
	4:   uint8(28),
	5:   uint8(28),
	6:   uint8(28),
	7:   uint8(28),
	8:   uint8(28),
	9:   uint8(7),
	10:  uint8(7),
	11:  uint8(28),
	12:  uint8(7),
	13:  uint8(7),
	14:  uint8(28),
	15:  uint8(28),
	16:  uint8(28),
	17:  uint8(28),
	18:  uint8(28),
	19:  uint8(28),
	20:  uint8(28),
	21:  uint8(28),
	22:  uint8(28),
	23:  uint8(28),
	24:  uint8(28),
	25:  uint8(28),
	26:  uint8(28),
	27:  uint8(28),
	28:  uint8(28),
	29:  uint8(28),
	30:  uint8(28),
	31:  uint8(28),
	32:  uint8(7),
	33:  uint8(15),
	34:  uint8(8),
	35:  uint8(5),
	36:  uint8(4),
	37:  uint8(22),
	38:  uint8(24),
	39:  uint8(8),
	40:  uint8(17),
	41:  uint8(18),
	42:  uint8(21),
	43:  uint8(20),
	44:  uint8(23),
	45:  uint8(11),
	46:  uint8(26),
	47:  uint8(16),
	48:  uint8(3),
	49:  uint8(3),
	50:  uint8(3),
	51:  uint8(3),
	52:  uint8(3),
	53:  uint8(3),
	54:  uint8(3),
	55:  uint8(3),
	56:  uint8(3),
	57:  uint8(3),
	58:  uint8(5),
	59:  uint8(19),
	60:  uint8(12),
	61:  uint8(14),
	62:  uint8(13),
	63:  uint8(6),
	64:  uint8(5),
	65:  uint8(1),
	66:  uint8(1),
	67:  uint8(1),
	68:  uint8(1),
	69:  uint8(1),
	70:  uint8(1),
	71:  uint8(1),
	72:  uint8(1),
	73:  uint8(1),
	74:  uint8(1),
	75:  uint8(1),
	76:  uint8(1),
	77:  uint8(1),
	78:  uint8(1),
	79:  uint8(1),
	80:  uint8(1),
	81:  uint8(1),
	82:  uint8(1),
	83:  uint8(1),
	84:  uint8(1),
	85:  uint8(1),
	86:  uint8(1),
	87:  uint8(1),
	89:  uint8(2),
	90:  uint8(2),
	91:  uint8(9),
	92:  uint8(28),
	93:  uint8(28),
	94:  uint8(28),
	95:  uint8(2),
	96:  uint8(8),
	97:  uint8(1),
	98:  uint8(1),
	99:  uint8(1),
	100: uint8(1),
	101: uint8(1),
	102: uint8(1),
	103: uint8(1),
	104: uint8(1),
	105: uint8(1),
	106: uint8(1),
	107: uint8(1),
	108: uint8(1),
	109: uint8(1),
	110: uint8(1),
	111: uint8(1),
	112: uint8(1),
	113: uint8(1),
	114: uint8(1),
	115: uint8(1),
	116: uint8(1),
	117: uint8(1),
	118: uint8(1),
	119: uint8(1),
	121: uint8(2),
	122: uint8(2),
	123: uint8(28),
	124: uint8(10),
	125: uint8(28),
	126: uint8(25),
	127: uint8(28),
	128: uint8(27),
	129: uint8(27),
	130: uint8(27),
	131: uint8(27),
	132: uint8(27),
	133: uint8(27),
	134: uint8(27),
	135: uint8(27),
	136: uint8(27),
	137: uint8(27),
	138: uint8(27),
	139: uint8(27),
	140: uint8(27),
	141: uint8(27),
	142: uint8(27),
	143: uint8(27),
	144: uint8(27),
	145: uint8(27),
	146: uint8(27),
	147: uint8(27),
	148: uint8(27),
	149: uint8(27),
	150: uint8(27),
	151: uint8(27),
	152: uint8(27),
	153: uint8(27),
	154: uint8(27),
	155: uint8(27),
	156: uint8(27),
	157: uint8(27),
	158: uint8(27),
	159: uint8(27),
	160: uint8(27),
	161: uint8(27),
	162: uint8(27),
	163: uint8(27),
	164: uint8(27),
	165: uint8(27),
	166: uint8(27),
	167: uint8(27),
	168: uint8(27),
	169: uint8(27),
	170: uint8(27),
	171: uint8(27),
	172: uint8(27),
	173: uint8(27),
	174: uint8(27),
	175: uint8(27),
	176: uint8(27),
	177: uint8(27),
	178: uint8(27),
	179: uint8(27),
	180: uint8(27),
	181: uint8(27),
	182: uint8(27),
	183: uint8(27),
	184: uint8(27),
	185: uint8(27),
	186: uint8(27),
	187: uint8(27),
	188: uint8(27),
	189: uint8(27),
	190: uint8(27),
	191: uint8(27),
	192: uint8(27),
	193: uint8(27),
	194: uint8(27),
	195: uint8(27),
	196: uint8(27),
	197: uint8(27),
	198: uint8(27),
	199: uint8(27),
	200: uint8(27),
	201: uint8(27),
	202: uint8(27),
	203: uint8(27),
	204: uint8(27),
	205: uint8(27),
	206: uint8(27),
	207: uint8(27),
	208: uint8(27),
	209: uint8(27),
	210: uint8(27),
	211: uint8(27),
	212: uint8(27),
	213: uint8(27),
	214: uint8(27),
	215: uint8(27),
	216: uint8(27),
	217: uint8(27),
	218: uint8(27),
	219: uint8(27),
	220: uint8(27),
	221: uint8(27),
	222: uint8(27),
	223: uint8(27),
	224: uint8(27),
	225: uint8(27),
	226: uint8(27),
	227: uint8(27),
	228: uint8(27),
	229: uint8(27),
	230: uint8(27),
	231: uint8(27),
	232: uint8(27),
	233: uint8(27),
	234: uint8(27),
	235: uint8(27),
	236: uint8(27),
	237: uint8(27),
	238: uint8(27),
	239: uint8(30),
	240: uint8(27),
	241: uint8(27),
	242: uint8(27),
	243: uint8(27),
	244: uint8(27),
	245: uint8(27),
	246: uint8(27),
	247: uint8(27),
	248: uint8(27),
	249: uint8(27),
	250: uint8(27),
	251: uint8(27),
	252: uint8(27),
	253: uint8(27),
	254: uint8(27),
	255: uint8(27),
}

/*
** The charMap() macro maps alphabetic characters (only) into their
** lower-case ASCII equivalent.  On ASCII machines, this is just
** an upper-to-lower case map.  On EBCDIC machines we also need
** to adjust the encoding.  The mapping is only valid for alphabetics
** which are the only characters for which this feature is used.
**
** Used by keywordhash.h
 */

var _aiOff = [77]uint16{
	0:  uint16(1),
	1:  uint16(2),
	2:  uint16(8),
	3:  uint16(15),
	4:  uint16(16),
	5:  uint16(26),
	6:  uint16(28),
	7:  uint16(32),
	8:  uint16(37),
	9:  uint16(38),
	10: uint16(40),
	11: uint16(48),
	12: uint16(63),
	13: uint16(64),
	14: uint16(69),
	15: uint16(71),
	16: uint16(79),
	17: uint16(80),
	18: uint16(116),
	19: uint16(202),
	20: uint16(203),
	21: uint16(205),
	22: uint16(206),
	23: uint16(207),
	24: uint16(209),
	25: uint16(210),
	26: uint16(211),
	27: uint16(213),
	28: uint16(214),
	29: uint16(217),
	30: uint16(218),
	31: uint16(219),
	32: uint16(775),
	33: uint16(7264),
	34: uint16(10792),
	35: uint16(10795),
	36: uint16(23228),
	37: uint16(23256),
	38: uint16(30204),
	39: uint16(54721),
	40: uint16(54753),
	41: uint16(54754),
	42: uint16(54756),
	43: uint16(54787),
	44: uint16(54793),
	45: uint16(54809),
	46: uint16(57153),
	47: uint16(57274),
	48: uint16(57921),
	49: uint16(58019),
	50: uint16(58363),
	51: uint16(61722),
	52: uint16(65268),
	53: uint16(65341),
	54: uint16(65373),
	55: uint16(65406),
	56: uint16(65408),
	57: uint16(65410),
	58: uint16(65415),
	59: uint16(65424),
	60: uint16(65436),
	61: uint16(65439),
	62: uint16(65450),
	63: uint16(65462),
	64: uint16(65472),
	65: uint16(65476),
	66: uint16(65478),
	67: uint16(65480),
	68: uint16(65482),
	69: uint16(65488),
	70: uint16(65506),
	71: uint16(65511),
	72: uint16(65514),
	73: uint16(65521),
	74: uint16(65527),
	75: uint16(65528),
	76: uint16(65529),
}

// C documentation
//
//	/*
//	** Return true if the first nCons constraints in the pUsage array are
//	** marked as in-use (have argvIndex>0). False otherwise.
//	*/
func _allConstraintsUsed(tls *libc.TLS, aUsage uintptr, nCons int32) (r int32) {
	var ii int32
	_ = ii
	ii = 0
	for {
		if !(ii < nCons) {
			break
		}
		if (**(**Tsqlite3_index_constraint_usage)(__ccgo_up(aUsage + uintptr(ii)*8))).FargvIndex <= 0 {
			return 0
		}
		goto _1
	_1:
		;
		ii = ii + 1
	}
	return int32(1)
}

// C documentation
//
//	/*
//	** Return TRUE if the given operator is one of the operators that is
//	** allowed for an indexable WHERE clause term.  The allowed operators are
//	** "=", "<", ">", "<=", ">=", "IN", "IS", and "IS NULL"
//	*/
func _allowedOp(tls *libc.TLS, op int32) (r int32) {
	if op > int32(TK_GE) {
		return 0
	}
	if op >= int32(TK_EQ) {
		return int32(1)
	}
	return libc.BoolInt32(op == int32(TK_IN) || op == int32(TK_ISNULL) || op == int32(TK_IS))
}

// C documentation
//
//	/*
//	** The string in pRec is known to look like an integer and to have a
//	** floating point value of rValue.  Return true and set *piValue to the
//	** integer value if the string is in range to be an integer.  Otherwise,
//	** return false.
//	*/
func _alsoAnInt(tls *libc.TLS, pRec uintptr, rValue float64, piValue uintptr) (r int32) {
	var iValue Ti64
	_ = iValue
	iValue = _sqlite3RealToI64(tls, rValue)
	if _sqlite3RealSameAsInt(tls, rValue, iValue) != 0 {
		**(**Ti64)(__ccgo_up(piValue)) = iValue
		return int32(1)
	}
	return libc.BoolInt32(0 == _sqlite3Atoi64(tls, (*TMem)(unsafe.Pointer(pRec)).Fz, piValue, (*TMem)(unsafe.Pointer(pRec)).Fn, (*TMem)(unsafe.Pointer(pRec)).Fenc))
}

func _analyzeFilterKeyword(tls *libc.TLS, _z uintptr, lastToken int32) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	*(*uintptr)(unsafe.Pointer(bp)) = _z
	if lastToken == int32(TK_RP) && _getToken(tls, bp) == int32(TK_LP) {
		return int32(TK_FILTER)
	}
	return int32(TK_ID)
}

func _analyzeOverKeyword(tls *libc.TLS, _z uintptr, lastToken int32) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	*(*uintptr)(unsafe.Pointer(bp)) = _z
	var t int32
	_ = t
	if lastToken == int32(TK_RP) {
		t = _getToken(tls, bp)
		if t == int32(TK_LP) || t == int32(TK_ID) {
			return int32(TK_OVER)
		}
	}
	return int32(TK_ID)
}

// C documentation
//
//	/*
//	** The following three functions are called immediately after the tokenizer
//	** reads the keywords WINDOW, OVER and FILTER, respectively, to determine
//	** whether the token should be treated as a keyword or an SQL identifier.
//	** This cannot be handled by the usual lemon %fallback method, due to
//	** the ambiguity in some constructions. e.g.
//	**
//	**   SELECT sum(x) OVER ...
//	**
//	** In the above, "OVER" might be a keyword, or it might be an alias for the
//	** sum(x) expression. If a "%fallback ID OVER" directive were added to
//	** grammar, then SQLite would always treat "OVER" as an alias, making it
//	** impossible to call a window-function without a FILTER clause.
//	**
//	** WINDOW is treated as a keyword if:
//	**
//	**   * the following token is an identifier, or a keyword that can fallback
//	**     to being an identifier, and
//	**   * the token after than one is TK_AS.
//	**
//	** OVER is a keyword if:
//	**
//	**   * the previous token was TK_RP, and
//	**   * the next token is either TK_LP or an identifier.
//	**
//	** FILTER is a keyword if:
//	**
//	**   * the previous token was TK_RP, and
//	**   * the next token is TK_LP.
//	*/
func _analyzeWindowKeyword(tls *libc.TLS, _z uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	*(*uintptr)(unsafe.Pointer(bp)) = _z
	var t int32
	_ = t
	t = _getToken(tls, bp)
	if t != int32(TK_ID) {
		return int32(TK_ID)
	}
	t = _getToken(tls, bp)
	if t != int32(TK_AS) {
		return int32(TK_ID)
	}
	return int32(TK_WINDOW)
}

var _and_logic = [9]uint8{
	4: uint8(1),
	5: uint8(2),
	7: uint8(2),
	8: uint8(2),
}

// C documentation
//
//	/*
//	** Take actions at the end of an API call to deal with error codes.
//	*/
func _apiHandleError(tls *libc.TLS, db uintptr, rc int32) (r int32) {
	if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 || rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(12)<<libc.Int32FromInt32(8) {
		_sqlite3OomClear(tls, db)
		_sqlite3Error(tls, db, int32(SQLITE_NOMEM))
		return int32(SQLITE_NOMEM)
	}
	return rc & (*Tsqlite3)(unsafe.Pointer(db)).FerrMask
}

// C documentation
//
//	/*
//	** Return TRUE if the double-quoted string  mis-feature should be supported.
//	*/
func _areDoubleQuotedStringsEnabled(tls *libc.TLS, db uintptr, pTopNC uintptr) (r int32) {
	if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 {
		return int32(1)
	} /* Always support for legacy schemas */
	if (*TNameContext)(unsafe.Pointer(pTopNC)).FncFlags&int32(NC_IsDDL) != 0 {
		/* Currently parsing a DDL statement */
		if _sqlite3WritableSchema(tls, db) != 0 && (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DqsDML) != uint64(0) {
			return int32(1)
		}
		return libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DqsDDL) != uint64(0))
	} else {
		/* Currently parsing a DML statement */
		return libc.BoolInt32((*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_DqsDML) != uint64(0))
	}
	return r
}

// C documentation
//
//	/*
//	** Register this backup object with the associated source pager for
//	** callbacks when pages are changed or the cache invalidated.
//	*/
func _attachBackupObject(tls *libc.TLS, p uintptr) {
	var pp uintptr
	_ = pp
	pp = _sqlite3PagerBackupPtr(tls, _sqlite3BtreePager(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).FpSrc))
	(*Tsqlite3_backup)(unsafe.Pointer(p)).FpNext = **(**uintptr)(__ccgo_up(pp))
	**(**uintptr)(__ccgo_up(pp)) = p
	(*Tsqlite3_backup)(unsafe.Pointer(p)).FisAttached = int32(1)
}

// C documentation
//
//	/* Attach a With object describing the WITH clause to a Select
//	  ** object describing the query for which the WITH clause is a prefix.
//	  */
func _attachWithToSelect(tls *libc.TLS, pParse uintptr, pSelect uintptr, pWith uintptr) (r uintptr) {
	if pSelect != 0 {
		(*TSelect)(unsafe.Pointer(pSelect)).FpWith = pWith
		_parserDoubleLinkSelect(tls, pParse, pSelect)
	} else {
		_sqlite3WithDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pWith)
	}
	return pSelect
}

var _autoInc = [12]TVdbeOpList{
	0: {
		Fopcode: uint8(OP_Null),
	},
	1: {
		Fopcode: uint8(OP_Rewind),
		Fp2:     int8(10),
	},
	2: {
		Fopcode: uint8(OP_Column),
	},
	3: {
		Fopcode: uint8(OP_Ne),
		Fp2:     int8(9),
	},
	4: {
		Fopcode: uint8(OP_Rowid),
	},
	5: {
		Fopcode: uint8(OP_Column),
		Fp2:     int8(1),
	},
	6: {
		Fopcode: uint8(OP_AddImm),
	},
	7: {
		Fopcode: uint8(OP_Copy),
	},
	8: {
		Fopcode: uint8(OP_Goto),
		Fp2:     int8(11),
	},
	9: {
		Fopcode: uint8(OP_Next),
		Fp2:     int8(2),
	},
	10: {
		Fopcode: uint8(OP_Integer),
	},
	11: {
		Fopcode: uint8(OP_Close),
	},
}

var _autoIncEnd = [5]TVdbeOpList{
	0: {
		Fopcode: uint8(OP_NotNull),
		Fp2:     int8(2),
	},
	1: {
		Fopcode: uint8(OP_NewRowid),
	},
	2: {
		Fopcode: uint8(OP_MakeRecord),
		Fp2:     int8(2),
	},
	3: {
		Fopcode: uint8(OP_Insert),
	},
	4: {
		Fopcode: uint8(OP_Close),
	},
}

// C documentation
//
//	/*
//	** Update the maximum rowid for an autoincrement calculation.
//	**
//	** This routine should be called when the regRowid register holds a
//	** new rowid that is about to be inserted.  If that new rowid is
//	** larger than the maximum rowid in the memId memory cell, then the
//	** memory cell is updated.
//	*/
func _autoIncStep(tls *libc.TLS, pParse uintptr, memId int32, regRowid int32) {
	if memId > 0 {
		_sqlite3VdbeAddOp2(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32(OP_MemMax), memId, regRowid)
	}
}

func _avgFinalize(tls *libc.TLS, context uintptr) {
	var p uintptr
	var r float64
	_, _ = p, r
	p = Xsqlite3_aggregate_context(tls, context, 0)
	if p != 0 && (*TSumCtx)(unsafe.Pointer(p)).Fcnt > 0 {
		if (*TSumCtx)(unsafe.Pointer(p)).Fapprox != 0 {
			r = (*TSumCtx)(unsafe.Pointer(p)).FrSum
			if !(_sqlite3IsOverflow(tls, (*TSumCtx)(unsafe.Pointer(p)).FrErr) != 0) {
				r = r + (*TSumCtx)(unsafe.Pointer(p)).FrErr
			}
		} else {
			r = float64((*TSumCtx)(unsafe.Pointer(p)).FiSum)
		}
		Xsqlite3_result_double(tls, context, r/float64((*TSumCtx)(unsafe.Pointer(p)).Fcnt))
	}
}

var _azExplainColNames16data = [60]Tu16{
	0:  uint16('a'),
	1:  uint16('d'),
	2:  uint16('d'),
	3:  uint16('r'),
	5:  uint16('o'),
	6:  uint16('p'),
	7:  uint16('c'),
	8:  uint16('o'),
	9:  uint16('d'),
	10: uint16('e'),
	12: uint16('p'),
	13: uint16('1'),
	15: uint16('p'),
	16: uint16('2'),
	18: uint16('p'),
	19: uint16('3'),
	21: uint16('p'),
	22: uint16('4'),
	24: uint16('p'),
	25: uint16('5'),
	27: uint16('c'),
	28: uint16('o'),
	29: uint16('m'),
	30: uint16('m'),
	31: uint16('e'),
	32: uint16('n'),
	33: uint16('t'),
	35: uint16('i'),
	36: uint16('d'),
	38: uint16('p'),
	39: uint16('a'),
	40: uint16('r'),
	41: uint16('e'),
	42: uint16('n'),
	43: uint16('t'),
	45: uint16('n'),
	46: uint16('o'),
	47: uint16('t'),
	48: uint16('u'),
	49: uint16('s'),
	50: uint16('e'),
	51: uint16('d'),
	53: uint16('d'),
	54: uint16('e'),
	55: uint16('t'),
	56: uint16('a'),
	57: uint16('i'),
	58: uint16('l'),
}

// C documentation
//
//	/*
//	** If pFile is currently larger than iSize bytes, then truncate it to
//	** exactly iSize bytes. If pFile is not larger than iSize bytes, then
//	** this function is a no-op.
//	**
//	** Return SQLITE_OK if everything is successful, or an SQLite error
//	** code if an error occurs.
//	*/
func _backupTruncateFile(tls *libc.TLS, pFile uintptr, iSize Ti64) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* iCurrent at bp+0 */ Ti64
	_ = rc
	rc = _sqlite3OsFileSize(tls, pFile, bp)
	if rc == SQLITE_OK && **(**Ti64)(__ccgo_up(bp)) > iSize {
		rc = _sqlite3OsTruncate(tls, pFile, iSize)
	}
	return rc
}

// C documentation
//
//	/*
//	** This function is called after the contents of page iPage of the
//	** source database have been modified. If page iPage has already been
//	** copied into the destination database, then the data written to the
//	** destination is now invalidated. The destination copy of iPage needs
//	** to be updated with the new data before the backup operation is
//	** complete.
//	**
//	** It is assumed that the mutex associated with the BtShared object
//	** corresponding to the source database is held when this function is
//	** called.
//	*/
func _backupUpdate(tls *libc.TLS, p uintptr, iPage TPgno, aData uintptr) {
	var rc int32
	var v1 uintptr
	_, _ = rc, v1
	for {
		if !(_isFatalError(tls, (*Tsqlite3_backup)(unsafe.Pointer(p)).Frc) != 0) && iPage < (*Tsqlite3_backup)(unsafe.Pointer(p)).FiNext {
			Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer((*Tsqlite3_backup)(unsafe.Pointer(p)).FpDestDb)).Fmutex)
			rc = _backupOnePage(tls, p, iPage, aData, int32(1))
			Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*Tsqlite3_backup)(unsafe.Pointer(p)).FpDestDb)).Fmutex)
			if rc != SQLITE_OK {
				(*Tsqlite3_backup)(unsafe.Pointer(p)).Frc = rc
			}
		}
		goto _2
	_2:
		;
		v1 = (*Tsqlite3_backup)(unsafe.Pointer(p)).FpNext
		p = v1
		if !(v1 != uintptr(0)) {
			break
		}
	}
}

// C documentation
//
//	/*
//	** Clear (destroy) the BtShared.pHasContent bitvec. This should be
//	** invoked at the conclusion of each write-transaction.
//	*/
func _btreeClearHasContent(tls *libc.TLS, pBt uintptr) {
	_sqlite3BitvecDestroy(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpHasContent)
	(*TBtShared)(unsafe.Pointer(pBt)).FpHasContent = uintptr(0)
}

// C documentation
//
//	/*
//	** Create a new cursor for the BTree whose root is on the page
//	** iTable. If a read-only cursor is requested, it is assumed that
//	** the caller already has at least a read-only transaction open
//	** on the database already. If a write-cursor is requested, then
//	** the caller is assumed to have an open write transaction.
//	**
//	** If the BTREE_WRCSR bit of wrFlag is clear, then the cursor can only
//	** be used for reading.  If the BTREE_WRCSR bit is set, then the cursor
//	** can be used for reading or for writing if other conditions for writing
//	** are also met.  These are the conditions that must be met in order
//	** for writing to be allowed:
//	**
//	** 1:  The cursor must have been opened with wrFlag containing BTREE_WRCSR
//	**
//	** 2:  Other database connections that share the same pager cache
//	**     but which are not in the READ_UNCOMMITTED state may not have
//	**     cursors open with wrFlag==0 on the same table.  Otherwise
//	**     the changes made by this write cursor would be visible to
//	**     the read cursors in the other database connection.
//	**
//	** 3:  The database must be writable (not on read-only media)
//	**
//	** 4:  There must be an active transaction.
//	**
//	** The BTREE_FORDELETE bit of wrFlag may optionally be set if BTREE_WRCSR
//	** is set.  If FORDELETE is set, that is a hint to the implementation that
//	** this cursor will only be used to seek to and delete entries of an index
//	** as part of a larger DELETE statement.  The FORDELETE hint is not used by
//	** this implementation.  But in a hypothetical alternative storage engine
//	** in which index entries are automatically deleted when corresponding table
//	** rows are deleted, the FORDELETE flag is a hint that all SEEK and DELETE
//	** operations on this cursor can be no-ops and all READ operations can
//	** return a null row (2-bytes: 0x01 0x00).
//	**
//	** No checking is done to make sure that page iTable really is the
//	** root page of a b-tree.  If it is not, then the cursor acquired
//	** will not work correctly.
//	**
//	** It is assumed that the sqlite3BtreeCursorZero() has been called
//	** on pCur to initialize the memory space prior to invoking this routine.
//	*/
func _btreeCursor(tls *libc.TLS, p uintptr, iTable TPgno, wrFlag int32, pKeyInfo uintptr, pCur uintptr) (r int32) {
	var pBt, pX, v2 uintptr
	_, _, _ = pBt, pX, v2
	pBt = (*TBtree)(unsafe.Pointer(p)).FpBt /* Looping over other all cursors */
	/* The following assert statements verify that if this is a sharable
	 ** b-tree database, the connection is holding the required table locks,
	 ** and that no other connection has any open cursor that conflicts with
	 ** this lock.  The iTable<1 term disables the check for corrupt schemas. */
	/* Assert that the caller has opened the required transaction. */
	if iTable <= uint32(1) {
		if iTable < uint32(1) {
			return _sqlite3CorruptError(tls, int32(77947))
		} else {
			if _btreePagecount(tls, pBt) == uint32(0) {
				iTable = uint32(0)
			}
		}
	}
	/* Now that no other errors can occur, finish filling in the BtCursor
	 ** variables and link the cursor into the BtShared list.  */
	(*TBtCursor)(unsafe.Pointer(pCur)).FpgnoRoot = iTable
	(*TBtCursor)(unsafe.Pointer(pCur)).FiPage = int8(-int32(1))
	(*TBtCursor)(unsafe.Pointer(pCur)).FpKeyInfo = pKeyInfo
	(*TBtCursor)(unsafe.Pointer(pCur)).FpBtree = p
	(*TBtCursor)(unsafe.Pointer(pCur)).FpBt = pBt
	(*TBtCursor)(unsafe.Pointer(pCur)).FcurFlags = uint8(0)
	/* If there are two or more cursors on the same btree, then all such
	 ** cursors *must* have the BTCF_Multiple flag set. */
	pX = (*TBtShared)(unsafe.Pointer(pBt)).FpCursor
	for {
		if !(pX != 0) {
			break
		}
		if (*TBtCursor)(unsafe.Pointer(pX)).FpgnoRoot == iTable {
			v2 = pX + 1
			*(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) | libc.Int32FromInt32(BTCF_Multiple))
			(*TBtCursor)(unsafe.Pointer(pCur)).FcurFlags = uint8(BTCF_Multiple)
		}
		goto _1
	_1:
		;
		pX = (*TBtCursor)(unsafe.Pointer(pX)).FpNext
	}
	(*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_INVALID)
	(*TBtCursor)(unsafe.Pointer(pCur)).FpNext = (*TBtShared)(unsafe.Pointer(pBt)).FpCursor
	(*TBtShared)(unsafe.Pointer(pBt)).FpCursor = pCur
	if wrFlag != 0 {
		v2 = pCur + 1
		*(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) | libc.Int32FromInt32(BTCF_WriteFlag))
		(*TBtCursor)(unsafe.Pointer(pCur)).FcurPagerFlags = uint8(0)
		if (*TBtShared)(unsafe.Pointer(pBt)).FpTmpSpace == uintptr(0) {
			return _allocateTempSpace(tls, pBt)
		}
	} else {
		(*TBtCursor)(unsafe.Pointer(pCur)).FcurPagerFlags = uint8(PAGER_GET_READONLY)
	}
	return SQLITE_OK
}

func _btreeCursorWithLock(tls *libc.TLS, p uintptr, iTable TPgno, wrFlag int32, pKeyInfo uintptr, pCur uintptr) (r int32) {
	var rc int32
	_ = rc
	_sqlite3BtreeEnter(tls, p)
	rc = _btreeCursor(tls, p, iTable, wrFlag, pKeyInfo, pCur)
	_sqlite3BtreeLeave(tls, p)
	return rc
}

// C documentation
//
//	/*
//	** Query the BtShared.pHasContent vector.
//	**
//	** This function is called when a free-list leaf page is removed from the
//	** free-list for reuse. It returns false if it is safe to retrieve the
//	** page from the pager layer with the 'no-content' flag set. True otherwise.
//	*/
func _btreeGetHasContent(tls *libc.TLS, pBt uintptr, pgno TPgno) (r int32) {
	var p uintptr
	_ = p
	p = (*TBtShared)(unsafe.Pointer(pBt)).FpHasContent
	return libc.BoolInt32(p != 0 && (pgno > _sqlite3BitvecSize(tls, p) || _sqlite3BitvecTestNotNull(tls, p, pgno) != 0))
}

// C documentation
//
//	/*
//	** Get a page from the pager.  Initialize the MemPage.pBt and
//	** MemPage.aData elements if needed.  See also: btreeGetUnusedPage().
//	**
//	** If the PAGER_GET_NOCONTENT flag is set, it means that we do not care
//	** about the content of the page at this time.  So do not go to the disk
//	** to fetch the content.  Just fill in the content with zeros for now.
//	** If in the future we call sqlite3PagerWrite() on this page, that
//	** means we have started to be concerned about content and the disk
//	** read should occur at that point.
//	*/
func _btreeGetPage(tls *libc.TLS, pBt uintptr, pgno TPgno, ppPage uintptr, flags int32) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* pDbPage at bp+0 */ uintptr
	_ = rc
	rc = _sqlite3PagerGet(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, pgno, bp, flags)
	if rc != 0 {
		return rc
	}
	**(**uintptr)(__ccgo_up(ppPage)) = _btreePageFromDbPage(tls, **(**uintptr)(__ccgo_up(bp)), pgno, pBt)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Get an unused page.
//	**
//	** This works just like btreeGetPage() with the addition:
//	**
//	**   *  If the page is already in use for some other purpose, immediately
//	**      release it and return an SQLITE_CURRUPT error.
//	**   *  Make sure the isInit flag is clear
//	*/
func _btreeGetUnusedPage(tls *libc.TLS, pBt uintptr, pgno TPgno, ppPage uintptr, flags int32) (r int32) {
	var rc int32
	_ = rc
	rc = _btreeGetPage(tls, pBt, pgno, ppPage, flags)
	if rc == SQLITE_OK {
		if _sqlite3PagerPageRefcount(tls, (*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(ppPage)))).FpDbPage) > int32(1) {
			_releasePage(tls, **(**uintptr)(__ccgo_up(ppPage)))
			**(**uintptr)(__ccgo_up(ppPage)) = uintptr(0)
			return _sqlite3CorruptError(tls, int32(75690))
		}
		(*TMemPage)(unsafe.Pointer(**(**uintptr)(__ccgo_up(ppPage)))).FisInit = uint8(0)
	} else {
		**(**uintptr)(__ccgo_up(ppPage)) = uintptr(0)
	}
	return rc
}

// C documentation
//
//	/*
//	** An implementation of a min-heap.
//	**
//	** aHeap[0] is the number of elements on the heap.  aHeap[1] is the
//	** root element.  The daughter nodes of aHeap[N] are aHeap[N*2]
//	** and aHeap[N*2+1].
//	**
//	** The heap property is this:  Every node is less than or equal to both
//	** of its daughter nodes.  A consequence of the heap property is that the
//	** root node aHeap[1] is always the minimum value currently in the heap.
//	**
//	** The btreeHeapInsert() routine inserts an unsigned 32-bit number onto
//	** the heap, preserving the heap property.  The btreeHeapPull() routine
//	** removes the root element from the heap (the minimum value in the heap)
//	** and then moves other nodes around as necessary to preserve the heap
//	** property.
//	**
//	** This heap is used for cell overlap and coverage testing.  Each u32
//	** entry represents the span of a cell or freeblock on a btree page.
//	** The upper 16 bits are the index of the first byte of a range and the
//	** lower 16 bits are the index of the last byte of that range.
//	*/
func _btreeHeapInsert(tls *libc.TLS, aHeap uintptr, x Tu32) {
	var i, j, v1 Tu32
	var v2 uintptr
	_, _, _, _ = i, j, v1, v2
	v2 = aHeap
	*(*Tu32)(unsafe.Pointer(v2)) = *(*Tu32)(unsafe.Pointer(v2)) + 1
	v1 = *(*Tu32)(unsafe.Pointer(v2))
	i = v1
	**(**Tu32)(__ccgo_up(aHeap + uintptr(i)*4)) = x
	for {
		v1 = i / libc.Uint32FromInt32(2)
		j = v1
		if !(v1 > uint32(0) && **(**Tu32)(__ccgo_up(aHeap + uintptr(j)*4)) > **(**Tu32)(__ccgo_up(aHeap + uintptr(i)*4))) {
			break
		}
		x = **(**Tu32)(__ccgo_up(aHeap + uintptr(j)*4))
		**(**Tu32)(__ccgo_up(aHeap + uintptr(j)*4)) = **(**Tu32)(__ccgo_up(aHeap + uintptr(i)*4))
		**(**Tu32)(__ccgo_up(aHeap + uintptr(i)*4)) = x
		i = j
	}
}

func _btreeHeapPull(tls *libc.TLS, aHeap uintptr, pOut uintptr) (r int32) {
	var i, j, x, v1 Tu32
	_, _, _, _ = i, j, x, v1
	v1 = **(**Tu32)(__ccgo_up(aHeap))
	x = v1
	if v1 == uint32(0) {
		return 0
	}
	**(**Tu32)(__ccgo_up(pOut)) = **(**Tu32)(__ccgo_up(aHeap + 1*4))
	**(**Tu32)(__ccgo_up(aHeap + 1*4)) = **(**Tu32)(__ccgo_up(aHeap + uintptr(x)*4))
	**(**Tu32)(__ccgo_up(aHeap + uintptr(x)*4)) = uint32(0xffffffff)
	**(**Tu32)(__ccgo_up(aHeap)) = **(**Tu32)(__ccgo_up(aHeap)) - 1
	i = uint32(1)
	for {
		v1 = i * libc.Uint32FromInt32(2)
		j = v1
		if !(v1 <= **(**Tu32)(__ccgo_up(aHeap))) {
			break
		}
		if **(**Tu32)(__ccgo_up(aHeap + uintptr(j)*4)) > **(**Tu32)(__ccgo_up(aHeap + uintptr(j+uint32(1))*4)) {
			j = j + 1
		}
		if **(**Tu32)(__ccgo_up(aHeap + uintptr(i)*4)) < **(**Tu32)(__ccgo_up(aHeap + uintptr(j)*4)) {
			break
		}
		x = **(**Tu32)(__ccgo_up(aHeap + uintptr(i)*4))
		**(**Tu32)(__ccgo_up(aHeap + uintptr(i)*4)) = **(**Tu32)(__ccgo_up(aHeap + uintptr(j)*4))
		**(**Tu32)(__ccgo_up(aHeap + uintptr(j)*4)) = x
		i = j
	}
	return int32(1)
}

// C documentation
//
//	/* Move the cursor to the last entry in the table.  Return SQLITE_OK
//	** on success.  Set *pRes to 0 if the cursor actually points to something
//	** or set *pRes to 1 if the table is empty.
//	*/
func _btreeLast(tls *libc.TLS, pCur uintptr, pRes uintptr) (r int32) {
	var rc int32
	var v1 uintptr
	_, _ = rc, v1
	rc = _moveToRoot(tls, pCur)
	if rc == SQLITE_OK {
		**(**int32)(__ccgo_up(pRes)) = 0
		rc = _moveToRightmost(tls, pCur)
		if rc == SQLITE_OK {
			v1 = pCur + 1
			*(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTCF_AtLast))
		} else {
			v1 = pCur + 1
			*(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(BTCF_AtLast))
		}
	} else {
		if rc == int32(SQLITE_EMPTY) {
			**(**int32)(__ccgo_up(pRes)) = int32(1)
			rc = SQLITE_OK
		}
	}
	return rc
}

// C documentation
//
//	/* This is a helper function for sqlite3BtreeLock(). By moving
//	** complex, but seldom used logic, out of sqlite3BtreeLock() and
//	** into this routine, we avoid unnecessary stack pointer changes
//	** and thus help the sqlite3BtreeLock() routine to run much faster
//	** in the common case.
//	*/
func _btreeLockCarefully(tls *libc.TLS, p uintptr) {
	var pLater uintptr
	_ = pLater
	/* In most cases, we should be able to acquire the lock we
	 ** want without having to go through the ascending lock
	 ** procedure that follows.  Just be sure not to block.
	 */
	if Xsqlite3_mutex_try(tls, (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).Fmutex) == SQLITE_OK {
		(*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).Fdb = (*TBtree)(unsafe.Pointer(p)).Fdb
		(*TBtree)(unsafe.Pointer(p)).Flocked = uint8(1)
		return
	}
	/* To avoid deadlock, first release all locks with a larger
	 ** BtShared address.  Then acquire our lock.  Then reacquire
	 ** the other BtShared locks that we used to hold in ascending
	 ** order.
	 */
	pLater = (*TBtree)(unsafe.Pointer(p)).FpNext
	for {
		if !(pLater != 0) {
			break
		}
		if (*TBtree)(unsafe.Pointer(pLater)).Flocked != 0 {
			_unlockBtreeMutex(tls, pLater)
		}
		goto _1
	_1:
		;
		pLater = (*TBtree)(unsafe.Pointer(pLater)).FpNext
	}
	_lockBtreeMutex(tls, p)
	pLater = (*TBtree)(unsafe.Pointer(p)).FpNext
	for {
		if !(pLater != 0) {
			break
		}
		if (*TBtree)(unsafe.Pointer(pLater)).FwantToLock != 0 {
			_lockBtreeMutex(tls, pLater)
		}
		goto _2
	_2:
		;
		pLater = (*TBtree)(unsafe.Pointer(pLater)).FpNext
	}
}

// C documentation
//
//	/*
//	** Retrieve a page from the pager cache. If the requested page is not
//	** already in the pager cache return NULL. Initialize the MemPage.pBt and
//	** MemPage.aData elements if needed.
//	*/
func _btreePageLookup(tls *libc.TLS, pBt uintptr, pgno TPgno) (r uintptr) {
	var pDbPage uintptr
	_ = pDbPage
	pDbPage = _sqlite3PagerLookup(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, pgno)
	if pDbPage != 0 {
		return _btreePageFromDbPage(tls, pDbPage, pgno, pBt)
	}
	return uintptr(0)
}

// C documentation
//
//	/*
//	** Return the size of the database file in pages. If there is any kind of
//	** error, return ((unsigned int)-1).
//	*/
func _btreePagecount(tls *libc.TLS, pBt uintptr) (r TPgno) {
	return (*TBtShared)(unsafe.Pointer(pBt)).FnPage
}

// C documentation
//
//	/*
//	** Set bit pgno of the BtShared.pHasContent bitvec. This is called
//	** when a page that previously contained data becomes a free-list leaf
//	** page.
//	**
//	** The BtShared.pHasContent bitvec exists to work around an obscure
//	** bug caused by the interaction of two useful IO optimizations surrounding
//	** free-list leaf pages:
//	**
//	**   1) When all data is deleted from a page and the page becomes
//	**      a free-list leaf page, the page is not written to the database
//	**      (as free-list leaf pages contain no meaningful data). Sometimes
//	**      such a page is not even journalled (as it will not be modified,
//	**      why bother journalling it?).
//	**
//	**   2) When a free-list leaf page is reused, its content is not read
//	**      from the database or written to the journal file (why should it
//	**      be, if it is not at all meaningful?).
//	**
//	** By themselves, these optimizations work fine and provide a handy
//	** performance boost to bulk delete or insert operations. However, if
//	** a page is moved to the free-list and then reused within the same
//	** transaction, a problem comes up. If the page is not journalled when
//	** it is moved to the free-list and it is also not journalled when it
//	** is extracted from the free-list and reused, then the original data
//	** may be lost. In the event of a rollback, it may not be possible
//	** to restore the database to its original configuration.
//	**
//	** The solution is the BtShared.pHasContent bitvec. Whenever a page is
//	** moved to become a free-list leaf page, the corresponding bit is
//	** set in the bitvec. Whenever a leaf page is extracted from the free-list,
//	** optimization 2 above is omitted if the corresponding bit is already
//	** set in BtShared.pHasContent. The contents of the bitvec are cleared
//	** at the end of every transaction.
//	*/
func _btreeSetHasContent(tls *libc.TLS, pBt uintptr, pgno TPgno) (r int32) {
	var rc int32
	_ = rc
	rc = SQLITE_OK
	if !((*TBtShared)(unsafe.Pointer(pBt)).FpHasContent != 0) {
		(*TBtShared)(unsafe.Pointer(pBt)).FpHasContent = _sqlite3BitvecCreate(tls, (*TBtShared)(unsafe.Pointer(pBt)).FnPage)
		if !((*TBtShared)(unsafe.Pointer(pBt)).FpHasContent != 0) {
			rc = int32(SQLITE_NOMEM)
		}
	}
	if rc == SQLITE_OK && pgno <= _sqlite3BitvecSize(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpHasContent) {
		rc = _sqlite3BitvecSet(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpHasContent, pgno)
	}
	return rc
}

func _cachedCellSize(tls *libc.TLS, p uintptr, N int32) (r Tu16) {
	if **(**Tu16)(__ccgo_up((*TCellArray)(unsafe.Pointer(p)).FszCell + uintptr(N)*2)) != 0 {
		return **(**Tu16)(__ccgo_up((*TCellArray)(unsafe.Pointer(p)).FszCell + uintptr(N)*2))
	}
	return _computeCellSize(tls, p, N)
}

func _callStatGet(tls *libc.TLS, pParse uintptr, regStat int32, iParam int32, regOut int32) {
	_sqlite3VdbeAddOp2(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32(OP_Integer), iParam, regStat+int32(1))
	_sqlite3VdbeAddFunctionCall(tls, pParse, 0, regStat, regOut, libc.Int32FromInt32(1)+libc.Int32FromInt32(IsStat4), uintptr(unsafe.Pointer(&_statGetFuncdef)), 0)
}

// C documentation
//
//	/*
//	** current_date()
//	**
//	** This function returns the same value as date('now').
//	*/
func _cdateFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
	_ = NotUsed
	_ = NotUsed2
	_dateFunc(tls, context, 0, uintptr(0))
}

// C documentation
//
//	/* Extra math functions that require linking with -lm
//	*/
//	/*
//	** Implementation SQL functions:
//	**
//	**   ceil(X)
//	**   ceiling(X)
//	**   floor(X)
//	**
//	** The sqlite3_user_data() pointer is a pointer to the libm implementation
//	** of the underlying C function.
//	*/
func _ceilingFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
	var x uintptr
	_ = x
	switch Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv))) {
	case int32(SQLITE_INTEGER):
		Xsqlite3_result_int64(tls, context, Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv))))
	case int32(SQLITE_FLOAT):
		x = Xsqlite3_user_data(tls, context)
		Xsqlite3_result_double(tls, context, (*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(&struct{ uintptr }{x})))(tls, Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv)))))
	default:
		break
	}
}

var _chacha20_init = [4]Tu32{
	0: uint32(0x61707865),
	1: uint32(0x3320646e),
	2: uint32(0x79622d32),
	3: uint32(0x6b206574),
}

// C documentation
//
//	/*
//	** Implementation of the changes() SQL function.
//	**
//	** IMP: R-32760-32347 The changes() SQL function is a wrapper
//	** around the sqlite3_changes64() C/C++ function and hence follows the
//	** same rules for counting changes.
//	*/
func _changes(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
	var db uintptr
	_ = db
	db = Xsqlite3_context_db_handle(tls, context)
	_ = NotUsed
	_ = NotUsed2
	Xsqlite3_result_int64(tls, context, Xsqlite3_changes64(tls, db))
}

// C documentation
//
//	/*
//	** Record an OOM error during integrity_check
//	*/
func _checkOom(tls *libc.TLS, pCheck uintptr) {
	(*TIntegrityCk)(unsafe.Pointer(pCheck)).Frc = int32(SQLITE_NOMEM)
	(*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr = 0 /* Causes integrity_check processing to stop */
	if (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr == 0 {
		(*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr + 1
	}
}

// C documentation
//
//	/*
//	** Delete all the content of a Select structure.  Deallocate the structure
//	** itself depending on the value of bFree
//	**
//	** If bFree==1, call sqlite3DbFree() on the p object.
//	** If bFree==0, Leave the first Select object unfreed
//	*/
func _clearSelect(tls *libc.TLS, db uintptr, p uintptr, bFree int32) {
	var pPrior uintptr
	_ = pPrior
	for p != 0 {
		pPrior = (*TSelect)(unsafe.Pointer(p)).FpPrior
		_sqlite3ExprListDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpEList)
		_sqlite3SrcListDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpSrc)
		_sqlite3ExprDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpWhere)
		_sqlite3ExprListDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpGroupBy)
		_sqlite3ExprDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpHaving)
		_sqlite3ExprListDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpOrderBy)
		_sqlite3ExprDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpLimit)
		if (*TSelect)(unsafe.Pointer(p)).FpWith != 0 {
			_sqlite3WithDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpWith)
		}
		if (*TSelect)(unsafe.Pointer(p)).FpWinDefn != 0 {
			_sqlite3WindowListDelete(tls, db, (*TSelect)(unsafe.Pointer(p)).FpWinDefn)
		}
		for (*TSelect)(unsafe.Pointer(p)).FpWin != 0 {
			_sqlite3WindowUnlinkFromSelect(tls, (*TSelect)(unsafe.Pointer(p)).FpWin)
		}
		if bFree != 0 {
			_sqlite3DbNNFreeNN(tls, db, p)
		}
		p = pPrior
		bFree = int32(1)
	}
}

// C documentation
//
//	/*
//	** Add code to implement the OFFSET
//	*/
func _codeOffset(tls *libc.TLS, v uintptr, iOffset int32, iContinue int32) {
	if iOffset > 0 {
		_sqlite3VdbeAddOp3(tls, v, int32(OP_IfPos), iOffset, iContinue, int32(1))
	}
}

// C documentation
//
//	/*
//	** Generate an instruction that will put the floating point
//	** value described by z[0..n-1] into register iMem.
//	**
//	** The z[] string will probably not be zero-terminated.  But the
//	** z[n] character is guaranteed to be something that does not look
//	** like the continuation of the number.
//	*/
func _codeReal(tls *libc.TLS, v uintptr, z uintptr, negateFlag int32, iMem int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var _ /* value at bp+0 */ float64
	if z != uintptr(0) {
		_sqlite3AtoF(tls, z, bp)
		/* The new AtoF never returns NaN */
		if negateFlag != 0 {
			**(**float64)(__ccgo_up(bp)) = -**(**float64)(__ccgo_up(bp))
		}
		_sqlite3VdbeAddOp4Dup8(tls, v, int32(OP_Real), 0, iMem, 0, bp, -int32(13))
	}
}

// C documentation
//
//	/*
//	** Table pTab is a WITHOUT ROWID table that is being written to. The cursor
//	** number is iCur, and register regData contains the new record for the
//	** PK index. This function adds code to invoke the pre-update hook,
//	** if one is registered.
//	*/
func _codeWithoutRowidPreupdate(tls *libc.TLS, pParse uintptr, pTab uintptr, iCur int32, regData int32) {
	var r int32
	var v uintptr
	_, _ = r, v
	v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe
	r = _sqlite3GetTempReg(tls, pParse)
	_sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, r)
	_sqlite3VdbeAddOp4(tls, v, int32(OP_Insert), iCur, regData, r, pTab, -int32(5))
	_sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_ISNOOP))
	_sqlite3ReleaseTempReg(tls, pParse, r)
}

var _colmask = int64(libc.Int32FromInt32(0x7FFFFFFF)) << libc.Int32FromInt32(32)

// C documentation
//
//	/*
//	** This function is called after invoking an sqlite3_value_XXX function on a
//	** column value (i.e. a value returned by evaluating an SQL expression in the
//	** select list of a SELECT statement) that may cause a malloc() failure. If
//	** malloc() has failed, the threads mallocFailed flag is cleared and the result
//	** code of statement pStmt set to SQLITE_NOMEM.
//	**
//	** Specifically, this is called from within:
//	**
//	**     sqlite3_column_int()
//	**     sqlite3_column_int64()
//	**     sqlite3_column_text()
//	**     sqlite3_column_text16()
//	**     sqlite3_column_double()
//	**     sqlite3_column_bytes()
//	**     sqlite3_column_bytes16()
//	**     sqlite3_column_blob()
//	*/
func _columnMallocFailure(tls *libc.TLS, pStmt uintptr) {
	var p uintptr
	_ = p
	/* If malloc() failed during an encoding conversion within an
	 ** sqlite3_column_XXX API, then set the return code of the statement to
	 ** SQLITE_NOMEM. The next call to _step() (if any) will return SQLITE_ERROR
	 ** and _finalize() will return NOMEM.
	 */
	p = pStmt
	if p != 0 {
		(*TVdbe)(unsafe.Pointer(p)).Frc = _sqlite3ApiExit(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, (*TVdbe)(unsafe.Pointer(p)).Frc)
		Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).Fmutex)
	}
}

// C documentation
//
//	/*
//	** Return a pointer to static memory containing an SQL NULL value.
//	*/
func _columnNullValue(tls *libc.TLS) (r uintptr) {
	return uintptr(unsafe.Pointer(&_nullMem))
}

// C documentation
//
//	/*
//	** Implementation of the sqlite_compileoption_get() function.
//	** The result is a string that identifies the compiler options
//	** used to build SQLite.
//	*/
func _compileoptiongetFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
	var n int32
	_ = n
	_ = argc
	/* IMP: R-04922-24076 The sqlite_compileoption_get() SQL function
	 ** is a wrapper around the sqlite3_compileoption_get() C/C++ function.
	 */
	n = Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(argv)))
	Xsqlite3_result_text(tls, context, Xsqlite3_compileoption_get(tls, n), -int32(1), libc.UintptrFromInt32(0))
}

// C documentation
//
//	/*
//	** Implementation of the sqlite_compileoption_used() function.
//	** The result is an integer that identifies if the compiler option
//	** was used to build SQLite.
//	*/
func _compileoptionusedFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
	var zOptName, v1 uintptr
	_, _ = zOptName, v1
	_ = argc
	/* IMP: R-39564-36305 The sqlite_compileoption_used() SQL
	 ** function is a wrapper around the sqlite3_compileoption_used() C/C++
	 ** function.
	 */
	v1 = Xsqlite3_value_text(tls, **(**uintptr)(__ccgo_up(argv)))
	zOptName = v1
	if v1 != uintptr(0) {
		Xsqlite3_result_int(tls, context, Xsqlite3_compileoption_used(tls, zOptName))
	}
}

// C documentation
//
//	/*
//	** Compute both YMD and HMS
//	*/
func _computeYMD_HMS(tls *libc.TLS, p uintptr) {
	_computeYMD(tls, p)
	_computeHMS(tls, p)
}

func _countFinalize(tls *libc.TLS, context uintptr) {
	var p uintptr
	var v1 int64
	_, _ = p, v1
	p = Xsqlite3_aggregate_context(tls, context, 0)
	if p != 0 {
		v1 = (*TCountCtx)(unsafe.Pointer(p)).Fn
	} else {
		v1 = 0
	}
	Xsqlite3_result_int64(tls, context, v1)
}

func _countInverse(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
	var p uintptr
	_ = p
	p = Xsqlite3_aggregate_context(tls, ctx, int32(8))
	/* p is always non-NULL since countStep() will have been called first */
	if (argc == 0 || int32(SQLITE_NULL) != Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv)))) && p != 0 {
		(*TCountCtx)(unsafe.Pointer(p)).Fn = (*TCountCtx)(unsafe.Pointer(p)).Fn - 1
	}
}

// C documentation
//
//	/*
//	** Count leading zeros for a 64-bit unsigned integer.
//	*/
func _countLeadingZeros(tls *libc.TLS, m Tu64) (r int32) {
	var n int32
	_ = n
	n = 0
	if m <= uint64(0x00000000ffffffff) {
		n = n + int32(32)
		m = m << uint64(32)
	}
	if m <= uint64(0x0000ffffffffffff) {
		n = n + int32(16)
		m = m << uint64(16)
	}
	if m <= uint64(0x00ffffffffffffff) {
		n = n + int32(8)
		m = m << uint64(8)
	}
	if m <= uint64(0x0fffffffffffffff) {
		n = n + int32(4)
		m = m << uint64(4)
	}
	if m <= uint64(0x3fffffffffffffff) {
		n = n + int32(2)
		m = m << uint64(2)
	}
	if m <= uint64(0x7fffffffffffffff) {
		n = n + int32(1)
	}
	return n
}

// C documentation
//
//	/*
//	** Return the number of LookasideSlot elements on the linked list
//	*/
func _countLookasideSlots(tls *libc.TLS, p uintptr) (r Tu32) {
	var cnt Tu32
	_ = cnt
	cnt = uint32(0)
	for p != 0 {
		p = (*TLookasideSlot)(unsafe.Pointer(p)).FpNext
		cnt = cnt + 1
	}
	return cnt
}

// C documentation
//
//	/*
//	** Routines to implement the count() aggregate function.
//	*/
func _countStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
	var p uintptr
	_ = p
	p = Xsqlite3_aggregate_context(tls, context, int32(8))
	if (argc == 0 || int32(SQLITE_NULL) != Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv)))) && p != 0 {
		(*TCountCtx)(unsafe.Pointer(p)).Fn = (*TCountCtx)(unsafe.Pointer(p)).Fn + 1
	}
	/* The sqlite3_aggregate_count() function is deprecated.  But just to make
	 ** sure it still operates correctly, verify that its count agrees with our
	 ** internal count when using count(*) and when the total count can be
	 ** expressed as a 32-bit integer. */
}

// C documentation
//
//	/*
//	** Create a new mask for cursor iCursor.
//	**
//	** There is one cursor per table in the FROM clause.  The number of
//	** tables in the FROM clause is limited by a test early in the
//	** sqlite3WhereBegin() routine.  So we know that the pMaskSet->ix[]
//	** array will never overflow.
//	*/
func _createMask(tls *libc.TLS, pMaskSet uintptr, iCursor int32) {
	var v1 int32
	var v2 uintptr
	_, _ = v1, v2
	v2 = pMaskSet + 4
	v1 = *(*int32)(unsafe.Pointer(v2))
	*(*int32)(unsafe.Pointer(v2)) = *(*int32)(unsafe.Pointer(v2)) + 1
	**(**int32)(__ccgo_up(pMaskSet + 8 + uintptr(v1)*4)) = iCursor
}

// C documentation
//
//	/*
//	** The actual function that does the work of creating a new module.
//	** This function implements the sqlite3_create_module() and
//	** sqlite3_create_module_v2() interfaces.
//	*/
func _createModule(tls *libc.TLS, db uintptr, zName uintptr, pModule uintptr, pAux uintptr, __ccgo_fp_xDestroy uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = SQLITE_OK
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	_sqlite3VtabCreateModule(tls, db, zName, pModule, pAux, __ccgo_fp_xDestroy)
	rc = _sqlite3ApiExit(tls, db, rc)
	if rc != SQLITE_OK && __ccgo_fp_xDestroy != 0 {
		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDestroy})))(tls, pAux)
	}
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return rc
}

// C documentation
//
//	/*
//	** Clear information from a Cte object, but do not deallocate storage
//	** for the object itself.
//	*/
func _cteClear(tls *libc.TLS, db uintptr, pCte uintptr) {
	_sqlite3ExprListDelete(tls, db, (*TCte)(unsafe.Pointer(pCte)).FpCols)
	_sqlite3SelectDelete(tls, db, (*TCte)(unsafe.Pointer(pCte)).FpSelect)
	_sqlite3DbFree(tls, db, (*TCte)(unsafe.Pointer(pCte)).FzName)
}

// C documentation
//
//	/*
//	** current_time()
//	**
//	** This function returns the same value as time('now').
//	*/
func _ctimeFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
	_ = NotUsed
	_ = NotUsed2
	_timeFunc(tls, context, 0, uintptr(0))
}

// C documentation
//
//	/*
//	** current_timestamp()
//	**
//	** This function returns the same value as datetime('now').
//	*/
func _ctimestampFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
	_ = NotUsed
	_ = NotUsed2
	_datetimeFunc(tls, context, 0, uintptr(0))
}

func _cume_distInvFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
	var p uintptr
	_ = p
	_ = nArg
	_ = apArg
	p = Xsqlite3_aggregate_context(tls, pCtx, int32(24))
	(*TCallCount)(unsafe.Pointer(p)).FnStep = (*TCallCount)(unsafe.Pointer(p)).FnStep + 1
}

// C documentation
//
//	/*
//	** Implementation of built-in window function cume_dist(). Assumes that
//	** the window frame has been set to:
//	**
//	**   GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING
//	*/
func _cume_distStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
	var p uintptr
	_ = p
	_ = nArg
	_ = apArg
	p = Xsqlite3_aggregate_context(tls, pCtx, int32(24))
	if p != 0 {
		(*TCallCount)(unsafe.Pointer(p)).FnTotal = (*TCallCount)(unsafe.Pointer(p)).FnTotal + 1
	}
}

func _cume_distValueFunc(tls *libc.TLS, pCtx uintptr) {
	var p uintptr
	var r float64
	_, _ = p, r
	p = Xsqlite3_aggregate_context(tls, pCtx, 0)
	if p != 0 {
		r = float64((*TCallCount)(unsafe.Pointer(p)).FnStep) / float64((*TCallCount)(unsafe.Pointer(p)).FnTotal)
		Xsqlite3_result_double(tls, pCtx, r)
	}
}

// C documentation
//
//	/* Verify that the database file has not be deleted or renamed out from
//	** under the pager.  Return SQLITE_OK if the database is still where it ought
//	** to be on disk.  Return non-zero (SQLITE_READONLY_DBMOVED or some other error
//	** code from sqlite3OsAccess()) if the database has gone missing.
//	*/
func _databaseIsUnmoved(tls *libc.TLS, pPager uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* bHasMoved at bp+0 */ int32
	_ = rc
	**(**int32)(__ccgo_up(bp)) = 0
	if (*TPager)(unsafe.Pointer(pPager)).FtempFile != 0 {
		return SQLITE_OK
	}
	if (*TPager)(unsafe.Pointer(pPager)).FdbSize == uint32(0) {
		return SQLITE_OK
	}
	rc = _sqlite3OsFileControl(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, int32(SQLITE_FCNTL_HAS_MOVED), bp)
	if rc == int32(SQLITE_NOTFOUND) {
		/* If the HAS_MOVED file-control is unimplemented, assume that the file
		 ** has not been moved.  That is the historical behavior of SQLite: prior to
		 ** version 3.8.3, it never checked */
		rc = SQLITE_OK
	} else {
		if rc == SQLITE_OK && **(**int32)(__ccgo_up(bp)) != 0 {
			rc = libc.Int32FromInt32(SQLITE_READONLY) | libc.Int32FromInt32(4)<<libc.Int32FromInt32(8)
		}
	}
	return rc
}

// C documentation
//
//	/*
//	** Return the number of days after the most recent Monday.
//	**
//	** In other words, return the day of the week according
//	** to this code:
//	**
//	**   0=Monday, 1=Tuesday, 2=Wednesday, ..., 6=Sunday.
//	*/
func _daysAfterMonday(tls *libc.TLS, pDate uintptr) (r int32) {
	return int32(((*TDateTime)(unsafe.Pointer(pDate)).FiJD+libc.Int64FromInt32(43200000))/libc.Int64FromInt32(86400000)) % int32(7)
}

// C documentation
//
//	/*
//	** Return the number of days after the most recent Sunday.
//	**
//	** In other words, return the day of the week according
//	** to this code:
//	**
//	**   0=Sunday, 1=Monday, 2=Tuesday, ..., 6=Saturday
//	*/
func _daysAfterSunday(tls *libc.TLS, pDate uintptr) (r int32) {
	return int32(((*TDateTime)(unsafe.Pointer(pDate)).FiJD+libc.Int64FromInt32(129600000))/libc.Int64FromInt32(86400000)) % int32(7)
}

// C documentation
//
//	/* Finish the work of sqlite3DbMallocRawNN for the unusual and
//	** slower case when the allocation cannot be fulfilled using lookaside.
//	*/
func _dbMallocRawFinish(tls *libc.TLS, db uintptr, n Tu64) (r uintptr) {
	var p uintptr
	_ = p
	p = _sqlite3Malloc(tls, n)
	if !(p != 0) {
		_sqlite3OomFault(tls, db)
	}
	return p
}

func _dbpageBegin(tls *libc.TLS, pVtab uintptr) (r int32) {
	var pTab uintptr
	_ = pTab
	pTab = pVtab
	(*TDbpageTable)(unsafe.Pointer(pTab)).FpgnoTrunc = uint32(0)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Close a dbpagevfs cursor.
//	*/
func _dbpageClose(tls *libc.TLS, pCursor uintptr) (r int32) {
	var pCsr uintptr
	_ = pCsr
	pCsr = pCursor
	if (*TDbpageCursor)(unsafe.Pointer(pCsr)).FpPage1 != 0 {
		_sqlite3PagerUnrefPageOne(tls, (*TDbpageCursor)(unsafe.Pointer(pCsr)).FpPage1)
	}
	Xsqlite3_free(tls, pCsr)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Disconnect from or destroy a dbpagevfs virtual table.
//	*/
func _dbpageDisconnect(tls *libc.TLS, pVtab uintptr) (r int32) {
	Xsqlite3_free(tls, pVtab)
	return SQLITE_OK
}

func _dbpageEof(tls *libc.TLS, pCursor uintptr) (r int32) {
	var pCsr uintptr
	_ = pCsr
	pCsr = pCursor
	return libc.BoolInt32((*TDbpageCursor)(unsafe.Pointer(pCsr)).Fpgno > (*TDbpageCursor)(unsafe.Pointer(pCsr)).FmxPgno)
}

// C documentation
//
//	/*
//	** Move a dbpagevfs cursor to the next entry in the file.
//	*/
func _dbpageNext(tls *libc.TLS, pCursor uintptr) (r int32) {
	var pCsr uintptr
	var rc int32
	_, _ = pCsr, rc
	rc = SQLITE_OK
	pCsr = pCursor
	(*TDbpageCursor)(unsafe.Pointer(pCsr)).Fpgno = (*TDbpageCursor)(unsafe.Pointer(pCsr)).Fpgno + 1
	return rc
}

// C documentation
//
//	/* Cancel any pending truncate.
//	*/
func _dbpageRollbackTo(tls *libc.TLS, pVtab uintptr, notUsed1 int32) (r int32) {
	var pTab uintptr
	_ = pTab
	pTab = pVtab
	(*TDbpageTable)(unsafe.Pointer(pTab)).FpgnoTrunc = uint32(0)
	_ = notUsed1
	return SQLITE_OK
}

var _dbpage_module = Tsqlite3_module{
	FiVersion: int32(2),
}

var _dbstat_module = Tsqlite3_module{}

// C documentation
//
//	/*
//	** Decode the flags byte (the first byte of the header) for a page
//	** and initialize fields of the MemPage structure accordingly.
//	**
//	** Only the following combinations are supported.  Anything different
//	** indicates a corrupt database files:
//	**
//	**         PTF_ZERODATA                             (0x02,  2)
//	**         PTF_LEAFDATA | PTF_INTKEY                (0x05,  5)
//	**         PTF_ZERODATA | PTF_LEAF                  (0x0a, 10)
//	**         PTF_LEAFDATA | PTF_INTKEY | PTF_LEAF     (0x0d, 13)
//	*/
func _decodeFlags(tls *libc.TLS, pPage uintptr, flagByte int32) (r int32) {
	var pBt uintptr
	_ = pBt /* A copy of pPage->pBt */
	pBt = (*TMemPage)(unsafe.Pointer(pPage)).FpBt
	(*TMemPage)(unsafe.Pointer(pPage)).Fmax1bytePayload = (*TBtShared)(unsafe.Pointer(pBt)).Fmax1bytePayload
	if flagByte >= libc.Int32FromInt32(PTF_ZERODATA)|libc.Int32FromInt32(PTF_LEAF) {
		(*TMemPage)(unsafe.Pointer(pPage)).FchildPtrSize = uint8(0)
		(*TMemPage)(unsafe.Pointer(pPage)).Fleaf = uint8(1)
		if flagByte == libc.Int32FromInt32(PTF_LEAFDATA)|libc.Int32FromInt32(PTF_INTKEY)|libc.Int32FromInt32(PTF_LEAF) {
			(*TMemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = uint8(1)
			(*TMemPage)(unsafe.Pointer(pPage)).FxCellSize = __ccgo_fp(_cellSizePtrTableLeaf)
			(*TMemPage)(unsafe.Pointer(pPage)).FxParseCell = __ccgo_fp(_btreeParseCellPtr)
			(*TMemPage)(unsafe.Pointer(pPage)).FintKey = uint8(1)
			(*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal = (*TBtShared)(unsafe.Pointer(pBt)).FmaxLeaf
			(*TMemPage)(unsafe.Pointer(pPage)).FminLocal = (*TBtShared)(unsafe.Pointer(pBt)).FminLeaf
		} else {
			if flagByte == libc.Int32FromInt32(PTF_ZERODATA)|libc.Int32FromInt32(PTF_LEAF) {
				(*TMemPage)(unsafe.Pointer(pPage)).FintKey = uint8(0)
				(*TMemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = uint8(0)
				(*TMemPage)(unsafe.Pointer(pPage)).FxCellSize = __ccgo_fp(_cellSizePtrIdxLeaf)
				(*TMemPage)(unsafe.Pointer(pPage)).FxParseCell = __ccgo_fp(_btreeParseCellPtrIndex)
				(*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal = (*TBtShared)(unsafe.Pointer(pBt)).FmaxLocal
				(*TMemPage)(unsafe.Pointer(pPage)).FminLocal = (*TBtShared)(unsafe.Pointer(pBt)).FminLocal
			} else {
				(*TMemPage)(unsafe.Pointer(pPage)).FintKey = uint8(0)
				(*TMemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = uint8(0)
				(*TMemPage)(unsafe.Pointer(pPage)).FxCellSize = __ccgo_fp(_cellSizePtrIdxLeaf)
				(*TMemPage)(unsafe.Pointer(pPage)).FxParseCell = __ccgo_fp(_btreeParseCellPtrIndex)
				return _sqlite3CorruptError(tls, int32(75283))
			}
		}
	} else {
		(*TMemPage)(unsafe.Pointer(pPage)).FchildPtrSize = uint8(4)
		(*TMemPage)(unsafe.Pointer(pPage)).Fleaf = uint8(0)
		if flagByte == int32(PTF_ZERODATA) {
			(*TMemPage)(unsafe.Pointer(pPage)).FintKey = uint8(0)
			(*TMemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = uint8(0)
			(*TMemPage)(unsafe.Pointer(pPage)).FxCellSize = __ccgo_fp(_cellSizePtr)
			(*TMemPage)(unsafe.Pointer(pPage)).FxParseCell = __ccgo_fp(_btreeParseCellPtrIndex)
			(*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal = (*TBtShared)(unsafe.Pointer(pBt)).FmaxLocal
			(*TMemPage)(unsafe.Pointer(pPage)).FminLocal = (*TBtShared)(unsafe.Pointer(pBt)).FminLocal
		} else {
			if flagByte == libc.Int32FromInt32(PTF_LEAFDATA)|libc.Int32FromInt32(PTF_INTKEY) {
				(*TMemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = uint8(0)
				(*TMemPage)(unsafe.Pointer(pPage)).FxCellSize = __ccgo_fp(_cellSizePtrNoPayload)
				(*TMemPage)(unsafe.Pointer(pPage)).FxParseCell = __ccgo_fp(_btreeParseCellPtrNoPayload)
				(*TMemPage)(unsafe.Pointer(pPage)).FintKey = uint8(1)
				(*TMemPage)(unsafe.Pointer(pPage)).FmaxLocal = (*TBtShared)(unsafe.Pointer(pBt)).FmaxLeaf
				(*TMemPage)(unsafe.Pointer(pPage)).FminLocal = (*TBtShared)(unsafe.Pointer(pBt)).FminLeaf
			} else {
				(*TMemPage)(unsafe.Pointer(pPage)).FintKey = uint8(0)
				(*TMemPage)(unsafe.Pointer(pPage)).FintKeyLeaf = uint8(0)
				(*TMemPage)(unsafe.Pointer(pPage)).FxCellSize = __ccgo_fp(_cellSizePtr)
				(*TMemPage)(unsafe.Pointer(pPage)).FxParseCell = __ccgo_fp(_btreeParseCellPtrIndex)
				return _sqlite3CorruptError(tls, int32(75307))
			}
		}
	}
	return SQLITE_OK
}

var _defaultMethods = Tsqlite3_mem_methods{}

var _defaultMethods1 = Tsqlite3_pcache_methods2{
	FiVersion: int32(1),
}

/* This case is for systems that have support for sleeping for fractions of
 ** a second.  Examples:  All windows systems, unix systems with nanosleep() */
var _delays = [12]Tu8{
	0:  uint8(1),
	1:  uint8(2),
	2:  uint8(5),
	3:  uint8(10),
	4:  uint8(15),
	5:  uint8(20),
	6:  uint8(25),
	7:  uint8(25),
	8:  uint8(25),
	9:  uint8(50),
	10: uint8(50),
	11: uint8(100),
}

// C documentation
//
//	/*
//	** Implementation of built-in window function dense_rank(). Assumes that
//	** the window frame has been set to:
//	**
//	**   RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
//	*/
func _dense_rankStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
	var p uintptr
	_ = p
	p = Xsqlite3_aggregate_context(tls, pCtx, int32(24))
	if p != 0 {
		(*TCallCount)(unsafe.Pointer(p)).FnStep = int64(1)
	}
	_ = nArg
	_ = apArg
}

func _dense_rankValueFunc(tls *libc.TLS, pCtx uintptr) {
	var p uintptr
	_ = p
	p = Xsqlite3_aggregate_context(tls, pCtx, int32(24))
	if p != 0 {
		if (*TCallCount)(unsafe.Pointer(p)).FnStep != 0 {
			(*TCallCount)(unsafe.Pointer(p)).FnValue = (*TCallCount)(unsafe.Pointer(p)).FnValue + 1
			(*TCallCount)(unsafe.Pointer(p)).FnStep = 0
		}
		Xsqlite3_result_int64(tls, pCtx, (*TCallCount)(unsafe.Pointer(p)).FnValue)
	}
}

/* C89 specifies that the constant "dummy" will be initialized to all
 ** zeros, which is correct.  MSVC generates a warning, nevertheless. */
var _dummy TVdbeOp

// C documentation
//
//	/*
//	** Return the number of bytes required to create a duplicate of the
//	** expression passed as the first argument.
//	**
//	** The value returned includes space to create a copy of the Expr struct
//	** itself and the buffer referred to by Expr.u.zToken, if any.
//	**
//	** The return value includes space to duplicate all Expr nodes in the
//	** tree formed by Expr.pLeft and Expr.pRight, but not any other
//	** substructure such as Expr.x.pList, Expr.x.pSelect, and Expr.y.pWin.
//	*/
func _dupedExprSize(tls *libc.TLS, p uintptr) (r int32) {
	var nByte int32
	_ = nByte
	nByte = _dupedExprNodeSize(tls, p, int32(EXPRDUP_REDUCE))
	if (*TExpr)(unsafe.Pointer(p)).FpLeft != 0 {
		nByte = nByte + _dupedExprSize(tls, (*TExpr)(unsafe.Pointer(p)).FpLeft)
	}
	if (*TExpr)(unsafe.Pointer(p)).FpRight != 0 {
		nByte = nByte + _dupedExprSize(tls, (*TExpr)(unsafe.Pointer(p)).FpRight)
	}
	return nByte
}

var _emptyArray = uint8(0x0b)

var _emptyObject = [2]Tu8{
	0: uint8(JSONB_ARRAY),
	1: uint8(JSONB_OBJECT),
}

var _emptyObject1 = uint8(0x0c)

var _endCode = [7]TVdbeOpList{
	0: {
		Fopcode: uint8(OP_AddImm),
		Fp1:     int8(1),
	},
	1: {
		Fopcode: uint8(OP_IfNotZero),
		Fp1:     int8(1),
		Fp2:     int8(4),
	},
	2: {
		Fopcode: uint8(OP_String8),
		Fp2:     int8(3),
	},
	3: {
		Fopcode: uint8(OP_ResultRow),
		Fp1:     int8(3),
		Fp2:     int8(1),
	},
	4: {
		Fopcode: uint8(OP_Halt),
	},
	5: {
		Fopcode: uint8(OP_String8),
		Fp2:     int8(3),
	},
	6: {
		Fopcode: uint8(OP_Goto),
		Fp2:     int8(3),
	},
}

// C documentation
//
//	/*
//	** Obtain the STATIC_MAIN mutex.
//	*/
func _enterMutex(tls *libc.TLS) {
	Xsqlite3_mutex_enter(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN)))
}

// C documentation
//
//	/*
//	** Set the error message of the context passed as the first argument to
//	** the result of formatting zFmt using printf() style formatting.
//	*/
func _errorMPrintf(tls *libc.TLS, pCtx uintptr, zFmt uintptr, va uintptr) {
	var ap Tva_list
	var db, zErr uintptr
	_, _, _ = ap, db, zErr
	db = Xsqlite3_context_db_handle(tls, pCtx)
	zErr = uintptr(0)
	ap = va
	zErr = _sqlite3VMPrintf(tls, db, zFmt, ap)
	_ = ap
	if zErr != 0 {
		Xsqlite3_result_error(tls, pCtx, zErr, -int32(1))
		_sqlite3DbFree(tls, db, zErr)
	} else {
		Xsqlite3_result_error_nomem(tls, pCtx)
	}
}

func _execSqlF(tls *libc.TLS, db uintptr, pzErrMsg uintptr, zSql uintptr, va uintptr) (r int32) {
	var ap Tva_list
	var rc int32
	var z uintptr
	_, _, _ = ap, rc, z
	ap = va
	z = _sqlite3VMPrintf(tls, db, zSql, ap)
	_ = ap
	if z == uintptr(0) {
		return int32(SQLITE_NOMEM)
	}
	rc = _execSql(tls, db, pzErrMsg, z)
	_sqlite3DbFree(tls, db, z)
	return rc
}

// C documentation
//
//	/*
//	** Allocate and return a pointer to an expression of type TK_ROW with
//	** Expr.iColumn set to value (iCol+1). The resolver will modify the
//	** expression to be a TK_COLUMN reading column iCol of the first
//	** table in the source-list (pSrc->a[0]).
//	*/
func _exprRowColumn(tls *libc.TLS, pParse uintptr, iCol int32) (r uintptr) {
	var pRet uintptr
	_ = pRet
	pRet = _sqlite3PExpr(tls, pParse, int32(TK_ROW), uintptr(0), uintptr(0))
	if pRet != 0 {
		(*TExpr)(unsafe.Pointer(pRet)).FiColumn = int16(iCol + int32(1))
	}
	return pRet
}

// C documentation
//
//	/*
//	** This routine examines sub-SELECT statements as an expression is being
//	** walked as part of sqlite3ExprIsTableConstant().  Sub-SELECTs are considered
//	** constant as long as they are uncorrelated - meaning that they do not
//	** contain any terms from outer contexts.
//	*/
func _exprSelectWalkTableConstant(tls *libc.TLS, pWalker uintptr, pSelect uintptr) (r int32) {
	if (*TSelect)(unsafe.Pointer(pSelect)).FselFlags&uint32(SF_Correlated) != uint32(0) {
		(*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(0)
		return int32(WRC_Abort)
	}
	return int32(WRC_Prune)
}

var _fakeCursor Tu8

// C documentation
//
//	/*
//	** Look up an index by name.  Or, if the name of a WITHOUT ROWID table
//	** is supplied instead, find the PRIMARY KEY index for that table.
//	*/
func _findIndexOrPrimaryKey(tls *libc.TLS, db uintptr, zName uintptr, zDb uintptr) (r uintptr) {
	var pIdx, pTab uintptr
	_, _ = pIdx, pTab
	pIdx = _sqlite3FindIndex(tls, db, zName, zDb)
	if pIdx == uintptr(0) {
		pTab = _sqlite3FindTable(tls, db, zName, zDb)
		if pTab != 0 && !((*TTable)(unsafe.Pointer(pTab)).FtabFlags&libc.Uint32FromInt32(TF_WithoutRowid) == libc.Uint32FromInt32(0)) {
			pIdx = _sqlite3PrimaryKeyIndex(tls, pTab)
		}
	}
	return pIdx
}

// C documentation
//
//	/*
//	** Use nodeAcquire() to obtain the leaf node containing the record with
//	** rowid iRowid. If successful, set *ppLeaf to point to the node and
//	** return SQLITE_OK. If there is no such record in the table, set
//	** *ppLeaf to 0 and return SQLITE_OK. If an error occurs, set *ppLeaf
//	** to zero and return an SQLite error code.
//	*/
func _findLeafNode(tls *libc.TLS, pRtree uintptr, iRowid Ti64, ppLeaf uintptr, piNode uintptr) (r int32) {
	var iNode Ti64
	var rc int32
	_, _ = iNode, rc
	**(**uintptr)(__ccgo_up(ppLeaf)) = uintptr(0)
	Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid, int32(1), iRowid)
	if Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid) == int32(SQLITE_ROW) {
		iNode = Xsqlite3_column_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid, 0)
		if piNode != 0 {
			**(**Tsqlite3_int64)(__ccgo_up(piNode)) = iNode
		}
		rc = _nodeAcquire(tls, pRtree, iNode, uintptr(0), ppLeaf)
		Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid)
	} else {
		rc = Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadRowid)
	}
	return rc
}

// C documentation
//
//	/*
//	** If pSel is not part of a compound SELECT, return a pointer to its
//	** expression list. Otherwise, return a pointer to the expression list
//	** of the leftmost SELECT in the compound.
//	*/
func _findLeftmostExprlist(tls *libc.TLS, pSel uintptr) (r uintptr) {
	for (*TSelect)(unsafe.Pointer(pSel)).FpPrior != 0 {
		pSel = (*TSelect)(unsafe.Pointer(pSel)).FpPrior
	}
	return (*TSelect)(unsafe.Pointer(pSel)).FpEList
}

// C documentation
//
//	/*
//	** Return a pointer to the right-most SELECT statement in a compound.
//	*/
func _findRightmost(tls *libc.TLS, p uintptr) (r uintptr) {
	for (*TSelect)(unsafe.Pointer(p)).FpNext != 0 {
		p = (*TSelect)(unsafe.Pointer(p)).FpNext
	}
	return p
}

// C documentation
//
//	/*
//	** If node pLeaf is not the root of the r-tree and its pParent pointer is
//	** still NULL, load all ancestor nodes of pLeaf into memory and populate
//	** the pLeaf->pParent chain all the way up to the root node.
//	**
//	** This operation is required when a row is deleted (or updated - an update
//	** is implemented as a delete followed by an insert). SQLite provides the
//	** rowid of the row to delete, which can be used to find the leaf on which
//	** the entry resides (argument pLeaf). Once the leaf is located, this
//	** function is called to determine its ancestry.
//	*/
func _fixLeafParent(tls *libc.TLS, pRtree uintptr, pLeaf uintptr) (r int32) {
	var iNode Ti64
	var pChild, pTest uintptr
	var rc, rc2 int32
	_, _, _, _, _ = iNode, pChild, pTest, rc, rc2
	rc = SQLITE_OK
	pChild = pLeaf
	for rc == SQLITE_OK && (*TRtreeNode)(unsafe.Pointer(pChild)).FiNode != int64(1) && (*TRtreeNode)(unsafe.Pointer(pChild)).FpParent == uintptr(0) {
		rc2 = SQLITE_OK /* sqlite3_reset() return code */
		Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadParent, int32(1), (*TRtreeNode)(unsafe.Pointer(pChild)).FiNode)
		rc = Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadParent)
		if rc == int32(SQLITE_ROW) { /* Node number of parent node */
			/* Before setting pChild->pParent, test that we are not creating a
			 ** loop of references (as we would if, say, pChild==pParent). We don't
			 ** want to do this as it leads to a memory leak when trying to delete
			 ** the referenced counted node structures.
			 */
			iNode = Xsqlite3_column_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadParent, 0)
			pTest = pLeaf
			for {
				if !(pTest != 0 && (*TRtreeNode)(unsafe.Pointer(pTest)).FiNode != iNode) {
					break
				}
				goto _1
			_1:
				;
				pTest = (*TRtreeNode)(unsafe.Pointer(pTest)).FpParent
			}
			if pTest == uintptr(0) {
				rc2 = _nodeAcquire(tls, pRtree, iNode, uintptr(0), pChild)
			}
		}
		rc = Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpReadParent)
		if rc == SQLITE_OK {
			rc = rc2
		}
		if rc == SQLITE_OK && !((*TRtreeNode)(unsafe.Pointer(pChild)).FpParent != 0) {
			rc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<<libc.Int32FromInt32(8)
		}
		pChild = (*TRtreeNode)(unsafe.Pointer(pChild)).FpParent
	}
	return rc
}

// C documentation
//
//	/*
//	** The second argument is a Trigger structure allocated by the
//	** fkActionTrigger() routine. This function deletes the Trigger structure
//	** and all of its sub-components.
//	**
//	** The Trigger structure or any of its sub-components may be allocated from
//	** the lookaside buffer belonging to database handle dbMem.
//	*/
func _fkTriggerDelete(tls *libc.TLS, dbMem uintptr, p uintptr) {
	var pStep uintptr
	_ = pStep
	if p != 0 {
		pStep = (*TTrigger)(unsafe.Pointer(p)).Fstep_list
		_sqlite3SrcListDelete(tls, dbMem, (*TTriggerStep)(unsafe.Pointer(pStep)).FpSrc)
		_sqlite3ExprDelete(tls, dbMem, (*TTriggerStep)(unsafe.Pointer(pStep)).FpWhere)
		_sqlite3ExprListDelete(tls, dbMem, (*TTriggerStep)(unsafe.Pointer(pStep)).FpExprList)
		_sqlite3SelectDelete(tls, dbMem, (*TTriggerStep)(unsafe.Pointer(pStep)).FpSelect)
		_sqlite3ExprDelete(tls, dbMem, (*TTrigger)(unsafe.Pointer(p)).FpWhen)
		_sqlite3DbFree(tls, dbMem, p)
	}
}

var _flags = libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_EXCLUSIVE) | libc.Int32FromInt32(SQLITE_OPEN_DELETEONCLOSE) | libc.Int32FromInt32(SQLITE_OPEN_TEMP_DB)

func _freeCursorWithCache(tls *libc.TLS, p uintptr, pCx uintptr) {
	var pCache uintptr
	_ = pCache
	pCache = (*TVdbeCursor)(unsafe.Pointer(pCx)).FpCache
	libc.SetBitFieldPtr8Uint32(pCx+8, libc.Uint32FromInt32(0), 4, 0x10)
	(*TVdbeCursor)(unsafe.Pointer(pCx)).FpCache = uintptr(0)
	if (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FpCValue != 0 {
		_sqlite3RCStrUnref(tls, (*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FpCValue)
		(*TVdbeTxtBlbCache)(unsafe.Pointer(pCache)).FpCValue = uintptr(0)
	}
	_sqlite3DbFree(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, pCache)
	_sqlite3VdbeFreeCursorNN(tls, p, pCx)
}

// C documentation
//
//	/*
//	** If the input FuncDef structure is ephemeral, then free it.  If
//	** the FuncDef is not ephemeral, then do nothing.
//	*/
func _freeEphemeralFunction(tls *libc.TLS, db uintptr, pDef uintptr) {
	if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_EPHEM) != uint32(0) {
		_sqlite3DbNNFreeNN(tls, db, pDef)
	}
}

// C documentation
//
//	/*
//	** Free and zero the sqlite3_index_info.idxStr value if needed.
//	*/
func _freeIdxStr(tls *libc.TLS, pIdxInfo uintptr) {
	if (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FneedToFreeIdxStr != 0 {
		Xsqlite3_free(tls, (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr)
		(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = uintptr(0)
		(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FneedToFreeIdxStr = 0
	}
}

func _freeP4(tls *libc.TLS, db uintptr, p4type int32, p4 uintptr) {
	var pSig uintptr
	_ = pSig
	switch p4type {
	case -int32(16):
		_freeP4FuncCtx(tls, db, p4)
	case -int32(13):
		fallthrough
	case -int32(14):
		fallthrough
	case -int32(7):
		fallthrough
	case -int32(15):
		if p4 != 0 {
			_sqlite3DbNNFreeNN(tls, db, p4)
		}
	case -int32(9):
		if (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) {
			_sqlite3KeyInfoUnref(tls, p4)
		}
	case -int32(8):
		_freeEphemeralFunction(tls, db, p4)
	case -int32(11):
		if (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) {
			_sqlite3ValueFree(tls, p4)
		} else {
			_freeP4Mem(tls, db, p4)
		}
	case -int32(12):
		if (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) {
			_sqlite3VtabUnlock(tls, p4)
		}
	case -int32(17):
		if (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) {
			_sqlite3DeleteTable(tls, db, p4)
		}
	case -int32(18):
		pSig = p4
		_sqlite3DbFree(tls, db, (*TSubrtnSig)(unsafe.Pointer(pSig)).FzAff)
		_sqlite3DbFree(tls, db, pSig)
		break
	}
}

func _freeP4FuncCtx(tls *libc.TLS, db uintptr, p uintptr) {
	_freeEphemeralFunction(tls, db, (*Tsqlite3_context)(unsafe.Pointer(p)).FpFunc)
	_sqlite3DbNNFreeNN(tls, db, p)
}

// C documentation
//
//	/*
//	** Delete a P4 value if necessary.
//	*/
func _freeP4Mem(tls *libc.TLS, db uintptr, p uintptr) {
	if (*TMem)(unsafe.Pointer(p)).FszMalloc != 0 {
		_sqlite3DbFree(tls, db, (*TMem)(unsafe.Pointer(p)).FzMalloc)
	}
	_sqlite3DbNNFreeNN(tls, db, p)
}

func _freePage(tls *libc.TLS, pPage uintptr, pRC uintptr) {
	if **(**int32)(__ccgo_up(pRC)) == SQLITE_OK {
		**(**int32)(__ccgo_up(pRC)) = _freePage2(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpBt, pPage, (*TMemPage)(unsafe.Pointer(pPage)).Fpgno)
	}
}

// C documentation
//
//	/*
//	** Free a buffer allocated by the readSuperJournal() function.
//	*/
func _freeSuperJournal(tls *libc.TLS, zSuper uintptr) {
	if zSuper != 0 {
		Xsqlite3_free(tls, zSuper+uintptr(-libc.Int32FromInt32(4)))
	}
}

func _fts5ApiColumnCount(tls *libc.TLS, pCtx uintptr) (r int32) {
	var pCsr uintptr
	_ = pCsr
	pCsr = pCtx
	return (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpConfig)).FnCol
}

func _fts5ApiColumnText(tls *libc.TLS, pCtx uintptr, iCol int32, pz uintptr, pn uintptr) (r int32) {
	var pCsr, pTab uintptr
	var rc int32
	_, _, _ = pCsr, pTab, rc
	rc = SQLITE_OK
	pCsr = pCtx
	pTab = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
	if iCol < 0 || iCol >= (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer(pTab)).FpConfig)).FnCol {
		rc = int32(SQLITE_RANGE)
	} else {
		if _fts5IsContentless(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab, 0) != 0 {
			**(**uintptr)(__ccgo_up(pz)) = uintptr(0)
			**(**int32)(__ccgo_up(pn)) = 0
		} else {
			rc = _fts5SeekCursor(tls, pCsr, 0)
			if rc == SQLITE_OK {
				rc = _fts5TextFromStmt(tls, (*TFts5Table)(unsafe.Pointer(pTab)).FpConfig, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, iCol, pz, pn)
				_sqlite3Fts5ClearLocale(tls, (*TFts5Table)(unsafe.Pointer(pTab)).FpConfig)
			}
		}
	}
	return rc
}

func _fts5ApiColumnTotalSize(tls *libc.TLS, pCtx uintptr, iCol int32, pnToken uintptr) (r int32) {
	var pCsr, pTab uintptr
	_, _ = pCsr, pTab
	pCsr = pCtx
	pTab = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
	return _sqlite3Fts5StorageSize(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iCol, pnToken)
}

func _fts5ApiGetAuxdata(tls *libc.TLS, pCtx uintptr, bClear int32) (r uintptr) {
	var pCsr, pData, pRet uintptr
	_, _, _ = pCsr, pData, pRet
	pCsr = pCtx
	pRet = uintptr(0)
	pData = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpAuxdata
	for {
		if !(pData != 0) {
			break
		}
		if (*TFts5Auxdata)(unsafe.Pointer(pData)).FpAux == (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpAux {
			break
		}
		goto _1
	_1:
		;
		pData = (*TFts5Auxdata)(unsafe.Pointer(pData)).FpNext
	}
	if pData != 0 {
		pRet = (*TFts5Auxdata)(unsafe.Pointer(pData)).FpPtr
		if bClear != 0 {
			(*TFts5Auxdata)(unsafe.Pointer(pData)).FpPtr = uintptr(0)
			(*TFts5Auxdata)(unsafe.Pointer(pData)).FxDelete = uintptr(0)
		}
	}
	return pRet
}

func _fts5ApiInst(tls *libc.TLS, pCtx uintptr, iIdx int32, piPhrase uintptr, piCol uintptr, piOff uintptr) (r int32) {
	var pCsr uintptr
	var rc, v1 int32
	var v2 bool
	_, _, _, _ = pCsr, rc, v1, v2
	pCsr = pCtx
	rc = SQLITE_OK
	if v2 = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&int32(FTS5CSR_REQUIRE_INST) == 0; !v2 {
		v1 = _fts5CacheInstArray(tls, pCsr)
		rc = v1
	}
	if v2 || SQLITE_OK == v1 {
		if iIdx < 0 || iIdx >= (*TFts5Cursor)(unsafe.Pointer(pCsr)).FnInstCount {
			rc = int32(SQLITE_RANGE)
		} else {
			**(**int32)(__ccgo_up(piPhrase)) = **(**int32)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(iIdx*int32(3))*4))
			**(**int32)(__ccgo_up(piCol)) = **(**int32)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(iIdx*int32(3)+int32(1))*4))
			**(**int32)(__ccgo_up(piOff)) = **(**int32)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(iIdx*int32(3)+int32(2))*4))
		}
	}
	return rc
}

func _fts5ApiInstCount(tls *libc.TLS, pCtx uintptr, pnInst uintptr) (r int32) {
	var pCsr uintptr
	var rc, v1 int32
	var v2 bool
	_, _, _, _ = pCsr, rc, v1, v2
	pCsr = pCtx
	rc = SQLITE_OK
	if v2 = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&int32(FTS5CSR_REQUIRE_INST) == 0; !v2 {
		v1 = _fts5CacheInstArray(tls, pCsr)
		rc = v1
	}
	if v2 || SQLITE_OK == v1 {
		**(**int32)(__ccgo_up(pnInst)) = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FnInstCount
	}
	return rc
}

// C documentation
//
//	/*
//	** xInstToken() API implemenetation.
//	*/
func _fts5ApiInstToken(tls *libc.TLS, pCtx uintptr, iIdx int32, iToken int32, ppOut uintptr, pnOut uintptr) (r int32) {
	var iCol, iOff, iPhrase, rc, v1 int32
	var iRowid Ti64
	var pCsr uintptr
	var v2 bool
	_, _, _, _, _, _, _, _ = iCol, iOff, iPhrase, iRowid, pCsr, rc, v1, v2
	pCsr = pCtx
	rc = SQLITE_OK
	if v2 = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&int32(FTS5CSR_REQUIRE_INST) == 0; !v2 {
		v1 = _fts5CacheInstArray(tls, pCsr)
		rc = v1
	}
	if v2 || SQLITE_OK == v1 {
		if iIdx < 0 || iIdx >= (*TFts5Cursor)(unsafe.Pointer(pCsr)).FnInstCount {
			rc = int32(SQLITE_RANGE)
		} else {
			iPhrase = **(**int32)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(iIdx*int32(3))*4))
			iCol = **(**int32)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(iIdx*int32(3)+int32(1))*4))
			iOff = **(**int32)(__ccgo_up((*TFts5Cursor)(unsafe.Pointer(pCsr)).FaInst + uintptr(iIdx*int32(3)+int32(2))*4))
			iRowid = _fts5CursorRowid(tls, pCsr)
			rc = _sqlite3Fts5ExprInstToken(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, iRowid, iPhrase, iCol, iOff, iToken, ppOut, pnOut)
		}
	}
	return rc
}

func _fts5ApiInvoke(tls *libc.TLS, pAux uintptr, pCsr uintptr, context uintptr, argc int32, argv uintptr) {
	(*TFts5Cursor)(unsafe.Pointer(pCsr)).FpAux = pAux
	(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5Auxiliary)(unsafe.Pointer(pAux)).FxFunc})))(tls, uintptr(unsafe.Pointer(&_sFts5Api)), pCsr, context, argc, argv)
	(*TFts5Cursor)(unsafe.Pointer(pCsr)).FpAux = uintptr(0)
}

func _fts5ApiPhraseCount(tls *libc.TLS, pCtx uintptr) (r int32) {
	var pCsr uintptr
	_ = pCsr
	pCsr = pCtx
	return _sqlite3Fts5ExprPhraseCount(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr)
}

func _fts5ApiPhraseFirst(tls *libc.TLS, pCtx uintptr, iPhrase int32, pIter uintptr, piCol uintptr, piOff uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var pCsr, v1 uintptr
	var rc int32
	var _ /* n at bp+0 */ int32
	_, _, _ = pCsr, rc, v1
	pCsr = pCtx
	rc = _fts5CsrPoslist(tls, pCsr, iPhrase, pIter, bp)
	if rc == SQLITE_OK {
		if (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa != 0 {
			v1 = (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa + uintptr(**(**int32)(__ccgo_up(bp)))
		} else {
			v1 = uintptr(0)
		}
		(*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fb = v1
		**(**int32)(__ccgo_up(piCol)) = 0
		**(**int32)(__ccgo_up(piOff)) = 0
		_fts5ApiPhraseNext(tls, pCtx, pIter, piCol, piOff)
	}
	return rc
}

func _fts5ApiPhraseNext(tls *libc.TLS, pCtx uintptr, pIter uintptr, piCol uintptr, piOff uintptr) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var nCol, v1 int32
	var _ /* iVal at bp+0 */ int32
	_, _ = nCol, v1
	if (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa >= (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fb {
		**(**int32)(__ccgo_up(piCol)) = -int32(1)
		**(**int32)(__ccgo_up(piOff)) = -int32(1)
	} else {
		**(**uintptr)(__ccgo_up(pIter)) += uintptr(_sqlite3Fts5GetVarint32(tls, (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa, bp))
		if **(**int32)(__ccgo_up(bp)) == int32(1) {
			/* Avoid returning a (*piCol) value that is too large for the table,
			 ** even if the position-list is corrupt. The caller might not be
			 ** expecting it.  */
			nCol = (*TFts5Config)(unsafe.Pointer((*TFts5Table)(unsafe.Pointer((*TFts5Cursor)(unsafe.Pointer(pCtx)).Fbase.FpVtab)).FpConfig)).FnCol
			**(**uintptr)(__ccgo_up(pIter)) += uintptr(_sqlite3Fts5GetVarint32(tls, (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa, bp))
			if **(**int32)(__ccgo_up(bp)) >= nCol {
				v1 = nCol - int32(1)
			} else {
				v1 = **(**int32)(__ccgo_up(bp))
			}
			**(**int32)(__ccgo_up(piCol)) = v1
			**(**int32)(__ccgo_up(piOff)) = 0
			**(**uintptr)(__ccgo_up(pIter)) += uintptr(_sqlite3Fts5GetVarint32(tls, (*TFts5PhraseIter)(unsafe.Pointer(pIter)).Fa, bp))
		}
		**(**int32)(__ccgo_up(piOff)) += **(**int32)(__ccgo_up(bp)) - int32(2)
	}
}

func _fts5ApiPhraseSize(tls *libc.TLS, pCtx uintptr, iPhrase int32) (r int32) {
	var pCsr uintptr
	_ = pCsr
	pCsr = pCtx
	return _sqlite3Fts5ExprPhraseSize(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, iPhrase)
}

// C documentation
//
//	/*
//	** xQueryToken() API implemenetation.
//	*/
func _fts5ApiQueryToken(tls *libc.TLS, pCtx uintptr, iPhrase int32, iToken int32, ppOut uintptr, pnOut uintptr) (r int32) {
	var pCsr uintptr
	_ = pCsr
	pCsr = pCtx
	return _sqlite3Fts5ExprQueryToken(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr, iPhrase, iToken, ppOut, pnOut)
}

func _fts5ApiRowCount(tls *libc.TLS, pCtx uintptr, pnRow uintptr) (r int32) {
	var pCsr, pTab uintptr
	_, _ = pCsr, pTab
	pCsr = pCtx
	pTab = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
	return _sqlite3Fts5StorageRowCount(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, pnRow)
}

func _fts5ApiRowid(tls *libc.TLS, pCtx uintptr) (r Tsqlite3_int64) {
	return _fts5CursorRowid(tls, pCtx)
}

// C documentation
//
//	/*
//	** Implementation of xTokenize() API. This is just xTokenize_v2() with NULL/0
//	** passed as the locale.
//	*/
func _fts5ApiTokenize(tls *libc.TLS, pCtx uintptr, pText uintptr, nText int32, pUserData uintptr, __ccgo_fp_xToken uintptr) (r int32) {
	return _fts5ApiTokenize_v2(tls, pCtx, pText, nText, uintptr(0), 0, pUserData, __ccgo_fp_xToken)
}

// C documentation
//
//	/*
//	** Implementation of xTokenize_v2() API.
//	*/
func _fts5ApiTokenize_v2(tls *libc.TLS, pCtx uintptr, pText uintptr, nText int32, pLoc uintptr, nLoc int32, pUserData uintptr, __ccgo_fp_xToken uintptr) (r int32) {
	var pCsr, pTab uintptr
	var rc int32
	_, _, _ = pCsr, pTab, rc
	pCsr = pCtx
	pTab = (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
	rc = SQLITE_OK
	_sqlite3Fts5SetLocale(tls, (*TFts5Table)(unsafe.Pointer(pTab)).FpConfig, pLoc, nLoc)
	rc = _sqlite3Fts5Tokenize(tls, (*TFts5Table)(unsafe.Pointer(pTab)).FpConfig, int32(FTS5_TOKENIZE_AUX), pText, nText, pUserData, __ccgo_fp_xToken)
	_sqlite3Fts5SetLocale(tls, (*TFts5Table)(unsafe.Pointer(pTab)).FpConfig, uintptr(0), 0)
	return rc
}

func _fts5ApiUserData(tls *libc.TLS, pCtx uintptr) (r uintptr) {
	var pCsr uintptr
	_ = pCsr
	pCsr = pCtx
	return (*TFts5Auxiliary)(unsafe.Pointer((*TFts5Cursor)(unsafe.Pointer(pCsr)).FpAux)).FpUserData
}

// C documentation
//
//	/*
//	** Delete a "ascii" tokenizer.
//	*/
func _fts5AsciiDelete(tls *libc.TLS, p uintptr) {
	Xsqlite3_free(tls, p)
}

// C documentation
//
//	/*
//	** Implementation of xBegin() method.
//	*/
func _fts5BeginMethod(tls *libc.TLS, pVtab uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = _fts5NewTransaction(tls, pVtab)
	if rc == SQLITE_OK {
	}
	return rc
}

// C documentation
//
//	/*
//	** Swap the contents of buffer *p1 with that of *p2.
//	*/
func _fts5BufferSwap(tls *libc.TLS, p1 uintptr, p2 uintptr) {
	var tmp TFts5Buffer
	_ = tmp
	tmp = **(**TFts5Buffer)(__ccgo_up(p1))
	**(**TFts5Buffer)(__ccgo_up(p1)) = **(**TFts5Buffer)(__ccgo_up(p2))
	**(**TFts5Buffer)(__ccgo_up(p2)) = tmp
}

// C documentation
//
//	/*
//	** Advance the iterator to the next coalesced phrase instance. Return
//	** an SQLite error code if an error occurs, or SQLITE_OK otherwise.
//	*/
func _fts5CInstIterNext(tls *libc.TLS, pIter uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var iEnd, rc int32
	var _ /* ic at bp+4 */ int32
	var _ /* io at bp+8 */ int32
	var _ /* ip at bp+0 */ int32
	_, _ = iEnd, rc
	rc = SQLITE_OK
	(*TCInstIter)(unsafe.Pointer(pIter)).FiStart = -int32(1)
	(*TCInstIter)(unsafe.Pointer(pIter)).FiEnd = -int32(1)
	for rc == SQLITE_OK && (*TCInstIter)(unsafe.Pointer(pIter)).FiInst < (*TCInstIter)(unsafe.Pointer(pIter)).FnInst {
		rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer((*TCInstIter)(unsafe.Pointer(pIter)).FpApi)).FxInst})))(tls, (*TCInstIter)(unsafe.Pointer(pIter)).FpFts, (*TCInstIter)(unsafe.Pointer(pIter)).FiInst, bp, bp+4, bp+8)
		if rc == SQLITE_OK {
			if **(**int32)(__ccgo_up(bp + 4)) == (*TCInstIter)(unsafe.Pointer(pIter)).FiCol {
				iEnd = **(**int32)(__ccgo_up(bp + 8)) - int32(1) + (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer((*TCInstIter)(unsafe.Pointer(pIter)).FpApi)).FxPhraseSize})))(tls, (*TCInstIter)(unsafe.Pointer(pIter)).FpFts, **(**int32)(__ccgo_up(bp)))
				if (*TCInstIter)(unsafe.Pointer(pIter)).FiStart < 0 {
					(*TCInstIter)(unsafe.Pointer(pIter)).FiStart = **(**int32)(__ccgo_up(bp + 8))
					(*TCInstIter)(unsafe.Pointer(pIter)).FiEnd = iEnd
				} else {
					if **(**int32)(__ccgo_up(bp + 8)) <= (*TCInstIter)(unsafe.Pointer(pIter)).FiEnd {
						if iEnd > (*TCInstIter)(unsafe.Pointer(pIter)).FiEnd {
							(*TCInstIter)(unsafe.Pointer(pIter)).FiEnd = iEnd
						}
					} else {
						break
					}
				}
			}
			(*TCInstIter)(unsafe.Pointer(pIter)).FiInst = (*TCInstIter)(unsafe.Pointer(pIter)).FiInst + 1
		}
	}
	return rc
}

func _fts5ChunkIterate(tls *libc.TLS, p uintptr, pSeg uintptr, pCtx uintptr, __ccgo_fp_xChunk uintptr) {
	var nChunk, nRem, pgno, pgnoSave, v2 int32
	var pChunk, pData uintptr
	var v1 int64
	_, _, _, _, _, _, _, _ = nChunk, nRem, pChunk, pData, pgno, pgnoSave, v1, v2
	nRem = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos /* Number of bytes still to come */
	pData = uintptr(0)
	pChunk = (*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).Fp + uintptr((*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset)
	if int64(nRem) < int64((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).FszLeaf)-(*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset {
		v1 = int64(nRem)
	} else {
		v1 = int64((*TFts5Data)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)).FszLeaf) - (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafOffset
	}
	nChunk = int32(v1)
	pgno = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiLeafPgno
	pgnoSave = 0
	/* This function does not work with detail=none databases. */
	if (*TFts5SegIter)(unsafe.Pointer(pSeg)).Fflags&int32(FTS5_SEGITER_REVERSE) == 0 {
		pgnoSave = pgno + int32(1)
	}
	for int32(1) != 0 {
		(*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xChunk})))(tls, p, pCtx, pChunk, nChunk)
		nRem = nRem - nChunk
		_fts5DataRelease(tls, pData)
		if nRem <= 0 {
			break
		} else {
			if (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg == uintptr(0) {
				_fts5IndexCorruptIdx(tls, p)
				return
			} else {
				pgno = pgno + 1
				pData = _fts5LeafRead(tls, p, int64((*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pSeg)).FpSeg)).FiSegid)<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B)+libc.Int32FromInt32(FTS5_DATA_DLI_B))+int64(libc.Int32FromInt32(0))<<(libc.Int32FromInt32(FTS5_DATA_PAGE_B)+libc.Int32FromInt32(FTS5_DATA_HEIGHT_B))+int64(libc.Int32FromInt32(0))<<libc.Int32FromInt32(FTS5_DATA_PAGE_B)+int64(pgno))
				if pData == uintptr(0) {
					break
				}
				pChunk = (*TFts5Data)(unsafe.Pointer(pData)).Fp + 4
				if nRem < (*TFts5Data)(unsafe.Pointer(pData)).FszLeaf-int32(4) {
					v2 = nRem
				} else {
					v2 = (*TFts5Data)(unsafe.Pointer(pData)).FszLeaf - int32(4)
				}
				nChunk = v2
				if pgno == pgnoSave {
					(*TFts5SegIter)(unsafe.Pointer(pSeg)).FpNextLeaf = pData
					pData = uintptr(0)
				}
			}
		}
	}
}

func _fts5ColumnSizeCb(tls *libc.TLS, pContext uintptr, tflags int32, pUnused uintptr, nUnused int32, iUnused1 int32, iUnused2 int32) (r int32) {
	var pCnt uintptr
	_ = pCnt
	pCnt = pContext
	_ = pUnused
	_ = nUnused
	_ = iUnused1
	_ = iUnused2
	if tflags&int32(FTS5_TOKEN_COLOCATED) == 0 {
		**(**int32)(__ccgo_up(pCnt)) = **(**int32)(__ccgo_up(pCnt)) + 1
	}
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Implementation of xCommit() method. This is a no-op. The contents of
//	** the pending-terms hash-table have already been flushed into the database
//	** by fts5SyncMethod().
//	*/
func _fts5CommitMethod(tls *libc.TLS, pVtab uintptr) (r int32) {
	_ = pVtab /* Call below is a no-op for NDEBUG builds */
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** The xConnect() and xCreate() methods for the virtual table. All the
//	** work is done in function fts5InitVtab().
//	*/
func _fts5ConnectMethod(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) {
	return _fts5InitVtab(tls, 0, db, pAux, argc, argv, ppVtab, pzErr)
}

// C documentation
//
//	/*
//	** Callback used by fts5Bm25GetData() to count the number of rows in the
//	** table matched by each individual phrase within the query.
//	*/
func _fts5CountCb(tls *libc.TLS, pApi uintptr, pFts uintptr, pUserData uintptr) (r int32) {
	var pn uintptr
	_ = pn
	pn = pUserData
	_ = pApi
	_ = pFts
	**(**Tsqlite3_int64)(__ccgo_up(pn)) = **(**Tsqlite3_int64)(__ccgo_up(pn)) + 1
	return SQLITE_OK
}

func _fts5CreateMethod(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) {
	return _fts5InitVtab(tls, int32(1), db, pAux, argc, argv, ppVtab, pzErr)
}

/*
** The different query plans.
 */

// C documentation
//
//	/*
//	** The fts5_api.xCreateTokenizer() method.
//	*/
func _fts5CreateTokenizer(tls *libc.TLS, pApi uintptr, zName uintptr, pUserData uintptr, pTokenizer uintptr, __ccgo_fp_xDestroy uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* pNew at bp+0 */ uintptr
	_ = rc
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
	rc = SQLITE_OK
	rc = _fts5NewTokenizerModule(tls, pApi, zName, pUserData, __ccgo_fp_xDestroy, bp)
	if **(**uintptr)(__ccgo_up(bp)) != 0 {
		(*TFts5TokenizerModule)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fx1 = **(**Tfts5_tokenizer)(__ccgo_up(pTokenizer))
		(*TFts5TokenizerModule)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fx2.FxCreate = __ccgo_fp(_fts5VtoVCreate)
		(*TFts5TokenizerModule)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fx2.FxTokenize = __ccgo_fp(_fts5V2toV1Tokenize)
		(*TFts5TokenizerModule)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fx2.FxDelete = __ccgo_fp(_fts5VtoVDelete)
	}
	return rc
}

// C documentation
//
//	/*
//	** Register a new tokenizer. This is the implementation of the
//	** fts5_api.xCreateTokenizer_v2() method.
//	*/
func _fts5CreateTokenizer_v2(tls *libc.TLS, pApi uintptr, zName uintptr, pUserData uintptr, pTokenizer uintptr, __ccgo_fp_xDestroy uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var pGlobal uintptr
	var rc int32
	var _ /* pNew at bp+0 */ uintptr
	_, _ = pGlobal, rc
	pGlobal = pApi
	rc = SQLITE_OK
	if (*Tfts5_tokenizer_v2)(unsafe.Pointer(pTokenizer)).FiVersion > int32(2) {
		rc = int32(SQLITE_ERROR)
	} else {
		**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
		rc = _fts5NewTokenizerModule(tls, pGlobal, zName, pUserData, __ccgo_fp_xDestroy, bp)
		if **(**uintptr)(__ccgo_up(bp)) != 0 {
			(*TFts5TokenizerModule)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fx2 = **(**Tfts5_tokenizer_v2)(__ccgo_up(pTokenizer))
			(*TFts5TokenizerModule)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FbV2Native = int32(1)
			(*TFts5TokenizerModule)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fx1.FxCreate = __ccgo_fp(_fts5VtoVCreate)
			(*TFts5TokenizerModule)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fx1.FxTokenize = __ccgo_fp(_fts5V1toV2Tokenize)
			(*TFts5TokenizerModule)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fx1.FxDelete = __ccgo_fp(_fts5VtoVDelete)
		}
	}
	return rc
}

func _fts5CursorFromCsrid(tls *libc.TLS, pGlobal uintptr, iCsrId Ti64) (r uintptr) {
	var pCsr uintptr
	_ = pCsr
	pCsr = (*TFts5Global)(unsafe.Pointer(pGlobal)).FpCsr
	for {
		if !(pCsr != 0) {
			break
		}
		if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FiCsrId == iCsrId {
			break
		}
		goto _1
	_1:
		;
		pCsr = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpNext
	}
	return pCsr
}

// C documentation
//
//	/*
//	** Return the rowid that the cursor currently points to.
//	*/
func _fts5CursorRowid(tls *libc.TLS, pCsr uintptr) (r Ti64) {
	if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter != 0 {
		return (*TFts5Sorter)(unsafe.Pointer((*TFts5Cursor)(unsafe.Pointer(pCsr)).FpSorter)).FiRowid
	} else {
		if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan >= int32(FTS5_PLAN_SCAN) {
			return Xsqlite3_column_int64(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpStmt, 0)
		} else {
			return _sqlite3Fts5ExprRowid(tls, (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpExpr)
		}
	}
	return r
}

// C documentation
//
//	/*
//	** Release a reference to data record returned by an earlier call to
//	** fts5DataRead().
//	*/
func _fts5DataRelease(tls *libc.TLS, pData uintptr) {
	Xsqlite3_free(tls, pData)
}

// C documentation
//
//	/*
//	** The xDestroy() virtual table method.
//	*/
func _fts5DestroyMethod(tls *libc.TLS, pVtab uintptr) (r int32) {
	var pTab uintptr
	var rc int32
	_, _ = pTab, rc
	pTab = pVtab
	rc = _sqlite3Fts5DropAll(tls, (*TFts5Table)(unsafe.Pointer(pTab)).FpConfig)
	if rc == SQLITE_OK {
		_fts5FreeVtab(tls, pVtab)
	}
	return rc
}

// C documentation
//
//	/*
//	** The xDisconnect() virtual table method.
//	*/
func _fts5DisconnectMethod(tls *libc.TLS, pVtab uintptr) (r int32) {
	_fts5FreeVtab(tls, pVtab)
	return SQLITE_OK
}

func _fts5DlidxIterEof(tls *libc.TLS, p uintptr, pIter uintptr) (r int32) {
	return libc.BoolInt32((*TFts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK || (*(*TFts5DlidxLvl)(unsafe.Pointer(pIter + 8))).FbEof != 0)
}

func _fts5DlidxIterNext(tls *libc.TLS, p uintptr, pIter uintptr) (r int32) {
	return _fts5DlidxIterNextR(tls, p, pIter, 0)
}

func _fts5DlidxIterPgno(tls *libc.TLS, pIter uintptr) (r int32) {
	return (*(*TFts5DlidxLvl)(unsafe.Pointer(pIter + 8))).FiLeafPgno
}

func _fts5DlidxIterPrev(tls *libc.TLS, p uintptr, pIter uintptr) (r int32) {
	return _fts5DlidxIterPrevR(tls, p, pIter, 0)
}

func _fts5DlidxIterRowid(tls *libc.TLS, pIter uintptr) (r Ti64) {
	return (*(*TFts5DlidxLvl)(unsafe.Pointer(pIter + 8))).FiRowid
}

// C documentation
//
//	/*
//	** This is the xEof method of the virtual table. SQLite calls this
//	** routine to find out if it has reached the end of a result set.
//	*/
func _fts5EofMethod(tls *libc.TLS, pCursor uintptr) (r int32) {
	var pCsr uintptr
	var v1 int32
	_, _ = pCsr, v1
	pCsr = pCursor
	if (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fcsrflags&int32(FTS5CSR_EOF) != 0 {
		v1 = int32(1)
	} else {
		v1 = 0
	}
	return v1
}

func _fts5ExecPrintf(tls *libc.TLS, db uintptr, pzErr uintptr, zFormat uintptr, va uintptr) (r int32) {
	var ap Tva_list
	var rc int32
	var zSql uintptr
	_, _, _ = ap, rc, zSql
	ap = va
	zSql = Xsqlite3_vmprintf(tls, zFormat, ap)
	if zSql == uintptr(0) {
		rc = int32(SQLITE_NOMEM)
	} else {
		rc = Xsqlite3_exec(tls, db, zSql, uintptr(0), uintptr(0), pzErr)
		Xsqlite3_free(tls, zSql)
	}
	_ = ap
	return rc
}

// C documentation
//
//	/*
//	** Advance iterator pIter until it points to a value equal to or laster
//	** than the initial value of *piLast. If this means the iterator points
//	** to a value laster than *piLast, update *piLast to the new lastest value.
//	**
//	** If the iterator reaches EOF, set *pbEof to true before returning. If
//	** an error occurs, set *pRc to an error code. If either *pbEof or *pRc
//	** are set, return a non-zero value. Otherwise, return zero.
//	*/
func _fts5ExprAdvanceto(tls *libc.TLS, pIter uintptr, bDesc int32, piLast uintptr, pRc uintptr, pbEof uintptr) (r int32) {
	var iLast, iRowid Ti64
	var rc int32
	_, _, _ = iLast, iRowid, rc
	iLast = **(**Ti64)(__ccgo_up(piLast))
	iRowid = (*TFts5IndexIter)(unsafe.Pointer(pIter)).FiRowid
	if bDesc == 0 && iLast > iRowid || bDesc != 0 && iLast < iRowid {
		rc = _sqlite3Fts5IterNextFrom(tls, pIter, iLast)
		if rc != 0 || (*TFts5IndexIter)(unsafe.Pointer(pIter)).FbEof != 0 {
			**(**int32)(__ccgo_up(pRc)) = rc
			**(**int32)(__ccgo_up(pbEof)) = int32(1)
			return int32(1)
		}
		iRowid = (*TFts5IndexIter)(unsafe.Pointer(pIter)).FiRowid
	}
	**(**Ti64)(__ccgo_up(piLast)) = iRowid
	return 0
}

// C documentation
//
//	/*
//	** TODO: Make this more efficient!
//	*/
func _fts5ExprColsetTest(tls *libc.TLS, pColset uintptr, iCol int32) (r int32) {
	var i int32
	_ = i
	i = 0
	for {
		if !(i < (*TFts5Colset)(unsafe.Pointer(pColset)).FnCol) {
			break
		}
		if *(*int32)(unsafe.Pointer(pColset + 4 + uintptr(i)*4)) == iCol {
			return int32(1)
		}
		goto _1
	_1:
		;
		i = i + 1
	}
	return 0
}

// C documentation
//
//	/*
//	** If pNode currently points to a match, this function returns SQLITE_OK
//	** without modifying it. Otherwise, pNode is advanced until it does point
//	** to a match or EOF is reached.
//	*/
func _fts5ExprNodeTest(tls *libc.TLS, pExpr uintptr, pNode uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = SQLITE_OK
	if (*TFts5ExprNode)(unsafe.Pointer(pNode)).FbEof == 0 {
		switch (*TFts5ExprNode)(unsafe.Pointer(pNode)).FeType {
		case int32(FTS5_STRING):
			rc = _fts5ExprNodeTest_STRING(tls, pExpr, pNode)
		case int32(FTS5_TERM):
			rc = _fts5ExprNodeTest_TERM(tls, pExpr, pNode)
		case int32(FTS5_AND):
			rc = _fts5ExprNodeTest_AND(tls, pExpr, pNode)
		case int32(FTS5_OR):
			_fts5ExprNodeTest_OR(tls, pExpr, pNode)
		default:
			rc = _fts5ExprNodeTest_NOT(tls, pExpr, pNode)
			break
		}
	}
	return rc
}

// C documentation
//
//	/*
//	** Search for an auxiliary function named zName that can be used with table
//	** pTab. If one is found, return a pointer to the corresponding Fts5Auxiliary
//	** structure. Otherwise, if no such function exists, return NULL.
//	*/
func _fts5FindAuxiliary(tls *libc.TLS, pTab uintptr, zName uintptr) (r uintptr) {
	var pAux uintptr
	_ = pAux
	pAux = (*TFts5Global)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpGlobal)).FpAux
	for {
		if !(pAux != 0) {
			break
		}
		if Xsqlite3_stricmp(tls, zName, (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FzFunc) == 0 {
			return pAux
		}
		goto _1
	_1:
		;
		pAux = (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FpNext
	}
	/* No function of the specified name was found. Return 0. */
	return uintptr(0)
}

// C documentation
//
//	/*
//	** This routine implements the xFindFunction method for the FTS3
//	** virtual table.
//	*/
func _fts5FindFunctionMethod(tls *libc.TLS, pVtab uintptr, nUnused int32, zName uintptr, __ccgo_fp_pxFunc uintptr, ppArg uintptr) (r int32) {
	var pAux, pTab uintptr
	_, _ = pAux, pTab
	pTab = pVtab
	_ = nUnused
	pAux = _fts5FindAuxiliary(tls, pTab, zName)
	if pAux != 0 {
		**(**uintptr)(__ccgo_up(__ccgo_fp_pxFunc)) = __ccgo_fp(_fts5ApiCallback)
		**(**uintptr)(__ccgo_up(ppArg)) = pAux
		return int32(1)
	}
	/* No function of the specified name was found. Return 0. */
	return 0
}

// C documentation
//
//	/*
//	** Delete a virtual table handle allocated by fts5InitVtab().
//	*/
func _fts5FreeVtab(tls *libc.TLS, pTab uintptr) {
	if pTab != 0 {
		_sqlite3Fts5IndexClose(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex)
		_sqlite3Fts5StorageClose(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
		_sqlite3Fts5ConfigFree(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)
		Xsqlite3_free(tls, pTab)
	}
}

func _fts5GetRowidLimit(tls *libc.TLS, pVal uintptr, iDefault Ti64) (r Ti64) {
	var eType int32
	_ = eType
	if pVal != 0 {
		eType = Xsqlite3_value_numeric_type(tls, pVal)
		if eType == int32(SQLITE_INTEGER) {
			return Xsqlite3_value_int64(tls, pVal)
		}
	}
	return iDefault
}

// C documentation
//
//	/*
//	** The only argument points to a buffer at least 4 bytes in size. This
//	** function interprets the first 4 bytes of the buffer as a 32-bit big-endian
//	** unsigned integer and returns the result.
//	*/
func _fts5GetU32(tls *libc.TLS, a uintptr) (r Tu32) {
	return uint32(**(**Tu8)(__ccgo_up(a)))<<libc.Int32FromInt32(24) + uint32(**(**Tu8)(__ccgo_up(a + 1)))<<libc.Int32FromInt32(16) + uint32(**(**Tu8)(__ccgo_up(a + 2)))<<libc.Int32FromInt32(8) + uint32(**(**Tu8)(__ccgo_up(a + 3)))<<libc.Int32FromInt32(0)
}

// C documentation
//
//	/*
//	** The only argument points to a buffer at least 8 bytes in size. This
//	** function interprets the first 8 bytes of the buffer as a 64-bit big-endian
//	** unsigned integer and returns the result.
//	*/
func _fts5GetU64(tls *libc.TLS, a uintptr) (r Tu64) {
	return uint64(**(**Tu8)(__ccgo_up(a)))<<libc.Int32FromInt32(56) + uint64(**(**Tu8)(__ccgo_up(a + 1)))<<libc.Int32FromInt32(48) + uint64(**(**Tu8)(__ccgo_up(a + 2)))<<libc.Int32FromInt32(40) + uint64(**(**Tu8)(__ccgo_up(a + 3)))<<libc.Int32FromInt32(32) + uint64(**(**Tu8)(__ccgo_up(a + 4)))<<libc.Int32FromInt32(24) + uint64(**(**Tu8)(__ccgo_up(a + 5)))<<libc.Int32FromInt32(16) + uint64(**(**Tu8)(__ccgo_up(a + 6)))<<libc.Int32FromInt32(8) + uint64(**(**Tu8)(__ccgo_up(a + 7)))<<libc.Int32FromInt32(0)
}

// C documentation
//
//	/*
//	** Close the read-only blob handle, if it is open.
//	*/
func _fts5IndexCloseReader(tls *libc.TLS, p uintptr) {
	var pReader uintptr
	var rc int32
	_, _ = pReader, rc
	if (*TFts5Index)(unsafe.Pointer(p)).FpReader != 0 {
		pReader = (*TFts5Index)(unsafe.Pointer(p)).FpReader
		(*TFts5Index)(unsafe.Pointer(p)).FpReader = uintptr(0)
		rc = Xsqlite3_blob_close(tls, pReader)
		if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
			(*TFts5Index)(unsafe.Pointer(p)).Frc = rc
		}
	}
}

// C documentation
//
//	/*
//	** TODO: Make this more efficient!
//	*/
func _fts5IndexColsetTest(tls *libc.TLS, pColset uintptr, iCol int32) (r int32) {
	var i int32
	_ = i
	i = 0
	for {
		if !(i < (*TFts5Colset)(unsafe.Pointer(pColset)).FnCol) {
			break
		}
		if *(*int32)(unsafe.Pointer(pColset + 4 + uintptr(i)*4)) == iCol {
			return int32(1)
		}
		goto _1
	_1:
		;
		i = i + 1
	}
	return 0
}

// C documentation
//
//	/*
//	** Discard all data currently cached in the hash-tables.
//	*/
func _fts5IndexDiscardData(tls *libc.TLS, p uintptr) {
	if (*TFts5Index)(unsafe.Pointer(p)).FpHash != 0 {
		_sqlite3Fts5HashClear(tls, (*TFts5Index)(unsafe.Pointer(p)).FpHash)
		(*TFts5Index)(unsafe.Pointer(p)).FnPendingData = 0
		(*TFts5Index)(unsafe.Pointer(p)).FnPendingRow = 0
		(*TFts5Index)(unsafe.Pointer(p)).FflushRc = SQLITE_OK
	}
	(*TFts5Index)(unsafe.Pointer(p)).FnContentlessDelete = 0
}

// C documentation
//
//	/*
//	** Flush any data stored in the in-memory hash tables to the database.
//	*/
func _fts5IndexFlush(tls *libc.TLS, p uintptr) {
	/* Unless it is empty, flush the hash table to disk */
	if (*TFts5Index)(unsafe.Pointer(p)).FflushRc != 0 {
		(*TFts5Index)(unsafe.Pointer(p)).Frc = (*TFts5Index)(unsafe.Pointer(p)).FflushRc
		return
	}
	if (*TFts5Index)(unsafe.Pointer(p)).FnPendingData != 0 || (*TFts5Index)(unsafe.Pointer(p)).FnContentlessDelete != 0 {
		_fts5FlushOneHash(tls, p)
		if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
			_sqlite3Fts5HashClear(tls, (*TFts5Index)(unsafe.Pointer(p)).FpHash)
			(*TFts5Index)(unsafe.Pointer(p)).FnPendingData = 0
			(*TFts5Index)(unsafe.Pointer(p)).FnPendingRow = 0
			(*TFts5Index)(unsafe.Pointer(p)).FnContentlessDelete = 0
		} else {
			if (*TFts5Index)(unsafe.Pointer(p)).FnPendingData != 0 || (*TFts5Index)(unsafe.Pointer(p)).FnContentlessDelete != 0 {
				(*TFts5Index)(unsafe.Pointer(p)).FflushRc = (*TFts5Index)(unsafe.Pointer(p)).Frc
			}
		}
	}
}

func _fts5IndexReturn(tls *libc.TLS, p uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = (*TFts5Index)(unsafe.Pointer(p)).Frc
	(*TFts5Index)(unsafe.Pointer(p)).Frc = SQLITE_OK
	return rc
}

// C documentation
//
//	/*
//	** Implementation of fts5_insttoken() function.
//	*/
func _fts5InsttokenFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
	_ = nArg
	Xsqlite3_result_value(tls, pCtx, **(**uintptr)(__ccgo_up(apArg)))
	Xsqlite3_result_subtype(tls, pCtx, uint32(FTS5_INSTTOKEN_SUBTYPE))
}

// C documentation
//
//	/*
//	** Return true if pTab is a contentless table. If parameter bIncludeUnindexed
//	** is true, this includes contentless tables that store UNINDEXED columns
//	** only.
//	*/
func _fts5IsContentless(tls *libc.TLS, pTab uintptr, bIncludeUnindexed int32) (r int32) {
	var eContent int32
	_ = eContent
	eContent = (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FeContent
	return libc.BoolInt32(eContent == int32(FTS5_CONTENT_NONE) || bIncludeUnindexed != 0 && eContent == int32(FTS5_CONTENT_UNINDEXED))
}

func _fts5IterClose(tls *libc.TLS, pIndexIter uintptr) {
	var pIndex, pIter uintptr
	_, _ = pIndex, pIter
	if pIndexIter != 0 {
		pIter = pIndexIter
		pIndex = (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex
		_fts5TokendataIterDelete(tls, (*TFts5Iter)(unsafe.Pointer(pIter)).FpTokenDataIter)
		_fts5MultiIterFree(tls, pIter)
		_fts5IndexCloseReader(tls, pIndex)
	}
}

// C documentation
//
//	/*
//	** xSetOutputs callback used by detail=none tables.
//	*/
func _fts5IterSetOutputs_None(tls *libc.TLS, pIter uintptr, pSeg uintptr) {
	(*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FiRowid = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FiRowid
	(*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = (*TFts5SegIter)(unsafe.Pointer(pSeg)).FnPos
}

func _fts5IterSetOutputs_Noop(tls *libc.TLS, pUnused1 uintptr, pUnused2 uintptr) {
	_ = pUnused1
	_ = pUnused2
}

// C documentation
//
//	/*
//	** xSetOutputs callback used when the Fts5Colset object has nCol==0 (match
//	** against no columns at all).
//	*/
func _fts5IterSetOutputs_ZeroColset(tls *libc.TLS, pIter uintptr, pSeg uintptr) {
	_ = pSeg
	(*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FnData = 0
}

func _fts5LeafFirstTermOff(tls *libc.TLS, pLeaf uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var _ /* ret at bp+0 */ int32
	_sqlite3Fts5GetVarint32(tls, (*TFts5Data)(unsafe.Pointer(pLeaf)).Fp+uintptr((*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf), bp)
	return **(**int32)(__ccgo_up(bp))
}

func _fts5LeafRead(tls *libc.TLS, p uintptr, iRowid Ti64) (r uintptr) {
	var pRet uintptr
	_ = pRet
	pRet = _fts5DataRead(tls, p, iRowid)
	if pRet != 0 {
		if (*TFts5Data)(unsafe.Pointer(pRet)).FszLeaf < int32(4) || (*TFts5Data)(unsafe.Pointer(pRet)).FszLeaf > (*TFts5Data)(unsafe.Pointer(pRet)).Fnn {
			_fts5IndexCorruptRowid(tls, p, iRowid)
			_fts5DataRelease(tls, pRet)
			pRet = uintptr(0)
		}
	}
	return pRet
}

// C documentation
//
//	/*
//	** Search the global context passed as the first argument for a tokenizer
//	** module named zName. If found, return a pointer to the Fts5TokenizerModule
//	** object. Otherwise, return NULL.
//	*/
func _fts5LocateTokenizer(tls *libc.TLS, pGlobal uintptr, zName uintptr) (r uintptr) {
	var pMod uintptr
	_ = pMod
	pMod = uintptr(0)
	if zName == uintptr(0) {
		pMod = (*TFts5Global)(unsafe.Pointer(pGlobal)).FpDfltTok
	} else {
		pMod = (*TFts5Global)(unsafe.Pointer(pGlobal)).FpTok
		for {
			if !(pMod != 0) {
				break
			}
			if Xsqlite3_stricmp(tls, zName, (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FzName) == 0 {
				break
			}
			goto _1
		_1:
			;
			pMod = (*TFts5TokenizerModule)(unsafe.Pointer(pMod)).FpNext
		}
	}
	return pMod
}

func _fts5MergeChunkCallback(tls *libc.TLS, p uintptr, pCtx uintptr, pChunk uintptr, nChunk int32) {
	var pWriter uintptr
	_ = pWriter
	pWriter = pCtx
	_fts5WriteAppendPoslistData(tls, p, pWriter, pChunk, nChunk)
}

// C documentation
//
//	/*
//	** Remove from colset pColset any columns that are not also in colset pMerge.
//	*/
func _fts5MergeColset(tls *libc.TLS, pColset uintptr, pMerge uintptr) {
	var iDiff, iIn, iMerge, iOut, v1 int32
	_, _, _, _, _ = iDiff, iIn, iMerge, iOut, v1
	iIn = 0    /* Next input in pColset */
	iMerge = 0 /* Next input in pMerge */
	iOut = 0   /* Next output slot in pColset */
	for iIn < (*TFts5Colset)(unsafe.Pointer(pColset)).FnCol && iMerge < (*TFts5Colset)(unsafe.Pointer(pMerge)).FnCol {
		iDiff = *(*int32)(unsafe.Pointer(pColset + 4 + uintptr(iIn)*4)) - *(*int32)(unsafe.Pointer(pMerge + 4 + uintptr(iMerge)*4))
		if iDiff == 0 {
			v1 = iOut
			iOut = iOut + 1
			*(*int32)(unsafe.Pointer(pColset + 4 + uintptr(v1)*4)) = *(*int32)(unsafe.Pointer(pMerge + 4 + uintptr(iMerge)*4))
			iMerge = iMerge + 1
			iIn = iIn + 1
		} else {
			if iDiff > 0 {
				iMerge = iMerge + 1
			} else {
				iIn = iIn + 1
			}
		}
	}
	(*TFts5Colset)(unsafe.Pointer(pColset)).FnCol = iOut
}

var _fts5Mod = Tsqlite3_module{
	FiVersion: int32(4),
}

// C documentation
//
//	/*
//	** xDestroy callback passed to sqlite3_create_module(). This is invoked
//	** when the db handle is being closed. Free memory associated with
//	** tokenizers and aux functions registered with this db handle.
//	*/
func _fts5ModuleDestroy(tls *libc.TLS, pCtx uintptr) {
	var pAux, pGlobal, pNextAux, pNextTok, pTok uintptr
	_, _, _, _, _ = pAux, pGlobal, pNextAux, pNextTok, pTok
	pGlobal = pCtx
	pAux = (*TFts5Global)(unsafe.Pointer(pGlobal)).FpAux
	for {
		if !(pAux != 0) {
			break
		}
		pNextAux = (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FpNext
		if (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FxDestroy != 0 {
			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5Auxiliary)(unsafe.Pointer(pAux)).FxDestroy})))(tls, (*TFts5Auxiliary)(unsafe.Pointer(pAux)).FpUserData)
		}
		Xsqlite3_free(tls, pAux)
		goto _1
	_1:
		;
		pAux = pNextAux
	}
	pTok = (*TFts5Global)(unsafe.Pointer(pGlobal)).FpTok
	for {
		if !(pTok != 0) {
			break
		}
		pNextTok = (*TFts5TokenizerModule)(unsafe.Pointer(pTok)).FpNext
		if (*TFts5TokenizerModule)(unsafe.Pointer(pTok)).FxDestroy != 0 {
			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5TokenizerModule)(unsafe.Pointer(pTok)).FxDestroy})))(tls, (*TFts5TokenizerModule)(unsafe.Pointer(pTok)).FpUserData)
		}
		Xsqlite3_free(tls, pTok)
		goto _2
	_2:
		;
		pTok = pNextTok
	}
	Xsqlite3_free(tls, pGlobal)
}

// C documentation
//
//	/*
//	** Return true if the iterator is at EOF or if an error has occurred.
//	** False otherwise.
//	*/
func _fts5MultiIterEof(tls *libc.TLS, p uintptr, pIter uintptr) (r int32) {
	return libc.BoolInt32((*TFts5Index)(unsafe.Pointer(p)).Frc != 0 || (*TFts5Iter)(unsafe.Pointer(pIter)).Fbase.FbEof != 0)
}

// C documentation
//
//	/*
//	** Move the iterator to the next entry at or following iMatch.
//	*/
func _fts5MultiIterNextFrom(tls *libc.TLS, p uintptr, pIter uintptr, iMatch Ti64) {
	var iRowid Ti64
	_ = iRowid
	for int32(1) != 0 {
		_fts5MultiIterNext(tls, p, pIter, int32(1), iMatch)
		if _fts5MultiIterEof(tls, p, pIter) != 0 {
			break
		}
		iRowid = _fts5MultiIterRowid(tls, pIter)
		if (*TFts5Iter)(unsafe.Pointer(pIter)).FbRev == 0 && iRowid >= iMatch {
			break
		}
		if (*TFts5Iter)(unsafe.Pointer(pIter)).FbRev != 0 && iRowid <= iMatch {
			break
		}
	}
}

func _fts5NewTransaction(tls *libc.TLS, pTab uintptr) (r int32) {
	var pCsr uintptr
	_ = pCsr
	pCsr = (*TFts5Global)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).FpGlobal)).FpCsr
	for {
		if !(pCsr != 0) {
			break
		}
		if (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab == pTab {
			return SQLITE_OK
		}
		goto _1
	_1:
		;
		pCsr = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FpNext
	}
	return _sqlite3Fts5StorageReset(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
}

// C documentation
//
//	/*
//	** Compare the values currently indicated by the two nodes as follows:
//	**
//	**    res = (*p1) - (*p2)
//	**
//	** Nodes that point to values that come later in the iteration order are
//	** considered to be larger. Nodes at EOF are the largest of all.
//	**
//	** This means that if the iteration order is ASC, then numerically larger
//	** rowids are considered larger. Or if it is the default DESC, numerically
//	** smaller rowids are larger.
//	*/
func _fts5NodeCompare(tls *libc.TLS, pExpr uintptr, p1 uintptr, p2 uintptr) (r int32) {
	if (*TFts5ExprNode)(unsafe.Pointer(p2)).FbEof != 0 {
		return -int32(1)
	}
	if (*TFts5ExprNode)(unsafe.Pointer(p1)).FbEof != 0 {
		return +libc.Int32FromInt32(1)
	}
	return _fts5RowidCmp(tls, pExpr, (*TFts5ExprNode)(unsafe.Pointer(p1)).FiRowid, (*TFts5ExprNode)(unsafe.Pointer(p2)).FiRowid)
}

func _fts5ParseFree(tls *libc.TLS, p uintptr) {
	Xsqlite3_free(tls, p)
}

func _fts5ParseStringFromToken(tls *libc.TLS, pToken uintptr, pz uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var _ /* rc at bp+0 */ int32
	**(**int32)(__ccgo_up(bp)) = SQLITE_OK
	**(**uintptr)(__ccgo_up(pz)) = _sqlite3Fts5Strndup(tls, bp, (*TFts5Token)(unsafe.Pointer(pToken)).Fp, (*TFts5Token)(unsafe.Pointer(pToken)).Fn)
	return **(**int32)(__ccgo_up(bp))
}

// C documentation
//
//	/*
//	** Delete a "porter" tokenizer.
//	*/
func _fts5PorterDelete(tls *libc.TLS, pTok uintptr) {
	var p uintptr
	_ = p
	if pTok != 0 {
		p = pTok
		if (*TPorterTokenizer)(unsafe.Pointer(p)).FpTokenizer != 0 {
			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TPorterTokenizer)(unsafe.Pointer(p)).Ftokenizer_v2.FxDelete})))(tls, (*TPorterTokenizer)(unsafe.Pointer(p)).FpTokenizer)
		}
		Xsqlite3_free(tls, p)
	}
}

// C documentation
//
//	/* porter rule condition: (m = 1) */
func _fts5Porter_MEq1(tls *libc.TLS, zStem uintptr, nStem int32) (r int32) {
	var n int32
	_ = n
	n = _fts5PorterGobbleVC(tls, zStem, nStem, 0)
	if n != 0 && 0 == _fts5PorterGobbleVC(tls, zStem+uintptr(n), nStem-n, int32(1)) {
		return int32(1)
	}
	return 0
}

// C documentation
//
//	/* porter rule condition: (m > 0) */
func _fts5Porter_MGt0(tls *libc.TLS, zStem uintptr, nStem int32) (r int32) {
	return libc.BoolInt32(!!(_fts5PorterGobbleVC(tls, zStem, nStem, 0) != 0))
}

// C documentation
//
//	/* porter rule condition: (m > 1) */
func _fts5Porter_MGt1(tls *libc.TLS, zStem uintptr, nStem int32) (r int32) {
	var n int32
	_ = n
	n = _fts5PorterGobbleVC(tls, zStem, nStem, 0)
	if n != 0 && _fts5PorterGobbleVC(tls, zStem+uintptr(n), nStem-n, int32(1)) != 0 {
		return int32(1)
	}
	return 0
}

// C documentation
//
//	/*
//	** Buffer aBuf[] contains a list of varints, all small enough to fit
//	** in a 32-bit integer. Return the size of the largest prefix of this
//	** list nMax bytes or less in size.
//	*/
func _fts5PoslistPrefix(tls *libc.TLS, aBuf uintptr, nMax int32) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var i, ret int32
	var _ /* dummy at bp+0 */ Tu32
	_, _ = i, ret
	ret = _sqlite3Fts5GetVarint32(tls, aBuf, bp)
	if ret < nMax {
		for int32(1) != 0 {
			i = _sqlite3Fts5GetVarint32(tls, aBuf+uintptr(ret), bp)
			if ret+i > nMax {
				break
			}
			ret = ret + i
		}
	}
	return ret
}

// C documentation
//
//	/*
//	** Write iVal, formated as a 32-bit big-endian unsigned integer, to the
//	** buffer indicated by the first argument.
//	*/
func _fts5PutU32(tls *libc.TLS, a uintptr, iVal Tu32) {
	**(**Tu8)(__ccgo_up(a)) = uint8(iVal >> libc.Int32FromInt32(24) & libc.Uint32FromInt32(0xFF))
	**(**Tu8)(__ccgo_up(a + 1)) = uint8(iVal >> libc.Int32FromInt32(16) & libc.Uint32FromInt32(0xFF))
	**(**Tu8)(__ccgo_up(a + 2)) = uint8(iVal >> libc.Int32FromInt32(8) & libc.Uint32FromInt32(0xFF))
	**(**Tu8)(__ccgo_up(a + 3)) = uint8(iVal >> libc.Int32FromInt32(0) & libc.Uint32FromInt32(0xFF))
}

// C documentation
//
//	/*
//	** Write iVal, formated as a 64-bit big-endian unsigned integer, to the
//	** buffer indicated by the first argument.
//	*/
func _fts5PutU64(tls *libc.TLS, a uintptr, iVal Tu64) {
	**(**Tu8)(__ccgo_up(a)) = uint8(iVal >> libc.Int32FromInt32(56) & libc.Uint64FromInt32(0xFF))
	**(**Tu8)(__ccgo_up(a + 1)) = uint8(iVal >> libc.Int32FromInt32(48) & libc.Uint64FromInt32(0xFF))
	**(**Tu8)(__ccgo_up(a + 2)) = uint8(iVal >> libc.Int32FromInt32(40) & libc.Uint64FromInt32(0xFF))
	**(**Tu8)(__ccgo_up(a + 3)) = uint8(iVal >> libc.Int32FromInt32(32) & libc.Uint64FromInt32(0xFF))
	**(**Tu8)(__ccgo_up(a + 4)) = uint8(iVal >> libc.Int32FromInt32(24) & libc.Uint64FromInt32(0xFF))
	**(**Tu8)(__ccgo_up(a + 5)) = uint8(iVal >> libc.Int32FromInt32(16) & libc.Uint64FromInt32(0xFF))
	**(**Tu8)(__ccgo_up(a + 6)) = uint8(iVal >> libc.Int32FromInt32(8) & libc.Uint64FromInt32(0xFF))
	**(**Tu8)(__ccgo_up(a + 7)) = uint8(iVal >> libc.Int32FromInt32(0) & libc.Uint64FromInt32(0xFF))
}

// C documentation
//
//	/*
//	** Write a 64-bit variable-length integer to memory starting at p[0].
//	** The length of data write will be between 1 and 9 bytes.  The number
//	** of bytes written is returned.
//	**
//	** A variable-length integer consists of the lower 7 bits of each byte
//	** for all bytes that have the 8th bit set and one byte with the 8th
//	** bit clear.  Except, if we get to the 9th byte, it stores the full
//	** 8 bits and is the last byte.
//	*/
func _fts5PutVarint64(tls *libc.TLS, p uintptr, v Tu64) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var i, j, n, v2 int32
	var v3 uintptr
	var _ /* buf at bp+0 */ [10]Tu8
	_, _, _, _, _ = i, j, n, v2, v3
	if v&(libc.Uint64FromUint32(0xff000000)<<libc.Int32FromInt32(32)) != 0 {
		**(**uint8)(__ccgo_up(p + 8)) = uint8(v)
		v = v >> uint64(8)
		i = int32(7)
		for {
			if !(i >= 0) {
				break
			}
			**(**uint8)(__ccgo_up(p + uintptr(i))) = uint8(v&libc.Uint64FromInt32(0x7f) | libc.Uint64FromInt32(0x80))
			v = v >> uint64(7)
			goto _1
		_1:
			;
			i = i - 1
		}
		return int32(9)
	}
	n = 0
	for cond := true; cond; cond = v != uint64(0) {
		v2 = n
		n = n + 1
		(**(**[10]Tu8)(__ccgo_up(bp)))[v2] = uint8(v&libc.Uint64FromInt32(0x7f) | libc.Uint64FromInt32(0x80))
		v = v >> uint64(7)
	}
	v3 = bp
	*(*Tu8)(unsafe.Pointer(v3)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v3))) & libc.Int32FromInt32(0x7f))
	i = 0
	j = n - libc.Int32FromInt32(1)
	for {
		if !(j >= 0) {
			break
		}
		**(**uint8)(__ccgo_up(p + uintptr(i))) = (**(**[10]Tu8)(__ccgo_up(bp)))[j]
		goto _4
	_4:
		;
		j = j - 1
		i = i + 1
	}
	return n
}

// C documentation
//
//	/*
//	** The xRelease() method.
//	**
//	** This is a no-op.
//	*/
func _fts5ReleaseMethod(tls *libc.TLS, pVtab uintptr, iSavepoint int32) (r int32) {
	var pTab uintptr
	var rc int32
	_, _ = pTab, rc
	pTab = pVtab
	rc = SQLITE_OK
	if iSavepoint+int32(1) < (*TFts5FullTable)(unsafe.Pointer(pTab)).FiSavepoint {
		rc = _sqlite3Fts5FlushToDisk(tls, pTab)
		if rc == SQLITE_OK {
			(*TFts5FullTable)(unsafe.Pointer(pTab)).FiSavepoint = iSavepoint
		}
	}
	return rc
}

// C documentation
//
//	/*
//	** Implementation of FTS5 xRename method. Rename an fts5 table.
//	*/
func _fts5RenameMethod(tls *libc.TLS, pVtab uintptr, zName uintptr) (r int32) {
	var pTab uintptr
	var rc int32
	_, _ = pTab, rc
	pTab = pVtab
	rc = _sqlite3Fts5StorageRename(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, zName)
	return rc
}

// C documentation
//
//	/*
//	** Parameter zFmt is a printf() style formatting string. This function
//	** formats it using the trailing arguments and returns the result as
//	** an error message to the context passed as the first argument.
//	*/
func _fts5ResultError(tls *libc.TLS, pCtx uintptr, zFmt uintptr, va uintptr) {
	var ap Tva_list
	var zErr uintptr
	_, _ = ap, zErr
	zErr = uintptr(0)
	ap = va
	zErr = Xsqlite3_vmprintf(tls, zFmt, ap)
	Xsqlite3_result_error(tls, pCtx, zErr, -int32(1))
	Xsqlite3_free(tls, zErr)
	_ = ap
}

// C documentation
//
//	/*
//	** Implementation of xRollback(). Discard the contents of the pending-terms
//	** hash-table. Any changes made to the database are reverted by SQLite.
//	*/
func _fts5RollbackMethod(tls *libc.TLS, pVtab uintptr) (r int32) {
	var pTab uintptr
	var rc int32
	_, _ = pTab, rc
	pTab = pVtab
	rc = _sqlite3Fts5StorageRollback(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
	(*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).Fpgsz = 0
	return rc
}

// C documentation
//
//	/*
//	** The xRollbackTo() method.
//	**
//	** Discard the contents of the pending terms table.
//	*/
func _fts5RollbackToMethod(tls *libc.TLS, pVtab uintptr, iSavepoint int32) (r int32) {
	var pTab uintptr
	var rc int32
	_, _ = pTab, rc
	pTab = pVtab
	rc = SQLITE_OK
	_fts5TripCursors(tls, pTab)
	if iSavepoint+int32(1) <= (*TFts5FullTable)(unsafe.Pointer(pTab)).FiSavepoint {
		(*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).Fpgsz = 0
		rc = _sqlite3Fts5StorageRollback(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
	}
	return rc
}

// C documentation
//
//	/*
//	** If pExpr is an ASC iterator, this function returns a value with the
//	** same sign as:
//	**
//	**   (iLhs - iRhs)
//	**
//	** Otherwise, if this is a DESC iterator, the opposite is returned:
//	**
//	**   (iRhs - iLhs)
//	*/
func _fts5RowidCmp(tls *libc.TLS, pExpr uintptr, iLhs Ti64, iRhs Ti64) (r int32) {
	if (*TFts5Expr)(unsafe.Pointer(pExpr)).FbDesc == 0 {
		if iLhs < iRhs {
			return -int32(1)
		}
		return libc.BoolInt32(iLhs > iRhs)
	} else {
		if iLhs > iRhs {
			return -int32(1)
		}
		return libc.BoolInt32(iLhs < iRhs)
	}
	return r
}

// C documentation
//
//	/*
//	** This is the xRowid method. The SQLite core calls this routine to
//	** retrieve the rowid for the current row of the result set. fts5
//	** exposes %_content.rowid as the rowid for the virtual table. The
//	** rowid should be written to *pRowid.
//	*/
func _fts5RowidMethod(tls *libc.TLS, pCursor uintptr, pRowid uintptr) (r int32) {
	var ePlan int32
	var pCsr uintptr
	_, _ = ePlan, pCsr
	pCsr = pCursor
	ePlan = (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan
	if ePlan == int32(FTS5_PLAN_SPECIAL) {
		**(**Tsqlite_int64)(__ccgo_up(pRowid)) = 0
	} else {
		**(**Tsqlite_int64)(__ccgo_up(pRowid)) = _fts5CursorRowid(tls, pCsr)
	}
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** The xSavepoint() method.
//	**
//	** Flush the contents of the pending-terms table to disk.
//	*/
func _fts5SavepointMethod(tls *libc.TLS, pVtab uintptr, iSavepoint int32) (r int32) {
	var pTab uintptr
	var rc int32
	_, _ = pTab, rc
	pTab = pVtab
	rc = SQLITE_OK
	rc = _sqlite3Fts5FlushToDisk(tls, pVtab)
	if rc == SQLITE_OK {
		(*TFts5FullTable)(unsafe.Pointer(pTab)).FiSavepoint = iSavepoint + int32(1)
	}
	return rc
}

// C documentation
//
//	/*
//	** Iterator pIter currently points to the first rowid of a doclist.
//	** There is a doclist-index associated with the final term on the current
//	** page. If the current term is the last term on the page, load the
//	** doclist-index from disk and initialize an iterator at (pIter->pDlidx).
//	*/
func _fts5SegIterLoadDlidx(tls *libc.TLS, p uintptr, pIter uintptr) {
	var bRev, iSeg int32
	var pLeaf uintptr
	_, _, _ = bRev, iSeg, pLeaf
	iSeg = (*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FiSegid
	bRev = (*TFts5SegIter)(unsafe.Pointer(pIter)).Fflags & int32(FTS5_SEGITER_REVERSE)
	pLeaf = (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf /* Current leaf data */
	/* Check if the current doclist ends on this page. If it does, return
	 ** early without loading the doclist-index (as it belongs to a different
	 ** term. */
	if (*TFts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno == (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno && (*TFts5SegIter)(unsafe.Pointer(pIter)).FiEndofDoclist < (*TFts5Data)(unsafe.Pointer(pLeaf)).FszLeaf {
		return
	}
	(*TFts5SegIter)(unsafe.Pointer(pIter)).FpDlidx = _fts5DlidxIterInit(tls, p, bRev, iSeg, (*TFts5SegIter)(unsafe.Pointer(pIter)).FiTermLeafPgno)
}

// C documentation
//
//	/*
//	** Advance the iterator passed as the second argument until it is at or
//	** past rowid iFrom. Regardless of the value of iFrom, the iterator is
//	** always advanced at least once.
//	*/
func _fts5SegIterNextFrom(tls *libc.TLS, p uintptr, pIter uintptr, iMatch Ti64) {
	var bMove, bRev, iLeafPgno int32
	var pDlidx uintptr
	_, _, _, _ = bMove, bRev, iLeafPgno, pDlidx
	bRev = (*TFts5SegIter)(unsafe.Pointer(pIter)).Fflags & int32(FTS5_SEGITER_REVERSE)
	pDlidx = (*TFts5SegIter)(unsafe.Pointer(pIter)).FpDlidx
	iLeafPgno = (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno
	bMove = int32(1)
	if bRev == 0 {
		for !(_fts5DlidxIterEof(tls, p, pDlidx) != 0) && iMatch > _fts5DlidxIterRowid(tls, pDlidx) {
			iLeafPgno = _fts5DlidxIterPgno(tls, pDlidx)
			_fts5DlidxIterNext(tls, p, pDlidx)
		}
		if iLeafPgno > (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno {
			_fts5SegIterGotoPage(tls, p, pIter, iLeafPgno)
			bMove = 0
		}
	} else {
		for !(_fts5DlidxIterEof(tls, p, pDlidx) != 0) && iMatch < _fts5DlidxIterRowid(tls, pDlidx) {
			_fts5DlidxIterPrev(tls, p, pDlidx)
		}
		iLeafPgno = _fts5DlidxIterPgno(tls, pDlidx)
		if iLeafPgno < (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno {
			(*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno = iLeafPgno + int32(1)
			_fts5SegIterReverseNewPage(tls, p, pIter)
			bMove = 0
		}
	}
	for cond := true; cond; cond = (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
		if bMove != 0 && (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
			(*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5SegIter)(unsafe.Pointer(pIter)).FxNext})))(tls, p, pIter, uintptr(0))
		}
		if (*TFts5SegIter)(unsafe.Pointer(pIter)).FpLeaf == uintptr(0) {
			break
		}
		if bRev == 0 && (*TFts5SegIter)(unsafe.Pointer(pIter)).FiRowid >= iMatch {
			break
		}
		if bRev != 0 && (*TFts5SegIter)(unsafe.Pointer(pIter)).FiRowid <= iMatch {
			break
		}
		bMove = int32(1)
	}
}

// C documentation
//
//	/*
//	** Ensure the segment-iterator passed as the only argument points to EOF.
//	*/
func _fts5SegIterSetEOF(tls *libc.TLS, pSeg uintptr) {
	_fts5DataRelease(tls, (*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf)
	(*TFts5SegIter)(unsafe.Pointer(pSeg)).FpLeaf = uintptr(0)
}

func _fts5SegIterSetNext(tls *libc.TLS, p uintptr, pIter uintptr) {
	if (*TFts5SegIter)(unsafe.Pointer(pIter)).Fflags&int32(FTS5_SEGITER_REVERSE) != 0 {
		(*TFts5SegIter)(unsafe.Pointer(pIter)).FxNext = __ccgo_fp(_fts5SegIterNext_Reverse)
	} else {
		if (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FeDetail == int32(FTS5_DETAIL_NONE) {
			(*TFts5SegIter)(unsafe.Pointer(pIter)).FxNext = __ccgo_fp(_fts5SegIterNext_None)
		} else {
			(*TFts5SegIter)(unsafe.Pointer(pIter)).FxNext = __ccgo_fp(_fts5SegIterNext)
		}
	}
}

func _fts5SegmentSize(tls *libc.TLS, pSeg uintptr) (r int32) {
	return int32(1) + (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoLast - (*TFts5StructureSegment)(unsafe.Pointer(pSeg)).FpgnoFirst
}

func _fts5SetEstimatedRows(tls *libc.TLS, pIdxInfo uintptr, nRow Ti64) {
	var v1 int64
	_ = v1
	if int64(libc.Int32FromInt32(1)) > nRow {
		v1 = int64(libc.Int32FromInt32(1))
	} else {
		v1 = nRow
	}
	(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = v1
}

// C documentation
//
//	/*
//	** Set the error message on the virtual table passed as the first argument.
//	*/
func _fts5SetVtabError(tls *libc.TLS, p uintptr, zFormat uintptr, va uintptr) {
	var ap Tva_list
	_ = ap /* ... printf arguments */
	ap = va
	Xsqlite3_free(tls, (*TFts5FullTable)(unsafe.Pointer(p)).Fp.Fbase.FzErrMsg)
	(*TFts5FullTable)(unsafe.Pointer(p)).Fp.Fbase.FzErrMsg = Xsqlite3_vmprintf(tls, zFormat, ap)
	_ = ap
}

func _fts5SnippetScore(tls *libc.TLS, pApi uintptr, pFts uintptr, nDocsize int32, aSeen uintptr, iCol int32, iPos int32, nToken int32, pnScore uintptr, piPos uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var i, iFirst, iLast, nScore, rc, v2 int32
	var iAdj, iEnd Tsqlite3_int64
	var _ /* iOff at bp+8 */ int32
	var _ /* ic at bp+4 */ int32
	var _ /* ip at bp+0 */ int32
	var _ /* nInst at bp+12 */ int32
	_, _, _, _, _, _, _, _ = i, iAdj, iEnd, iFirst, iLast, nScore, rc, v2
	**(**int32)(__ccgo_up(bp)) = 0
	**(**int32)(__ccgo_up(bp + 4)) = 0
	**(**int32)(__ccgo_up(bp + 8)) = 0
	iFirst = -int32(1)
	nScore = 0
	iLast = 0
	iEnd = int64(iPos) + int64(nToken)
	rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxInstCount})))(tls, pFts, bp+12)
	i = 0
	for {
		if !(i < **(**int32)(__ccgo_up(bp + 12)) && rc == SQLITE_OK) {
			break
		}
		rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxInst})))(tls, pFts, i, bp, bp+4, bp+8)
		if rc == SQLITE_OK && **(**int32)(__ccgo_up(bp + 4)) == iCol && **(**int32)(__ccgo_up(bp + 8)) >= iPos && int64(**(**int32)(__ccgo_up(bp + 8))) < iEnd {
			if **(**uint8)(__ccgo_up(aSeen + uintptr(**(**int32)(__ccgo_up(bp))))) != 0 {
				v2 = int32(1)
			} else {
				v2 = int32(1000)
			}
			nScore = nScore + v2
			**(**uint8)(__ccgo_up(aSeen + uintptr(**(**int32)(__ccgo_up(bp))))) = uint8(1)
			if iFirst < 0 {
				iFirst = **(**int32)(__ccgo_up(bp + 8))
			}
			iLast = **(**int32)(__ccgo_up(bp + 8)) + (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExtensionApi)(unsafe.Pointer(pApi)).FxPhraseSize})))(tls, pFts, **(**int32)(__ccgo_up(bp)))
		}
		goto _1
	_1:
		;
		i = i + 1
	}
	**(**int32)(__ccgo_up(pnScore)) = nScore
	if piPos != 0 {
		iAdj = int64(iFirst - (nToken-(iLast-iFirst))/int32(2))
		if iAdj+int64(nToken) > int64(nDocsize) {
			iAdj = int64(nDocsize - nToken)
		}
		if iAdj < 0 {
			iAdj = 0
		}
		**(**int32)(__ccgo_up(piPos)) = int32(iAdj)
	}
	return rc
}

func _fts5StmtType(tls *libc.TLS, pCsr uintptr) (r int32) {
	var v1 int32
	_ = v1
	if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FePlan == int32(FTS5_PLAN_SCAN) {
		if (*TFts5Cursor)(unsafe.Pointer(pCsr)).FbDesc != 0 {
			v1 = int32(FTS5_STMT_SCAN_DESC)
		} else {
			v1 = FTS5_STMT_SCAN_ASC
		}
		return v1
	}
	return int32(FTS5_STMT_LOOKUP)
}

// C documentation
//
//	/*
//	** This function is called to process a DELETE on a contentless_delete=1
//	** table. It adds the tombstone required to delete the entry with rowid
//	** iDel. If successful, SQLITE_OK is returned. Or, if an error occurs,
//	** an SQLite error code.
//	*/
func _fts5StorageContentlessDelete(tls *libc.TLS, p uintptr, iDel Ti64) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var iOrigin Ti64
	var rc int32
	var _ /* pLookup at bp+0 */ uintptr
	_, _ = iOrigin, rc
	iOrigin = 0
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
	rc = SQLITE_OK
	/* Look up the origin of the document in the %_docsize table. Store
	 ** this in stack variable iOrigin.  */
	rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_LOOKUP_DOCSIZE), bp, uintptr(0))
	if rc == SQLITE_OK {
		Xsqlite3_bind_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), iDel)
		if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) {
			iOrigin = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1))
		}
		rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp)))
	}
	if rc == SQLITE_OK && iOrigin != 0 {
		rc = _sqlite3Fts5IndexContentlessDelete(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex, iOrigin, iDel)
	}
	return rc
}

func _fts5StorageDecodeSizeArray(tls *libc.TLS, aCol uintptr, nCol int32, aBlob uintptr, nBlob int32) (r int32) {
	var i, iOff int32
	_, _ = i, iOff
	iOff = 0
	i = 0
	for {
		if !(i < nCol) {
			break
		}
		if iOff >= nBlob {
			return int32(1)
		}
		iOff = iOff + _sqlite3Fts5GetVarint32(tls, aBlob+uintptr(iOff), aCol+uintptr(i)*4)
		goto _1
	_1:
		;
		i = i + 1
	}
	return libc.BoolInt32(iOff != nBlob)
}

func _fts5StorageInsert(tls *libc.TLS, pRc uintptr, pTab uintptr, apVal uintptr, piRowid uintptr) {
	var rc int32
	_ = rc
	rc = **(**int32)(__ccgo_up(pRc))
	if rc == SQLITE_OK {
		rc = _sqlite3Fts5StorageContentInsert(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, 0, apVal, piRowid)
	}
	if rc == SQLITE_OK {
		rc = _sqlite3Fts5StorageIndexInsert(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, apVal, **(**Ti64)(__ccgo_up(piRowid)))
	}
	**(**int32)(__ccgo_up(pRc)) = rc
}

// C documentation
//
//	/*
//	** Tokenization callback used when inserting tokens into the FTS index.
//	*/
func _fts5StorageInsertCallback(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintptr, nToken int32, iUnused1 int32, iUnused2 int32) (r int32) {
	var pCtx, pIdx uintptr
	_, _ = pCtx, pIdx
	pCtx = pContext
	pIdx = (*TFts5Storage)(unsafe.Pointer((*TFts5InsertCtx)(unsafe.Pointer(pCtx)).FpStorage)).FpIndex
	_ = iUnused1
	_ = iUnused2
	if nToken > int32(FTS5_MAX_TOKEN_SIZE) {
		nToken = int32(FTS5_MAX_TOKEN_SIZE)
	}
	if tflags&int32(FTS5_TOKEN_COLOCATED) == 0 || (*TFts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol == 0 {
		(*TFts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol = (*TFts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol + 1
	}
	return _sqlite3Fts5IndexWrite(tls, pIdx, (*TFts5InsertCtx)(unsafe.Pointer(pCtx)).FiCol, (*TFts5InsertCtx)(unsafe.Pointer(pCtx)).FszCol-int32(1), pToken, nToken)
}

// C documentation
//
//	/*
//	** Insert a record into the %_docsize table. Specifically, do:
//	**
//	**   INSERT OR REPLACE INTO %_docsize(id, sz) VALUES(iRowid, pBuf);
//	**
//	** If there is no %_docsize table (as happens if the columnsize=0 option
//	** is specified when the FTS5 table is created), this function is a no-op.
//	*/
func _fts5StorageInsertDocsize(tls *libc.TLS, p uintptr, iRowid Ti64, pBuf uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* iOrigin at bp+8 */ Ti64
	var _ /* pReplace at bp+0 */ uintptr
	_ = rc
	rc = SQLITE_OK
	if (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FbColumnsize != 0 {
		**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
		rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_REPLACE_DOCSIZE), bp, uintptr(0))
		if rc == SQLITE_OK {
			Xsqlite3_bind_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), iRowid)
			if (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FbContentlessDelete != 0 {
				**(**Ti64)(__ccgo_up(bp + 8)) = 0
				rc = _sqlite3Fts5IndexGetOrigin(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex, bp+8)
				Xsqlite3_bind_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(3), **(**Ti64)(__ccgo_up(bp + 8)))
			}
		}
		if rc == SQLITE_OK {
			Xsqlite3_bind_blob(tls, **(**uintptr)(__ccgo_up(bp)), int32(2), (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fp, (*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn, libc.UintptrFromInt32(0))
			Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp)))
			rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp)))
			Xsqlite3_bind_null(tls, **(**uintptr)(__ccgo_up(bp)), int32(2))
		}
	}
	return rc
}

// C documentation
//
//	/*
//	** Tokenization callback used by integrity check.
//	*/
func _fts5StorageIntegrityCallback(tls *libc.TLS, pContext uintptr, tflags int32, pToken uintptr, nToken int32, iUnused1 int32, iUnused2 int32) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var iCol, iPos, ii, nByte, nChar, rc int32
	var pCtx, pTermset uintptr
	var _ /* bPresent at bp+0 */ int32
	_, _, _, _, _, _, _, _ = iCol, iPos, ii, nByte, nChar, pCtx, pTermset, rc
	pCtx = pContext
	pTermset = (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpTermset
	rc = SQLITE_OK
	_ = iUnused1
	_ = iUnused2
	if nToken > int32(FTS5_MAX_TOKEN_SIZE) {
		nToken = int32(FTS5_MAX_TOKEN_SIZE)
	}
	if tflags&int32(FTS5_TOKEN_COLOCATED) == 0 || (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol == 0 {
		(*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol = (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol + 1
	}
	switch (*TFts5Config)(unsafe.Pointer((*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FeDetail {
	case FTS5_DETAIL_FULL:
		iPos = (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FszCol - int32(1)
		iCol = (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiCol
	case int32(FTS5_DETAIL_COLUMNS):
		iPos = (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiCol
		iCol = 0
	default:
		iPos = 0
		iCol = 0
		break
	}
	rc = _sqlite3Fts5TermsetAdd(tls, pTermset, 0, pToken, nToken, bp)
	if rc == SQLITE_OK && **(**int32)(__ccgo_up(bp)) == 0 {
		**(**Tu64)(__ccgo_up(pCtx + 16)) ^= _sqlite3Fts5IndexEntryCksum(tls, (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiRowid, iCol, iPos, 0, pToken, nToken)
	}
	ii = 0
	for {
		if !(rc == SQLITE_OK && ii < (*TFts5Config)(unsafe.Pointer((*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FnPrefix) {
			break
		}
		nChar = **(**int32)(__ccgo_up((*TFts5Config)(unsafe.Pointer((*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FpConfig)).FaPrefix + uintptr(ii)*4))
		nByte = _sqlite3Fts5IndexCharlenToBytelen(tls, pToken, nToken, nChar)
		if nByte != 0 {
			rc = _sqlite3Fts5TermsetAdd(tls, pTermset, ii+int32(1), pToken, nByte, bp)
			if **(**int32)(__ccgo_up(bp)) == 0 {
				**(**Tu64)(__ccgo_up(pCtx + 16)) ^= _sqlite3Fts5IndexEntryCksum(tls, (*TFts5IntegrityCtx)(unsafe.Pointer(pCtx)).FiRowid, iCol, iPos, ii+int32(1), pToken, nByte)
			}
		}
		goto _1
	_1:
		;
		ii = ii + 1
	}
	return rc
}

// C documentation
//
//	/*
//	** Allocate a new rowid. This is used for "external content" tables when
//	** a NULL value is inserted into the rowid column. The new rowid is allocated
//	** by inserting a dummy row into the %_docsize table. The dummy will be
//	** overwritten later.
//	**
//	** If the %_docsize table does not exist, SQLITE_MISMATCH is returned. In
//	** this case the user is required to provide a rowid explicitly.
//	*/
func _fts5StorageNewRowid(tls *libc.TLS, p uintptr, piRowid uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* pReplace at bp+0 */ uintptr
	_ = rc
	rc = int32(SQLITE_MISMATCH)
	if (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FbColumnsize != 0 {
		**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
		rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_REPLACE_DOCSIZE), bp, uintptr(0))
		if rc == SQLITE_OK {
			Xsqlite3_bind_null(tls, **(**uintptr)(__ccgo_up(bp)), int32(1))
			Xsqlite3_bind_null(tls, **(**uintptr)(__ccgo_up(bp)), int32(2))
			Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp)))
			rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp)))
		}
		if rc == SQLITE_OK {
			**(**Ti64)(__ccgo_up(piRowid)) = Xsqlite3_last_insert_rowid(tls, (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).Fdb)
		}
	}
	return rc
}

func _fts5StructureInvalidate(tls *libc.TLS, p uintptr) {
	if (*TFts5Index)(unsafe.Pointer(p)).FpStruct != 0 {
		_fts5StructureRelease(tls, (*TFts5Index)(unsafe.Pointer(p)).FpStruct)
		(*TFts5Index)(unsafe.Pointer(p)).FpStruct = uintptr(0)
	}
}

/*
** Return the total number of segments in index structure pStruct. This
** function is only ever used as part of assert() conditions.
 */

// C documentation
//
//	/*
//	** Read, deserialize and return the structure record.
//	**
//	** The Fts5Structure.aLevel[] and each Fts5StructureLevel.aSeg[] array
//	** are over-allocated as described for function fts5StructureDecode()
//	** above.
//	**
//	** If an error occurs, NULL is returned and an error code left in the
//	** Fts5Index handle. If an error has already occurred when this function
//	** is called, it is a no-op.
//	*/
func _fts5StructureRead(tls *libc.TLS, p uintptr) (r uintptr) {
	if (*TFts5Index)(unsafe.Pointer(p)).FpStruct == uintptr(0) {
		(*TFts5Index)(unsafe.Pointer(p)).FiStructVersion = _fts5IndexDataVersion(tls, p)
		if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
			(*TFts5Index)(unsafe.Pointer(p)).FpStruct = _fts5StructureReadUncached(tls, p)
		}
	}
	if (*TFts5Index)(unsafe.Pointer(p)).Frc != SQLITE_OK {
		return uintptr(0)
	}
	_fts5StructureRef(tls, (*TFts5Index)(unsafe.Pointer(p)).FpStruct)
	return (*TFts5Index)(unsafe.Pointer(p)).FpStruct
}

func _fts5StructureRef(tls *libc.TLS, pStruct uintptr) {
	(*TFts5Structure)(unsafe.Pointer(pStruct)).FnRef = (*TFts5Structure)(unsafe.Pointer(pStruct)).FnRef + 1
}

// C documentation
//
//	/*
//	** Free a trigram tokenizer.
//	*/
func _fts5TriDelete(tls *libc.TLS, p uintptr) {
	Xsqlite3_free(tls, p)
}

// C documentation
//
//	/*
//	** Delete a "unicode61" tokenizer.
//	*/
func _fts5UnicodeDelete(tls *libc.TLS, pTok uintptr) {
	var p uintptr
	_ = p
	if pTok != 0 {
		p = pTok
		Xsqlite3_free(tls, (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaiException)
		Xsqlite3_free(tls, (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaFold)
		Xsqlite3_free(tls, p)
	}
	return
}

// C documentation
//
//	/*
//	** Return true if the p->aiException[] array contains the value iCode.
//	*/
func _fts5UnicodeIsException(tls *libc.TLS, p uintptr, iCode int32) (r int32) {
	var a uintptr
	var iHi, iLo, iTest int32
	_, _, _, _ = a, iHi, iLo, iTest
	if (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnException > 0 {
		a = (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FaiException
		iLo = 0
		iHi = (*TUnicode61Tokenizer)(unsafe.Pointer(p)).FnException - int32(1)
		for iHi >= iLo {
			iTest = (iHi + iLo) / int32(2)
			if iCode == **(**int32)(__ccgo_up(a + uintptr(iTest)*4)) {
				return int32(1)
			} else {
				if iCode > **(**int32)(__ccgo_up(a + uintptr(iTest)*4)) {
					iLo = iTest + int32(1)
				} else {
					iHi = iTest - int32(1)
				}
			}
		}
	}
	return 0
}

// C documentation
//
//	/*
//	** xTokenizer method for a wrapper tokenizer that offers the v1 interface
//	** (no support for locales).
//	*/
func _fts5V1toV2Tokenize(tls *libc.TLS, pTok uintptr, pCtx uintptr, flags int32, pText uintptr, nText int32, __ccgo_fp_xToken uintptr) (r int32) {
	var p uintptr
	_ = p
	p = pTok
	return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5VtoVTokenizer)(unsafe.Pointer(p)).Fx2.FxTokenize})))(tls, (*TFts5VtoVTokenizer)(unsafe.Pointer(p)).FpReal, pCtx, flags, pText, nText, uintptr(0), 0, __ccgo_fp_xToken)
}

// C documentation
//
//	/*
//	** xTokenizer method for a wrapper tokenizer that offers the v2 interface
//	** (with locale support).
//	*/
func _fts5V2toV1Tokenize(tls *libc.TLS, pTok uintptr, pCtx uintptr, flags int32, pText uintptr, nText int32, pLocale uintptr, nLocale int32, __ccgo_fp_xToken uintptr) (r int32) {
	var p uintptr
	_ = p
	p = pTok
	_ = pLocale
	_ = nLocale
	return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5VtoVTokenizer)(unsafe.Pointer(p)).Fx1.FxTokenize})))(tls, (*TFts5VtoVTokenizer)(unsafe.Pointer(p)).FpReal, pCtx, flags, pText, nText, __ccgo_fp_xToken)
}

var _fts5Vocab = Tsqlite3_module{
	FiVersion: int32(2),
}

// C documentation
//
//	/*
//	** The xConnect() and xCreate() methods for the virtual table. All the
//	** work is done in function fts5VocabInitVtab().
//	*/
func _fts5VocabConnectMethod(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) {
	return _fts5VocabInitVtab(tls, db, pAux, argc, argv, ppVtab, pzErr)
}

func _fts5VocabCreateMethod(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) {
	return _fts5VocabInitVtab(tls, db, pAux, argc, argv, ppVtab, pzErr)
}

// C documentation
//
//	/*
//	** The xDestroy() virtual table method.
//	*/
func _fts5VocabDestroyMethod(tls *libc.TLS, pVtab uintptr) (r int32) {
	var pTab uintptr
	_ = pTab
	pTab = pVtab
	Xsqlite3_free(tls, pTab)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** The xDisconnect() virtual table method.
//	*/
func _fts5VocabDisconnectMethod(tls *libc.TLS, pVtab uintptr) (r int32) {
	var pTab uintptr
	_ = pTab
	pTab = pVtab
	Xsqlite3_free(tls, pTab)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** This is the xEof method of the virtual table. SQLite calls this
//	** routine to find out if it has reached the end of a result set.
//	*/
func _fts5VocabEofMethod(tls *libc.TLS, pCursor uintptr) (r int32) {
	var pCsr uintptr
	_ = pCsr
	pCsr = pCursor
	return (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).FbEof
}

// C documentation
//
//	/*
//	** This is the xRowid method. The SQLite core calls this routine to
//	** retrieve the rowid for the current row of the result set. The
//	** rowid should be written to *pRowid.
//	*/
func _fts5VocabRowidMethod(tls *libc.TLS, pCursor uintptr, pRowid uintptr) (r int32) {
	var pCsr uintptr
	_ = pCsr
	pCsr = pCursor
	**(**Tsqlite_int64)(__ccgo_up(pRowid)) = (*TFts5VocabCursor)(unsafe.Pointer(pCsr)).Frowid
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Delete an Fts5VtoVTokenizer wrapper tokenizer.
//	*/
func _fts5VtoVDelete(tls *libc.TLS, pTok uintptr) {
	var p uintptr
	_ = p
	p = pTok
	if p != 0 {
		if (*TFts5VtoVTokenizer)(unsafe.Pointer(p)).FbV2Native != 0 {
			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5VtoVTokenizer)(unsafe.Pointer(p)).Fx2.FxDelete})))(tls, (*TFts5VtoVTokenizer)(unsafe.Pointer(p)).FpReal)
		} else {
			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TFts5VtoVTokenizer)(unsafe.Pointer(p)).Fx1.FxDelete})))(tls, (*TFts5VtoVTokenizer)(unsafe.Pointer(p)).FpReal)
		}
		Xsqlite3_free(tls, p)
	}
}

// C documentation
//
//	/*
//	** If the current doclist-index accumulating in pWriter->aDlidx[] is large
//	** enough, flush it to disk and return 1. Otherwise discard it and return
//	** zero.
//	*/
func _fts5WriteFlushDlidx(tls *libc.TLS, p uintptr, pWriter uintptr) (r int32) {
	var bFlag int32
	_ = bFlag
	bFlag = 0
	/* If there were FTS5_MIN_DLIDX_SIZE or more empty leaf pages written
	 ** to the database, also write the doclist-index to disk.  */
	if (**(**TFts5DlidxWriter)(__ccgo_up((*TFts5SegWriter)(unsafe.Pointer(pWriter)).FaDlidx))).Fbuf.Fn > 0 && (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FnEmpty >= int32(FTS5_MIN_DLIDX_SIZE) {
		bFlag = int32(1)
	}
	_fts5WriteDlidxClear(tls, p, pWriter, bFlag)
	(*TFts5SegWriter)(unsafe.Pointer(pWriter)).FnEmpty = 0
	return bFlag
}

// C documentation
//
//	/* For rule J, fts5yyRuleInfoLhs[J] contains the symbol on the left-hand side
//	** of that rule */
var _fts5yyRuleInfoLhs = [28]uint8{
	0:  uint8(16),
	1:  uint8(20),
	2:  uint8(20),
	3:  uint8(20),
	4:  uint8(20),
	5:  uint8(21),
	6:  uint8(21),
	7:  uint8(17),
	8:  uint8(17),
	9:  uint8(17),
	10: uint8(17),
	11: uint8(17),
	12: uint8(17),
	13: uint8(19),
	14: uint8(19),
	15: uint8(18),
	16: uint8(18),
	17: uint8(22),
	18: uint8(22),
	19: uint8(22),
	20: uint8(23),
	21: uint8(23),
	22: uint8(25),
	23: uint8(25),
	24: uint8(24),
	25: uint8(24),
	26: uint8(26),
	27: uint8(26),
}

// C documentation
//
//	/* For rule J, fts5yyRuleInfoNRhs[J] contains the negative of the number
//	** of symbols on the right-hand side of that rule. */
var _fts5yyRuleInfoNRhs = [28]int8{
	0:  int8(-int32(1)),
	1:  int8(-int32(4)),
	2:  int8(-int32(3)),
	3:  int8(-int32(1)),
	4:  int8(-int32(2)),
	5:  int8(-int32(2)),
	6:  int8(-int32(1)),
	7:  int8(-int32(3)),
	8:  int8(-int32(3)),
	9:  int8(-int32(3)),
	10: int8(-int32(5)),
	11: int8(-int32(3)),
	12: int8(-int32(1)),
	13: int8(-int32(1)),
	14: int8(-int32(2)),
	15: int8(-int32(1)),
	16: int8(-int32(3)),
	17: int8(-int32(1)),
	18: int8(-int32(2)),
	19: int8(-int32(5)),
	20: int8(-int32(1)),
	21: int8(-int32(2)),
	23: int8(-int32(2)),
	24: int8(-int32(4)),
	25: int8(-int32(2)),
	26: int8(-int32(1)),
}

// C documentation
//
//	/*
//	** The following is executed when the parser accepts
//	*/
func _fts5yy_accept(tls *libc.TLS, fts5yypParser uintptr) {
	var pParse uintptr
	_ = pParse
	pParse = (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse
	/* Here code is inserted which will be executed whenever the
	 ** parser accepts */
	/*********** Begin %parse_accept code *****************************************/
	/*********** End %parse_accept code *******************************************/
	(*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse = pParse /* Suppress warning about unused %extra_argument variable */
}

// C documentation
//
//	/* Next are the tables used to determine what action to take based on the
//	** current state and lookahead token.  These tables are used to implement
//	** functions that take a state number and lookahead value and return an
//	** action integer.
//	**
//	** Suppose the action integer is N.  Then the action is determined as
//	** follows
//	**
//	**   0 <= N <= fts5YY_MAX_SHIFT             Shift N.  That is, push the lookahead
//	**                                      token onto the stack and goto state N.
//	**
//	**   N between fts5YY_MIN_SHIFTREDUCE       Shift to an arbitrary state then
//	**     and fts5YY_MAX_SHIFTREDUCE           reduce by rule N-fts5YY_MIN_SHIFTREDUCE.
//	**
//	**   N == fts5YY_ERROR_ACTION               A syntax error has occurred.
//	**
//	**   N == fts5YY_ACCEPT_ACTION              The parser accepts its input.
//	**
//	**   N == fts5YY_NO_ACTION                  No such action.  Denotes unused
//	**                                      slots in the fts5yy_action[] table.
//	**
//	**   N between fts5YY_MIN_REDUCE            Reduce by rule N-fts5YY_MIN_REDUCE
//	**     and fts5YY_MAX_REDUCE
//	**
//	** The action table is constructed as a single large table named fts5yy_action[].
//	** Given state S and lookahead X, the action is computed as either:
//	**
//	**    (A)   N = fts5yy_action[ fts5yy_shift_ofst[S] + X ]
//	**    (B)   N = fts5yy_default[S]
//	**
//	** The (A) formula is preferred.  The B formula is used instead if
//	** fts5yy_lookahead[fts5yy_shift_ofst[S]+X] is not equal to X.
//	**
//	** The formulas above are for computing the action when the lookahead is
//	** a terminal symbol.  If the lookahead is a non-terminal (as occurs after
//	** a reduce action) then the fts5yy_reduce_ofst[] array is used in place of
//	** the fts5yy_shift_ofst[] array.
//	**
//	** The following are the tables generated in this section:
//	**
//	**  fts5yy_action[]        A single table containing all actions.
//	**  fts5yy_lookahead[]     A table containing the lookahead for each entry in
//	**                     fts5yy_action.  Used to detect hash collisions.
//	**  fts5yy_shift_ofst[]    For each state, the offset into fts5yy_action for
//	**                     shifting terminals.
//	**  fts5yy_reduce_ofst[]   For each state, the offset into fts5yy_action for
//	**                     shifting non-terminals after a reduce.
//	**  fts5yy_default[]       Default action for each state.
//	**
//	*********** Begin parsing tables **********************************************/
var _fts5yy_action = [105]uint8{
	0:   uint8(81),
	1:   uint8(20),
	2:   uint8(96),
	3:   uint8(6),
	4:   uint8(28),
	5:   uint8(99),
	6:   uint8(98),
	7:   uint8(26),
	8:   uint8(26),
	9:   uint8(18),
	10:  uint8(96),
	11:  uint8(6),
	12:  uint8(28),
	13:  uint8(17),
	14:  uint8(98),
	15:  uint8(56),
	16:  uint8(26),
	17:  uint8(19),
	18:  uint8(96),
	19:  uint8(6),
	20:  uint8(28),
	21:  uint8(14),
	22:  uint8(98),
	23:  uint8(14),
	24:  uint8(26),
	25:  uint8(31),
	26:  uint8(92),
	27:  uint8(96),
	28:  uint8(6),
	29:  uint8(28),
	30:  uint8(108),
	31:  uint8(98),
	32:  uint8(25),
	33:  uint8(26),
	34:  uint8(21),
	35:  uint8(96),
	36:  uint8(6),
	37:  uint8(28),
	38:  uint8(78),
	39:  uint8(98),
	40:  uint8(58),
	41:  uint8(26),
	42:  uint8(29),
	43:  uint8(96),
	44:  uint8(6),
	45:  uint8(28),
	46:  uint8(107),
	47:  uint8(98),
	48:  uint8(22),
	49:  uint8(26),
	50:  uint8(24),
	51:  uint8(16),
	52:  uint8(12),
	53:  uint8(11),
	54:  uint8(1),
	55:  uint8(13),
	56:  uint8(13),
	57:  uint8(24),
	58:  uint8(16),
	59:  uint8(23),
	60:  uint8(11),
	61:  uint8(33),
	62:  uint8(34),
	63:  uint8(13),
	64:  uint8(97),
	65:  uint8(8),
	66:  uint8(27),
	67:  uint8(32),
	68:  uint8(98),
	69:  uint8(7),
	70:  uint8(26),
	71:  uint8(3),
	72:  uint8(4),
	73:  uint8(5),
	74:  uint8(3),
	75:  uint8(4),
	76:  uint8(5),
	77:  uint8(3),
	78:  uint8(83),
	79:  uint8(4),
	80:  uint8(5),
	81:  uint8(3),
	82:  uint8(63),
	83:  uint8(5),
	84:  uint8(3),
	85:  uint8(62),
	86:  uint8(12),
	87:  uint8(2),
	88:  uint8(86),
	89:  uint8(13),
	90:  uint8(9),
	91:  uint8(30),
	92:  uint8(10),
	93:  uint8(10),
	94:  uint8(54),
	95:  uint8(57),
	96:  uint8(75),
	97:  uint8(78),
	98:  uint8(78),
	99:  uint8(53),
	100: uint8(57),
	101: uint8(15),
	102: uint8(82),
	103: uint8(82),
	104: uint8(71),
}

var _fts5yy_default = [35]uint8{
	0:  uint8(80),
	1:  uint8(80),
	2:  uint8(80),
	3:  uint8(80),
	4:  uint8(80),
	5:  uint8(80),
	6:  uint8(95),
	7:  uint8(80),
	8:  uint8(80),
	9:  uint8(105),
	10: uint8(80),
	11: uint8(110),
	12: uint8(110),
	13: uint8(80),
	14: uint8(110),
	15: uint8(110),
	16: uint8(80),
	17: uint8(80),
	18: uint8(80),
	19: uint8(80),
	20: uint8(80),
	21: uint8(91),
	22: uint8(80),
	23: uint8(80),
	24: uint8(80),
	25: uint8(101),
	26: uint8(100),
	27: uint8(80),
	28: uint8(80),
	29: uint8(90),
	30: uint8(103),
	31: uint8(80),
	32: uint8(80),
	33: uint8(104),
	34: uint8(80),
}

/********** End of lemon-generated parsing tables *****************************/

/* The next table maps tokens (terminal symbols) into fallback tokens.
** If a construct like the following:
**
**      %fallback ID X Y Z.
**
** appears in the grammar, then ID becomes a fallback token for X, Y,
** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser
** but it does not parse, the type of the token is changed to ID and
** the parse is retried before an error is thrown.
**
** This feature can be used, for example, to cause some keywords in a language
** to revert to identifiers if they keyword does not apply in the context where
** it appears.
 */

var _fts5yy_lookahead = [121]uint8{
	0:   uint8(16),
	1:   uint8(17),
	2:   uint8(18),
	3:   uint8(19),
	4:   uint8(20),
	5:   uint8(22),
	6:   uint8(22),
	7:   uint8(24),
	8:   uint8(24),
	9:   uint8(17),
	10:  uint8(18),
	11:  uint8(19),
	12:  uint8(20),
	13:  uint8(7),
	14:  uint8(22),
	15:  uint8(9),
	16:  uint8(24),
	17:  uint8(17),
	18:  uint8(18),
	19:  uint8(19),
	20:  uint8(20),
	21:  uint8(9),
	22:  uint8(22),
	23:  uint8(9),
	24:  uint8(24),
	25:  uint8(13),
	26:  uint8(17),
	27:  uint8(18),
	28:  uint8(19),
	29:  uint8(20),
	30:  uint8(26),
	31:  uint8(22),
	32:  uint8(24),
	33:  uint8(24),
	34:  uint8(17),
	35:  uint8(18),
	36:  uint8(19),
	37:  uint8(20),
	38:  uint8(15),
	39:  uint8(22),
	40:  uint8(9),
	41:  uint8(24),
	42:  uint8(17),
	43:  uint8(18),
	44:  uint8(19),
	45:  uint8(20),
	46:  uint8(26),
	47:  uint8(22),
	48:  uint8(21),
	49:  uint8(24),
	50:  uint8(6),
	51:  uint8(7),
	52:  uint8(9),
	53:  uint8(9),
	54:  uint8(10),
	55:  uint8(12),
	56:  uint8(12),
	57:  uint8(6),
	58:  uint8(7),
	59:  uint8(21),
	60:  uint8(9),
	61:  uint8(24),
	62:  uint8(25),
	63:  uint8(12),
	64:  uint8(18),
	65:  uint8(5),
	66:  uint8(20),
	67:  uint8(14),
	68:  uint8(22),
	69:  uint8(5),
	70:  uint8(24),
	71:  uint8(3),
	72:  uint8(1),
	73:  uint8(2),
	74:  uint8(3),
	75:  uint8(1),
	76:  uint8(2),
	77:  uint8(3),
	79:  uint8(1),
	80:  uint8(2),
	81:  uint8(3),
	82:  uint8(11),
	83:  uint8(2),
	84:  uint8(3),
	85:  uint8(11),
	86:  uint8(9),
	87:  uint8(10),
	88:  uint8(5),
	89:  uint8(12),
	90:  uint8(23),
	91:  uint8(24),
	92:  uint8(10),
	93:  uint8(10),
	94:  uint8(8),
	95:  uint8(9),
	96:  uint8(9),
	97:  uint8(15),
	98:  uint8(15),
	99:  uint8(8),
	100: uint8(9),
	101: uint8(9),
	102: uint8(27),
	103: uint8(27),
	104: uint8(11),
	105: uint8(27),
	106: uint8(27),
	107: uint8(27),
	108: uint8(27),
	109: uint8(27),
	110: uint8(27),
	111: uint8(27),
	112: uint8(27),
	113: uint8(27),
	114: uint8(27),
	115: uint8(27),
	116: uint8(27),
	117: uint8(27),
	118: uint8(27),
	119: uint8(27),
	120: uint8(27),
}

var _fts5yy_reduce_ofst = [18]int8{
	0:  int8(-int32(16)),
	1:  int8(-int32(8)),
	3:  int8(9),
	4:  int8(17),
	5:  int8(25),
	6:  int8(46),
	7:  int8(-int32(17)),
	8:  int8(-int32(17)),
	9:  int8(37),
	10: int8(67),
	11: int8(4),
	12: int8(4),
	13: int8(8),
	14: int8(4),
	15: int8(20),
	16: int8(27),
	17: int8(38),
}

var _fts5yy_shift_ofst = [35]uint8{
	0:  uint8(44),
	1:  uint8(44),
	2:  uint8(44),
	3:  uint8(44),
	4:  uint8(44),
	5:  uint8(44),
	6:  uint8(51),
	7:  uint8(77),
	8:  uint8(43),
	9:  uint8(12),
	10: uint8(14),
	11: uint8(83),
	12: uint8(82),
	13: uint8(14),
	14: uint8(23),
	15: uint8(23),
	16: uint8(31),
	17: uint8(31),
	18: uint8(71),
	19: uint8(74),
	20: uint8(78),
	21: uint8(81),
	22: uint8(86),
	23: uint8(91),
	24: uint8(6),
	25: uint8(53),
	26: uint8(53),
	27: uint8(60),
	28: uint8(64),
	29: uint8(68),
	30: uint8(53),
	31: uint8(87),
	32: uint8(92),
	33: uint8(53),
	34: uint8(93),
}

// C documentation
//
//	/*
//	** Implementation of the geopoly_area(X) function.
//	**
//	** If the input is a well-formed Geopoly BLOB then return the area
//	** enclosed by the polygon.  If the polygon circulates clockwise instead
//	** of counterclockwise (as it should) then return the negative of the
//	** enclosed area.  Otherwise return NULL.
//	*/
func _geopolyAreaFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
	var p uintptr
	_ = p
	p = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0))
	_ = argc
	if p != 0 {
		Xsqlite3_result_double(tls, context, _geopolyArea(tls, p))
		Xsqlite3_free(tls, p)
	}
}

func _geopolyBBoxFinal(tls *libc.TLS, context uintptr) {
	var p, pBBox uintptr
	_, _ = p, pBBox
	pBBox = Xsqlite3_aggregate_context(tls, context, 0)
	if pBBox == uintptr(0) {
		return
	}
	p = _geopolyBBox(tls, context, uintptr(0), pBBox+4, uintptr(0))
	if p != 0 {
		Xsqlite3_result_blob(tls, context, p+4, int32(4)+int32(8)*(*TGeoPoly)(unsafe.Pointer(p)).FnVertex, uintptr(-libc.Int32FromInt32(1)))
		Xsqlite3_free(tls, p)
	}
}

// C documentation
//
//	/*
//	** Implementation of the geopoly_bbox(X) SQL function.
//	*/
func _geopolyBBoxFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
	var p uintptr
	_ = p
	p = _geopolyBBox(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0), uintptr(0))
	_ = argc
	if p != 0 {
		Xsqlite3_result_blob(tls, context, p+4, int32(4)+int32(8)*(*TGeoPoly)(unsafe.Pointer(p)).FnVertex, uintptr(-libc.Int32FromInt32(1)))
		Xsqlite3_free(tls, p)
	}
}

// C documentation
//
//	/*
//	** Implementation of the geopoly_blob(X) function.
//	**
//	** If the input is a well-formed Geopoly BLOB or JSON string
//	** then return the BLOB representation of the polygon.  Otherwise
//	** return NULL.
//	*/
func _geopolyBlobFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
	var p uintptr
	_ = p
	p = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0))
	_ = argc
	if p != 0 {
		Xsqlite3_result_blob(tls, context, p+4, int32(4)+int32(8)*(*TGeoPoly)(unsafe.Pointer(p)).FnVertex, uintptr(-libc.Int32FromInt32(1)))
		Xsqlite3_free(tls, p)
	}
}

// C documentation
//
//	/*
//	** Implementation of the geopoly_ccw(X) function.
//	**
//	** If the rotation of polygon X is clockwise (incorrect) instead of
//	** counter-clockwise (the correct winding order according to RFC7946)
//	** then reverse the order of the vertexes in polygon X.
//	**
//	** In other words, this routine returns a CCW polygon regardless of the
//	** winding order of its input.
//	**
//	** Use this routine to sanitize historical inputs that that sometimes
//	** contain polygons that wind in the wrong direction.
//	*/
func _geopolyCcwFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
	var ii, jj int32
	var p uintptr
	var t TGeoCoord
	_, _, _, _ = ii, jj, p, t
	p = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0))
	_ = argc
	if p != 0 {
		if _geopolyArea(tls, p) < float64(0) {
			ii = int32(1)
			jj = (*TGeoPoly)(unsafe.Pointer(p)).FnVertex - libc.Int32FromInt32(1)
			for {
				if !(ii < jj) {
					break
				}
				t = **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2))*4))
				**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2))*4)) = **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(jj*int32(2))*4))
				**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(jj*int32(2))*4)) = t
				t = **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2)+int32(1))*4))
				**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(ii*int32(2)+int32(1))*4)) = **(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(jj*int32(2)+int32(1))*4))
				**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(jj*int32(2)+int32(1))*4)) = t
				goto _1
			_1:
				;
				ii = ii + 1
				jj = jj - 1
			}
		}
		Xsqlite3_result_blob(tls, context, p+4, int32(4)+int32(8)*(*TGeoPoly)(unsafe.Pointer(p)).FnVertex, uintptr(-libc.Int32FromInt32(1)))
		Xsqlite3_free(tls, p)
	}
}

// C documentation
//
//	/*
//	** GEOPOLY virtual table module xConnect method.
//	*/
func _geopolyConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) {
	return _geopolyInit(tls, db, pAux, argc, argv, ppVtab, pzErr, 0)
}

// C documentation
//
//	/*
//	** GEOPOLY virtual table module xCreate method.
//	*/
func _geopolyCreate(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) {
	return _geopolyInit(tls, db, pAux, argc, argv, ppVtab, pzErr, int32(1))
}

// C documentation
//
//	/*
//	** Enable or disable debugging output
//	*/
func _geopolyDebugFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
	_ = context
	_ = argc
	_ = argv
}

// C documentation
//
//	/*
//	** Merge two lists of sorted events by X coordinate
//	*/
func _geopolyEventMerge(tls *libc.TLS, pLeft uintptr, pRight uintptr) (r uintptr) {
	bp := tls.Alloc(32)
	defer tls.Free(32)
	var pLast, v1 uintptr
	var _ /* head at bp+0 */ TGeoEvent
	_, _ = pLast, v1
	(**(**TGeoEvent)(__ccgo_up(bp))).FpNext = uintptr(0)
	pLast = bp
	for pRight != 0 && pLeft != 0 {
		if (*TGeoEvent)(unsafe.Pointer(pRight)).Fx <= (*TGeoEvent)(unsafe.Pointer(pLeft)).Fx {
			(*TGeoEvent)(unsafe.Pointer(pLast)).FpNext = pRight
			pLast = pRight
			pRight = (*TGeoEvent)(unsafe.Pointer(pRight)).FpNext
		} else {
			(*TGeoEvent)(unsafe.Pointer(pLast)).FpNext = pLeft
			pLast = pLeft
			pLeft = (*TGeoEvent)(unsafe.Pointer(pLeft)).FpNext
		}
	}
	if pRight != 0 {
		v1 = pRight
	} else {
		v1 = pLeft
	}
	(*TGeoEvent)(unsafe.Pointer(pLast)).FpNext = v1
	return (**(**TGeoEvent)(__ccgo_up(bp))).FpNext
}

var _geopolyModule = Tsqlite3_module{
	FiVersion: int32(3),
}

// C documentation
//
//	/*
//	** Merge two lists of sorted segments by Y, and then by C.
//	*/
func _geopolySegmentMerge(tls *libc.TLS, pLeft uintptr, pRight uintptr) (r1 uintptr) {
	bp := tls.Alloc(48)
	defer tls.Free(48)
	var pLast, v1 uintptr
	var r float64
	var _ /* head at bp+0 */ TGeoSegment
	_, _, _ = pLast, r, v1
	(**(**TGeoSegment)(__ccgo_up(bp))).FpNext = uintptr(0)
	pLast = bp
	for pRight != 0 && pLeft != 0 {
		r = (*TGeoSegment)(unsafe.Pointer(pRight)).Fy - (*TGeoSegment)(unsafe.Pointer(pLeft)).Fy
		if r == float64(0) {
			r = (*TGeoSegment)(unsafe.Pointer(pRight)).FC - (*TGeoSegment)(unsafe.Pointer(pLeft)).FC
		}
		if r < float64(0) {
			(*TGeoSegment)(unsafe.Pointer(pLast)).FpNext = pRight
			pLast = pRight
			pRight = (*TGeoSegment)(unsafe.Pointer(pRight)).FpNext
		} else {
			(*TGeoSegment)(unsafe.Pointer(pLast)).FpNext = pLeft
			pLast = pLeft
			pLeft = (*TGeoSegment)(unsafe.Pointer(pLeft)).FpNext
		}
	}
	if pRight != 0 {
		v1 = pRight
	} else {
		v1 = pLeft
	}
	(*TGeoSegment)(unsafe.Pointer(pLast)).FpNext = v1
	return (**(**TGeoSegment)(__ccgo_up(bp))).FpNext
}

// C documentation
//
//	/*
//	** Sort a list of GeoSegments in order of increasing Y and in the event of
//	** a tie, increasing C (slope).
//	*/
func _geopolySortSegmentsByYAndC(tls *libc.TLS, pList uintptr) (r uintptr) {
	var a [50]uintptr
	var i, mx int32
	var p uintptr
	_, _, _, _ = a, i, mx, p
	mx = 0
	for pList != 0 {
		p = pList
		pList = (*TGeoSegment)(unsafe.Pointer(pList)).FpNext
		(*TGeoSegment)(unsafe.Pointer(p)).FpNext = uintptr(0)
		i = 0
		for {
			if !(i < mx && a[i] != 0) {
				break
			}
			p = _geopolySegmentMerge(tls, a[i], p)
			a[i] = uintptr(0)
			goto _1
		_1:
			;
			i = i + 1
		}
		a[i] = p
		if i >= mx {
			mx = i + int32(1)
		}
	}
	p = uintptr(0)
	i = 0
	for {
		if !(i < mx) {
			break
		}
		p = _geopolySegmentMerge(tls, a[i], p)
		goto _2
	_2:
		;
		i = i + 1
	}
	return p
}

// C documentation
//
//	/* Do a 4-byte byte swap */
func _geopolySwab32(tls *libc.TLS, a uintptr) {
	var t uint8
	_ = t
	t = **(**uint8)(__ccgo_up(a))
	**(**uint8)(__ccgo_up(a)) = **(**uint8)(__ccgo_up(a + 3))
	**(**uint8)(__ccgo_up(a + 3)) = t
	t = **(**uint8)(__ccgo_up(a + 1))
	**(**uint8)(__ccgo_up(a + 1)) = **(**uint8)(__ccgo_up(a + 2))
	**(**uint8)(__ccgo_up(a + 2)) = t
}

var _getCacheSize = [9]TVdbeOpList{
	0: {
		Fopcode: uint8(OP_Transaction),
	},
	1: {
		Fopcode: uint8(OP_ReadCookie),
		Fp2:     int8(1),
		Fp3:     int8(BTREE_DEFAULT_CACHE_SIZE),
	},
	2: {
		Fopcode: uint8(OP_IfPos),
		Fp1:     int8(1),
		Fp2:     int8(8),
	},
	3: {
		Fopcode: uint8(OP_Integer),
		Fp2:     int8(2),
	},
	4: {
		Fopcode: uint8(OP_Subtract),
		Fp1:     int8(1),
		Fp2:     int8(2),
		Fp3:     int8(1),
	},
	5: {
		Fopcode: uint8(OP_IfPos),
		Fp1:     int8(1),
		Fp2:     int8(8),
	},
	6: {
		Fopcode: uint8(OP_Integer),
		Fp2:     int8(1),
	},
	7: {
		Fopcode: uint8(OP_Noop),
	},
	8: {
		Fopcode: uint8(OP_ResultRow),
		Fp1:     int8(1),
		Fp2:     int8(1),
	},
}

// C documentation
//
//	/*
//	** Argument z points into the body of a constraint - specifically the
//	** second token of the constraint definition.  For a named constraint,
//	** z points to the first token past the CONSTRAINT keyword.  For an
//	** unnamed NOT NULL constraint, z points to the first byte past the NOT
//	** keyword.
//	**
//	** Return the number of bytes until the end of the constraint.
//	*/
func _getConstraint(tls *libc.TLS, z uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var iOff, n int32
	var _ /* t at bp+0 */ int32
	_, _ = iOff, n
	iOff = 0
	**(**int32)(__ccgo_up(bp)) = 0
	/* Now, the current constraint proceeds until the next occurence of one
	 ** of the following tokens:
	 **
	 **   CONSTRAINT, PRIMARY, NOT, UNIQUE, CHECK, DEFAULT,
	 **   COLLATE, REFERENCES, FOREIGN, GENERATED, AS, RP, or COMMA
	 **
	 ** Also exit the loop if ILLEGAL turns up.
	 */
	for int32(1) != 0 {
		n = _getConstraintToken(tls, z+uintptr(iOff), bp)
		if **(**int32)(__ccgo_up(bp)) == int32(TK_CONSTRAINT) || **(**int32)(__ccgo_up(bp)) == int32(TK_PRIMARY) || **(**int32)(__ccgo_up(bp)) == int32(TK_NOT) || **(**int32)(__ccgo_up(bp)) == int32(TK_UNIQUE) || **(**int32)(__ccgo_up(bp)) == int32(TK_CHECK) || **(**int32)(__ccgo_up(bp)) == int32(TK_DEFAULT) || **(**int32)(__ccgo_up(bp)) == int32(TK_COLLATE) || **(**int32)(__ccgo_up(bp)) == int32(TK_REFERENCES) || **(**int32)(__ccgo_up(bp)) == int32(TK_FOREIGN) || **(**int32)(__ccgo_up(bp)) == int32(TK_RP) || **(**int32)(__ccgo_up(bp)) == int32(TK_COMMA) || **(**int32)(__ccgo_up(bp)) == int32(TK_ILLEGAL) || **(**int32)(__ccgo_up(bp)) == int32(TK_AS) || **(**int32)(__ccgo_up(bp)) == int32(TK_GENERATED) {
			break
		}
		iOff = iOff + n
	}
	return iOff
}

// C documentation
//
//	/*
//	** Return the number of bytes until the end of the next non-whitespace and
//	** non-comment token.  For the purpose of this function, a "(" token includes
//	** all of the bytes through and including the matching ")", or until the
//	** first illegal token, whichever comes first.
//	**
//	** Write the token type into *piToken.
//	**
//	** The value returned is the number of bytes in the token itself plus
//	** the number of bytes of leading whitespace and comments skipped plus
//	** all bytes through the next matching ")" if the token is TK_LP.
//	**
//	** Example:    (Note: '.' used in place of '*' in the example z[] text)
//	**
//	**                                    ,--------- *piToken := TK_RP
//	**                                    v
//	**    z[] = " /.comment./ --comment\n (two three four) five"
//	**          |                                        |
//	**          |<-------------------------------------->|
//	**                              |
//	**                              `--- return value
//	*/
func _getConstraintToken(tls *libc.TLS, z uintptr, piToken uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var iOff, nNest int32
	var _ /* t at bp+0 */ int32
	_, _ = iOff, nNest
	iOff = 0
	**(**int32)(__ccgo_up(bp)) = 0
	for cond := true; cond; cond = **(**int32)(__ccgo_up(bp)) == int32(TK_SPACE) || **(**int32)(__ccgo_up(bp)) == int32(TK_COMMENT) {
		iOff = int32(int64(iOff) + _sqlite3GetToken(tls, z+uintptr(iOff), bp))
	}
	**(**int32)(__ccgo_up(piToken)) = **(**int32)(__ccgo_up(bp))
	if **(**int32)(__ccgo_up(bp)) == int32(TK_LP) {
		nNest = int32(1)
		for nNest > 0 {
			iOff = int32(int64(iOff) + _sqlite3GetToken(tls, z+uintptr(iOff), bp))
			if **(**int32)(__ccgo_up(bp)) == int32(TK_LP) {
				nNest = nNest + 1
			} else {
				if **(**int32)(__ccgo_up(bp)) == int32(TK_RP) {
					**(**int32)(__ccgo_up(bp)) = int32(TK_LP)
					nNest = nNest - 1
				} else {
					if **(**int32)(__ccgo_up(bp)) == int32(TK_ILLEGAL) {
						break
					}
				}
			}
		}
	}
	**(**int32)(__ccgo_up(piToken)) = **(**int32)(__ccgo_up(bp))
	return iOff
}

// C documentation
//
//	/*
//	** The second argument to this function contains the text of an SQL statement
//	** that returns a single integer value. The statement is compiled and executed
//	** using database connection db. If successful, the integer value returned
//	** is written to *piVal and SQLITE_OK returned. Otherwise, an SQLite error
//	** code is returned and the value of *piVal after returning is not defined.
//	*/
func _getIntFromStmt(tls *libc.TLS, db uintptr, zSql uintptr, piVal uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* pStmt at bp+0 */ uintptr
	_ = rc
	rc = int32(SQLITE_NOMEM)
	if zSql != 0 {
		**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
		rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp, uintptr(0))
		if rc == SQLITE_OK {
			if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) {
				**(**int32)(__ccgo_up(piVal)) = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), 0)
			}
			rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp)))
		}
	}
	return rc
}

// C documentation
//
//	/* The page getter method for when the pager is an error state */
func _getPageError(tls *libc.TLS, pPager uintptr, pgno TPgno, ppPage uintptr, flags int32) (r int32) {
	_ = pgno
	_ = flags
	**(**uintptr)(__ccgo_up(ppPage)) = uintptr(0)
	return (*TPager)(unsafe.Pointer(pPager)).FerrCode
}

// C documentation
//
//	/*
//	** Return a pointer to a TriggerPrg object containing the sub-program for
//	** trigger pTrigger with default ON CONFLICT algorithm orconf. If no such
//	** TriggerPrg object exists, a new object is allocated and populated before
//	** being returned.
//	*/
func _getRowTrigger(tls *libc.TLS, pParse uintptr, pTrigger uintptr, pTab uintptr, orconf int32) (r uintptr) {
	var pPrg, pRoot, v1 uintptr
	_, _, _ = pPrg, pRoot, v1
	if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 {
		v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel
	} else {
		v1 = pParse
	}
	pRoot = v1
	/* It may be that this trigger has already been coded (or is in the
	 ** process of being coded). If this is the case, then an entry with
	 ** a matching TriggerPrg.pTrigger field will be present somewhere
	 ** in the Parse.pTriggerPrg list. Search for such an entry.  */
	pPrg = (*TParse)(unsafe.Pointer(pRoot)).FpTriggerPrg
	for {
		if !(pPrg != 0 && ((*TTriggerPrg)(unsafe.Pointer(pPrg)).FpTrigger != pTrigger || (*TTriggerPrg)(unsafe.Pointer(pPrg)).Forconf != orconf)) {
			break
		}
		goto _2
	_2:
		;
		pPrg = (*TTriggerPrg)(unsafe.Pointer(pPrg)).FpNext
	}
	/* If an existing TriggerPrg could not be located, create a new one. */
	if !(pPrg != 0) {
		pPrg = _codeRowTrigger(tls, pParse, pTrigger, pTab, orconf)
		(*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FerrByteOffset = -int32(1)
	}
	return pPrg
}

// C documentation
//
//	/*
//	** Return the id of the next token in string (*pz). Before returning, set
//	** (*pz) to point to the byte following the parsed token.
//	*/
func _getToken(tls *libc.TLS, pz uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var z uintptr
	var _ /* t at bp+0 */ int32
	_ = z
	z = **(**uintptr)(__ccgo_up(pz)) /* Token type to return */
	for cond := true; cond; cond = **(**int32)(__ccgo_up(bp)) == int32(TK_SPACE) || **(**int32)(__ccgo_up(bp)) == int32(TK_COMMENT) {
		z = z + uintptr(_sqlite3GetToken(tls, z, bp))
	}
	if **(**int32)(__ccgo_up(bp)) == int32(TK_ID) || **(**int32)(__ccgo_up(bp)) == int32(TK_STRING) || **(**int32)(__ccgo_up(bp)) == int32(TK_JOIN_KW) || **(**int32)(__ccgo_up(bp)) == int32(TK_WINDOW) || **(**int32)(__ccgo_up(bp)) == int32(TK_OVER) || _sqlite3ParserFallback(tls, **(**int32)(__ccgo_up(bp))) == int32(TK_ID) {
		**(**int32)(__ccgo_up(bp)) = int32(TK_ID)
	}
	**(**uintptr)(__ccgo_up(pz)) = z
	return **(**int32)(__ccgo_up(bp))
}

// C documentation
//
//	/*
//	** Return the number of bytes of leading whitespace/comments in string z[].
//	*/
func _getWhitespace(tls *libc.TLS, z uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var n, nRet int32
	var _ /* t at bp+0 */ int32
	_, _ = n, nRet
	nRet = 0
	for int32(1) != 0 {
		**(**int32)(__ccgo_up(bp)) = 0
		n = int32(_sqlite3GetToken(tls, z+uintptr(nRet), bp))
		if **(**int32)(__ccgo_up(bp)) != int32(TK_SPACE) && **(**int32)(__ccgo_up(bp)) != int32(TK_COMMENT) {
			break
		}
		nRet = nRet + n
	}
	return nRet
}

var _globInfo = TcompareInfo{
	FmatchAll: uint8('*'),
	FmatchOne: uint8('?'),
	FmatchSet: uint8('['),
}

func _groupConcatFinalize(tls *libc.TLS, context uintptr) {
	var pGCC uintptr
	_ = pGCC
	pGCC = Xsqlite3_aggregate_context(tls, context, 0)
	if pGCC != 0 {
		_sqlite3ResultStrAccum(tls, context, pGCC)
		Xsqlite3_free(tls, (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FpnSepLengths)
	}
}

// C documentation
//
//	/*
//	** Slow paths for sqlite3VdbeAddOp3() and sqlite3VdbeAddOp4Int() for the
//	** unusual case when we need to increase the size of the Vdbe.aOp[] array
//	** before adding the new opcode.
//	*/
func _growOp3(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32, p3 int32) (r int32) {
	if _growOpArray(tls, p, int32(1)) != 0 {
		return int32(1)
	}
	return _sqlite3VdbeAddOp3(tls, p, op, p1, p2, p3)
}

// C documentation
//
//	/*
//	** Return true if the SELECT statement which is known to be the recursive
//	** part of a recursive CTE still has its anchor terms attached.  If the
//	** anchor terms have already been removed, then return false.
//	*/
func _hasAnchor(tls *libc.TLS, p uintptr) (r int32) {
	for p != 0 && (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Recursive) != uint32(0) {
		p = (*TSelect)(unsafe.Pointer(p)).FpPrior
	}
	return libc.BoolInt32(p != uintptr(0))
}

// C documentation
//
//	/* Return true if column number x is any of the first nCol entries of aiCol[].
//	** This is used to determine if the column number x appears in any of the
//	** first nCol entries of an index.
//	*/
func _hasColumn(tls *libc.TLS, aiCol uintptr, nCol int32, x int32) (r int32) {
	var v1 int32
	var v2 uintptr
	_, _ = v1, v2
	for {
		v1 = nCol
		nCol = nCol - 1
		if !(v1 > 0) {
			break
		}
		v2 = aiCol
		aiCol += 2
		if x == int32(**(**Ti16)(__ccgo_up(v2))) {
			return int32(1)
		}
	}
	return 0
}

// C documentation
//
//	/* The following three functions, heightOfExpr(), heightOfExprList()
//	** and heightOfSelect(), are used to determine the maximum height
//	** of any expression tree referenced by the structure passed as the
//	** first argument.
//	**
//	** If this maximum height is greater than the current value pointed
//	** to by pnHeight, the second parameter, then set *pnHeight to that
//	** value.
//	*/
func _heightOfExpr(tls *libc.TLS, p uintptr, pnHeight uintptr) {
	if p != 0 {
		if (*TExpr)(unsafe.Pointer(p)).FnHeight > **(**int32)(__ccgo_up(pnHeight)) {
			**(**int32)(__ccgo_up(pnHeight)) = (*TExpr)(unsafe.Pointer(p)).FnHeight
		}
	}
}

func _heightOfSelect(tls *libc.TLS, pSelect uintptr, pnHeight uintptr) {
	var p uintptr
	_ = p
	p = pSelect
	for {
		if !(p != 0) {
			break
		}
		_heightOfExpr(tls, (*TSelect)(unsafe.Pointer(p)).FpWhere, pnHeight)
		_heightOfExpr(tls, (*TSelect)(unsafe.Pointer(p)).FpHaving, pnHeight)
		_heightOfExpr(tls, (*TSelect)(unsafe.Pointer(p)).FpLimit, pnHeight)
		_heightOfExprList(tls, (*TSelect)(unsafe.Pointer(p)).FpEList, pnHeight)
		_heightOfExprList(tls, (*TSelect)(unsafe.Pointer(p)).FpGroupBy, pnHeight)
		_heightOfExprList(tls, (*TSelect)(unsafe.Pointer(p)).FpOrderBy, pnHeight)
		goto _1
	_1:
		;
		p = (*TSelect)(unsafe.Pointer(p)).FpPrior
	}
}

type _ht = T_ht

var _iCode = [128]uint8{
	66:  uint8(1),
	67:  uint8(2),
	68:  uint8(3),
	70:  uint8(1),
	71:  uint8(2),
	74:  uint8(2),
	75:  uint8(2),
	76:  uint8(4),
	77:  uint8(5),
	78:  uint8(5),
	80:  uint8(1),
	81:  uint8(2),
	82:  uint8(6),
	83:  uint8(2),
	84:  uint8(3),
	86:  uint8(1),
	88:  uint8(2),
	90:  uint8(2),
	98:  uint8(1),
	99:  uint8(2),
	100: uint8(3),
	102: uint8(1),
	103: uint8(2),
	106: uint8(2),
	107: uint8(2),
	108: uint8(4),
	109: uint8(5),
	110: uint8(5),
	112: uint8(1),
	113: uint8(2),
	114: uint8(6),
	115: uint8(2),
	116: uint8(3),
	118: uint8(1),
	120: uint8(2),
	122: uint8(2),
}

var _iExplainColNames16 = [12]Tu8{
	1:  uint8(5),
	2:  uint8(12),
	3:  uint8(15),
	4:  uint8(18),
	5:  uint8(21),
	6:  uint8(24),
	7:  uint8(27),
	8:  uint8(35),
	9:  uint8(38),
	10: uint8(45),
	11: uint8(53),
}

var _iLength = [8]Tu8{
	0: uint8(2),
	1: uint8(2),
	2: uint8(3),
	3: uint8(5),
	4: uint8(3),
	5: uint8(4),
	6: uint8(5),
	7: uint8(4),
}

/* This VDBE program seeks a btree cursor to the identified
 ** db/table/row entry. The reason for using a vdbe program instead
 ** of writing code to use the b-tree layer directly is that the
 ** vdbe program will take advantage of the various transaction,
 ** locking and error handling infrastructure built into the vdbe.
 **
 ** After seeking the cursor, the vdbe executes an OP_ResultRow.
 ** Code external to the Vdbe then "borrows" the b-tree cursor and
 ** uses it to implement the blob_read(), blob_write() and
 ** blob_bytes() functions.
 **
 ** The sqlite3_blob_close() function finalizes the vdbe program,
 ** which closes the b-tree cursor and (possibly) commits the
 ** transaction.
 */
var _iLn int32

var _iLn1 int32

/* When setting the auto_vacuum mode to either "full" or
 ** "incremental", write the value of meta[6] in the database
 ** file. Before writing to meta[6], check that meta[3] indicates
 ** that this really is an auto-vacuum capable database.
 */
var _iLn11 int32

var _iLn2 int32

var _iLn21 int32

var _iLn3 int32

var _iOffset = [8]Tu8{
	1: uint8(1),
	2: uint8(2),
	3: uint8(4),
	4: uint8(9),
	5: uint8(12),
	6: uint8(15),
	7: uint8(20),
}

var _iValue = [8]Tu8{
	0: uint8(1),
	4: uint8(1),
	5: uint8(1),
	6: uint8(3),
	7: uint8(2),
}

// C documentation
//
//	/* Return the first index on the list */
func _indexIteratorFirst(tls *libc.TLS, pIter uintptr, pIx uintptr) (r uintptr) {
	if (*TIndexIterator)(unsafe.Pointer(pIter)).FeType != 0 {
		**(**int32)(__ccgo_up(pIx)) = (**(**TIndexListTerm)(__ccgo_up((*(*struct {
			FnIdx int32
			FaIdx uintptr
		})(unsafe.Pointer(pIter + 8))).FaIdx))).Fix
		return (**(**TIndexListTerm)(__ccgo_up((*(*struct {
			FnIdx int32
			FaIdx uintptr
		})(unsafe.Pointer(pIter + 8))).FaIdx))).Fp
	} else {
		**(**int32)(__ccgo_up(pIx)) = 0
		return (*TIndexIterator)(unsafe.Pointer(pIter)).Fu.Flx.FpIdx
	}
	return r
}

// C documentation
//
//	/*
//	** Check to see if index pIdx is a partial index whose conditional
//	** expression might change values due to an UPDATE.  Return true if
//	** the index is subject to change and false if the index is guaranteed
//	** to be unchanged.  This is an optimization.  False-positives are a
//	** performance degradation, but false-negatives can result in a corrupt
//	** index and incorrect answers.
//	**
//	** aXRef[j] will be non-negative if column j of the original table is
//	** being updated.  chngRowid will be true if the rowid of the table is
//	** being updated.
//	*/
func _indexWhereClauseMightChange(tls *libc.TLS, pIdx uintptr, aXRef uintptr, chngRowid int32) (r int32) {
	if (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere == uintptr(0) {
		return 0
	}
	return _sqlite3ExprReferencesUpdatedColumn(tls, (*TIndex)(unsafe.Pointer(pIdx)).FpPartIdxWhere, aXRef, chngRowid)
}

// C documentation
//
//	/*
//	** This routine does the work of loading query data into an array of
//	** registers so that it can be added to the sorter.
//	*/
func _innerLoopLoadRow(tls *libc.TLS, pParse uintptr, pSelect uintptr, pInfo uintptr) {
	_sqlite3ExprCodeExprList(tls, pParse, (*TSelect)(unsafe.Pointer(pSelect)).FpEList, (*TRowLoadInfo)(unsafe.Pointer(pInfo)).FregResult, 0, (*TRowLoadInfo)(unsafe.Pointer(pInfo)).FecelFlags)
}

// C documentation
//
//	/* Link pNew element into the hash table pH.  If pEntry!=0 then also
//	** insert pNew into the pEntry hash bucket.
//	*/
func _insertElement(tls *libc.TLS, pH uintptr, pEntry uintptr, pNew uintptr) {
	var pHead, v1 uintptr
	_, _ = pHead, v1 /* First element already in pEntry */
	if pEntry != 0 {
		if (*T_ht)(unsafe.Pointer(pEntry)).Fcount != 0 {
			v1 = (*T_ht)(unsafe.Pointer(pEntry)).Fchain
		} else {
			v1 = uintptr(0)
		}
		pHead = v1
		(*T_ht)(unsafe.Pointer(pEntry)).Fcount = (*T_ht)(unsafe.Pointer(pEntry)).Fcount + 1
		(*T_ht)(unsafe.Pointer(pEntry)).Fchain = pNew
	} else {
		pHead = uintptr(0)
	}
	if pHead != 0 {
		(*THashElem)(unsafe.Pointer(pNew)).Fnext = pHead
		(*THashElem)(unsafe.Pointer(pNew)).Fprev = (*THashElem)(unsafe.Pointer(pHead)).Fprev
		if (*THashElem)(unsafe.Pointer(pHead)).Fprev != 0 {
			(*THashElem)(unsafe.Pointer((*THashElem)(unsafe.Pointer(pHead)).Fprev)).Fnext = pNew
		} else {
			(*THash)(unsafe.Pointer(pH)).Ffirst = pNew
		}
		(*THashElem)(unsafe.Pointer(pHead)).Fprev = pNew
	} else {
		(*THashElem)(unsafe.Pointer(pNew)).Fnext = (*THash)(unsafe.Pointer(pH)).Ffirst
		if (*THash)(unsafe.Pointer(pH)).Ffirst != 0 {
			(*THashElem)(unsafe.Pointer((*THash)(unsafe.Pointer(pH)).Ffirst)).Fprev = pNew
		}
		(*THashElem)(unsafe.Pointer(pNew)).Fprev = uintptr(0)
		(*THash)(unsafe.Pointer(pH)).Ffirst = pNew
	}
}

// C documentation
//
//	/*
//	** Helper subroutine for PRAGMA integrity_check:
//	**
//	** Generate code to output a single-column result row with a value of the
//	** string held in register 3.  Decrement the result count in register 1
//	** and halt if the maximum number of result rows have been issued.
//	*/
func _integrityCheckResultRow(tls *libc.TLS, v uintptr) (r int32) {
	var addr int32
	_ = addr
	_sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(3), int32(1))
	addr = _sqlite3VdbeAddOp3(tls, v, int32(OP_IfPos), int32(1), _sqlite3VdbeCurrentAddr(tls, v)+int32(2), int32(1))
	_sqlite3VdbeAddOp0(tls, v, int32(OP_Halt))
	return addr
}

// C documentation
//
//	/*
//	** Invalidate the overflow page-list cache for all cursors opened
//	** on the shared btree structure pBt.
//	*/
func _invalidateAllOverflowCache(tls *libc.TLS, pBt uintptr) {
	var p, v2 uintptr
	_, _ = p, v2
	p = (*TBtShared)(unsafe.Pointer(pBt)).FpCursor
	for {
		if !(p != 0) {
			break
		}
		v2 = p + 1
		*(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) & ^libc.Int32FromInt32(BTCF_ValidOvfl))
		goto _1
	_1:
		;
		p = (*TBtCursor)(unsafe.Pointer(p)).FpNext
	}
}

func _invokeValueDestructor(tls *libc.TLS, p uintptr, __ccgo_fp_xDel uintptr, pCtx uintptr) (r int32) {
	if __ccgo_fp_xDel == uintptr(0) {
		/* noop */
	} else {
		if __ccgo_fp_xDel == uintptr(-libc.Int32FromInt32(1)) {
			/* noop */
		} else {
			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xDel})))(tls, p)
		}
	}
	Xsqlite3_result_error_toobig(tls, pCtx)
	return int32(SQLITE_TOOBIG)
}

// C documentation
//
//	/*
//	** Argument rc is an SQLite error code. Return true if this error is
//	** considered fatal if encountered during a backup operation. All errors
//	** are considered fatal except for SQLITE_BUSY and SQLITE_LOCKED.
//	*/
func _isFatalError(tls *libc.TLS, rc int32) (r int32) {
	return libc.BoolInt32(rc != SQLITE_OK && rc != int32(SQLITE_BUSY) && rc != int32(SQLITE_LOCKED))
}

// C documentation
//
//	/*
//	** This function determines whether or not the atomic-write or
//	** atomic-batch-write optimizations can be used with this pager. The
//	** atomic-write optimization can be used if:
//	**
//	**  (a) the value returned by OsDeviceCharacteristics() indicates that
//	**      a database page may be written atomically, and
//	**  (b) the value returned by OsSectorSize() is less than or equal
//	**      to the page size.
//	**
//	** If it can be used, then the value returned is the size of the journal
//	** file when it contains rollback data for exactly one page.
//	**
//	** The atomic-batch-write optimization can be used if OsDeviceCharacteristics()
//	** returns a value with the SQLITE_IOCAP_BATCH_ATOMIC bit set. -1 is
//	** returned in this case.
//	**
//	** If neither optimization can be used, 0 is returned.
//	*/
func _jrnlBufferSize(tls *libc.TLS, pPager uintptr) (r int32) {
	_ = pPager
	return 0
}

/*
** If SQLITE_CHECK_PAGES is defined then we do some sanity checking
** on the cache using a hash function.  This is used for testing
** and debugging only.
 */

func _jsonArrayFinal(tls *libc.TLS, ctx uintptr) {
	_jsonArrayCompute(tls, ctx, int32(1))
}

func _jsonArrayValue(tls *libc.TLS, ctx uintptr) {
	_jsonArrayCompute(tls, ctx, 0)
}

// C documentation
//
//	/*
//	** Expand pParse->aBlob so that it holds at least N bytes.
//	**
//	** Return the number of errors.
//	*/
func _jsonBlobExpand(tls *libc.TLS, pParse uintptr, N Tu32) (r int32) {
	var aNew uintptr
	var t Tu64
	_, _ = aNew, t
	if (*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc == uint32(0) {
		t = uint64(100)
	} else {
		t = uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc * uint32(2))
	}
	if t < uint64(N) {
		t = uint64(N + uint32(100))
	}
	aNew = _sqlite3DbRealloc(tls, (*TJsonParse)(unsafe.Pointer(pParse)).Fdb, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob, t)
	if aNew == uintptr(0) {
		(*TJsonParse)(unsafe.Pointer(pParse)).Foom = uint8(1)
		return int32(1)
	}
	(*TJsonParse)(unsafe.Pointer(pParse)).FaBlob = aNew
	(*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc = uint32(t)
	return 0
}

func _jsonBlobExpandAndAppendNode(tls *libc.TLS, pParse uintptr, eType Tu8, szPayload Tu64, aPayload uintptr) {
	if _jsonBlobExpand(tls, pParse, uint32(uint64((*TJsonParse)(unsafe.Pointer(pParse)).FnBlob)+szPayload+uint64(9))) != 0 {
		return
	}
	_jsonBlobAppendNode(tls, pParse, eType, szPayload, aPayload)
}

func _jsonCacheDeleteGeneric(tls *libc.TLS, p uintptr) {
	_jsonCacheDelete(tls, p)
}

// C documentation
//
//	/* Destructor for a jsonEachCursor object */
func _jsonEachClose(tls *libc.TLS, cur uintptr) (r int32) {
	var p uintptr
	_ = p
	p = cur
	_jsonEachCursorReset(tls, p)
	_sqlite3DbFree(tls, (*TJsonEachCursor)(unsafe.Pointer(p)).Fdb, cur)
	return SQLITE_OK
}

// C documentation
//
//	/* destructor for json_each virtual table */
func _jsonEachDisconnect(tls *libc.TLS, pVtab uintptr) (r int32) {
	var p uintptr
	_ = p
	p = pVtab
	_sqlite3DbFree(tls, (*TJsonEachConnection)(unsafe.Pointer(p)).Fdb, pVtab)
	return SQLITE_OK
}

// C documentation
//
//	/* Return TRUE if the jsonEachCursor object has been advanced off the end
//	** of the JSON object */
func _jsonEachEof(tls *libc.TLS, cur uintptr) (r int32) {
	var p uintptr
	_ = p
	p = cur
	return libc.BoolInt32((*TJsonEachCursor)(unsafe.Pointer(p)).Fi >= (*TJsonEachCursor)(unsafe.Pointer(p)).FiEnd)
}

// C documentation
//
//	/* The methods of the json_each virtual table */
var _jsonEachModule = Tsqlite3_module{}

// C documentation
//
//	/*
//	** Return true if z[] begins with 4 (or more) hexadecimal digits
//	*/
func _jsonIs4Hex(tls *libc.TLS, z uintptr) (r int32) {
	return libc.BoolInt32(_jsonIs2Hex(tls, z) != 0 && _jsonIs2Hex(tls, z+2) != 0)
}

func _jsonObjectFinal(tls *libc.TLS, ctx uintptr) {
	_jsonObjectCompute(tls, ctx, int32(1))
}

func _jsonObjectValue(tls *libc.TLS, ctx uintptr) {
	_jsonObjectCompute(tls, ctx, 0)
}

// C documentation
//
//	/*
//	** Decrement the reference count on the JsonParse object.  When the
//	** count reaches zero, free the object.
//	*/
func _jsonParseFree(tls *libc.TLS, pParse uintptr) {
	if pParse != 0 {
		if (*TJsonParse)(unsafe.Pointer(pParse)).FnJPRef > uint32(1) {
			(*TJsonParse)(unsafe.Pointer(pParse)).FnJPRef = (*TJsonParse)(unsafe.Pointer(pParse)).FnJPRef - 1
		} else {
			_jsonParseReset(tls, pParse)
			_sqlite3DbFree(tls, (*TJsonParse)(unsafe.Pointer(pParse)).Fdb, pParse)
		}
	}
}

/**************************************************************************
** Utility routines for the JSON text parser
**************************************************************************/

// C documentation
//
//	/*
//	** Reclaim all memory allocated by a JsonParse object.  But do not
//	** delete the JsonParse object itself.
//	*/
func _jsonParseReset(tls *libc.TLS, pParse uintptr) {
	if (*TJsonParse)(unsafe.Pointer(pParse)).FbJsonIsRCStr != 0 {
		_sqlite3RCStrUnref(tls, (*TJsonParse)(unsafe.Pointer(pParse)).FzJson)
		(*TJsonParse)(unsafe.Pointer(pParse)).FzJson = uintptr(0)
		(*TJsonParse)(unsafe.Pointer(pParse)).FnJson = 0
		(*TJsonParse)(unsafe.Pointer(pParse)).FbJsonIsRCStr = uint8(0)
	}
	if (*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc != 0 {
		_sqlite3DbFree(tls, (*TJsonParse)(unsafe.Pointer(pParse)).Fdb, (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob)
		(*TJsonParse)(unsafe.Pointer(pParse)).FaBlob = uintptr(0)
		(*TJsonParse)(unsafe.Pointer(pParse)).FnBlob = uint32(0)
		(*TJsonParse)(unsafe.Pointer(pParse)).FnBlobAlloc = uint32(0)
	}
}

// C documentation
//
//	/* Append indentation to the pretty JSON under construction */
func _jsonPrettyIndent(tls *libc.TLS, pPretty uintptr) {
	var jj Tu32
	_ = jj
	jj = uint32(0)
	for {
		if !(jj < (*TJsonPretty)(unsafe.Pointer(pPretty)).FnIndent) {
			break
		}
		_jsonAppendRaw(tls, (*TJsonPretty)(unsafe.Pointer(pPretty)).FpOut, (*TJsonPretty)(unsafe.Pointer(pPretty)).FzIndent, (*TJsonPretty)(unsafe.Pointer(pPretty)).FszIndent)
		goto _1
	_1:
		;
		jj = jj + 1
	}
}

// C documentation
//
//	/* Initialize the JsonString object
//	*/
func _jsonStringInit(tls *libc.TLS, p uintptr, pCtx uintptr) {
	(*TJsonString)(unsafe.Pointer(p)).FpCtx = pCtx
	(*TJsonString)(unsafe.Pointer(p)).FeErr = uint8(0)
	_jsonStringZero(tls, p)
}

// C documentation
//
//	/* Free all allocated memory and reset the JsonString object back to its
//	** initial state.
//	*/
func _jsonStringReset(tls *libc.TLS, p uintptr) {
	if !((*TJsonString)(unsafe.Pointer(p)).FbStatic != 0) {
		_sqlite3RCStrUnref(tls, (*TJsonString)(unsafe.Pointer(p)).FzBuf)
	}
	_jsonStringZero(tls, p)
}

// C documentation
//
//	/*
//	** Given that a JSONB_ARRAY object starts at offset i, return
//	** the number of entries in that array.
//	*/
func _jsonbArrayCount(tls *libc.TLS, pParse uintptr, iRoot Tu32) (r Tu32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var i, iEnd, k, n Tu32
	var _ /* sz at bp+0 */ Tu32
	_, _, _, _ = i, iEnd, k, n
	k = uint32(0)
	n = _jsonbPayloadSize(tls, pParse, iRoot, bp)
	iEnd = iRoot + n + **(**Tu32)(__ccgo_up(bp))
	i = iRoot + n
	for {
		if !(n > uint32(0) && i < iEnd) {
			break
		}
		n = _jsonbPayloadSize(tls, pParse, i, bp)
		goto _1
	_1:
		;
		i = i + (**(**Tu32)(__ccgo_up(bp)) + n)
		k = k + 1
	}
	return k
}

// C documentation
//
//	/*
//	**    julianday( TIMESTRING, MOD, MOD, ...)
//	**
//	** Return the julian day number of the date specified in the arguments
//	*/
func _juliandayFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
	bp := tls.Alloc(48)
	defer tls.Free(48)
	var _ /* x at bp+0 */ TDateTime
	if _isDate(tls, context, argc, argv, bp) == 0 {
		_computeJD(tls, bp)
		Xsqlite3_result_double(tls, context, float64((**(**TDateTime)(__ccgo_up(bp))).FiJD)/float64(8.64e+07))
	}
}

// C documentation
//
//	/*
//	** Initialize the Kahan-Babaska-Neumaier sum from a 64-bit integer
//	*/
func _kahanBabuskaNeumaierInit(tls *libc.TLS, p uintptr, iVal Ti64) {
	var iSm Ti64
	_ = iSm
	if iVal <= -int64(4503599627370496) || iVal >= +libc.Int64FromInt64(4503599627370496) {
		iSm = iVal % int64(16384)
		(*TSumCtx)(unsafe.Pointer(p)).FrSum = float64(iVal - iSm)
		(*TSumCtx)(unsafe.Pointer(p)).FrErr = float64(iSm)
	} else {
		(*TSumCtx)(unsafe.Pointer(p)).FrSum = float64(iVal)
		(*TSumCtx)(unsafe.Pointer(p)).FrErr = float64(0)
	}
}

// C documentation
//
//	/*
//	** Do one step of the Kahan-Babushka-Neumaier summation.
//	**
//	** https://en.wikipedia.org/wiki/Kahan_summation_algorithm
//	**
//	** Variables are marked "volatile" to defeat c89 x86 floating point
//	** optimizations can mess up this algorithm.
//	*/
func _kahanBabuskaNeumaierStep(tls *libc.TLS, pSum uintptr, r float64) {
	var s, t float64
	_, _ = s, t
	s = (*TSumCtx)(unsafe.Pointer(pSum)).FrSum
	t = s + r
	if libc.Xfabs(tls, s) > libc.Xfabs(tls, r) {
		**(**float64)(__ccgo_up(pSum + 8)) += s - t + r
	} else {
		**(**float64)(__ccgo_up(pSum + 8)) += r - t + s
	}
	(*TSumCtx)(unsafe.Pointer(pSum)).FrSum = t
}

// C documentation
//
//	/*
//	** Add a (possibly large) integer to the running sum.
//	*/
func _kahanBabuskaNeumaierStepInt64(tls *libc.TLS, pSum uintptr, iVal Ti64) {
	var iBig, iSm Ti64
	_, _ = iBig, iSm
	if iVal <= -int64(4503599627370496) || iVal >= +libc.Int64FromInt64(4503599627370496) {
		iSm = iVal % int64(16384)
		iBig = iVal - iSm
		_kahanBabuskaNeumaierStep(tls, pSum, float64(iBig))
		_kahanBabuskaNeumaierStep(tls, pSum, float64(iSm))
	} else {
		_kahanBabuskaNeumaierStep(tls, pSum, float64(iVal))
	}
}

// C documentation
//
//	/*
//	** Implementation of the last_insert_rowid() SQL function.  The return
//	** value is the same as the sqlite3_last_insert_rowid() API function.
//	*/
func _last_insert_rowid(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
	var db uintptr
	_ = db
	db = Xsqlite3_context_db_handle(tls, context)
	_ = NotUsed
	_ = NotUsed2
	/* IMP: R-51513-12026 The last_insert_rowid() SQL function is a
	 ** wrapper around the sqlite3_last_insert_rowid() C/C++ interface
	 ** function. */
	Xsqlite3_result_int64(tls, context, Xsqlite3_last_insert_rowid(tls, db))
}

func _last_valueValueFunc(tls *libc.TLS, pCtx uintptr) {
	var p uintptr
	_ = p
	p = Xsqlite3_aggregate_context(tls, pCtx, 0)
	if p != 0 && (*TLastValueCtx)(unsafe.Pointer(p)).FpVal != 0 {
		Xsqlite3_result_value(tls, pCtx, (*TLastValueCtx)(unsafe.Pointer(p)).FpVal)
	}
}

// C documentation
//
//	/*
//	** Release the STATIC_MAIN mutex.
//	*/
func _leaveMutex(tls *libc.TLS) {
	Xsqlite3_mutex_leave(tls, _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN)))
}

var _lenOne = [1]uint32{
	0: uint32(1),
}

// C documentation
//
//	/* If SQLITE_CASE_SENSITIVE_LIKE is defined, then the LIKE operator
//	** is case sensitive causing 'a' LIKE 'A' to be false */
var _likeInfoAlt = TcompareInfo{
	FmatchAll: uint8('%'),
	FmatchOne: uint8('_'),
}

/*
** Possible error returns from patternMatch()
 */

// C documentation
//
//	/* The correct SQL-92 behavior is for the LIKE operator to ignore
//	** case.  Thus  'a' LIKE 'A' would be true. */
var _likeInfoNorm = TcompareInfo{
	FmatchAll: uint8('%'),
	FmatchOne: uint8('_'),
	FnoCase:   uint8(1),
}

// C documentation
//
//	/*
//	** Generate code that will cause the most recent index analysis to
//	** be loaded into internal hash tables where is can be used.
//	*/
func _loadAnalysis(tls *libc.TLS, pParse uintptr, iDb int32) {
	var v uintptr
	_ = v
	v = _sqlite3GetVdbe(tls, pParse)
	if v != 0 {
		_sqlite3VdbeAddOp1(tls, v, int32(OP_LoadAnalysis), iDb)
	}
}

// C documentation
//
//	/*
//	** Obtain the BtShared mutex associated with B-Tree handle p. Also,
//	** set BtShared.db to the database handle associated with p and the
//	** p->locked boolean to true.
//	*/
func _lockBtreeMutex(tls *libc.TLS, p uintptr) {
	Xsqlite3_mutex_enter(tls, (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).Fmutex)
	(*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).Fdb = (*TBtree)(unsafe.Pointer(p)).Fdb
	(*TBtree)(unsafe.Pointer(p)).Flocked = uint8(1)
}

var _mAnytimeConfigOption = libc.Uint64FromInt32(0) | libc.Uint64FromInt32(1)<<libc.Int32FromInt32(SQLITE_CONFIG_LOG) | libc.Uint64FromInt32(1)<<libc.Int32FromInt32(SQLITE_CONFIG_PCACHE_HDRSZ)

// C documentation
//
//	/* During the search for the best function definition, this procedure
//	** is called to test how well the function passed as the first argument
//	** matches the request for a function with nArg arguments in a system
//	** that uses encoding enc. The value returned indicates how well the
//	** request is matched. A higher value indicates a better match.
//	**
//	** If nArg is -1 that means to only return a match (non-zero) if p->nArg
//	** is also -1.  In other words, we are searching for a function that
//	** takes a variable number of arguments.
//	**
//	** If nArg is -2 that means that we are searching for any function
//	** regardless of the number of arguments it uses, so return a positive
//	** match score for any
//	**
//	** The returned value is always between 0 and 6, as follows:
//	**
//	** 0: Not a match.
//	** 1: UTF8/16 conversion required and function takes any number of arguments.
//	** 2: UTF16 byte order change required and function takes any number of args.
//	** 3: encoding matches and function takes any number of arguments
//	** 4: UTF8/16 conversion required - argument count matches exactly
//	** 5: UTF16 byte order conversion required - argument count matches exactly
//	** 6: Perfect match:  encoding and argument count match exactly.
//	**
//	** If nArg==(-2) then any function with a non-null xSFunc is
//	** a perfect match and any function with xSFunc NULL is
//	** a non-match.
//	*/
func _matchQuality(tls *libc.TLS, p uintptr, nArg int32, enc Tu8) (r int32) {
	var match, v1 int32
	_, _ = match, v1
	/* Wrong number of arguments means "no match" */
	if int32((*TFuncDef)(unsafe.Pointer(p)).FnArg) != nArg {
		if nArg == -int32(2) {
			if (*TFuncDef)(unsafe.Pointer(p)).FxSFunc == uintptr(0) {
				v1 = 0
			} else {
				v1 = int32(FUNC_PERFECT_MATCH)
			}
			return v1
		}
		if int32((*TFuncDef)(unsafe.Pointer(p)).FnArg) >= 0 {
			return 0
		}
		/* Special p->nArg values available to built-in functions only:
		 **    -3     1 or more arguments required
		 **    -4     2 or more arguments required
		 */
		if int32((*TFuncDef)(unsafe.Pointer(p)).FnArg) < -int32(2) && nArg < -int32(2)-int32((*TFuncDef)(unsafe.Pointer(p)).FnArg) {
			return 0
		}
	}
	/* Give a better score to a function with a specific number of arguments
	 ** than to function that accepts any number of arguments. */
	if int32((*TFuncDef)(unsafe.Pointer(p)).FnArg) == nArg {
		match = int32(4)
	} else {
		match = int32(1)
	}
	/* Bonus points if the text encoding matches */
	if uint32(enc) == (*TFuncDef)(unsafe.Pointer(p)).FfuncFlags&uint32(SQLITE_FUNC_ENCMASK) {
		match = match + int32(2) /* Exact encoding match */
	} else {
		if uint32(enc)&(*TFuncDef)(unsafe.Pointer(p)).FfuncFlags&uint32(2) != uint32(0) {
			match = match + int32(1) /* Both are UTF16, but with different byte orders */
		}
	}
	return match
}

// C documentation
//
//	/*
//	** Implementation of 1-argument SQL math functions:
//	**
//	**   exp(X)  - Compute e to the X-th power
//	*/
func _math1Func(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
	var ans, v0 float64
	var type0 int32
	var x uintptr
	_, _, _, _ = ans, type0, v0, x
	type0 = Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv)))
	if type0 != int32(SQLITE_INTEGER) && type0 != int32(SQLITE_FLOAT) {
		return
	}
	v0 = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv)))
	x = Xsqlite3_user_data(tls, context)
	ans = (*(*func(*libc.TLS, float64) float64)(unsafe.Pointer(&struct{ uintptr }{x})))(tls, v0)
	Xsqlite3_result_double(tls, context, ans)
}

// C documentation
//
//	/*
//	** Add the size of memory allocation "p" to the count in
//	** *db->pnBytesFreed.
//	*/
func _measureAllocationSize(tls *libc.TLS, db uintptr, p uintptr) {
	**(**int32)(__ccgo_up((*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed)) += _sqlite3DbMallocSize(tls, db, p)
}

// C documentation
//
//	/*
//	** State information local to the memory allocation subsystem.
//	*/
var _mem0 = TMem0Global{}

// C documentation
//
//	/*
//	** Return some kind of integer value which is the best we can do
//	** at representing the value that *pMem describes as an integer.
//	** If pMem is an integer, then the value is exact.  If pMem is
//	** a floating-point then the value returned is the integer part.
//	** If pMem is a string or blob, then we make an attempt to convert
//	** it into an integer and return that.  If pMem represents an
//	** an SQL-NULL value, return 0.
//	**
//	** If pMem represents a string value, its encoding might be changed.
//	*/
func _memIntValue(tls *libc.TLS, pMem uintptr) (r Ti64) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var _ /* value at bp+0 */ Ti64
	**(**Ti64)(__ccgo_up(bp)) = 0
	_sqlite3Atoi64(tls, (*TMem)(unsafe.Pointer(pMem)).Fz, bp, (*TMem)(unsafe.Pointer(pMem)).Fn, (*TMem)(unsafe.Pointer(pMem)).Fenc)
	return **(**Ti64)(__ccgo_up(bp))
}

// C documentation
//
//	/*
//	** Test for access permissions. Return true if the requested permission
//	** is available, or false otherwise.
//	**
//	** With memdb, no files ever exist on disk.  So always return false.
//	*/
func _memdbAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) (r int32) {
	_ = pVfs
	_ = zPath
	_ = flags
	**(**int32)(__ccgo_up(pResOut)) = 0
	return SQLITE_OK
}

func _memdbCurrentTimeInt64(tls *libc.TLS, pVfs uintptr, p uintptr) (r int32) {
	return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxCurrentTimeInt64})))(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, p)
}

// C documentation
//
//	/*
//	** Return the device characteristic flags supported by an memdb-file.
//	*/
func _memdbDeviceCharacteristics(tls *libc.TLS, pFile uintptr) (r int32) {
	_ = pFile
	return libc.Int32FromInt32(SQLITE_IOCAP_ATOMIC) | libc.Int32FromInt32(SQLITE_IOCAP_POWERSAFE_OVERWRITE) | libc.Int32FromInt32(SQLITE_IOCAP_SAFE_APPEND) | libc.Int32FromInt32(SQLITE_IOCAP_SEQUENTIAL)
}

// C documentation
//
//	/*
//	** Close the dynamic library handle pHandle.
//	*/
func _memdbDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) {
	(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxDlClose})))(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, pHandle)
}

// C documentation
//
//	/*
//	** Populate the buffer zErrMsg (size nByte bytes) with a human readable
//	** utf-8 string describing the most recent error encountered associated
//	** with dynamic libraries.
//	*/
func _memdbDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zErrMsg uintptr) {
	(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxDlError})))(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, nByte, zErrMsg)
}

// C documentation
//
//	/*
//	** Open the dynamic library located at zPath and return a handle.
//	*/
func _memdbDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) (r uintptr) {
	return (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxDlOpen})))(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zPath)
}

// C documentation
//
//	/*
//	** Return a pointer to the symbol zSymbol in the dynamic library pHandle.
//	*/
func _memdbDlSym(tls *libc.TLS, pVfs uintptr, p uintptr, zSym uintptr) (r uintptr) {
	return (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxDlSym})))(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, p, zSym)
}

// C documentation
//
//	/*
//	** Enter/leave the mutex on a MemStore
//	*/
func _memdbEnter(tls *libc.TLS, p uintptr) {
	Xsqlite3_mutex_enter(tls, (*TMemStore)(unsafe.Pointer(p)).FpMutex)
}

// C documentation
//
//	/* Fetch a page of a memory-mapped file */
func _memdbFetch(tls *libc.TLS, pFile uintptr, iOfst Tsqlite3_int64, iAmt int32, pp uintptr) (r int32) {
	var p uintptr
	_ = p
	p = (*TMemFile)(unsafe.Pointer(pFile)).FpStore
	_memdbEnter(tls, p)
	if iOfst+int64(iAmt) > (*TMemStore)(unsafe.Pointer(p)).Fsz || (*TMemStore)(unsafe.Pointer(p)).FmFlags&uint32(SQLITE_DESERIALIZE_RESIZEABLE) != uint32(0) {
		**(**uintptr)(__ccgo_up(pp)) = uintptr(0)
	} else {
		(*TMemStore)(unsafe.Pointer(p)).FnMmap = (*TMemStore)(unsafe.Pointer(p)).FnMmap + 1
		**(**uintptr)(__ccgo_up(pp)) = (*TMemStore)(unsafe.Pointer(p)).FaData + uintptr(iOfst)
	}
	_memdbLeave(tls, p)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Return the current file-size of an memdb-file.
//	*/
func _memdbFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) (r int32) {
	var p uintptr
	_ = p
	p = (*TMemFile)(unsafe.Pointer(pFile)).FpStore
	_memdbEnter(tls, p)
	**(**Tsqlite_int64)(__ccgo_up(pSize)) = (*TMemStore)(unsafe.Pointer(p)).Fsz
	_memdbLeave(tls, p)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Translate a database connection pointer and schema name into a
//	** MemFile pointer.
//	*/
func _memdbFromDbSchema(tls *libc.TLS, db uintptr, zSchema uintptr) (r uintptr) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var pStore uintptr
	var rc int32
	var _ /* p at bp+0 */ uintptr
	_, _ = pStore, rc
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
	rc = Xsqlite3_file_control(tls, db, zSchema, int32(SQLITE_FCNTL_FILE_POINTER), bp)
	if rc != 0 {
		return uintptr(0)
	}
	if (*TMemFile)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).Fbase.FpMethods != uintptr(unsafe.Pointer(&_memdb_io_methods)) {
		return uintptr(0)
	}
	pStore = (*TMemFile)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpStore
	_memdbEnter(tls, pStore)
	if (*TMemStore)(unsafe.Pointer(pStore)).FzFName != uintptr(0) {
		**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
	}
	_memdbLeave(tls, pStore)
	return **(**uintptr)(__ccgo_up(bp))
}

func _memdbGetLastError(tls *libc.TLS, pVfs uintptr, a int32, b uintptr) (r int32) {
	return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxGetLastError})))(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, a, b)
}

func _memdbLeave(tls *libc.TLS, p uintptr) {
	Xsqlite3_mutex_leave(tls, (*TMemStore)(unsafe.Pointer(p)).FpMutex)
}

// C documentation
//
//	/*
//	** Lock an memdb-file.
//	*/
func _memdbLock(tls *libc.TLS, pFile uintptr, eLock int32) (r int32) {
	var p, pThis uintptr
	var rc int32
	_, _, _ = p, pThis, rc
	pThis = pFile
	p = (*TMemFile)(unsafe.Pointer(pThis)).FpStore
	rc = SQLITE_OK
	if eLock <= (*TMemFile)(unsafe.Pointer(pThis)).FeLock {
		return SQLITE_OK
	}
	_memdbEnter(tls, p)
	if eLock > int32(SQLITE_LOCK_SHARED) && (*TMemStore)(unsafe.Pointer(p)).FmFlags&uint32(SQLITE_DESERIALIZE_READONLY) != 0 {
		rc = int32(SQLITE_READONLY)
	} else {
		switch eLock {
		case int32(SQLITE_LOCK_SHARED):
			if (*TMemStore)(unsafe.Pointer(p)).FnWrLock > 0 {
				rc = int32(SQLITE_BUSY)
			} else {
				(*TMemStore)(unsafe.Pointer(p)).FnRdLock = (*TMemStore)(unsafe.Pointer(p)).FnRdLock + 1
			}
		case int32(SQLITE_LOCK_RESERVED):
			fallthrough
		case int32(SQLITE_LOCK_PENDING):
			if (*TMemFile)(unsafe.Pointer(pThis)).FeLock == int32(SQLITE_LOCK_SHARED) {
				if (*TMemStore)(unsafe.Pointer(p)).FnWrLock > 0 {
					rc = int32(SQLITE_BUSY)
				} else {
					(*TMemStore)(unsafe.Pointer(p)).FnWrLock = int32(1)
				}
			}
		default:
			if (*TMemStore)(unsafe.Pointer(p)).FnRdLock > int32(1) {
				rc = int32(SQLITE_BUSY)
			} else {
				if (*TMemFile)(unsafe.Pointer(pThis)).FeLock == int32(SQLITE_LOCK_SHARED) {
					(*TMemStore)(unsafe.Pointer(p)).FnWrLock = int32(1)
				}
			}
			break
		}
	}
	if rc == SQLITE_OK {
		(*TMemFile)(unsafe.Pointer(pThis)).FeLock = eLock
	}
	_memdbLeave(tls, p)
	return rc
}

// C documentation
//
//	/*
//	** Populate the buffer pointed to by zBufOut with nByte bytes of
//	** random data.
//	*/
func _memdbRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) (r int32) {
	return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxRandomness})))(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, nByte, zBufOut)
}

// C documentation
//
//	/*
//	** Sleep for nMicro microseconds. Return the number of microseconds
//	** actually slept.
//	*/
func _memdbSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) (r int32) {
	return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer((*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FxSleep})))(tls, (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, nMicro)
}

// C documentation
//
//	/*
//	** Sync an memdb-file.
//	*/
func _memdbSync(tls *libc.TLS, pFile uintptr, flags int32) (r int32) {
	_ = pFile
	_ = flags
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Truncate an memdb-file.
//	**
//	** In rollback mode (which is always the case for memdb, as it does not
//	** support WAL mode) the truncate() method is only used to reduce
//	** the size of a file, never to increase the size.
//	*/
func _memdbTruncate(tls *libc.TLS, pFile uintptr, size Tsqlite_int64) (r int32) {
	var p uintptr
	var rc int32
	_, _ = p, rc
	p = (*TMemFile)(unsafe.Pointer(pFile)).FpStore
	rc = SQLITE_OK
	_memdbEnter(tls, p)
	if size > (*TMemStore)(unsafe.Pointer(p)).Fsz {
		/* This can only happen with a corrupt wal mode db */
		rc = int32(SQLITE_CORRUPT)
	} else {
		(*TMemStore)(unsafe.Pointer(p)).Fsz = size
	}
	_memdbLeave(tls, p)
	return rc
}

// C documentation
//
//	/* Release a memory-mapped page */
func _memdbUnfetch(tls *libc.TLS, pFile uintptr, iOfst Tsqlite3_int64, pPage uintptr) (r int32) {
	var p uintptr
	_ = p
	p = (*TMemFile)(unsafe.Pointer(pFile)).FpStore
	_ = iOfst
	_ = pPage
	_memdbEnter(tls, p)
	(*TMemStore)(unsafe.Pointer(p)).FnMmap = (*TMemStore)(unsafe.Pointer(p)).FnMmap - 1
	_memdbLeave(tls, p)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Unlock an memdb-file.
//	*/
func _memdbUnlock(tls *libc.TLS, pFile uintptr, eLock int32) (r int32) {
	var p, pThis uintptr
	_, _ = p, pThis
	pThis = pFile
	p = (*TMemFile)(unsafe.Pointer(pThis)).FpStore
	if eLock >= (*TMemFile)(unsafe.Pointer(pThis)).FeLock {
		return SQLITE_OK
	}
	_memdbEnter(tls, p)
	if eLock == int32(SQLITE_LOCK_SHARED) {
		if (*TMemFile)(unsafe.Pointer(pThis)).FeLock > int32(SQLITE_LOCK_SHARED) {
			(*TMemStore)(unsafe.Pointer(p)).FnWrLock = (*TMemStore)(unsafe.Pointer(p)).FnWrLock - 1
		}
	} else {
		if (*TMemFile)(unsafe.Pointer(pThis)).FeLock > int32(SQLITE_LOCK_SHARED) {
			(*TMemStore)(unsafe.Pointer(p)).FnWrLock = (*TMemStore)(unsafe.Pointer(p)).FnWrLock - 1
		}
		(*TMemStore)(unsafe.Pointer(p)).FnRdLock = (*TMemStore)(unsafe.Pointer(p)).FnRdLock - 1
	}
	(*TMemFile)(unsafe.Pointer(pThis)).FeLock = eLock
	_memdbLeave(tls, p)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** File-scope variables for holding the memdb files that are accessible
//	** to multiple database connections in separate threads.
//	**
//	** Must hold SQLITE_MUTEX_STATIC_VFS1 to access any part of this object.
//	*/
var _memdb_g TMemFS

var _memdb_io_methods = Tsqlite3_io_methods{
	FiVersion: int32(3),
}

// C documentation
//
//	/*
//	** Close the file.
//	*/
func _memjrnlClose(tls *libc.TLS, pJfd uintptr) (r int32) {
	var p uintptr
	_ = p
	p = pJfd
	_memjrnlFreeChunks(tls, (*TMemJournal)(unsafe.Pointer(p)).FpFirst)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Query the size of the file in bytes.
//	*/
func _memjrnlFileSize(tls *libc.TLS, pJfd uintptr, pSize uintptr) (r int32) {
	var p uintptr
	_ = p
	p = pJfd
	**(**Tsqlite_int64)(__ccgo_up(pSize)) = (*TMemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Free the list of FileChunk structures headed at MemJournal.pFirst.
//	*/
func _memjrnlFreeChunks(tls *libc.TLS, pFirst uintptr) {
	var pIter, pNext uintptr
	_, _ = pIter, pNext
	pIter = pFirst
	for {
		if !(pIter != 0) {
			break
		}
		pNext = (*TFileChunk)(unsafe.Pointer(pIter)).FpNext
		Xsqlite3_free(tls, pIter)
		goto _1
	_1:
		;
		pIter = pNext
	}
}

// C documentation
//
//	/*
//	** Sync the file.
//	**
//	** If the real file has been created, call its xSync method. Otherwise,
//	** syncing an in-memory journal is a no-op.
//	*/
func _memjrnlSync(tls *libc.TLS, pJfd uintptr, flags int32) (r int32) {
	_ = pJfd
	_ = flags
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Truncate the in-memory file.
//	*/
func _memjrnlTruncate(tls *libc.TLS, pJfd uintptr, size Tsqlite_int64) (r int32) {
	var iOff Ti64
	var p, pIter uintptr
	_, _, _ = iOff, p, pIter
	p = pJfd
	if size < (*TMemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset {
		pIter = uintptr(0)
		if size == 0 {
			_memjrnlFreeChunks(tls, (*TMemJournal)(unsafe.Pointer(p)).FpFirst)
			(*TMemJournal)(unsafe.Pointer(p)).FpFirst = uintptr(0)
		} else {
			iOff = int64((*TMemJournal)(unsafe.Pointer(p)).FnChunkSize)
			pIter = (*TMemJournal)(unsafe.Pointer(p)).FpFirst
			for {
				if !(pIter != 0 && iOff < size) {
					break
				}
				iOff = iOff + int64((*TMemJournal)(unsafe.Pointer(p)).FnChunkSize)
				goto _1
			_1:
				;
				pIter = (*TFileChunk)(unsafe.Pointer(pIter)).FpNext
			}
			if pIter != 0 {
				_memjrnlFreeChunks(tls, (*TFileChunk)(unsafe.Pointer(pIter)).FpNext)
				(*TFileChunk)(unsafe.Pointer(pIter)).FpNext = uintptr(0)
			}
		}
		(*TMemJournal)(unsafe.Pointer(p)).Fendpoint.FpChunk = pIter
		(*TMemJournal)(unsafe.Pointer(p)).Fendpoint.FiOffset = size
		(*TMemJournal)(unsafe.Pointer(p)).Freadpoint.FpChunk = uintptr(0)
		(*TMemJournal)(unsafe.Pointer(p)).Freadpoint.FiOffset = 0
	}
	return SQLITE_OK
}

func _minMaxFinalize(tls *libc.TLS, context uintptr) {
	_minMaxValueFinalize(tls, context, 0)
}

func _minMaxValue(tls *libc.TLS, context uintptr) {
	_minMaxValueFinalize(tls, context, int32(1))
}

func _minMaxValueFinalize(tls *libc.TLS, context uintptr, bValue int32) {
	var pRes uintptr
	_ = pRes
	pRes = Xsqlite3_aggregate_context(tls, context, 0)
	if pRes != 0 {
		if (*Tsqlite3_value)(unsafe.Pointer(pRes)).Fflags != 0 {
			Xsqlite3_result_value(tls, context, pRes)
		}
		if bValue == 0 {
			_sqlite3VdbeMemRelease(tls, pRes)
		}
	}
}

var _misuse = [34]Tu16{
	0:  uint16('b'),
	1:  uint16('a'),
	2:  uint16('d'),
	3:  uint16(' '),
	4:  uint16('p'),
	5:  uint16('a'),
	6:  uint16('r'),
	7:  uint16('a'),
	8:  uint16('m'),
	9:  uint16('e'),
	10: uint16('t'),
	11: uint16('e'),
	12: uint16('r'),
	13: uint16(' '),
	14: uint16('o'),
	15: uint16('r'),
	16: uint16(' '),
	17: uint16('o'),
	18: uint16('t'),
	19: uint16('h'),
	20: uint16('e'),
	21: uint16('r'),
	22: uint16(' '),
	23: uint16('A'),
	24: uint16('P'),
	25: uint16('I'),
	26: uint16(' '),
	27: uint16('m'),
	28: uint16('i'),
	29: uint16('s'),
	30: uint16('u'),
	31: uint16('s'),
	32: uint16('e'),
}

// C documentation
//
//	/*
//	** Another built-in collating sequence: NOCASE.
//	**
//	** This collating sequence is intended to be used for "case independent
//	** comparison". SQLite's knowledge of upper and lower case equivalents
//	** extends only to the 26 characters used in the English language.
//	**
//	** At the moment there is only a UTF-8 implementation.
//	*/
func _nocaseCollatingFunc(tls *libc.TLS, NotUsed uintptr, nKey1 int32, pKey1 uintptr, nKey2 int32, pKey2 uintptr) (r1 int32) {
	var r, v1 int32
	_, _ = r, v1
	if nKey1 < nKey2 {
		v1 = nKey1
	} else {
		v1 = nKey2
	}
	r = Xsqlite3_strnicmp(tls, pKey1, pKey2, v1)
	_ = NotUsed
	if 0 == r {
		r = nKey1 - nKey2
	}
	return r
}

// C documentation
//
//	/*
//	** Clear the Rtree.pNodeBlob object
//	*/
func _nodeBlobReset(tls *libc.TLS, pRtree uintptr) {
	var pBlob uintptr
	_ = pBlob
	pBlob = (*TRtree)(unsafe.Pointer(pRtree)).FpNodeBlob
	(*TRtree)(unsafe.Pointer(pRtree)).FpNodeBlob = uintptr(0)
	Xsqlite3_blob_close(tls, pBlob)
}

// C documentation
//
//	/*
//	** Return the index of the cell containing a pointer to node pNode
//	** in its parent. If pNode is the root node, return -1.
//	*/
func _nodeParentIndex(tls *libc.TLS, pRtree uintptr, pNode uintptr, piIndex uintptr) (r int32) {
	var pParent uintptr
	_ = pParent
	pParent = (*TRtreeNode)(unsafe.Pointer(pNode)).FpParent
	if pParent != 0 {
		return _nodeRowidIndex(tls, pRtree, pParent, (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode, piIndex)
	} else {
		**(**int32)(__ccgo_up(piIndex)) = -int32(1)
		return SQLITE_OK
	}
	return r
}

// C documentation
//
//	/*
//	** Increment the reference count of node p.
//	*/
func _nodeReference(tls *libc.TLS, p uintptr) {
	if p != 0 {
		(*TRtreeNode)(unsafe.Pointer(p)).FnRef = (*TRtreeNode)(unsafe.Pointer(p)).FnRef + 1
	}
}

// C documentation
//
//	/*
//	** Release a reference to a node. If the node is dirty and the reference
//	** count drops to zero, the node data is written to the database.
//	*/
func _nodeRelease(tls *libc.TLS, pRtree uintptr, pNode uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = SQLITE_OK
	if pNode != 0 {
		(*TRtreeNode)(unsafe.Pointer(pNode)).FnRef = (*TRtreeNode)(unsafe.Pointer(pNode)).FnRef - 1
		if (*TRtreeNode)(unsafe.Pointer(pNode)).FnRef == 0 {
			(*TRtree)(unsafe.Pointer(pRtree)).FnNodeRef = (*TRtree)(unsafe.Pointer(pRtree)).FnNodeRef - 1
			if (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode == int64(1) {
				(*TRtree)(unsafe.Pointer(pRtree)).FiDepth = -int32(1)
			}
			if (*TRtreeNode)(unsafe.Pointer(pNode)).FpParent != 0 {
				rc = _nodeRelease(tls, pRtree, (*TRtreeNode)(unsafe.Pointer(pNode)).FpParent)
			}
			if rc == SQLITE_OK {
				rc = _nodeWrite(tls, pRtree, pNode)
			}
			_nodeHashDelete(tls, pRtree, pNode)
			Xsqlite3_free(tls, pNode)
		}
	}
	return rc
}

// C documentation
//
//	/*
//	** One of the cells in node pNode is guaranteed to have a 64-bit
//	** integer value equal to iRowid. Return the index of this cell.
//	*/
func _nodeRowidIndex(tls *libc.TLS, pRtree uintptr, pNode uintptr, iRowid Ti64, piIndex uintptr) (r int32) {
	var ii, nCell int32
	_, _ = ii, nCell
	nCell = _readInt16(tls, (*TRtreeNode)(unsafe.Pointer(pNode)).FzData+2)
	ii = 0
	for {
		if !(ii < nCell) {
			break
		}
		if _nodeGetRowid(tls, pRtree, pNode, ii) == iRowid {
			**(**int32)(__ccgo_up(piIndex)) = ii
			return SQLITE_OK
		}
		goto _1
	_1:
		;
		ii = ii + 1
	}
	return libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<<libc.Int32FromInt32(8)
}

// C documentation
//
//	/*
//	** If the node is dirty, write it out to the database.
//	*/
func _nodeWrite(tls *libc.TLS, pRtree uintptr, pNode uintptr) (r int32) {
	var p uintptr
	var rc int32
	_, _ = p, rc
	rc = SQLITE_OK
	if (*TRtreeNode)(unsafe.Pointer(pNode)).FisDirty != 0 {
		p = (*TRtree)(unsafe.Pointer(pRtree)).FpWriteNode
		if (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode != 0 {
			Xsqlite3_bind_int64(tls, p, int32(1), (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode)
		} else {
			Xsqlite3_bind_null(tls, p, int32(1))
		}
		Xsqlite3_bind_blob(tls, p, int32(2), (*TRtreeNode)(unsafe.Pointer(pNode)).FzData, (*TRtree)(unsafe.Pointer(pRtree)).FiNodeSize, libc.UintptrFromInt32(0))
		Xsqlite3_step(tls, p)
		(*TRtreeNode)(unsafe.Pointer(pNode)).FisDirty = 0
		rc = Xsqlite3_reset(tls, p)
		Xsqlite3_bind_null(tls, p, int32(2))
		if (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode == 0 && rc == SQLITE_OK {
			(*TRtreeNode)(unsafe.Pointer(pNode)).FiNode = Xsqlite3_last_insert_rowid(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb)
			_nodeHashInsert(tls, pRtree, pNode)
		}
	}
	return rc
}

func _noopMutexAlloc(tls *libc.TLS, id int32) (r uintptr) {
	_ = id
	return libc.UintptrFromInt32(8)
}

func _noopMutexEnd(tls *libc.TLS) (r int32) {
	return SQLITE_OK
}

func _noopMutexEnter(tls *libc.TLS, p uintptr) {
	_ = p
	return
}

func _noopMutexFree(tls *libc.TLS, p uintptr) {
	_ = p
	return
}

// C documentation
//
//	/*
//	** Stub routines for all mutex methods.
//	**
//	** This routines provide no mutual exclusion or error checking.
//	*/
func _noopMutexInit(tls *libc.TLS) (r int32) {
	return SQLITE_OK
}

func _noopMutexLeave(tls *libc.TLS, p uintptr) {
	_ = p
	return
}

func _noopMutexTry(tls *libc.TLS, p uintptr) (r int32) {
	_ = p
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** No-op implementations of xStep() and xFinalize().  Used as place-holders
//	** for built-in window functions that never call those interfaces.
//	**
//	** The noopValueFunc() is called but is expected to do nothing.  The
//	** noopStepFunc() is never called, and so it is marked with NO_TEST to
//	** let the test coverage routine know not to expect this function to be
//	** invoked.
//	*/
func _noopStepFunc(tls *libc.TLS, p uintptr, n int32, a uintptr) {
	/*NO_TEST*/
	_ = p /*NO_TEST*/
	_ = n /*NO_TEST*/
	_ = a /*NO_TEST*/
	/*NO_TEST*/
}

/*NO_TEST*/
func _noopValueFunc(tls *libc.TLS, p uintptr) {
	_ = p /*no-op*/
}

/* Window functions that use all window interfaces: xStep, xFinal,
** xValue, and xInverse */

/* Window functions that are implemented using bytecode and thus have
** no-op routines for their methods */

/* Window functions that use all window interfaces: xStep, the
** same routine for xFinalize and xValue and which never call
** xInverse. */

func _nth_valueFinalizeFunc(tls *libc.TLS, pCtx uintptr) {
	var p uintptr
	_ = p
	p = Xsqlite3_aggregate_context(tls, pCtx, 0)
	if p != 0 && (*TNthValueCtx)(unsafe.Pointer(p)).FpValue != 0 {
		Xsqlite3_result_value(tls, pCtx, (*TNthValueCtx)(unsafe.Pointer(p)).FpValue)
		Xsqlite3_value_free(tls, (*TNthValueCtx)(unsafe.Pointer(p)).FpValue)
		(*TNthValueCtx)(unsafe.Pointer(p)).FpValue = uintptr(0)
	}
}

func _ntileInvFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
	var p uintptr
	_ = p
	_ = nArg
	_ = apArg
	p = Xsqlite3_aggregate_context(tls, pCtx, int32(24))
	(*TNtileCtx)(unsafe.Pointer(p)).FiRow = (*TNtileCtx)(unsafe.Pointer(p)).FiRow + 1
}

func _ntileValueFunc(tls *libc.TLS, pCtx uintptr) {
	var iRow, iSmall, nLarge Ti64
	var nSize int32
	var p uintptr
	_, _, _, _, _ = iRow, iSmall, nLarge, nSize, p
	p = Xsqlite3_aggregate_context(tls, pCtx, int32(24))
	if p != 0 && (*TNtileCtx)(unsafe.Pointer(p)).FnParam > 0 {
		nSize = int32((*TNtileCtx)(unsafe.Pointer(p)).FnTotal / (*TNtileCtx)(unsafe.Pointer(p)).FnParam)
		if nSize == 0 {
			Xsqlite3_result_int64(tls, pCtx, (*TNtileCtx)(unsafe.Pointer(p)).FiRow+int64(1))
		} else {
			nLarge = (*TNtileCtx)(unsafe.Pointer(p)).FnTotal - (*TNtileCtx)(unsafe.Pointer(p)).FnParam*int64(nSize)
			iSmall = nLarge * int64(nSize+libc.Int32FromInt32(1))
			iRow = (*TNtileCtx)(unsafe.Pointer(p)).FiRow
			if iRow < iSmall {
				Xsqlite3_result_int64(tls, pCtx, int64(1)+iRow/int64(nSize+libc.Int32FromInt32(1)))
			} else {
				Xsqlite3_result_int64(tls, pCtx, int64(1)+nLarge+(iRow-iSmall)/int64(nSize))
			}
		}
	}
}

var _nullElement = THashElem{}

/* Even though the Mem structure contains an element
 ** of type i64, on certain architectures (x86) with certain compiler
 ** switches (-Os), gcc may align this Mem object on a 4-byte boundary
 ** instead of an 8-byte one. This all works fine, except that when
 ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s
 ** that a Mem structure is located on an 8-byte boundary. To prevent
 ** these assert()s from failing, when building with SQLITE_DEBUG defined
 ** using gcc, we force nullMem to be 8-byte aligned using the magical
 ** __attribute__((aligned(8))) macro.  */
var _nullMem = TMem{
	Fflags: libc.Uint16FromInt32(MEM_Null),
}

// C documentation
//
//	/*
//	** Compute the number of pages of cache requested.   p->szCache is the
//	** cache size requested by the "PRAGMA cache_size" statement.
//	*/
func _numberOfCachePages(tls *libc.TLS, p uintptr) (r int32) {
	var n Ti64
	_ = n
	if (*TPCache)(unsafe.Pointer(p)).FszCache >= 0 {
		/* IMPLEMENTATION-OF: R-42059-47211 If the argument N is positive then the
		 ** suggested cache size is set to N. */
		return (*TPCache)(unsafe.Pointer(p)).FszCache
	} else {
		/* IMPLEMENTATION-OF: R-59858-46238 If the argument N is negative, then the
		 ** number of cache pages is adjusted to be a number of pages that would
		 ** use approximately abs(N*1024) bytes of memory based on the current
		 ** page size. */
		n = int64(-libc.Int32FromInt32(1024)) * int64((*TPCache)(unsafe.Pointer(p)).FszCache) / int64((*TPCache)(unsafe.Pointer(p)).FszPage+(*TPCache)(unsafe.Pointer(p)).FszExtra)
		if n > int64(1000000000) {
			n = int64(1000000000)
		}
		return int32(n)
	}
	return r
}

var _openBlob = [6]TVdbeOpList{
	0: {
		Fopcode: uint8(OP_TableLock),
	},
	1: {
		Fopcode: uint8(OP_OpenRead),
	},
	2: {
		Fopcode: uint8(OP_NotExists),
		Fp2:     int8(5),
		Fp3:     int8(1),
	},
	3: {
		Fopcode: uint8(OP_Column),
		Fp3:     int8(1),
	},
	4: {
		Fopcode: uint8(OP_ResultRow),
		Fp1:     int8(1),
	},
	5: {
		Fopcode: uint8(OP_Halt),
	},
}

var _ops = [2]Tu8{
	0: uint8(TK_GE),
	1: uint8(TK_LE),
}

/***************************************************************************
** Routines with file scope above.  Interface to the rest of the where.c
** subsystem follows.
***************************************************************************/

var _or_logic = [9]uint8{
	1: uint8(1),
	2: uint8(2),
	3: uint8(1),
	4: uint8(1),
	5: uint8(1),
	6: uint8(2),
	7: uint8(1),
	8: uint8(2),
}

// C documentation
//
//	/*
//	** Return the register of pOp->p2 after first preparing it to be
//	** overwritten with an integer value.
//	*/
func _out2PrereleaseWithClear(tls *libc.TLS, pOut uintptr) (r uintptr) {
	_sqlite3VdbeMemSetNull(tls, pOut)
	(*TMem)(unsafe.Pointer(pOut)).Fflags = uint16(MEM_Int)
	return pOut
}

var _outOfMem = [14]Tu16{
	0:  uint16('o'),
	1:  uint16('u'),
	2:  uint16('t'),
	3:  uint16(' '),
	4:  uint16('o'),
	5:  uint16('f'),
	6:  uint16(' '),
	7:  uint16('m'),
	8:  uint16('e'),
	9:  uint16('m'),
	10: uint16('o'),
	11: uint16('r'),
	12: uint16('y'),
}

// C documentation
//
//	/*
//	** During a rollback, when the pager reloads information into the cache
//	** so that the cache is restored to its original state at the start of
//	** the transaction, for each page restored this routine is called.
//	**
//	** This routine needs to reset the extra data section at the end of the
//	** page to agree with the restored data.
//	*/
func _pageReinit(tls *libc.TLS, pData uintptr) {
	var pPage uintptr
	_ = pPage
	pPage = _sqlite3PagerGetExtra(tls, pData)
	if (*TMemPage)(unsafe.Pointer(pPage)).FisInit != 0 {
		(*TMemPage)(unsafe.Pointer(pPage)).FisInit = uint8(0)
		if _sqlite3PagerPageRefcount(tls, pData) > int32(1) {
			/* pPage might not be a btree page;  it might be an overflow page
			 ** or ptrmap page or a free page.  In those cases, the following
			 ** call to btreeInitPage() will likely return SQLITE_CORRUPT.
			 ** But no harm is done by this.  And it is very important that
			 ** btreeInitPage() be called on every btree page so we make
			 ** the call for every page that comes in for re-initializing. */
			_btreeInitPage(tls, pPage)
		}
	}
}

// C documentation
//
//	/*
//	** Free all PgHdr objects stored in the Pager.pMmapFreelist list.
//	*/
func _pagerFreeMapHdrs(tls *libc.TLS, pPager uintptr) {
	var p, pNext uintptr
	_, _ = p, pNext
	p = (*TPager)(unsafe.Pointer(pPager)).FpMmapFreelist
	for {
		if !(p != 0) {
			break
		}
		pNext = (*TPgHdr)(unsafe.Pointer(p)).FpDirty
		Xsqlite3_free(tls, p)
		goto _1
	_1:
		;
		p = pNext
	}
}

// C documentation
//
//	/*
//	** Open a temporary file.
//	**
//	** Write the file descriptor into *pFile. Return SQLITE_OK on success
//	** or some other error code if we fail. The OS will automatically
//	** delete the temporary file when it is closed.
//	**
//	** The flags passed to the VFS layer xOpen() call are those specified
//	** by parameter vfsFlags ORed with the following:
//	**
//	**     SQLITE_OPEN_READWRITE
//	**     SQLITE_OPEN_CREATE
//	**     SQLITE_OPEN_EXCLUSIVE
//	**     SQLITE_OPEN_DELETEONCLOSE
//	*/
func _pagerOpentemp(tls *libc.TLS, pPager uintptr, pFile uintptr, vfsFlags int32) (r int32) {
	var rc int32
	_ = rc /* Return code */
	vfsFlags = vfsFlags | (libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_EXCLUSIVE) | libc.Int32FromInt32(SQLITE_OPEN_DELETEONCLOSE))
	rc = _sqlite3OsOpen(tls, (*TPager)(unsafe.Pointer(pPager)).FpVfs, uintptr(0), pFile, vfsFlags, uintptr(0))
	return rc
}

// C documentation
//
//	/*
//	** This function is called to rollback a transaction on a WAL database.
//	*/
func _pagerRollbackWal(tls *libc.TLS, pPager uintptr) (r int32) {
	var pList, pNext uintptr
	var rc int32
	_, _, _ = pList, pNext, rc /* List of dirty pages to revert */
	/* For all pages in the cache that are currently dirty or have already
	 ** been written (but not committed) to the log file, do one of the
	 ** following:
	 **
	 **   + Discard the cached page (if refcount==0), or
	 **   + Reload page content from the database (if refcount>0).
	 */
	(*TPager)(unsafe.Pointer(pPager)).FdbSize = (*TPager)(unsafe.Pointer(pPager)).FdbOrigSize
	rc = _sqlite3WalUndo(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, __ccgo_fp(_pagerUndoCallback), pPager)
	pList = _sqlite3PcacheDirtyList(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache)
	for pList != 0 && rc == SQLITE_OK {
		pNext = (*TPgHdr)(unsafe.Pointer(pList)).FpDirty
		rc = _pagerUndoCallback(tls, pPager, (*TPgHdr)(unsafe.Pointer(pList)).Fpgno)
		pList = pNext
	}
	return rc
}

// C documentation
//
//	/*
//	** This function is invoked once for each page that has already been
//	** written into the log file when a WAL transaction is rolled back.
//	** Parameter iPg is the page number of said page. The pCtx argument
//	** is actually a pointer to the Pager structure.
//	**
//	** If page iPg is present in the cache, and has no outstanding references,
//	** it is discarded. Otherwise, if there are one or more outstanding
//	** references, the page content is reloaded from the database. If the
//	** attempt to reload content from the database is required and fails,
//	** return an SQLite error code. Otherwise, SQLITE_OK.
//	*/
func _pagerUndoCallback(tls *libc.TLS, pCtx uintptr, iPg TPgno) (r int32) {
	var pPager, pPg uintptr
	var rc int32
	_, _, _ = pPager, pPg, rc
	rc = SQLITE_OK
	pPager = pCtx
	pPg = _sqlite3PagerLookup(tls, pPager, iPg)
	if pPg != 0 {
		if _sqlite3PcachePageRefcount(tls, pPg) == int64(1) {
			_sqlite3PcacheDrop(tls, pPg)
		} else {
			rc = _readDbPage(tls, pPg)
			if rc == SQLITE_OK {
				(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TPager)(unsafe.Pointer(pPager)).FxReiniter})))(tls, pPg)
			}
			_sqlite3PagerUnrefNotNull(tls, pPg)
		}
	}
	/* Normally, if a transaction is rolled back, any backup processes are
	 ** updated as data is copied out of the rollback journal and into the
	 ** database. This is not generally possible with a WAL database, as
	 ** rollback involves simply truncating the log file. Therefore, if one
	 ** or more frames have already been written to the log (and therefore
	 ** also copied into the backup databases) as part of this transaction,
	 ** the backups must be restarted.
	 */
	_sqlite3BackupRestart(tls, (*TPager)(unsafe.Pointer(pPager)).FpBackup)
	return rc
}

// C documentation
//
//	/*
//	** If the reference count has reached zero, rollback any active
//	** transaction and unlock the pager.
//	**
//	** Except, in locking_mode=EXCLUSIVE when there is nothing to in
//	** the rollback journal, the unlock is not performed and there is
//	** nothing to rollback, so this routine is a no-op.
//	*/
func _pagerUnlockIfUnused(tls *libc.TLS, pPager uintptr) {
	if _sqlite3PcacheRefCount(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache) == 0 {
		/* because page1 is never memory mapped */
		_pagerUnlockAndRollback(tls, pPager)
	}
}

// C documentation
//
//	/*
//	** Parameter aData must point to a buffer of pPager->pageSize bytes
//	** of data. Compute and return a checksum based on the contents of the
//	** page of data and the current value of pPager->cksumInit.
//	**
//	** This is not a real checksum. It is really just the sum of the
//	** random initial value (pPager->cksumInit) and every 200th byte
//	** of the page data, starting with byte offset (pPager->pageSize%200).
//	** Each byte is interpreted as an 8-bit unsigned integer.
//	**
//	** Changing the formula used to compute this checksum results in an
//	** incompatible journal file format.
//	**
//	** If journal corruption occurs due to a power failure, the most likely
//	** scenario is that one end or the other of the record will be changed.
//	** It is much less likely that the two ends of the journal record will be
//	** correct and the middle be corrupt.  Thus, this "checksum" scheme,
//	** though fast and simple, catches the mostly likely kind of corruption.
//	*/
func _pager_cksum(tls *libc.TLS, pPager uintptr, aData uintptr) (r Tu32) {
	var cksum Tu32
	var i int32
	_, _ = cksum, i
	cksum = (*TPager)(unsafe.Pointer(pPager)).FcksumInit                /* Checksum value to return */
	i = int32((*TPager)(unsafe.Pointer(pPager)).FpageSize - int64(200)) /* Loop counter */
	for i > 0 {
		cksum = cksum + uint32(**(**Tu8)(__ccgo_up(aData + uintptr(i))))
		i = i - int32(200)
	}
	return cksum
}

// C documentation
//
//	/*
//	** This function is called whenever an IOERR or FULL error that requires
//	** the pager to transition into the ERROR state may have occurred.
//	** The first argument is a pointer to the pager structure, the second
//	** the error-code about to be returned by a pager API function. The
//	** value returned is a copy of the second argument to this function.
//	**
//	** If the second argument is SQLITE_FULL, SQLITE_IOERR or one of the
//	** IOERR sub-codes, the pager enters the ERROR state and the error code
//	** is stored in Pager.errCode. While the pager remains in the ERROR state,
//	** all major API calls on the Pager will immediately return Pager.errCode.
//	**
//	** The ERROR state indicates that the contents of the pager-cache
//	** cannot be trusted. This state can be cleared by completely discarding
//	** the contents of the pager-cache. If a transaction was active when
//	** the persistent error occurred, then the rollback journal may need
//	** to be replayed to restore the contents of the database file (as if
//	** it were a hot-journal).
//	*/
func _pager_error(tls *libc.TLS, pPager uintptr, rc int32) (r int32) {
	var rc2 int32
	_ = rc2
	rc2 = rc & int32(0xff)
	if rc2 == int32(SQLITE_FULL) || rc2 == int32(SQLITE_IOERR) {
		(*TPager)(unsafe.Pointer(pPager)).FerrCode = rc
		(*TPager)(unsafe.Pointer(pPager)).FeState = uint8(PAGER_ERROR)
		_setGetterMethod(tls, pPager)
	}
	return rc
}

// C documentation
//
//	/*
//	** Discard the entire contents of the in-memory page-cache.
//	*/
func _pager_reset(tls *libc.TLS, pPager uintptr) {
	(*TPager)(unsafe.Pointer(pPager)).FiDataVersion = (*TPager)(unsafe.Pointer(pPager)).FiDataVersion + 1
	_sqlite3BackupRestart(tls, (*TPager)(unsafe.Pointer(pPager)).FpBackup)
	_sqlite3PcacheClear(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache)
}

// C documentation
//
//	/*
//	** Try to obtain a lock of type locktype on the database file. If
//	** a similar or greater lock is already held, this function is a no-op
//	** (returning SQLITE_OK immediately).
//	**
//	** Otherwise, attempt to obtain the lock using sqlite3OsLock(). Invoke
//	** the busy callback if the lock is currently not available. Repeat
//	** until the busy callback returns false or until the attempt to
//	** obtain the lock succeeds.
//	**
//	** Return SQLITE_OK on success and an error code if we cannot obtain
//	** the lock. If the lock is obtained successfully, set the Pager.state
//	** variable to locktype before returning.
//	*/
func _pager_wait_on_lock(tls *libc.TLS, pPager uintptr, locktype int32) (r int32) {
	var rc int32
	_ = rc /* Return code */
	/* Check that this is either a no-op (because the requested lock is
	 ** already held), or one of the transitions that the busy-handler
	 ** may be invoked during, according to the comment above
	 ** sqlite3PagerSetBusyhandler().
	 */
	for cond := true; cond; cond = rc == int32(SQLITE_BUSY) && (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TPager)(unsafe.Pointer(pPager)).FxBusyHandler})))(tls, (*TPager)(unsafe.Pointer(pPager)).FpBusyHandlerArg) != 0 {
		rc = _pagerLockDb(tls, pPager, locktype)
	}
	return rc
}

/*
** Function assertTruncateConstraint(pPager) checks that one of the
** following is true for all dirty pages currently in the page-cache:
**
**   a) The page number is less than or equal to the size of the
**      current database image, in pages, OR
**
**   b) if the page content were written at this time, it would not
**      be necessary to write the current content out to the sub-journal.
**
** If the condition asserted by this function were not true, and the
** dirty page were to be discarded from the cache via the pagerStress()
** routine, pagerStress() would not write the current page content to
** the database file. If a savepoint transaction were rolled back after
** this happened, the correct behavior would be to restore the current
** content of the page. However, since this content is not present in either
** the database file or the portion of the rollback journal and
** sub-journal rolled back the content could not be restored and the
** database image would become corrupt. It is therefore fortunate that
** this circumstance cannot arise.
 */

// C documentation
//
//	/*
//	** Write mapping (iNode->iPar) to the <rtree>_parent table.
//	*/
func _parentWrite(tls *libc.TLS, pRtree uintptr, iNode Tsqlite3_int64, iPar Tsqlite3_int64) (r int32) {
	Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteParent, int32(1), iNode)
	Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteParent, int32(2), iPar)
	Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteParent)
	return Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteParent)
}

func _parserStackFree(tls *libc.TLS, pOld uintptr, pParse uintptr) {
	_ = pParse
	Xsqlite3_free(tls, pOld)
}

func _pcache1Fetch(tls *libc.TLS, p uintptr, iKey uint32, createFlag int32) (r uintptr) {
	var pCache uintptr
	_ = pCache
	pCache = p
	if (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex != 0 {
		return _pcache1FetchWithMutex(tls, p, iKey, createFlag)
	} else {
		return _pcache1FetchNoMutex(tls, p, iKey, createFlag)
	}
	return r
}

func _pcache1FetchWithMutex(tls *libc.TLS, p uintptr, iKey uint32, createFlag int32) (r uintptr) {
	var pCache, pPage uintptr
	_, _ = pCache, pPage
	pCache = p
	Xsqlite3_mutex_enter(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex)
	pPage = _pcache1FetchNoMutex(tls, p, iKey, createFlag)
	Xsqlite3_mutex_leave(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex)
	return pPage
}

// C documentation
//
//	/*
//	** Free a page object allocated by pcache1AllocPage().
//	*/
func _pcache1FreePage(tls *libc.TLS, p uintptr) {
	var pCache uintptr
	_ = pCache
	pCache = (*TPgHdr1)(unsafe.Pointer(p)).FpCache
	if (*TPgHdr1)(unsafe.Pointer(p)).FisBulkLocal != 0 {
		(*TPgHdr1)(unsafe.Pointer(p)).FpNext = (*TPCache1)(unsafe.Pointer(pCache)).FpFree
		(*TPCache1)(unsafe.Pointer(pCache)).FpFree = p
	} else {
		_pcache1Free(tls, (*TPgHdr1)(unsafe.Pointer(p)).Fpage.FpBuf)
	}
	**(**uint32)(__ccgo_up((*TPCache1)(unsafe.Pointer(pCache)).FpnPurgeable)) = **(**uint32)(__ccgo_up((*TPCache1)(unsafe.Pointer(pCache)).FpnPurgeable)) - 1
}

// C documentation
//
//	/*
//	** Return the size of a pcache allocation
//	*/
func _pcache1MemSize(tls *libc.TLS, p uintptr) (r int32) {
	var iSize int32
	_ = iSize
	if p >= _pcache1_g.FpStart && p < _pcache1_g.FpEnd {
		return _pcache1_g.FszSlot
	} else {
		iSize = _sqlite3MallocSize(tls, p)
		return iSize
	}
	return r
}

// C documentation
//
//	/*
//	** This function is used internally to remove the page pPage from the
//	** PGroup LRU list, if is part of it. If pPage is not part of the PGroup
//	** LRU list, then this function is a no-op.
//	**
//	** The PGroup mutex must be held when this function is called.
//	*/
func _pcache1PinPage(tls *libc.TLS, pPage uintptr) (r uintptr) {
	(*TPgHdr1)(unsafe.Pointer((*TPgHdr1)(unsafe.Pointer(pPage)).FpLruPrev)).FpLruNext = (*TPgHdr1)(unsafe.Pointer(pPage)).FpLruNext
	(*TPgHdr1)(unsafe.Pointer((*TPgHdr1)(unsafe.Pointer(pPage)).FpLruNext)).FpLruPrev = (*TPgHdr1)(unsafe.Pointer(pPage)).FpLruPrev
	(*TPgHdr1)(unsafe.Pointer(pPage)).FpLruNext = uintptr(0)
	/* pPage->pLruPrev = 0;
	 ** No need to clear pLruPrev as it is never accessed if pLruNext is 0 */
	(*TPCache1)(unsafe.Pointer((*TPgHdr1)(unsafe.Pointer(pPage)).FpCache)).FnRecyclable = (*TPCache1)(unsafe.Pointer((*TPgHdr1)(unsafe.Pointer(pPage)).FpCache)).FnRecyclable - 1
	return pPage
}

// C documentation
//
//	/*
//	** Implementation of the sqlite3_pcache.xShrink method.
//	**
//	** Free up as much memory as possible.
//	*/
func _pcache1Shrink(tls *libc.TLS, p uintptr) {
	var pCache, pGroup uintptr
	var savedMaxPage uint32
	_, _, _ = pCache, pGroup, savedMaxPage
	pCache = p
	if (*TPCache1)(unsafe.Pointer(pCache)).FbPurgeable != 0 {
		pGroup = (*TPCache1)(unsafe.Pointer(pCache)).FpGroup
		Xsqlite3_mutex_enter(tls, (*TPGroup)(unsafe.Pointer(pGroup)).Fmutex)
		savedMaxPage = (*TPGroup)(unsafe.Pointer(pGroup)).FnMaxPage
		(*TPGroup)(unsafe.Pointer(pGroup)).FnMaxPage = uint32(0)
		_pcache1EnforceMaxPage(tls, pCache)
		(*TPGroup)(unsafe.Pointer(pGroup)).FnMaxPage = savedMaxPage
		Xsqlite3_mutex_leave(tls, (*TPGroup)(unsafe.Pointer(pGroup)).Fmutex)
	}
}

// C documentation
//
//	/*
//	** Implementation of the sqlite3_pcache.xTruncate method.
//	**
//	** Discard all unpinned pages in the cache with a page number equal to
//	** or greater than parameter iLimit. Any pinned pages with a page number
//	** equal to or greater than iLimit are implicitly unpinned.
//	*/
func _pcache1Truncate(tls *libc.TLS, p uintptr, iLimit uint32) {
	var pCache uintptr
	_ = pCache
	pCache = p
	Xsqlite3_mutex_enter(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex)
	if iLimit <= (*TPCache1)(unsafe.Pointer(pCache)).FiMaxKey {
		_pcache1TruncateUnsafe(tls, pCache, iLimit)
		(*TPCache1)(unsafe.Pointer(pCache)).FiMaxKey = iLimit - uint32(1)
	}
	Xsqlite3_mutex_leave(tls, (*TPGroup)(unsafe.Pointer((*TPCache1)(unsafe.Pointer(pCache)).FpGroup)).Fmutex)
}

// C documentation
//
//	/*
//	** Global data used by this cache.
//	*/
var _pcache1_g TPCacheGlobal

/*
** All code in this file should access the global structure above via the
** alias "pcache1". This ensures that the WSD emulation is used when
** compiling for systems that do not support real WSD.
 */

/*
** Macros to enter and leave the PCache LRU mutex.
 */

/******************************************************************************/
/******** Page Allocation/SQLITE_CONFIG_PCACHE Related Functions **************/

// C documentation
//
//	/*
//	** Wrapper around the pluggable caches xUnpin method. If the cache is
//	** being used for an in-memory database, this function is a no-op.
//	*/
func _pcacheUnpin(tls *libc.TLS, p uintptr) {
	if (*TPCache)(unsafe.Pointer((*TPgHdr)(unsafe.Pointer(p)).FpCache)).FbPurgeable != 0 {
		(*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxUnpin})))(tls, (*TPCache)(unsafe.Pointer((*TPgHdr)(unsafe.Pointer(p)).FpCache)).FpCache, (*TPgHdr)(unsafe.Pointer(p)).FpPage, 0)
	}
}

func _percent_rankInvFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
	var p uintptr
	_ = p
	_ = nArg
	_ = apArg
	p = Xsqlite3_aggregate_context(tls, pCtx, int32(24))
	(*TCallCount)(unsafe.Pointer(p)).FnStep = (*TCallCount)(unsafe.Pointer(p)).FnStep + 1
}

// C documentation
//
//	/*
//	** Implementation of built-in window function percent_rank(). Assumes that
//	** the window frame has been set to:
//	**
//	**   GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
//	*/
func _percent_rankStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
	var p uintptr
	_ = p
	_ = nArg
	_ = apArg
	p = Xsqlite3_aggregate_context(tls, pCtx, int32(24))
	if p != 0 {
		(*TCallCount)(unsafe.Pointer(p)).FnTotal = (*TCallCount)(unsafe.Pointer(p)).FnTotal + 1
	}
}

func _percent_rankValueFunc(tls *libc.TLS, pCtx uintptr) {
	var p uintptr
	var r float64
	_, _ = p, r
	p = Xsqlite3_aggregate_context(tls, pCtx, int32(24))
	if p != 0 {
		(*TCallCount)(unsafe.Pointer(p)).FnValue = (*TCallCount)(unsafe.Pointer(p)).FnStep
		if (*TCallCount)(unsafe.Pointer(p)).FnTotal > int64(1) {
			r = float64((*TCallCount)(unsafe.Pointer(p)).FnValue) / float64((*TCallCount)(unsafe.Pointer(p)).FnTotal-libc.Int64FromInt32(1))
			Xsqlite3_result_double(tls, pCtx, r)
		} else {
			Xsqlite3_result_double(tls, pCtx, float64(0))
		}
	}
}

// C documentation
//
//	/*
//	** For any p between -348 and +347, return the integer part of
//	**
//	**    pow(10,p) * pow(2,63-pow10to2(p))
//	**
//	** Or, in other words, for any p in range, return the most significant
//	** 64 bits of pow(10,p).  The pow(10,p) value is shifted left or right,
//	** as appropriate so the most significant 64 bits fit exactly into a
//	** 64-bit unsigned integer.
//	**
//	** Write into *pLo the next 32 significant bits of the answer after
//	** the first 64.
//	**
//	** Algorithm:
//	**
//	** (1) For p between 0 and 26, return the value directly from the aBase[]
//	**     lookup table.
//	**
//	** (2) For p outside the range 0 to 26, use aScale[] for the initial value
//	**     then refine that result (if necessary) by a single multiplication
//	**     against aBase[].
//	**
//	** The constant tables aBase[], aScale[], and aScaleLo[] are generated
//	** by the C program at ../tool/mkfptab.c run with the --round option.
//	*/
func _powerOfTen(tls *libc.TLS, p int32, pLo uintptr) (r Tu64) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var g, n int32
	var s, x Tu64
	var _ /* lo at bp+0 */ Tu32
	_, _, _, _ = g, n, s, x
	if p < 0 {
		if p == -int32(1) {
			**(**Tu32)(__ccgo_up(pLo)) = _aScaleLo[int32(13)]
			return _aScale[int32(13)]
		}
		g = p / int32(27)
		n = p % int32(27)
		if n != 0 {
			g = g - 1
			n = n + int32(27)
		}
	} else {
		if p < int32(27) {
			**(**Tu32)(__ccgo_up(pLo)) = uint32(0)
			return _aBase[p]
		} else {
			g = p / int32(27)
			n = p % int32(27)
		}
	}
	s = _aScale[g+int32(13)]
	if n == 0 {
		**(**Tu32)(__ccgo_up(pLo)) = _aScaleLo[g+int32(13)]
		return s
	}
	x = _sqlite3Multiply160(tls, s, _aScaleLo[g+int32(13)], _aBase[n], bp)
	if libc.Uint64FromInt32(1)<<libc.Int32FromInt32(63)&x == uint64(0) {
		x = x<<int32(1) | uint64(**(**Tu32)(__ccgo_up(bp))>>libc.Int32FromInt32(31)&libc.Uint32FromInt32(1))
		**(**Tu32)(__ccgo_up(bp)) = **(**Tu32)(__ccgo_up(bp))<<libc.Int32FromInt32(1) | uint32(1)
	}
	**(**Tu32)(__ccgo_up(pLo)) = **(**Tu32)(__ccgo_up(bp))
	return x
}

// C documentation
//
//	/* Close a pragma virtual table cursor */
func _pragmaVtabClose(tls *libc.TLS, cur uintptr) (r int32) {
	var pCsr uintptr
	_ = pCsr
	pCsr = cur
	_pragmaVtabCursorClear(tls, pCsr)
	Xsqlite3_free(tls, pCsr)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Pragma virtual table module xDisconnect method.
//	*/
func _pragmaVtabDisconnect(tls *libc.TLS, pVtab uintptr) (r int32) {
	var pTab uintptr
	_ = pTab
	pTab = pVtab
	Xsqlite3_free(tls, pTab)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Pragma virtual table module xEof method.
//	*/
func _pragmaVtabEof(tls *libc.TLS, pVtabCursor uintptr) (r int32) {
	var pCsr uintptr
	_ = pCsr
	pCsr = pVtabCursor
	return libc.BoolInt32((*TPragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma == uintptr(0))
}

// C documentation
//
//	/* The pragma virtual table object */
var _pragmaVtabModule = Tsqlite3_module{}

// C documentation
//
//	/* Advance the pragma virtual table cursor to the next row */
func _pragmaVtabNext(tls *libc.TLS, pVtabCursor uintptr) (r int32) {
	var pCsr uintptr
	var rc int32
	_, _ = pCsr, rc
	pCsr = pVtabCursor
	rc = SQLITE_OK
	/* Increment the xRowid value */
	(*TPragmaVtabCursor)(unsafe.Pointer(pCsr)).FiRowid = (*TPragmaVtabCursor)(unsafe.Pointer(pCsr)).FiRowid + 1
	if int32(SQLITE_ROW) != Xsqlite3_step(tls, (*TPragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma) {
		rc = Xsqlite3_finalize(tls, (*TPragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma)
		(*TPragmaVtabCursor)(unsafe.Pointer(pCsr)).FpPragma = uintptr(0)
		_pragmaVtabCursorClear(tls, pCsr)
	}
	return rc
}

// C documentation
//
//	/*
//	** Pragma virtual table module xRowid method.
//	*/
func _pragmaVtabRowid(tls *libc.TLS, pVtabCursor uintptr, p uintptr) (r int32) {
	var pCsr uintptr
	_ = pCsr
	pCsr = pVtabCursor
	**(**Tsqlite_int64)(__ccgo_up(p)) = (*TPragmaVtabCursor)(unsafe.Pointer(pCsr)).FiRowid
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Unless it is NULL, argument zSql points to a buffer allocated using
//	** sqlite3_malloc containing an SQL statement. This function prepares the SQL
//	** statement against database db and frees the buffer. If statement
//	** compilation is successful, *ppStmt is set to point to the new statement
//	** handle and SQLITE_OK is returned.
//	**
//	** Otherwise, if an error occurs, *ppStmt is set to NULL and an error code
//	** returned. In this case, *pzErrmsg may also be set to point to an error
//	** message. It is the responsibility of the caller to free this error message
//	** buffer using sqlite3_free().
//	**
//	** If argument zSql is NULL, this function assumes that an OOM has occurred.
//	** In this case SQLITE_NOMEM is returned and *ppStmt set to NULL.
//	*/
func _prepareFreeAndCollectError(tls *libc.TLS, db uintptr, ppStmt uintptr, pzErrmsg uintptr, zSql uintptr) (r int32) {
	var rc int32
	_ = rc
	if zSql == uintptr(0) {
		rc = int32(SQLITE_NOMEM)
		**(**uintptr)(__ccgo_up(ppStmt)) = uintptr(0)
	} else {
		rc = _prepareAndCollectError(tls, db, ppStmt, pzErrmsg, zSql)
		Xsqlite3_free(tls, zSql)
	}
	return rc
}

// C documentation
//
//	/*
//	** This function is called to determine whether or not it is safe to
//	** push WHERE clause expression pExpr down to FROM clause sub-query
//	** pSubq, which contains at least one window function. Return 1
//	** if it is safe and the expression should be pushed down, or 0
//	** otherwise.
//	**
//	** It is only safe to push the expression down if it consists only
//	** of constants and copies of expressions that appear in the PARTITION
//	** BY clause of all window function used by the sub-query. It is safe
//	** to filter out entire partitions, but not rows within partitions, as
//	** this may change the results of the window functions.
//	**
//	** At the time this function is called it is guaranteed that
//	**
//	**   * the sub-query uses only one distinct window frame, and
//	**   * that the window frame has a PARTITION BY clause.
//	*/
func _pushDownWindowCheck(tls *libc.TLS, pParse uintptr, pSubq uintptr, pExpr uintptr) (r int32) {
	return _sqlite3ExprIsConstantOrGroupBy(tls, pParse, pExpr, (*TWindow)(unsafe.Pointer((*TSelect)(unsafe.Pointer(pSubq)).FpWin)).FpPartition)
}

// C documentation
//
//	/*
//	** Write a 64-bit variable-length integer to memory starting at p[0].
//	** The length of data write will be between 1 and 9 bytes.  The number
//	** of bytes written is returned.
//	**
//	** A variable-length integer consists of the lower 7 bits of each byte
//	** for all bytes that have the 8th bit set and one byte with the 8th
//	** bit clear.  Except, if we get to the 9th byte, it stores the full
//	** 8 bits and is the last byte.
//	*/
func _putVarint64(tls *libc.TLS, p uintptr, v Tu64) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var i, j, n, v2 int32
	var v3 uintptr
	var _ /* buf at bp+0 */ [10]Tu8
	_, _, _, _, _ = i, j, n, v2, v3
	if v&(libc.Uint64FromUint32(0xff000000)<<libc.Int32FromInt32(32)) != 0 {
		**(**uint8)(__ccgo_up(p + 8)) = uint8(v)
		v = v >> uint64(8)
		i = int32(7)
		for {
			if !(i >= 0) {
				break
			}
			**(**uint8)(__ccgo_up(p + uintptr(i))) = uint8(v&libc.Uint64FromInt32(0x7f) | libc.Uint64FromInt32(0x80))
			v = v >> uint64(7)
			goto _1
		_1:
			;
			i = i - 1
		}
		return int32(9)
	}
	n = 0
	for cond := true; cond; cond = v != uint64(0) {
		v2 = n
		n = n + 1
		(**(**[10]Tu8)(__ccgo_up(bp)))[v2] = uint8(v&libc.Uint64FromInt32(0x7f) | libc.Uint64FromInt32(0x80))
		v = v >> uint64(7)
	}
	v3 = bp
	*(*Tu8)(unsafe.Pointer(v3)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v3))) & libc.Int32FromInt32(0x7f))
	i = 0
	j = n - libc.Int32FromInt32(1)
	for {
		if !(j >= 0) {
			break
		}
		**(**uint8)(__ccgo_up(p + uintptr(i))) = (**(**[10]Tu8)(__ccgo_up(bp)))[j]
		goto _4
	_4:
		;
		j = j - 1
		i = i + 1
	}
	return n
}

// C documentation
//
//	/*
//	** pow10to2(x) computes floor(log2(pow(10,x))).
//	** pow2to10(y) computes floor(log10(pow(2,y))).
//	**
//	** Conceptually, pow10to2(p) converts a base-10 exponent p into
//	** a corresponding base-2 exponent, and pow2to10(e) converts a base-2
//	** exponent into a base-10 exponent.
//	**
//	** The conversions are based on the observation that:
//	**
//	**     ln(10.0)/ln(2.0) == 108853/32768     (approximately)
//	**     ln(2.0)/ln(10.0) == 78913/262144     (approximately)
//	**
//	** These ratios are approximate, but they are accurate to 5 digits,
//	** which is close enough for the usage here.  Right-shift is used
//	** for division so that rounding of negative numbers happens in the
//	** right direction.
//	*/
func _pwr10to2(tls *libc.TLS, p int32) (r int32) {
	return p * int32(108853) >> int32(15)
}

func _pwr2to10(tls *libc.TLS, p int32) (r int32) {
	return p * int32(78913) >> int32(18)
}

// C documentation
//
//	/*
//	** Implementation of randomblob(N).  Return a random blob
//	** that is N bytes long.
//	*/
func _randomBlob(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
	var n Tsqlite3_int64
	var p uintptr
	_, _ = n, p
	_ = argc
	n = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv)))
	if n < int64(1) {
		n = int64(1)
	}
	p = _contextMalloc(tls, context, n)
	if p != 0 {
		Xsqlite3_randomness(tls, int32(n), p)
		Xsqlite3_result_blob(tls, context, p, int32(n), __ccgo_fp(Xsqlite3_free))
	}
}

// C documentation
//
//	/*
//	** Implementation of random().  Return a random integer.
//	*/
func _randomFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var _ /* r at bp+0 */ Tsqlite_int64
	_ = NotUsed
	_ = NotUsed2
	Xsqlite3_randomness(tls, int32(8), bp)
	if **(**Tsqlite_int64)(__ccgo_up(bp)) < 0 {
		/* We need to prevent a random number of 0x8000000000000000
		 ** (or -9223372036854775808) since when you do abs() of that
		 ** number of you get the same value back again.  To do this
		 ** in a way that is testable, mask the sign bit off of negative
		 ** values, resulting in a positive value.  Then take the
		 ** 2s complement of that positive value.  The end result can
		 ** therefore be no less than -9223372036854775807.
		 */
		**(**Tsqlite_int64)(__ccgo_up(bp)) = -(**(**Tsqlite_int64)(__ccgo_up(bp)) & (libc.Int64FromUint32(0xffffffff) | libc.Int64FromInt32(0x7fffffff)<<libc.Int32FromInt32(32)))
	}
	Xsqlite3_result_int64(tls, context, **(**Tsqlite_int64)(__ccgo_up(bp)))
}

// C documentation
//
//	/*
//	** Implementation of built-in window function rank(). Assumes that
//	** the window frame has been set to:
//	**
//	**   RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
//	*/
func _rankStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
	var p uintptr
	_ = p
	p = Xsqlite3_aggregate_context(tls, pCtx, int32(24))
	if p != 0 {
		(*TCallCount)(unsafe.Pointer(p)).FnStep = (*TCallCount)(unsafe.Pointer(p)).FnStep + 1
		if (*TCallCount)(unsafe.Pointer(p)).FnValue == 0 {
			(*TCallCount)(unsafe.Pointer(p)).FnValue = (*TCallCount)(unsafe.Pointer(p)).FnStep
		}
	}
	_ = nArg
	_ = apArg
}

func _rankValueFunc(tls *libc.TLS, pCtx uintptr) {
	var p uintptr
	_ = p
	p = Xsqlite3_aggregate_context(tls, pCtx, int32(24))
	if p != 0 {
		Xsqlite3_result_int64(tls, pCtx, (*TCallCount)(unsafe.Pointer(p)).FnValue)
		(*TCallCount)(unsafe.Pointer(p)).FnValue = 0
	}
}

// C documentation
//
//	/*
//	** Destroy the private VFS created for the rbu handle passed as the only
//	** argument by an earlier call to rbuCreateVfs().
//	*/
func _rbuDeleteVfs(tls *libc.TLS, p uintptr) {
	if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzVfsName != 0 {
		Xsqlite3rbu_destroy_vfs(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzVfsName)
		(*Tsqlite3rbu)(unsafe.Pointer(p)).FzVfsName = uintptr(0)
	}
}

// C documentation
//
//	/*
//	** This routine is a copy of the sqlite3FileSuffix3() routine from the core.
//	** It is a no-op unless SQLITE_ENABLE_8_3_NAMES is defined.
//	**
//	** If SQLITE_ENABLE_8_3_NAMES is set at compile-time and if the database
//	** filename in zBaseFilename is a URI with the "8_3_names=1" parameter and
//	** if filename in z[] has a suffix (a.k.a. "extension") that is longer than
//	** three characters, then shorten the suffix on z[] to be the last three
//	** characters of the original suffix.
//	**
//	** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always
//	** do the suffix shortening regardless of URI parameter.
//	**
//	** Examples:
//	**
//	**     test.db-journal    =>   test.nal
//	**     test.db-wal        =>   test.wal
//	**     test.db-shm        =>   test.shm
//	**     test.db-mj7f3319fa =>   test.9fa
//	*/
func _rbuFileSuffix3(tls *libc.TLS, zBase uintptr, z uintptr) {
	_ = zBase
	_ = z
}

// C documentation
//
//	/*
//	** Given that zWal points to a buffer containing a wal file name passed to
//	** either the xOpen() or xAccess() VFS method, search the main-db list for
//	** a file-handle opened by the same database connection on the corresponding
//	** database file.
//	**
//	** If parameter bRbu is true, only search for file-descriptors with
//	** rbu_file.pDb!=0.
//	*/
func _rbuFindMaindb(tls *libc.TLS, pRbuVfs uintptr, zWal uintptr, bRbu int32) (r uintptr) {
	var pDb uintptr
	_ = pDb
	Xsqlite3_mutex_enter(tls, (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).Fmutex)
	if bRbu != 0 {
		pDb = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMainRbu
		for {
			if !(pDb != 0 && (*Trbu_file)(unsafe.Pointer(pDb)).FzWal != zWal) {
				break
			}
			goto _1
		_1:
			;
			pDb = (*Trbu_file)(unsafe.Pointer(pDb)).FpMainRbuNext
		}
	} else {
		pDb = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMain
		for {
			if !(pDb != 0 && (*Trbu_file)(unsafe.Pointer(pDb)).FzWal != zWal) {
				break
			}
			goto _2
		_2:
			;
			pDb = (*Trbu_file)(unsafe.Pointer(pDb)).FpMainNext
		}
	}
	Xsqlite3_mutex_leave(tls, (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).Fmutex)
	return pDb
}

// C documentation
//
//	/*
//	** Free an RbuState object allocated by rbuLoadState().
//	*/
func _rbuFreeState(tls *libc.TLS, p uintptr) {
	if p != 0 {
		Xsqlite3_free(tls, (*TRbuState)(unsafe.Pointer(p)).FzTbl)
		Xsqlite3_free(tls, (*TRbuState)(unsafe.Pointer(p)).FzDataTbl)
		Xsqlite3_free(tls, (*TRbuState)(unsafe.Pointer(p)).FzIdx)
		Xsqlite3_free(tls, p)
	}
}

// C documentation
//
//	/*
//	** Read and return an unsigned 32-bit big-endian integer from the buffer
//	** passed as the only argument.
//	*/
func _rbuGetU32(tls *libc.TLS, aBuf uintptr) (r Tu32) {
	return uint32(**(**Tu8)(__ccgo_up(aBuf)))<<libc.Int32FromInt32(24) + uint32(**(**Tu8)(__ccgo_up(aBuf + 1)))<<libc.Int32FromInt32(16) + uint32(**(**Tu8)(__ccgo_up(aBuf + 2)))<<libc.Int32FromInt32(8) + uint32(**(**Tu8)(__ccgo_up(aBuf + 3)))
}

// C documentation
//
//	/*
//	** This is a wrapper around "sqlite3_mprintf(zFmt, ...)". If an OOM occurs,
//	** an error code is stored in the RBU handle passed as the first argument.
//	**
//	** If an error has already occurred (p->rc is already set to something other
//	** than SQLITE_OK), then this function returns NULL without modifying the
//	** stored error code. In this case it still calls sqlite3_free() on any
//	** printf() parameters associated with %z conversions.
//	*/
func _rbuMPrintf(tls *libc.TLS, p uintptr, zFmt uintptr, va uintptr) (r uintptr) {
	var ap Tva_list
	var zSql uintptr
	_, _ = ap, zSql
	zSql = uintptr(0)
	ap = va
	zSql = Xsqlite3_vmprintf(tls, zFmt, ap)
	if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
		if zSql == uintptr(0) {
			(*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM)
		}
	} else {
		Xsqlite3_free(tls, zSql)
		zSql = uintptr(0)
	}
	_ = ap
	return zSql
}

// C documentation
//
//	/*
//	** Add an item to the main-db lists, if it is not already present.
//	**
//	** There are two main-db lists. One for all file descriptors, and one
//	** for all file descriptors with rbu_file.pDb!=0. If the argument has
//	** rbu_file.pDb!=0, then it is assumed to already be present on the
//	** main list and is only added to the pDb!=0 list.
//	*/
func _rbuMainlistAdd(tls *libc.TLS, p uintptr) {
	var pIter, pRbuVfs uintptr
	_, _ = pIter, pRbuVfs
	pRbuVfs = (*Trbu_file)(unsafe.Pointer(p)).FpRbuVfs
	Xsqlite3_mutex_enter(tls, (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).Fmutex)
	if (*Trbu_file)(unsafe.Pointer(p)).FpRbu == uintptr(0) {
		pIter = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMain
		for {
			if !(pIter != 0) {
				break
			}
			goto _1
		_1:
			;
			pIter = (*Trbu_file)(unsafe.Pointer(pIter)).FpMainNext
		}
		(*Trbu_file)(unsafe.Pointer(p)).FpMainNext = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMain
		(*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMain = p
	} else {
		pIter = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMainRbu
		for {
			if !(pIter != 0 && pIter != p) {
				break
			}
			goto _2
		_2:
			;
			pIter = (*Trbu_file)(unsafe.Pointer(pIter)).FpMainRbuNext
		}
		if pIter == uintptr(0) {
			(*Trbu_file)(unsafe.Pointer(p)).FpMainRbuNext = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMainRbu
			(*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpMainRbu = p
		}
	}
	Xsqlite3_mutex_leave(tls, (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).Fmutex)
}

// C documentation
//
//	/*
//	** Finalize all statements and free all allocations that are specific to
//	** the current object (table/index pair).
//	*/
func _rbuObjIterClearStatements(tls *libc.TLS, pIter uintptr) {
	var pTmp, pUp uintptr
	_, _ = pTmp, pUp
	Xsqlite3_finalize(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect)
	Xsqlite3_finalize(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpInsert)
	Xsqlite3_finalize(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpDelete)
	Xsqlite3_finalize(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FpTmpInsert)
	pUp = (*TRbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate
	for pUp != 0 {
		pTmp = (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpNext
		Xsqlite3_finalize(tls, (*TRbuUpdateStmt)(unsafe.Pointer(pUp)).FpUpdate)
		Xsqlite3_free(tls, pUp)
		pUp = pTmp
	}
	Xsqlite3_free(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol)
	Xsqlite3_free(tls, (*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdxSql)
	(*TRbuObjIter)(unsafe.Pointer(pIter)).FpSelect = uintptr(0)
	(*TRbuObjIter)(unsafe.Pointer(pIter)).FpInsert = uintptr(0)
	(*TRbuObjIter)(unsafe.Pointer(pIter)).FpDelete = uintptr(0)
	(*TRbuObjIter)(unsafe.Pointer(pIter)).FpRbuUpdate = uintptr(0)
	(*TRbuObjIter)(unsafe.Pointer(pIter)).FpTmpInsert = uintptr(0)
	(*TRbuObjIter)(unsafe.Pointer(pIter)).FnCol = 0
	(*TRbuObjIter)(unsafe.Pointer(pIter)).FnIdxCol = 0
	(*TRbuObjIter)(unsafe.Pointer(pIter)).FaIdxCol = uintptr(0)
	(*TRbuObjIter)(unsafe.Pointer(pIter)).FzIdxSql = uintptr(0)
}

// C documentation
//
//	/*
//	** Write an unsigned 32-bit value in big-endian format to the supplied
//	** buffer.
//	*/
func _rbuPutU32(tls *libc.TLS, aBuf uintptr, iVal Tu32) {
	**(**Tu8)(__ccgo_up(aBuf)) = uint8(iVal >> libc.Int32FromInt32(24) & uint32(0xFF))
	**(**Tu8)(__ccgo_up(aBuf + 1)) = uint8(iVal >> libc.Int32FromInt32(16) & uint32(0xFF))
	**(**Tu8)(__ccgo_up(aBuf + 2)) = uint8(iVal >> libc.Int32FromInt32(8) & uint32(0xFF))
	**(**Tu8)(__ccgo_up(aBuf + 3)) = uint8(iVal >> libc.Int32FromInt32(0) & uint32(0xFF))
}

// C documentation
//
//	/*
//	** The SELECT statement iterating through the keys for the current object
//	** (p->objiter.pSelect) currently points to a valid row. This function
//	** determines the type of operation requested by this row and returns
//	** one of the following values to indicate the result:
//	**
//	**     * RBU_INSERT
//	**     * RBU_DELETE
//	**     * RBU_IDX_DELETE
//	**     * RBU_UPDATE
//	**
//	** If RBU_UPDATE is returned, then output variable *pzMask is set to
//	** point to the text value indicating the columns to update.
//	**
//	** If the rbu_control field contains an invalid value, an error code and
//	** message are left in the RBU handle and zero returned.
//	*/
func _rbuStepType(tls *libc.TLS, p uintptr, pzMask uintptr) (r int32) {
	var iCol, iVal, res int32
	var z uintptr
	_, _, _, _ = iCol, iVal, res, z
	iCol = (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FnCol /* Index of rbu_control column */
	res = 0                                                 /* Return value */
	switch Xsqlite3_column_type(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpSelect, iCol) {
	case int32(SQLITE_INTEGER):
		iVal = Xsqlite3_column_int(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpSelect, iCol)
		switch iVal {
		case 0:
			res = int32(RBU_INSERT)
		case int32(1):
			res = int32(RBU_DELETE)
		case int32(2):
			res = int32(RBU_REPLACE)
		case int32(3):
			res = int32(RBU_IDX_DELETE)
		case int32(4):
			res = int32(RBU_IDX_INSERT)
			break
		}
	case int32(SQLITE_TEXT):
		z = Xsqlite3_column_text(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).Fobjiter.FpSelect, iCol)
		if z == uintptr(0) {
			(*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_NOMEM)
		} else {
			**(**uintptr)(__ccgo_up(pzMask)) = z
		}
		res = int32(RBU_UPDATE)
	default:
		break
	}
	if res == 0 {
		_rbuBadControlError(tls, p)
	}
	return res
}

// C documentation
//
//	/*
//	** Compare strings z1 and z2, returning 0 if they are identical, or non-zero
//	** otherwise. Either or both argument may be NULL. Two NULL values are
//	** considered equal, and NULL is considered distinct from all other values.
//	*/
func _rbuStrCompare(tls *libc.TLS, z1 uintptr, z2 uintptr) (r int32) {
	if z1 == uintptr(0) && z2 == uintptr(0) {
		return 0
	}
	if z1 == uintptr(0) || z2 == uintptr(0) {
		return int32(1)
	}
	return libc.BoolInt32(Xsqlite3_stricmp(tls, z1, z2) != 0)
}

// C documentation
//
//	/*
//	** Test for access permissions. Return true if the requested permission
//	** is available, or false otherwise.
//	*/
func _rbuVfsAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var pDb, pRbuVfs, pRealVfs uintptr
	var rc int32
	var _ /* sz at bp+0 */ Tsqlite3_int64
	_, _, _, _ = pDb, pRbuVfs, pRealVfs, rc
	pRbuVfs = pVfs
	pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).FpRealVfs
	rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxAccess})))(tls, pRealVfs, zPath, flags, pResOut)
	/* If this call is to check if a *-wal file associated with an RBU target
	 ** database connection exists, and the RBU update is in RBU_STAGE_OAL,
	 ** the following special handling is activated:
	 **
	 **   a) if the *-wal file does exist, return SQLITE_CANTOPEN. This
	 **      ensures that the RBU extension never tries to update a database
	 **      in wal mode, even if the first page of the database file has
	 **      been damaged.
	 **
	 **   b) if the *-wal file does not exist, claim that it does anyway,
	 **      causing SQLite to call xOpen() to open it. This call will also
	 **      be intercepted (see the rbuVfsOpen() function) and the *-oal
	 **      file opened instead.
	 */
	if rc == SQLITE_OK && flags == SQLITE_ACCESS_EXISTS {
		pDb = _rbuFindMaindb(tls, pRbuVfs, zPath, int32(1))
		if pDb != 0 && (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(pDb)).FpRbu)).FeStage == int32(RBU_STAGE_OAL) {
			if **(**int32)(__ccgo_up(pResOut)) != 0 {
				rc = int32(SQLITE_CANTOPEN)
			} else {
				**(**Tsqlite3_int64)(__ccgo_up(bp)) = 0
				rc = _rbuVfsFileSize(tls, pDb, bp)
				**(**int32)(__ccgo_up(pResOut)) = libc.BoolInt32(**(**Tsqlite3_int64)(__ccgo_up(bp)) > 0)
			}
		}
	}
	return rc
}

// C documentation
//
//	/*
//	** Check if another file-handle holds a RESERVED lock on an rbuVfs-file.
//	*/
func _rbuVfsCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) (r int32) {
	var p uintptr
	_ = p
	p = pFile
	return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxCheckReservedLock})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, pResOut)
}

// C documentation
//
//	/*
//	** Return the current time as a Julian Day number in *pTimeOut.
//	*/
func _rbuVfsCurrentTime(tls *libc.TLS, pVfs uintptr, pTimeOut uintptr) (r int32) {
	var pRealVfs uintptr
	_ = pRealVfs
	pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
	return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxCurrentTime})))(tls, pRealVfs, pTimeOut)
}

// C documentation
//
//	/*
//	** Delete the file located at zPath.
//	*/
func _rbuVfsDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) (r int32) {
	var pRealVfs uintptr
	_ = pRealVfs
	pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
	return (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxDelete})))(tls, pRealVfs, zPath, dirSync)
}

// C documentation
//
//	/*
//	** Return the device characteristic flags supported by an rbuVfs-file.
//	*/
func _rbuVfsDeviceCharacteristics(tls *libc.TLS, pFile uintptr) (r int32) {
	var p uintptr
	_ = p
	p = pFile
	return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxDeviceCharacteristics})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal)
}

// C documentation
//
//	/*
//	** Close the dynamic library handle pHandle.
//	*/
func _rbuVfsDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) {
	var pRealVfs uintptr
	_ = pRealVfs
	pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
	(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxDlClose})))(tls, pRealVfs, pHandle)
}

// C documentation
//
//	/*
//	** Populate the buffer zErrMsg (size nByte bytes) with a human readable
//	** utf-8 string describing the most recent error encountered associated
//	** with dynamic libraries.
//	*/
func _rbuVfsDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zErrMsg uintptr) {
	var pRealVfs uintptr
	_ = pRealVfs
	pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
	(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxDlError})))(tls, pRealVfs, nByte, zErrMsg)
}

// C documentation
//
//	/*
//	** Open the dynamic library located at zPath and return a handle.
//	*/
func _rbuVfsDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) (r uintptr) {
	var pRealVfs uintptr
	_ = pRealVfs
	pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
	return (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxDlOpen})))(tls, pRealVfs, zPath)
}

// C documentation
//
//	/*
//	** Return a pointer to the symbol zSymbol in the dynamic library pHandle.
//	*/
func _rbuVfsDlSym(tls *libc.TLS, pVfs uintptr, pArg uintptr, zSym uintptr) (r uintptr) {
	var pRealVfs uintptr
	_ = pRealVfs
	pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
	return (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxDlSym})))(tls, pRealVfs, pArg, zSym)
}

// C documentation
//
//	/*
//	** Return the current file-size of an rbuVfs-file.
//	*/
func _rbuVfsFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) (r int32) {
	var p uintptr
	var rc int32
	_, _ = p, rc
	p = pFile
	rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxFileSize})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, pSize)
	/* If this is an RBU vacuum operation and this is the target database,
	 ** pretend that it has at least one page. Otherwise, SQLite will not
	 ** check for the existence of a *-wal file. rbuVfsRead() contains
	 ** similar logic.  */
	if rc == SQLITE_OK && **(**Tsqlite_int64)(__ccgo_up(pSize)) == 0 && (*Trbu_file)(unsafe.Pointer(p)).FpRbu != 0 && (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpRbu)).FzTarget == uintptr(0) && (*Trbu_file)(unsafe.Pointer(p)).FopenFlags&int32(SQLITE_OPEN_MAIN_DB) != 0 {
		**(**Tsqlite_int64)(__ccgo_up(pSize)) = int64(1024)
	}
	return rc
}

// C documentation
//
//	/*
//	** Populate buffer zOut with the full canonical pathname corresponding
//	** to the pathname in zPath. zOut is guaranteed to point to a buffer
//	** of at least (DEVSYM_MAX_PATHNAME+1) bytes.
//	*/
func _rbuVfsFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) (r int32) {
	var pRealVfs uintptr
	_ = pRealVfs
	pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
	return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxFullPathname})))(tls, pRealVfs, zPath, nOut, zOut)
}

// C documentation
//
//	/*
//	** No-op.
//	*/
func _rbuVfsGetLastError(tls *libc.TLS, pVfs uintptr, a int32, b uintptr) (r int32) {
	_ = pVfs
	_ = a
	_ = b
	return 0
}

// C documentation
//
//	/*
//	** Lock an rbuVfs-file.
//	*/
func _rbuVfsLock(tls *libc.TLS, pFile uintptr, eLock int32) (r int32) {
	var p, pRbu uintptr
	var rc int32
	_, _, _ = p, pRbu, rc
	p = pFile
	pRbu = (*Trbu_file)(unsafe.Pointer(p)).FpRbu
	rc = SQLITE_OK
	if eLock == int32(SQLITE_LOCK_EXCLUSIVE) && ((*Trbu_file)(unsafe.Pointer(p)).FbNolock != 0 || pRbu != 0 && (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FeStage != int32(RBU_STAGE_DONE)) {
		/* Do not allow EXCLUSIVE locks. Preventing SQLite from taking this
		 ** prevents it from checkpointing the database from sqlite3_close(). */
		rc = int32(SQLITE_BUSY)
	} else {
		rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxLock})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, eLock)
	}
	return rc
}

// C documentation
//
//	/*
//	** Populate the buffer pointed to by zBufOut with nByte bytes of
//	** random data.
//	*/
func _rbuVfsRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) (r int32) {
	var pRealVfs uintptr
	_ = pRealVfs
	pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
	return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxRandomness})))(tls, pRealVfs, nByte, zBufOut)
}

// C documentation
//
//	/*
//	** Return the sector-size in bytes for an rbuVfs-file.
//	*/
func _rbuVfsSectorSize(tls *libc.TLS, pFile uintptr) (r int32) {
	var p uintptr
	_ = p
	p = pFile
	return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxSectorSize})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal)
}

// C documentation
//
//	/*
//	** Memory barrier.
//	*/
func _rbuVfsShmBarrier(tls *libc.TLS, pFile uintptr) {
	var p uintptr
	_ = p
	p = pFile
	(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxShmBarrier})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal)
}

// C documentation
//
//	/*
//	** The xShmUnmap method.
//	*/
func _rbuVfsShmUnmap(tls *libc.TLS, pFile uintptr, delFlag int32) (r int32) {
	var eStage, rc, v1 int32
	var p uintptr
	_, _, _, _ = eStage, p, rc, v1
	p = pFile
	rc = SQLITE_OK
	if (*Trbu_file)(unsafe.Pointer(p)).FpRbu != 0 {
		v1 = (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage
	} else {
		v1 = 0
	}
	eStage = v1
	if eStage == int32(RBU_STAGE_OAL) || eStage == int32(RBU_STAGE_MOVE) {
		/* no-op */
	} else {
		/* Release the checkpointer and writer locks */
		_rbuUnlockShm(tls, p)
		rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxShmUnmap})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, delFlag)
	}
	return rc
}

// C documentation
//
//	/*
//	** Sleep for nMicro microseconds. Return the number of microseconds
//	** actually slept.
//	*/
func _rbuVfsSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) (r int32) {
	var pRealVfs uintptr
	_ = pRealVfs
	pRealVfs = (*Trbu_vfs)(unsafe.Pointer(pVfs)).FpRealVfs
	return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pRealVfs)).FxSleep})))(tls, pRealVfs, nMicro)
}

// C documentation
//
//	/*
//	** Sync an rbuVfs-file.
//	*/
func _rbuVfsSync(tls *libc.TLS, pFile uintptr, flags int32) (r int32) {
	var p uintptr
	_ = p
	p = pFile
	if (*Trbu_file)(unsafe.Pointer(p)).FpRbu != 0 && (*Tsqlite3rbu)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpRbu)).FeStage == int32(RBU_STAGE_CAPTURE) {
		if (*Trbu_file)(unsafe.Pointer(p)).FopenFlags&int32(SQLITE_OPEN_MAIN_DB) != 0 {
			return libc.Int32FromInt32(SQLITE_NOTICE) | libc.Int32FromInt32(3)<<libc.Int32FromInt32(8)
		}
		return SQLITE_OK
	}
	return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxSync})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, flags)
}

// C documentation
//
//	/*
//	** Truncate an rbuVfs-file.
//	*/
func _rbuVfsTruncate(tls *libc.TLS, pFile uintptr, size Tsqlite_int64) (r int32) {
	var p uintptr
	var rc int32
	_, _ = p, rc
	p = pFile
	if (*Trbu_file)(unsafe.Pointer(p)).FopenFlags&int32(SQLITE_OPEN_DELETEONCLOSE) != 0 && (*Trbu_file)(unsafe.Pointer(p)).FpRbu != 0 {
		rc = _rbuUpdateTempSize(tls, p, size)
		if rc != SQLITE_OK {
			return rc
		}
	}
	return (*(*func(*libc.TLS, uintptr, Tsqlite3_int64) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxTruncate})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, size)
}

// C documentation
//
//	/*
//	** Unlock an rbuVfs-file.
//	*/
func _rbuVfsUnlock(tls *libc.TLS, pFile uintptr, eLock int32) (r int32) {
	var p uintptr
	_ = p
	p = pFile
	return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxUnlock})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, eLock)
}

// C documentation
//
//	/*
//	** Write data to an rbuVfs-file.
//	*/
func _rbuVfsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst Tsqlite_int64) (r int32) {
	var p, pBuf, pRbu uintptr
	var rc int32
	var szNew Ti64
	_, _, _, _, _ = p, pBuf, pRbu, rc, szNew
	p = pFile
	pRbu = (*Trbu_file)(unsafe.Pointer(p)).FpRbu
	if pRbu != 0 && (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == int32(RBU_STAGE_CAPTURE) {
		rc = _rbuCaptureDbWrite(tls, (*Trbu_file)(unsafe.Pointer(p)).FpRbu, iOfst)
	} else {
		if pRbu != 0 {
			if (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FeStage == int32(RBU_STAGE_OAL) && (*Trbu_file)(unsafe.Pointer(p)).FopenFlags&int32(SQLITE_OPEN_WAL) != 0 && iOfst >= (*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FiOalSz {
				(*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FiOalSz = int64(iAmt) + iOfst
			} else {
				if (*Trbu_file)(unsafe.Pointer(p)).FopenFlags&int32(SQLITE_OPEN_DELETEONCLOSE) != 0 {
					szNew = int64(iAmt) + iOfst
					if szNew > (*Trbu_file)(unsafe.Pointer(p)).Fsz {
						rc = _rbuUpdateTempSize(tls, p, szNew)
						if rc != SQLITE_OK {
							return rc
						}
					}
				}
			}
		}
		rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Tsqlite3_int64) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxWrite})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst)
		if rc == SQLITE_OK && iOfst == 0 && (*Trbu_file)(unsafe.Pointer(p)).FopenFlags&int32(SQLITE_OPEN_MAIN_DB) != 0 {
			/* These look like magic numbers. But they are stable, as they are part
			 ** of the definition of the SQLite file format, which may not change. */
			pBuf = zBuf
			(*Trbu_file)(unsafe.Pointer(p)).FiCookie = _rbuGetU32(tls, pBuf+24)
			(*Trbu_file)(unsafe.Pointer(p)).FiWriteVer = **(**Tu8)(__ccgo_up(pBuf + 19))
		}
	}
	return rc
}

var _rbuvfs_io_methods = Tsqlite3_io_methods{
	FiVersion: int32(2),
}

var _rbuvfs_io_methods1 = Tsqlite3_io_methods{
	FiVersion: int32(1),
}

// C documentation
//
//	/*
//	** Read a 32-bit integer from the given file descriptor.  Store the integer
//	** that is read in *pRes.  Return SQLITE_OK if everything worked, or an
//	** error code is something goes wrong.
//	**
//	** All values are stored on disk as big-endian.
//	*/
func _read32bits(tls *libc.TLS, fd uintptr, offset Ti64, pRes uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* ac at bp+0 */ [4]uint8
	_ = rc
	rc = _sqlite3OsRead(tls, fd, bp, int32(4), offset)
	if rc == SQLITE_OK {
		**(**Tu32)(__ccgo_up(pRes)) = _sqlite3Get4byte(tls, bp)
	}
	return rc
}

/*
** Write a 32-bit integer into a string buffer in big-endian byte order.
 */

/* Read the specified cookie value */
var _readCookie = [3]TVdbeOpList{
	0: {
		Fopcode: uint8(OP_Transaction),
	},
	1: {
		Fopcode: uint8(OP_ReadCookie),
		Fp2:     int8(1),
	},
	2: {
		Fopcode: uint8(OP_ResultRow),
		Fp1:     int8(1),
		Fp2:     int8(1),
	},
}

func _releasePage(tls *libc.TLS, pPage uintptr) {
	if pPage != 0 {
		_releasePageNotNull(tls, pPage)
	}
}

// C documentation
//
//	/*
//	** Release a MemPage.  This should be called once for each prior
//	** call to btreeGetPage.
//	**
//	** Page1 is a special case and must be released using releasePageOne().
//	*/
func _releasePageNotNull(tls *libc.TLS, pPage uintptr) {
	_sqlite3PagerUnrefNotNull(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage)
}

func _releasePageOne(tls *libc.TLS, pPage uintptr) {
	_sqlite3PagerUnrefPageOne(tls, (*TMemPage)(unsafe.Pointer(pPage)).FpDbPage)
}

// C documentation
//
//	/*
//	** Decrement the BtShared.nRef counter.  When it reaches zero,
//	** remove the BtShared structure from the sharing list.  Return
//	** true if the BtShared.nRef counter reaches zero and return
//	** false if it is still positive.
//	*/
func _removeFromSharingList(tls *libc.TLS, pBt uintptr) (r int32) {
	var pList, pMainMtx uintptr
	var removed int32
	_, _, _ = pList, pMainMtx, removed
	removed = 0
	pMainMtx = _sqlite3MutexAlloc(tls, int32(SQLITE_MUTEX_STATIC_MAIN))
	Xsqlite3_mutex_enter(tls, pMainMtx)
	(*TBtShared)(unsafe.Pointer(pBt)).FnRef = (*TBtShared)(unsafe.Pointer(pBt)).FnRef - 1
	if (*TBtShared)(unsafe.Pointer(pBt)).FnRef <= 0 {
		if _sqlite3SharedCacheList == pBt {
			_sqlite3SharedCacheList = (*TBtShared)(unsafe.Pointer(pBt)).FpNext
		} else {
			pList = _sqlite3SharedCacheList
			for pList != 0 && (*TBtShared)(unsafe.Pointer(pList)).FpNext != pBt {
				pList = (*TBtShared)(unsafe.Pointer(pList)).FpNext
			}
			if pList != 0 {
				(*TBtShared)(unsafe.Pointer(pList)).FpNext = (*TBtShared)(unsafe.Pointer(pBt)).FpNext
			}
		}
		if int32(SQLITE_THREADSAFE) != 0 {
			Xsqlite3_mutex_free(tls, (*TBtShared)(unsafe.Pointer(pBt)).Fmutex)
		}
		removed = int32(1)
	}
	Xsqlite3_mutex_leave(tls, pMainMtx)
	return removed
}

func _removeNode(tls *libc.TLS, pRtree uintptr, pNode uintptr, iHeight int32) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var pParent uintptr
	var rc, rc2, v1 int32
	var _ /* iCell at bp+0 */ int32
	_, _, _, _ = pParent, rc, rc2, v1
	pParent = uintptr(0)
	/* Remove the entry in the parent cell. */
	rc = _nodeParentIndex(tls, pRtree, pNode, bp)
	if rc == SQLITE_OK {
		pParent = (*TRtreeNode)(unsafe.Pointer(pNode)).FpParent
		(*TRtreeNode)(unsafe.Pointer(pNode)).FpParent = uintptr(0)
		rc = _deleteCell(tls, pRtree, pParent, **(**int32)(__ccgo_up(bp)), iHeight+int32(1))
	}
	rc2 = _nodeRelease(tls, pRtree, pParent)
	if rc == SQLITE_OK {
		rc = rc2
	}
	if rc != SQLITE_OK {
		return rc
	}
	/* Remove the xxx_node entry. */
	Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteNode, int32(1), (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode)
	Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteNode)
	v1 = Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteNode)
	rc = v1
	if SQLITE_OK != v1 {
		return rc
	}
	/* Remove the xxx_parent entry. */
	Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteParent, int32(1), (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode)
	Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteParent)
	v1 = Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpDeleteParent)
	rc = v1
	if SQLITE_OK != v1 {
		return rc
	}
	/* Remove the node from the in-memory hash table and link it into
	 ** the Rtree.pDeleted list. Its contents will be re-inserted later on.
	 */
	_nodeHashDelete(tls, pRtree, pNode)
	(*TRtreeNode)(unsafe.Pointer(pNode)).FiNode = int64(iHeight)
	(*TRtreeNode)(unsafe.Pointer(pNode)).FpNext = (*TRtree)(unsafe.Pointer(pRtree)).FpDeleted
	(*TRtreeNode)(unsafe.Pointer(pNode)).FnRef = (*TRtreeNode)(unsafe.Pointer(pNode)).FnRef + 1
	(*TRtree)(unsafe.Pointer(pRtree)).FpDeleted = pNode
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Free the contents of Parse object (*pParse). Do not free the memory
//	** occupied by the Parse object itself.
//	*/
func _renameParseCleanup(tls *libc.TLS, pParse uintptr) {
	var db, pIdx, v1 uintptr
	_, _, _ = db, pIdx, v1
	db = (*TParse)(unsafe.Pointer(pParse)).Fdb
	if (*TParse)(unsafe.Pointer(pParse)).FpVdbe != 0 {
		_sqlite3VdbeFinalize(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe)
	}
	_sqlite3DeleteTable(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpNewTable)
	for {
		v1 = (*TParse)(unsafe.Pointer(pParse)).FpNewIndex
		pIdx = v1
		if !(v1 != uintptr(0)) {
			break
		}
		(*TParse)(unsafe.Pointer(pParse)).FpNewIndex = (*TIndex)(unsafe.Pointer(pIdx)).FpNext
		_sqlite3FreeIndex(tls, db, pIdx)
	}
	_sqlite3DeleteTrigger(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpNewTrigger)
	_sqlite3DbFree(tls, db, (*TParse)(unsafe.Pointer(pParse)).FzErrMsg)
	_renameTokenFree(tls, db, (*TParse)(unsafe.Pointer(pParse)).FpRename)
	_sqlite3ParseObjectReset(tls, pParse)
}

// C documentation
//
//	/*
//	** Generate code to reload the schema for database iDb. And, if iDb!=1, for
//	** the temp database as well.
//	*/
func _renameReloadSchema(tls *libc.TLS, pParse uintptr, iDb int32, p5 Tu16) {
	var v uintptr
	_ = v
	v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe
	if v != 0 {
		_sqlite3ChangeCookie(tls, pParse, iDb)
		_sqlite3VdbeAddParseSchemaOp(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, iDb, uintptr(0), p5)
		if iDb != int32(1) {
			_sqlite3VdbeAddParseSchemaOp(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32(1), uintptr(0), p5)
		}
	}
}

// C documentation
//
//	/*
//	** Free the list of RenameToken objects given in the second argument
//	*/
func _renameTokenFree(tls *libc.TLS, db uintptr, pToken uintptr) {
	var p, pNext uintptr
	_, _ = p, pNext
	p = pToken
	for {
		if !(p != 0) {
			break
		}
		pNext = (*TRenameToken)(unsafe.Pointer(p)).FpNext
		_sqlite3DbFree(tls, db, p)
		goto _1
	_1:
		;
		p = pNext
	}
}

// C documentation
//
//	/*
//	** Generate code to return a single integer value.
//	*/
func _returnSingleInt(tls *libc.TLS, v uintptr, _value Ti64) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	*(*Ti64)(unsafe.Pointer(bp)) = _value
	_sqlite3VdbeAddOp4Dup8(tls, v, int32(OP_Int64), 0, int32(1), 0, bp, -int32(14))
	_sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), int32(1))
}

// C documentation
//
//	/*
//	** Generate code to return a single text value.
//	*/
func _returnSingleText(tls *libc.TLS, v uintptr, zValue uintptr) {
	if zValue != 0 {
		_sqlite3VdbeLoadString(tls, v, int32(1), zValue)
		_sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), int32(1), int32(1))
	}
}

// C documentation
//
//	/*
//	** Convert a sorted list of elements into a binary tree. Make the tree
//	** as deep as it needs to be in order to contain the entire list.
//	*/
func _rowSetListToTree(tls *libc.TLS, _pList uintptr) (r uintptr) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	*(*uintptr)(unsafe.Pointer(bp)) = _pList
	var iDepth int32
	var p, pLeft, v1 uintptr
	_, _, _, _ = iDepth, p, pLeft, v1 /* Left subtree */
	p = **(**uintptr)(__ccgo_up(bp))
	**(**uintptr)(__ccgo_up(bp)) = (*TRowSetEntry)(unsafe.Pointer(p)).FpRight
	v1 = libc.UintptrFromInt32(0)
	(*TRowSetEntry)(unsafe.Pointer(p)).FpRight = v1
	(*TRowSetEntry)(unsafe.Pointer(p)).FpLeft = v1
	iDepth = int32(1)
	for {
		if !(**(**uintptr)(__ccgo_up(bp)) != 0) {
			break
		}
		pLeft = p
		p = **(**uintptr)(__ccgo_up(bp))
		**(**uintptr)(__ccgo_up(bp)) = (*TRowSetEntry)(unsafe.Pointer(p)).FpRight
		(*TRowSetEntry)(unsafe.Pointer(p)).FpLeft = pLeft
		(*TRowSetEntry)(unsafe.Pointer(p)).FpRight = _rowSetNDeepTree(tls, bp, iDepth)
		goto _2
	_2:
		;
		iDepth = iDepth + 1
	}
	return p
}

// C documentation
//
//	/*
//	** Convert a sorted list of elements (connected by pRight) into a binary
//	** tree with depth of iDepth.  A depth of 1 means the tree contains a single
//	** node taken from the head of *ppList.  A depth of 2 means a tree with
//	** three nodes.  And so forth.
//	**
//	** Use as many entries from the input list as required and update the
//	** *ppList to point to the unused elements of the list.  If the input
//	** list contains too few elements, then construct an incomplete tree
//	** and leave *ppList set to NULL.
//	**
//	** Return a pointer to the root of the constructed binary tree.
//	*/
func _rowSetNDeepTree(tls *libc.TLS, ppList uintptr, iDepth int32) (r uintptr) {
	var p, pLeft, v1 uintptr
	_, _, _ = p, pLeft, v1                              /* Left subtree */
	if **(**uintptr)(__ccgo_up(ppList)) == uintptr(0) { /*OPTIMIZATION-IF-TRUE*/
		/* Prevent unnecessary deep recursion when we run out of entries */
		return uintptr(0)
	}
	if iDepth > int32(1) { /*OPTIMIZATION-IF-TRUE*/
		/* This branch causes a *balanced* tree to be generated.  A valid tree
		 ** is still generated without this branch, but the tree is wildly
		 ** unbalanced and inefficient. */
		pLeft = _rowSetNDeepTree(tls, ppList, iDepth-int32(1))
		p = **(**uintptr)(__ccgo_up(ppList))
		if p == uintptr(0) { /*OPTIMIZATION-IF-FALSE*/
			/* It is safe to always return here, but the resulting tree
			 ** would be unbalanced */
			return pLeft
		}
		(*TRowSetEntry)(unsafe.Pointer(p)).FpLeft = pLeft
		**(**uintptr)(__ccgo_up(ppList)) = (*TRowSetEntry)(unsafe.Pointer(p)).FpRight
		(*TRowSetEntry)(unsafe.Pointer(p)).FpRight = _rowSetNDeepTree(tls, ppList, iDepth-int32(1))
	} else {
		p = **(**uintptr)(__ccgo_up(ppList))
		**(**uintptr)(__ccgo_up(ppList)) = (*TRowSetEntry)(unsafe.Pointer(p)).FpRight
		v1 = libc.UintptrFromInt32(0)
		(*TRowSetEntry)(unsafe.Pointer(p)).FpRight = v1
		(*TRowSetEntry)(unsafe.Pointer(p)).FpLeft = v1
	}
	return p
}

// C documentation
//
//	/*
//	** The input, pIn, is a binary tree (or subtree) of RowSetEntry objects.
//	** Convert this tree into a linked list connected by the pRight pointers
//	** and return pointers to the first and last elements of the new list.
//	*/
func _rowSetTreeToList(tls *libc.TLS, pIn uintptr, ppFirst uintptr, ppLast uintptr) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var _ /* p at bp+0 */ uintptr
	if (*TRowSetEntry)(unsafe.Pointer(pIn)).FpLeft != 0 {
		_rowSetTreeToList(tls, (*TRowSetEntry)(unsafe.Pointer(pIn)).FpLeft, ppFirst, bp)
		(*TRowSetEntry)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpRight = pIn
	} else {
		**(**uintptr)(__ccgo_up(ppFirst)) = pIn
	}
	if (*TRowSetEntry)(unsafe.Pointer(pIn)).FpRight != 0 {
		_rowSetTreeToList(tls, (*TRowSetEntry)(unsafe.Pointer(pIn)).FpRight, pIn+8, ppLast)
	} else {
		**(**uintptr)(__ccgo_up(ppLast)) = pIn
	}
}

// C documentation
//
//	/*
//	** Implementation of built-in window function row_number(). Assumes that the
//	** window frame has been coerced to:
//	**
//	**   ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
//	*/
func _row_numberStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
	var p uintptr
	_ = p
	p = Xsqlite3_aggregate_context(tls, pCtx, int32(8))
	if p != 0 {
		**(**Ti64)(__ccgo_up(p)) = **(**Ti64)(__ccgo_up(p)) + 1
	}
	_ = nArg
	_ = apArg
}

func _row_numberValueFunc(tls *libc.TLS, pCtx uintptr) {
	var p uintptr
	var v1 int64
	_, _ = p, v1
	p = Xsqlite3_aggregate_context(tls, pCtx, int32(8))
	if p != 0 {
		v1 = **(**Ti64)(__ccgo_up(p))
	} else {
		v1 = 0
	}
	Xsqlite3_result_int64(tls, pCtx, v1)
}

// C documentation
//
//	/*
//	** Write mapping (iRowid->iNode) to the <rtree>_rowid table.
//	*/
func _rowidWrite(tls *libc.TLS, pRtree uintptr, iRowid Tsqlite3_int64, iNode Tsqlite3_int64) (r int32) {
	Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid, int32(1), iRowid)
	Xsqlite3_bind_int64(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid, int32(2), iNode)
	Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid)
	return Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid)
}

// C documentation
//
//	/*
//	** Called when a transaction starts.
//	*/
func _rtreeBeginTransaction(tls *libc.TLS, pVtab uintptr) (r int32) {
	var pRtree uintptr
	_ = pRtree
	pRtree = pVtab
	(*TRtree)(unsafe.Pointer(pRtree)).FinWrTrans = uint8(1)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** The second and subsequent arguments to this function are a format string
//	** and printf style arguments. This function formats the string and attempts
//	** to compile it as an SQL statement.
//	**
//	** If successful, a pointer to the new SQL statement is returned. Otherwise,
//	** NULL is returned and an error code left in RtreeCheck.rc.
//	*/
func _rtreeCheckPrepare(tls *libc.TLS, pCheck uintptr, zFmt uintptr, va uintptr) (r uintptr) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var ap Tva_list
	var z uintptr
	var _ /* pRet at bp+0 */ uintptr
	_, _ = ap, z
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
	ap = va
	z = Xsqlite3_vmprintf(tls, zFmt, ap)
	if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK {
		if z == uintptr(0) {
			(*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc = int32(SQLITE_NOMEM)
		} else {
			(*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc = Xsqlite3_prepare_v2(tls, (*TRtreeCheck)(unsafe.Pointer(pCheck)).Fdb, z, -int32(1), bp, uintptr(0))
		}
	}
	Xsqlite3_free(tls, z)
	_ = ap
	return **(**uintptr)(__ccgo_up(bp))
}

// C documentation
//
//	/*
//	** Reset SQL statement pStmt. If the sqlite3_reset() call returns an error,
//	** and RtreeCheck.rc==SQLITE_OK, set RtreeCheck.rc to the error code.
//	*/
func _rtreeCheckReset(tls *libc.TLS, pCheck uintptr, pStmt uintptr) {
	var rc int32
	_ = rc
	rc = Xsqlite3_reset(tls, pStmt)
	if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK {
		(*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc = rc
	}
}

// C documentation
//
//	/*
//	** Rtree virtual table module xConnect method.
//	*/
func _rtreeConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) {
	return _rtreeInit(tls, db, pAux, argc, argv, ppVtab, pzErr, 0)
}

// C documentation
//
//	/*
//	** Rtree virtual table module xCreate method.
//	*/
func _rtreeCreate(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) (r int32) {
	return _rtreeInit(tls, db, pAux, argc, argv, ppVtab, pzErr, int32(1))
}

// C documentation
//
//	/*
//	** Rtree virtual table module xDisconnect method.
//	*/
func _rtreeDisconnect(tls *libc.TLS, pVtab uintptr) (r int32) {
	_rtreeRelease(tls, pVtab)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Called when a transaction completes (either by COMMIT or ROLLBACK).
//	** The sqlite3_blob object should be released at this point.
//	*/
func _rtreeEndTransaction(tls *libc.TLS, pVtab uintptr) (r int32) {
	var pRtree uintptr
	_ = pRtree
	pRtree = pVtab
	(*TRtree)(unsafe.Pointer(pRtree)).FinWrTrans = uint8(0)
	_nodeBlobReset(tls, pRtree)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** This routine deletes the RtreeGeomCallback object that was attached
//	** one of the SQL functions create by sqlite3_rtree_geometry_callback()
//	** or sqlite3_rtree_query_callback().  In other words, this routine is the
//	** destructor for an RtreeGeomCallback objecct.  This routine is called when
//	** the corresponding SQL function is deleted.
//	*/
func _rtreeFreeCallback(tls *libc.TLS, p uintptr) {
	var pInfo uintptr
	_ = pInfo
	pInfo = p
	if (*TRtreeGeomCallback)(unsafe.Pointer(pInfo)).FxDestructor != 0 {
		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TRtreeGeomCallback)(unsafe.Pointer(pInfo)).FxDestructor})))(tls, (*TRtreeGeomCallback)(unsafe.Pointer(pInfo)).FpContext)
	}
	Xsqlite3_free(tls, p)
}

// C documentation
//
//	/*
//	** Insert cell pCell into node pNode. Node pNode is the head of a
//	** subtree iHeight high (leaf nodes have iHeight==0).
//	*/
func _rtreeInsertCell(tls *libc.TLS, pRtree uintptr, pNode uintptr, pCell uintptr, iHeight int32) (r int32) {
	var pChild uintptr
	var rc int32
	_, _ = pChild, rc
	rc = SQLITE_OK
	if iHeight > 0 {
		pChild = _nodeHashLookup(tls, pRtree, (*TRtreeCell)(unsafe.Pointer(pCell)).FiRowid)
		if pChild != 0 {
			_nodeRelease(tls, pRtree, (*TRtreeNode)(unsafe.Pointer(pChild)).FpParent)
			_nodeReference(tls, pNode)
			(*TRtreeNode)(unsafe.Pointer(pChild)).FpParent = pNode
		}
	}
	if _nodeInsertCell(tls, pRtree, pNode, pCell) != 0 {
		rc = _SplitNode(tls, pRtree, pNode, pCell, iHeight)
	} else {
		rc = _AdjustTree(tls, pRtree, pNode, pCell)
		if rc == SQLITE_OK {
			if iHeight == 0 {
				rc = _rowidWrite(tls, pRtree, (*TRtreeCell)(unsafe.Pointer(pCell)).FiRowid, (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode)
			} else {
				rc = _parentWrite(tls, pRtree, (*TRtreeCell)(unsafe.Pointer(pCell)).FiRowid, (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode)
			}
		}
	}
	return rc
}

var _rtreeModule = Tsqlite3_module{
	FiVersion: int32(4),
}

// C documentation
//
//	/*
//	** Select a currently unused rowid for a new r-tree record.
//	*/
func _rtreeNewRowid(tls *libc.TLS, pRtree uintptr, piRowid uintptr) (r int32) {
	var rc int32
	_ = rc
	Xsqlite3_bind_null(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid, int32(1))
	Xsqlite3_bind_null(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid, int32(2))
	Xsqlite3_step(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid)
	rc = Xsqlite3_reset(tls, (*TRtree)(unsafe.Pointer(pRtree)).FpWriteRowid)
	**(**Ti64)(__ccgo_up(piRowid)) = Xsqlite3_last_insert_rowid(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb)
	return rc
}

// C documentation
//
//	/*
//	** Rtree virtual table module xNext method.
//	*/
func _rtreeNext(tls *libc.TLS, pVtabCursor uintptr) (r int32) {
	var pCsr uintptr
	var rc int32
	_, _ = pCsr, rc
	pCsr = pVtabCursor
	rc = SQLITE_OK
	/* Move to the next entry that matches the configured constraints. */
	if (*TRtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid != 0 {
		(*TRtreeCursor)(unsafe.Pointer(pCsr)).FbAuxValid = uint8(0)
		Xsqlite3_reset(tls, (*TRtreeCursor)(unsafe.Pointer(pCsr)).FpReadAux)
	}
	_rtreeSearchPointPop(tls, pCsr)
	rc = _rtreeStepToLeaf(tls, pCsr)
	return rc
}

// C documentation
//
//	/*
//	** Increment the r-tree reference count.
//	*/
func _rtreeReference(tls *libc.TLS, pRtree uintptr) {
	(*TRtree)(unsafe.Pointer(pRtree)).FnBusy = (*TRtree)(unsafe.Pointer(pRtree)).FnBusy + 1
}

func _rtreeRollback(tls *libc.TLS, pVtab uintptr) (r int32) {
	return _rtreeEndTransaction(tls, pVtab)
}

// C documentation
//
//	/*
//	** The xSavepoint method.
//	**
//	** This module does not need to do anything to support savepoints. However,
//	** it uses this hook to close any open blob handle. This is done because a
//	** DROP TABLE command - which fortunately always opens a savepoint - cannot
//	** succeed if there are any open blob handles. i.e. if the blob handle were
//	** not closed here, the following would fail:
//	**
//	**   BEGIN;
//	**     INSERT INTO rtree...
//	**     DROP TABLE <tablename>;    -- Would fail with SQLITE_LOCKED
//	**   COMMIT;
//	*/
func _rtreeSavepoint(tls *libc.TLS, pVtab uintptr, iSavepoint int32) (r int32) {
	var iwt Tu8
	var pRtree uintptr
	_, _ = iwt, pRtree
	pRtree = pVtab
	iwt = (*TRtree)(unsafe.Pointer(pRtree)).FinWrTrans
	_ = iSavepoint
	(*TRtree)(unsafe.Pointer(pRtree)).FinWrTrans = uint8(0)
	_nodeBlobReset(tls, pRtree)
	(*TRtree)(unsafe.Pointer(pRtree)).FinWrTrans = iwt
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Return the length of a token
//	*/
func _rtreeTokenLength(tls *libc.TLS, z uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var _ /* dummy at bp+0 */ int32
	**(**int32)(__ccgo_up(bp)) = 0
	return int32(_sqlite3GetToken(tls, z, bp))
}

var _sFts5Api = TFts5ExtensionApi{
	FiVersion: int32(4),
}

var _sMutex = Tsqlite3_mutex_methods{}

// C documentation
//
//	/*
//	** Return true if pNew is to be preferred over pOld.
//	**
//	** This function assumes that for each argument sample, the contents of
//	** the anEq[] array from pSample->anEq[pSample->iCol] onwards are valid.
//	*/
func _sampleIsBetter(tls *libc.TLS, pAccum uintptr, pNew uintptr, pOld uintptr) (r int32) {
	var nEqNew, nEqOld TtRowcnt
	_, _ = nEqNew, nEqOld
	nEqNew = **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pNew)).FanEq + uintptr((*TStatSample)(unsafe.Pointer(pNew)).FiCol)*8))
	nEqOld = **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pOld)).FanEq + uintptr((*TStatSample)(unsafe.Pointer(pOld)).FiCol)*8))
	if nEqNew > nEqOld {
		return int32(1)
	}
	if nEqNew == nEqOld {
		if (*TStatSample)(unsafe.Pointer(pNew)).FiCol < (*TStatSample)(unsafe.Pointer(pOld)).FiCol {
			return int32(1)
		}
		return libc.BoolInt32((*TStatSample)(unsafe.Pointer(pNew)).FiCol == (*TStatSample)(unsafe.Pointer(pOld)).FiCol && _sampleIsBetterPost(tls, pAccum, pNew, pOld) != 0)
	}
	return 0
}

// C documentation
//
//	/*
//	** pNew and pOld are both candidate non-periodic samples selected for
//	** the same column (pNew->iCol==pOld->iCol). Ignoring this column and
//	** considering only any trailing columns and the sample hash value, this
//	** function returns true if sample pNew is to be preferred over pOld.
//	** In other words, if we assume that the cardinalities of the selected
//	** column for pNew and pOld are equal, is pNew to be preferred over pOld.
//	**
//	** This function assumes that for each argument sample, the contents of
//	** the anEq[] array from pSample->anEq[pSample->iCol+1] onwards are valid.
//	*/
func _sampleIsBetterPost(tls *libc.TLS, pAccum uintptr, pNew uintptr, pOld uintptr) (r int32) {
	var i, nCol int32
	_, _ = i, nCol
	nCol = (*TStatAccum)(unsafe.Pointer(pAccum)).FnCol
	i = (*TStatSample)(unsafe.Pointer(pNew)).FiCol + int32(1)
	for {
		if !(i < nCol) {
			break
		}
		if **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pNew)).FanEq + uintptr(i)*8)) > **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pOld)).FanEq + uintptr(i)*8)) {
			return int32(1)
		}
		if **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pNew)).FanEq + uintptr(i)*8)) < **(**TtRowcnt)(__ccgo_up((*TStatSample)(unsafe.Pointer(pOld)).FanEq + uintptr(i)*8)) {
			return 0
		}
		goto _1
	_1:
		;
		i = i + 1
	}
	if (*TStatSample)(unsafe.Pointer(pNew)).FiHash > (*TStatSample)(unsafe.Pointer(pOld)).FiHash {
		return int32(1)
	}
	return 0
}

// C documentation
//
//	/*
//	** Save the positions of all cursors (except pExcept) that are open on
//	** the table with root-page iRoot.  "Saving the cursor position" means that
//	** the location in the btree is remembered in such a way that it can be
//	** moved back to the same spot after the btree has been modified.  This
//	** routine is called just before cursor pExcept is used to modify the
//	** table, for example in BtreeDelete() or BtreeInsert().
//	**
//	** If there are two or more cursors on the same btree, then all such
//	** cursors should have their BTCF_Multiple flag set.  The btreeCursor()
//	** routine enforces that rule.  This routine only needs to be called in
//	** the uncommon case when pExpect has the BTCF_Multiple flag set.
//	**
//	** If pExpect!=NULL and if no other cursors are found on the same root-page,
//	** then the BTCF_Multiple flag on pExpect is cleared, to avoid another
//	** pointless call to this routine.
//	**
//	** Implementation note:  This routine merely checks to see if any cursors
//	** need to be saved.  It calls out to saveCursorsOnList() in the (unusual)
//	** event that cursors are in need to being saved.
//	*/
func _saveAllCursors(tls *libc.TLS, pBt uintptr, iRoot TPgno, pExcept uintptr) (r int32) {
	var p, v2 uintptr
	_, _ = p, v2
	p = (*TBtShared)(unsafe.Pointer(pBt)).FpCursor
	for {
		if !(p != 0) {
			break
		}
		if p != pExcept && (uint32(0) == iRoot || (*TBtCursor)(unsafe.Pointer(p)).FpgnoRoot == iRoot) {
			break
		}
		goto _1
	_1:
		;
		p = (*TBtCursor)(unsafe.Pointer(p)).FpNext
	}
	if p != 0 {
		return _saveCursorsOnList(tls, p, iRoot, pExcept)
	}
	if pExcept != 0 {
		v2 = pExcept + 1
		*(*Tu8)(unsafe.Pointer(v2)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v2))) & ^libc.Int32FromInt32(BTCF_Multiple))
	}
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Format a string using printf() style formatting and then append it to the
//	** buffer using sessionAppendString().
//	*/
func _sessionAppendPrintf(tls *libc.TLS, p uintptr, pRc uintptr, zFmt uintptr, va uintptr) {
	var ap Tva_list
	var zApp uintptr
	_, _ = ap, zApp
	if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK {
		zApp = uintptr(0)
		ap = va
		zApp = Xsqlite3_vmprintf(tls, zFmt, ap)
		if zApp == uintptr(0) {
			**(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM)
		} else {
			_sessionAppendStr(tls, p, zApp, pRc)
		}
		_ = ap
		Xsqlite3_free(tls, zApp)
	}
}

// C documentation
//
//	/*
//	** Attempt to apply all the changes in retry buffer pRetry to the database.
//	** Except, if parameter iSkip is greater than or equal to 0, skip change
//	** iSkip.
//	*/
func _sessionApplyRetryBuffer(tls *libc.TLS, pRetry uintptr, iSkip int32, db uintptr, bPatchset int32, zTab uintptr, pApply uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var ii, rc, rc2 int32
	var _ /* pIter at bp+0 */ uintptr
	_, _, _ = ii, rc, rc2
	rc = SQLITE_OK
	rc2 = SQLITE_OK
	ii = 0
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
	rc = _sessionRetryIterInit(tls, pRetry, bPatchset, zTab, pApply, bp)
	ii = 0
	for {
		if !(rc == SQLITE_OK && int32(SQLITE_ROW) == Xsqlite3changeset_next(tls, **(**uintptr)(__ccgo_up(bp)))) {
			break
		}
		if ii != iSkip {
			rc = _sessionApplyOneWithRetry(tls, db, **(**uintptr)(__ccgo_up(bp)), pApply, __ccgo_fp_xConflict, pCtx)
		}
		goto _1
	_1:
		;
		ii = ii + 1
	}
	rc2 = Xsqlite3changeset_finalize(tls, **(**uintptr)(__ccgo_up(bp)))
	if rc == SQLITE_OK {
		rc = rc2
	}
	return rc
}

// C documentation
//
//	/*
//	** Iterator pIter must point to an SQLITE_INSERT entry. This function
//	** transfers new.* values from the current iterator entry to statement
//	** pStmt. The table being inserted into has nCol columns.
//	**
//	** New.* value $i from the iterator is bound to variable ($i+1) of
//	** statement pStmt. If parameter abPK is NULL, all values from 0 to (nCol-1)
//	** are transfered to the statement. Otherwise, if abPK is not NULL, it points
//	** to an array nCol elements in size. In this case only those values for
//	** which abPK[$i] is true are read from the iterator and bound to the
//	** statement.
//	**
//	** An SQLite error code is returned if an error occurs. Otherwise, SQLITE_OK.
//	*/
func _sessionBindRow(tls *libc.TLS, pIter uintptr, __ccgo_fp_xValue uintptr, nCol int32, abPK uintptr, pStmt uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var i, rc int32
	var _ /* pVal at bp+0 */ uintptr
	_, _ = i, rc
	rc = SQLITE_OK
	/* Neither sqlite3changeset_old or sqlite3changeset_new can fail if the
	 ** argument iterator points to a suitable entry. Make sure that xValue
	 ** is one of these to guarantee that it is safe to ignore the return
	 ** in the code below. */
	i = 0
	for {
		if !(rc == SQLITE_OK && i < nCol) {
			break
		}
		if !(abPK != 0) || **(**Tu8)(__ccgo_up(abPK + uintptr(i))) != 0 {
			**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
			(*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xValue})))(tls, pIter, i, bp)
			if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) {
				/* The value in the changeset was "undefined". This indicates a
				 ** corrupt changeset blob.  */
				rc = _sqlite3CorruptError(tls, int32(238490))
			} else {
				rc = _sessionBindValue(tls, pStmt, i+int32(1), **(**uintptr)(__ccgo_up(bp)))
			}
		}
		goto _1
	_1:
		;
		i = i + 1
	}
	return rc
}

// C documentation
//
//	/*
//	** A wrapper around sqlite3_bind_value() that detects an extra problem.
//	** See comments in the body of this function for details.
//	*/
func _sessionBindValue(tls *libc.TLS, pStmt uintptr, i int32, pVal uintptr) (r int32) {
	var eType int32
	_ = eType
	eType = Xsqlite3_value_type(tls, pVal)
	/* COVERAGE: The (pVal->z==0) branch is never true using current versions
	 ** of SQLite. If a malloc fails in an sqlite3_value_xxx() function, either
	 ** the (pVal->z) variable remains as it was or the type of the value is
	 ** set to SQLITE_NULL.  */
	if (eType == int32(SQLITE_TEXT) || eType == int32(SQLITE_BLOB)) && (*Tsqlite3_value)(unsafe.Pointer(pVal)).Fz == uintptr(0) {
		/* This condition occurs when an earlier OOM in a call to
		 ** sqlite3_value_text() or sqlite3_value_blob() (perhaps from within
		 ** a conflict-handler) has zeroed the pVal->z pointer. Return NOMEM. */
		return int32(SQLITE_NOMEM)
	}
	return Xsqlite3_bind_value(tls, pStmt, i, pVal)
}

// C documentation
//
//	/*
//	** This function is called by all six sqlite3changeset_apply() variants:
//	**
//	**   +  sqlite3changeset_apply()
//	**   +  sqlite3changeset_apply_v2()
//	**   +  sqlite3changeset_apply_v3()
//	**   +  sqlite3changeset_apply_strm()
//	**   +  sqlite3changeset_apply_strm_v2()
//	**   +  sqlite3changeset_apply_strm_v3()
//	**
//	** Arguments passed to this function are as follows:
//	**
//	** db:
//	**   Database handle to apply changeset to main database of.
//	**
//	** nChangeset/pChangeset:
//	**   These are both passed zero for the streaming variants. For the normal
//	**   apply() functions, these are passed the size of and the buffer containing
//	**   the changeset, respectively.
//	**
//	** xInput/pIn:
//	**   These are both passed zero for the normal variants. For the streaming
//	**   apply() functions, these are passed the input callback and context
//	**   pointer, respectively.
//	**
//	** xFilter:
//	**   The filter function as passed to apply() or apply_v2() (to filter by
//	**   table name), if any. This is always NULL for apply_v3() calls.
//	**
//	** xFilterIter:
//	**   The filter function as passed to apply_v3(), if any.
//	**
//	** xConflict:
//	**   The conflict handler callback (must not be NULL).
//	**
//	** pCtx:
//	**   The context pointer passed to the xFilter and xConflict handler callbacks.
//	**
//	** ppRebase, pnRebase:
//	**   Zero for apply(). The rebase changeset output pointers, if any, for
//	**   apply_v2() and apply_v3().
//	**
//	** flags:
//	**   Zero for apply(). The flags parameter for apply_v2() and apply_v3().
//	*/
func _sessionChangesetApplyV23(tls *libc.TLS, db uintptr, nChangeset int32, pChangeset uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xFilterIter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var bInverse, rc int32
	var _ /* pIter at bp+0 */ uintptr
	_, _ = bInverse, rc /* Iterator to skip through changeset */
	bInverse = libc.BoolInt32(!!(flags&libc.Int32FromInt32(SQLITE_CHANGESETAPPLY_INVERT) != 0))
	rc = _sessionChangesetStart(tls, bp, __ccgo_fp_xInput, pIn, nChangeset, pChangeset, bInverse, int32(1))
	if rc == SQLITE_OK {
		rc = _sessionChangesetApply(tls, db, **(**uintptr)(__ccgo_up(bp)), __ccgo_fp_xFilter, __ccgo_fp_xFilterIter, __ccgo_fp_xConflict, pCtx, ppRebase, pnRebase, flags)
	}
	return rc
}

// C documentation
//
//	/*
//	** The input pointer currently points to the second byte of a table-header.
//	** Specifically, to the following:
//	**
//	**   + number of columns in table (varint)
//	**   + array of PK flags (1 byte per column),
//	**   + table name (nul terminated).
//	**
//	** This function ensures that all of the above is present in the input
//	** buffer (i.e. that it can be accessed without any calls to xInput()).
//	** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.
//	** The input pointer is not moved.
//	*/
func _sessionChangesetBufferTblhdr(tls *libc.TLS, pIn uintptr, pnByte uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var nBuf, nRead, rc int32
	var _ /* nCol at bp+0 */ int32
	_, _, _ = nBuf, nRead, rc
	rc = SQLITE_OK
	**(**int32)(__ccgo_up(bp)) = 0
	nRead = 0
	rc = _sessionInputBuffer(tls, pIn, int32(9))
	if rc == SQLITE_OK {
		nBuf = (*TSessionInput)(unsafe.Pointer(pIn)).FnData - (*TSessionInput)(unsafe.Pointer(pIn)).FiNext
		nRead = nRead + _sessionVarintGetSafe(tls, (*TSessionInput)(unsafe.Pointer(pIn)).FaData+uintptr((*TSessionInput)(unsafe.Pointer(pIn)).FiNext), nBuf, bp)
		/* The hard upper limit for the number of columns in an SQLite
		 ** database table is, according to sqliteLimit.h, 32676. So
		 ** consider any table-header that purports to have more than 65536
		 ** columns to be corrupt. This is convenient because otherwise,
		 ** if the (nCol>65536) condition below were omitted, a sufficiently
		 ** large value for nCol may cause nRead to wrap around and become
		 ** negative. Leading to a crash. */
		if **(**int32)(__ccgo_up(bp)) < 0 || **(**int32)(__ccgo_up(bp)) > int32(65536) {
			rc = _sqlite3CorruptError(tls, int32(237400))
		} else {
			rc = _sessionInputBuffer(tls, pIn, nRead+**(**int32)(__ccgo_up(bp))+int32(100))
			nRead = nRead + **(**int32)(__ccgo_up(bp))
		}
	}
	for rc == SQLITE_OK {
		for (*TSessionInput)(unsafe.Pointer(pIn)).FiNext+nRead < (*TSessionInput)(unsafe.Pointer(pIn)).FnData && **(**Tu8)(__ccgo_up((*TSessionInput)(unsafe.Pointer(pIn)).FaData + uintptr((*TSessionInput)(unsafe.Pointer(pIn)).FiNext+nRead))) != 0 {
			nRead = nRead + 1
		}
		/* Break out of the loop if if the nul-terminator byte has been found.
		 ** Otherwise, read some more input data and keep seeking. If there is
		 ** no more input data, consider the changeset corrupt.  */
		if (*TSessionInput)(unsafe.Pointer(pIn)).FiNext+nRead < (*TSessionInput)(unsafe.Pointer(pIn)).FnData {
			break
		}
		rc = _sessionInputBuffer(tls, pIn, nRead+int32(100))
		if rc == SQLITE_OK && (*TSessionInput)(unsafe.Pointer(pIn)).FiNext+nRead >= (*TSessionInput)(unsafe.Pointer(pIn)).FnData {
			rc = _sqlite3CorruptError(tls, int32(237418))
		}
	}
	**(**int32)(__ccgo_up(pnByte)) = nRead + int32(1)
	return rc
}

// C documentation
//
//	/*
//	** Advance the changeset iterator to the next change.
//	**
//	** If both paRec and pnRec are NULL, then this function works like the public
//	** API sqlite3changeset_next(). If SQLITE_ROW is returned, then the
//	** sqlite3changeset_new() and old() APIs may be used to query for values.
//	**
//	** Otherwise, if paRec and pnRec are not NULL, then a pointer to the change
//	** record is written to *paRec before returning and the number of bytes in
//	** the record to *pnRec.
//	**
//	** Either way, this function returns SQLITE_ROW if the iterator is
//	** successfully advanced to the next change in the changeset, an SQLite
//	** error code if an error occurs, or SQLITE_DONE if there are no further
//	** changes in the changeset.
//	*/
func _sessionChangesetNext(tls *libc.TLS, p uintptr, paRec uintptr, pnRec uintptr, pbNew uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* bEmpty at bp+0 */ int32
	_ = rc
	for cond := true; cond; cond = rc == int32(SQLITE_ROW) && (*Tsqlite3_changeset_iter)(unsafe.Pointer(p)).FbSkipEmpty != 0 && **(**int32)(__ccgo_up(bp)) != 0 {
		**(**int32)(__ccgo_up(bp)) = 0
		rc = _sessionChangesetNextOne(tls, p, paRec, pnRec, pbNew, bp)
	}
	return rc
}

func _sessionDiffCount(tls *libc.TLS, pCtx uintptr) (r int32) {
	var p uintptr
	var v1 int32
	_, _ = p, v1
	p = pCtx
	if (*TSessionDiffCtx)(unsafe.Pointer(p)).FnOldOff != 0 {
		v1 = (*TSessionDiffCtx)(unsafe.Pointer(p)).FnOldOff
	} else {
		v1 = Xsqlite3_column_count(tls, (*TSessionDiffCtx)(unsafe.Pointer(p)).FpStmt)
	}
	return v1 - (*TSessionDiffCtx)(unsafe.Pointer(p)).FbRowid
}

func _sessionDiffDepth(tls *libc.TLS, pCtx uintptr) (r int32) {
	_ = pCtx
	return 0
}

func _sessionDiffFindNew(tls *libc.TLS, op int32, pSession uintptr, pTab uintptr, zDb1 uintptr, zDb2 uintptr, zExpr uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var iRowid Ti64
	var pDiffCtx, zStmt uintptr
	var rc int32
	var v1 int64
	var _ /* pStmt at bp+0 */ uintptr
	_, _, _, _, _ = iRowid, pDiffCtx, rc, zStmt, v1
	rc = SQLITE_OK
	zStmt = _sessionSelectFindNew(tls, zDb1, zDb2, (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zExpr)
	if zStmt == uintptr(0) {
		rc = int32(SQLITE_NOMEM)
	} else {
		rc = Xsqlite3_prepare_v2(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb, zStmt, -int32(1), bp, uintptr(0))
		if rc == SQLITE_OK {
			pDiffCtx = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx
			(*TSessionDiffCtx)(unsafe.Pointer(pDiffCtx)).FpStmt = **(**uintptr)(__ccgo_up(bp))
			(*TSessionDiffCtx)(unsafe.Pointer(pDiffCtx)).FnOldOff = 0
			(*TSessionDiffCtx)(unsafe.Pointer(pDiffCtx)).FbRowid = (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid
			for int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) {
				if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 {
					v1 = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0)
				} else {
					v1 = 0
				}
				iRowid = v1
				_sessionPreupdateOneChange(tls, op, iRowid, pSession, pTab)
			}
			rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp)))
		}
		Xsqlite3_free(tls, zStmt)
	}
	return rc
}

// C documentation
//
//	/*
//	** Install the diff hooks on the session object passed as the only
//	** argument.
//	*/
func _sessionDiffHooks(tls *libc.TLS, pSession uintptr, pDiffCtx uintptr) {
	(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx = pDiffCtx
	(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld = __ccgo_fp(_sessionDiffOld)
	(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew = __ccgo_fp(_sessionDiffNew)
	(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxCount = __ccgo_fp(_sessionDiffCount)
	(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxDepth = __ccgo_fp(_sessionDiffDepth)
}

func _sessionDiffNew(tls *libc.TLS, pCtx uintptr, iVal int32, ppVal uintptr) (r int32) {
	var p uintptr
	_ = p
	p = pCtx
	**(**uintptr)(__ccgo_up(ppVal)) = Xsqlite3_column_value(tls, (*TSessionDiffCtx)(unsafe.Pointer(p)).FpStmt, iVal+(*TSessionDiffCtx)(unsafe.Pointer(p)).FbRowid)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** The diff hook implementations.
//	*/
func _sessionDiffOld(tls *libc.TLS, pCtx uintptr, iVal int32, ppVal uintptr) (r int32) {
	var p uintptr
	_ = p
	p = pCtx
	**(**uintptr)(__ccgo_up(ppVal)) = Xsqlite3_column_value(tls, (*TSessionDiffCtx)(unsafe.Pointer(p)).FpStmt, iVal+(*TSessionDiffCtx)(unsafe.Pointer(p)).FnOldOff+(*TSessionDiffCtx)(unsafe.Pointer(p)).FbRowid)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Finalize statement pStmt. If (*pRc) is SQLITE_OK when this function is
//	** called, set it to the results of the sqlite3_finalize() call. Or, if
//	** it is already set to an error code, leave it as is.
//	*/
func _sessionFinalizeStmt(tls *libc.TLS, pStmt uintptr, pRc uintptr) {
	var rc int32
	_ = rc
	rc = Xsqlite3_finalize(tls, pStmt)
	if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK {
		**(**int32)(__ccgo_up(pRc)) = rc
	}
}

func _sessionFindTable(tls *libc.TLS, pSession uintptr, zName uintptr, ppTab uintptr) (r int32) {
	var nName, rc int32
	var pRet uintptr
	_, _, _ = nName, pRet, rc
	rc = SQLITE_OK
	nName = _sqlite3Strlen30(tls, zName)
	/* Search for an existing table */
	pRet = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpTable
	for {
		if !(pRet != 0) {
			break
		}
		if 0 == Xsqlite3_strnicmp(tls, (*TSessionTable)(unsafe.Pointer(pRet)).FzName, zName, nName+int32(1)) {
			break
		}
		goto _1
	_1:
		;
		pRet = (*TSessionTable)(unsafe.Pointer(pRet)).FpNext
	}
	if pRet == uintptr(0) && (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbAutoAttach != 0 {
		/* If there is a table-filter configured, invoke it. If it returns 0,
		 ** do not automatically add the new table. */
		if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FxTableFilter == uintptr(0) || (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_session)(unsafe.Pointer(pSession)).FxTableFilter})))(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpFilterCtx, zName) != 0 {
			rc = Xsqlite3session_attach(tls, pSession, zName)
			if rc == SQLITE_OK {
				pRet = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpTable
				for pRet != 0 && (*TSessionTable)(unsafe.Pointer(pRet)).FpNext != 0 {
					pRet = (*TSessionTable)(unsafe.Pointer(pRet)).FpNext
				}
			}
		}
	}
	**(**uintptr)(__ccgo_up(ppTab)) = pRet
	return rc
}

// C documentation
//
//	/*
//	** Append the hash of the blob passed via the second and third arguments to
//	** the hash-key value passed as the first. Return the new hash-key value.
//	*/
func _sessionHashAppendBlob(tls *libc.TLS, h uint32, n int32, z uintptr) (r uint32) {
	var i int32
	_ = i
	i = 0
	for {
		if !(i < n) {
			break
		}
		h = h<<int32(3) ^ h ^ uint32(**(**Tu8)(__ccgo_up(z + uintptr(i))))
		goto _1
	_1:
		;
		i = i + 1
	}
	return h
}

// C documentation
//
//	/*
//	** This is a helper function used by sessionMergeUpdate().
//	**
//	** When this function is called, both *paOne and *paTwo point to a value
//	** within a change record. Before it returns, both have been advanced so
//	** as to point to the next value in the record.
//	**
//	** If, when this function is called, *paTwo points to a valid value (i.e.
//	** *paTwo[0] is not 0x00 - the "no value" placeholder), a copy of the *paTwo
//	** pointer is returned and *pnVal is set to the number of bytes in the
//	** serialized value. Otherwise, a copy of *paOne is returned and *pnVal
//	** set to the number of bytes in the value at *paOne. If *paOne points
//	** to the "no value" placeholder, *pnVal is set to 1. In other words:
//	**
//	**   if( *paTwo is valid ) return *paTwo;
//	**   return *paOne;
//	**
//	*/
func _sessionMergeValue(tls *libc.TLS, paOne uintptr, paTwo uintptr, pnVal uintptr) (r uintptr) {
	var a1, a2, pRet uintptr
	var n1, n2 int32
	_, _, _, _, _ = a1, a2, n1, n2, pRet
	a1 = **(**uintptr)(__ccgo_up(paOne))
	a2 = **(**uintptr)(__ccgo_up(paTwo))
	pRet = uintptr(0)
	if a2 != 0 {
		n2 = _sessionSerialLen(tls, a2)
		if **(**Tu8)(__ccgo_up(a2)) != 0 {
			**(**int32)(__ccgo_up(pnVal)) = n2
			pRet = a2
		}
		**(**uintptr)(__ccgo_up(paTwo)) = a2 + uintptr(n2)
	}
	n1 = _sessionSerialLen(tls, a1)
	if pRet == uintptr(0) {
		**(**int32)(__ccgo_up(pnVal)) = n1
		pRet = a1
	}
	**(**uintptr)(__ccgo_up(paOne)) = a1 + uintptr(n1)
	return pRet
}

func _sessionPreupdateCount(tls *libc.TLS, pCtx uintptr) (r int32) {
	return Xsqlite3_preupdate_count(tls, pCtx)
}

func _sessionPreupdateDepth(tls *libc.TLS, pCtx uintptr) (r int32) {
	return Xsqlite3_preupdate_depth(tls, pCtx)
}

// C documentation
//
//	/*
//	** Install the pre-update hooks on the session object passed as the only
//	** argument.
//	*/
func _sessionPreupdateHooks(tls *libc.TLS, pSession uintptr) {
	(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb
	(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxOld = __ccgo_fp(_sessionPreupdateOld)
	(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxNew = __ccgo_fp(_sessionPreupdateNew)
	(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxCount = __ccgo_fp(_sessionPreupdateCount)
	(*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FxDepth = __ccgo_fp(_sessionPreupdateDepth)
}

func _sessionPreupdateNew(tls *libc.TLS, pCtx uintptr, iVal int32, ppVal uintptr) (r int32) {
	return Xsqlite3_preupdate_new(tls, pCtx, iVal, ppVal)
}

// C documentation
//
//	/*
//	** The pre-update hook implementations.
//	*/
func _sessionPreupdateOld(tls *libc.TLS, pCtx uintptr, iVal int32, ppVal uintptr) (r int32) {
	return Xsqlite3_preupdate_old(tls, pCtx, iVal, ppVal)
}

func _sessionStat1Count(tls *libc.TLS, pCtx uintptr) (r int32) {
	var p uintptr
	_ = p
	p = pCtx
	return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSessionStat1Ctx)(unsafe.Pointer(p)).Fhook.FxCount})))(tls, (*TSessionStat1Ctx)(unsafe.Pointer(p)).Fhook.FpCtx)
}

func _sessionStat1Depth(tls *libc.TLS, pCtx uintptr) (r int32) {
	var p uintptr
	_ = p
	p = pCtx
	return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSessionStat1Ctx)(unsafe.Pointer(p)).Fhook.FxDepth})))(tls, (*TSessionStat1Ctx)(unsafe.Pointer(p)).Fhook.FpCtx)
}

func _sessionStat1New(tls *libc.TLS, pCtx uintptr, iCol int32, ppVal uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var p uintptr
	var rc int32
	var _ /* pVal at bp+0 */ uintptr
	_, _ = p, rc
	p = pCtx
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
	rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSessionStat1Ctx)(unsafe.Pointer(p)).Fhook.FxNew})))(tls, (*TSessionStat1Ctx)(unsafe.Pointer(p)).Fhook.FpCtx, iCol, bp)
	if rc == SQLITE_OK && iCol == int32(1) && Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(bp))) == int32(SQLITE_NULL) {
		**(**uintptr)(__ccgo_up(bp)) = (*Tsqlite3_session)(unsafe.Pointer((*TSessionStat1Ctx)(unsafe.Pointer(p)).FpSession)).FpZeroBlob
	}
	**(**uintptr)(__ccgo_up(ppVal)) = **(**uintptr)(__ccgo_up(bp))
	return rc
}

func _sessionStat1Old(tls *libc.TLS, pCtx uintptr, iCol int32, ppVal uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var p uintptr
	var rc int32
	var _ /* pVal at bp+0 */ uintptr
	_, _ = p, rc
	p = pCtx
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
	rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TSessionStat1Ctx)(unsafe.Pointer(p)).Fhook.FxOld})))(tls, (*TSessionStat1Ctx)(unsafe.Pointer(p)).Fhook.FpCtx, iCol, bp)
	if rc == SQLITE_OK && iCol == int32(1) && Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(bp))) == int32(SQLITE_NULL) {
		**(**uintptr)(__ccgo_up(bp)) = (*Tsqlite3_session)(unsafe.Pointer((*TSessionStat1Ctx)(unsafe.Pointer(p)).FpSession)).FpZeroBlob
	}
	**(**uintptr)(__ccgo_up(ppVal)) = **(**uintptr)(__ccgo_up(bp))
	return rc
}

// C documentation
//
//	/*
//	** Free all cached UPDATE statements.
//	*/
func _sessionUpdateFree(tls *libc.TLS, p uintptr) {
	var pNext, pUp uintptr
	_, _ = pNext, pUp
	pUp = (*TSessionApplyCtx)(unsafe.Pointer(p)).FpUp
	for {
		if !(pUp != 0) {
			break
		}
		pNext = (*TSessionUpdate)(unsafe.Pointer(pUp)).FpNext
		Xsqlite3_finalize(tls, (*TSessionUpdate)(unsafe.Pointer(pUp)).FpStmt)
		Xsqlite3_free(tls, pUp)
		goto _1
	_1:
		;
		pUp = pNext
	}
	(*TSessionApplyCtx)(unsafe.Pointer(p)).FpUp = uintptr(0)
	Xsqlite3_free(tls, (*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask)
	(*TSessionApplyCtx)(unsafe.Pointer(p)).FaUpdateMask = uintptr(0)
}

var _sessions_strm_chunk_size = int32(SESSIONS_STRM_CHUNK_SIZE)

/* Write the specified cookie value */
var _setCookie = [2]TVdbeOpList{
	0: {
		Fopcode: uint8(OP_Transaction),
		Fp2:     int8(1),
	},
	1: {
		Fopcode: uint8(OP_SetCookie),
	},
}

// C documentation
//
//	/*
//	** Attempt to set the page size of the destination to match the page size
//	** of the source.
//	*/
func _setDestPgsz(tls *libc.TLS, pDest uintptr, pSrc uintptr) (r int32) {
	return _sqlite3BtreeSetPageSize(tls, pDest, _sqlite3BtreeGetPageSize(tls, pSrc), 0, 0)
}

var _setMeta6 = [5]TVdbeOpList{
	0: {
		Fopcode: uint8(OP_Transaction),
		Fp2:     int8(1),
	},
	1: {
		Fopcode: uint8(OP_ReadCookie),
		Fp2:     int8(1),
		Fp3:     int8(BTREE_LARGEST_ROOT_PAGE),
	},
	2: {
		Fopcode: uint8(OP_If),
		Fp1:     int8(1),
	},
	3: {
		Fopcode: uint8(OP_Halt),
		Fp2:     int8(OE_Abort),
	},
	4: {
		Fopcode: uint8(OP_SetCookie),
		Fp2:     int8(BTREE_INCR_VACUUM),
	},
}

// C documentation
//
//	/*
//	** Set the bit in the IntegrityCk.aPgRef[] array that corresponds to page iPg.
//	*/
func _setPageReferenced(tls *libc.TLS, pCheck uintptr, iPg TPgno) {
	var v1 uintptr
	_ = v1
	v1 = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FaPgRef + uintptr(iPg/uint32(8))
	*(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(1)<<(iPg&libc.Uint32FromInt32(0x07)))
}

// C documentation
//
//	/*
//	** Implementation of sign(X) function.
//	*/
func _signFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
	var type0, v1, v2 int32
	var x float64
	_, _, _, _ = type0, x, v1, v2
	_ = argc
	type0 = Xsqlite3_value_numeric_type(tls, **(**uintptr)(__ccgo_up(argv)))
	if type0 != int32(SQLITE_INTEGER) && type0 != int32(SQLITE_FLOAT) {
		return
	}
	x = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv)))
	if x < float64(0) {
		v1 = -int32(1)
	} else {
		if x > float64(0) {
			v2 = +libc.Int32FromInt32(1)
		} else {
			v2 = 0
		}
		v1 = v2
	}
	Xsqlite3_result_int(tls, context, v1)
}

// C documentation
//
//	/*
//	** zSql[] is a CREATE TABLE statement, supposedly.  Find the offset
//	** into zSql[] of the first character past the first "(" and write
//	** that offset into *piOff and return SQLITE_OK.  Or, if not found,
//	** set the SQLITE_CORRUPT error code and return SQLITE_ERROR.
//	*/
func _skipCreateTable(tls *libc.TLS, ctx uintptr, zSql uintptr, piOff uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var iOff int32
	var _ /* t at bp+0 */ int32
	_ = iOff
	iOff = 0
	if zSql == uintptr(0) {
		return int32(SQLITE_ERROR)
	}
	/* Jump past the "CREATE TABLE" bit. */
	for int32(1) != 0 {
		**(**int32)(__ccgo_up(bp)) = 0
		iOff = int32(int64(iOff) + _sqlite3GetToken(tls, zSql+uintptr(iOff), bp))
		if **(**int32)(__ccgo_up(bp)) == int32(TK_LP) {
			break
		}
		if **(**int32)(__ccgo_up(bp)) == int32(TK_ILLEGAL) {
			Xsqlite3_result_error_code(tls, ctx, _sqlite3CorruptError(tls, int32(123048)))
			return int32(SQLITE_ERROR)
		}
	}
	**(**int32)(__ccgo_up(piOff)) = iOff
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Implementation of the sqlite_source_id() function. The result is a string
//	** that identifies the particular version of the source code used to build
//	** SQLite.
//	*/
func _sourceidFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
	_ = NotUsed
	_ = NotUsed2
	/* IMP: R-24470-31136 This function is an SQL wrapper around the
	 ** sqlite3_sourceid() C interface. */
	Xsqlite3_result_text(tls, context, Xsqlite3_sourceid(tls), -int32(1), libc.UintptrFromInt32(0))
}

// C documentation
//
//	/*
//	** Compute the absolute value of a 32-bit signed integer, if possible.  Or
//	** if the integer has a value of -2147483648, return +2147483647
//	*/
func _sqlite3AbsInt32(tls *libc.TLS, x int32) (r int32) {
	if x >= 0 {
		return x
	}
	if x == libc.Int32FromUint32(0x80000000) {
		return int32(0x7fffffff)
	}
	return -x
}

// C documentation
//
//	/*
//	** Attempt to add, subtract, or multiply the 64-bit signed value iB against
//	** the other 64-bit signed integer at *pA and store the result in *pA.
//	** Return 0 on success.  Or if the operation would have resulted in an
//	** overflow, leave *pA unchanged and return 1.
//	*/
func _sqlite3AddInt64(tls *libc.TLS, pA uintptr, iB Ti64) (r int32) {
	var iA Ti64
	_ = iA
	iA = **(**Ti64)(__ccgo_up(pA))
	if iB >= 0 {
		if iA > 0 && libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<<libc.Int32FromInt32(32)-iA < iB {
			return int32(1)
		}
	} else {
		if iA < 0 && -(iA+(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<<libc.Int32FromInt32(32))) > iB+int64(1) {
			return int32(1)
		}
	}
	**(**Ti64)(__ccgo_up(pA)) += iB
	return 0
}

// C documentation
//
//	/*
//	** This function must be called before exiting any API function (i.e.
//	** returning control to the user) that has called sqlite3_malloc or
//	** sqlite3_realloc.
//	**
//	** The returned value is normally a copy of the second argument to this
//	** function. However, if a malloc() failure has occurred since the previous
//	** invocation SQLITE_NOMEM is returned instead.
//	**
//	** If an OOM as occurred, then the connection error-code (the value
//	** returned by sqlite3_errcode()) is set to SQLITE_NOMEM.
//	*/
func _sqlite3ApiExit(tls *libc.TLS, db uintptr, rc int32) (r int32) {
	/* If the db handle must hold the connection handle mutex here.
	 ** Otherwise the read (and possible write) of db->mallocFailed
	 ** is unsafe, as is the call to sqlite3Error().
	 */
	if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 || rc != 0 {
		return _apiHandleError(tls, db, rc)
	}
	return 0
}

/************** End of malloc.c **********************************************/
/************** Begin file printf.c ******************************************/
/*
** The "printf" code that follows dates from the 1980's.  It is in
** the public domain.
**
**************************************************************************
**
** This file contains code for a set of "printf"-like routines.  These
** routines format strings much like the printf() from the standard C
** library, though the implementation here has enhancements to support
** SQLite.
 */
/* #include "sqliteInt.h" */

/*
** Conversion types fall into various categories as defined by the
** following enumeration.
 */
/* The rest are extensions, not normally found in printf() */

// C documentation
//
//	/*
//	** The following structure contains pointers to all SQLite API routines.
//	** A pointer to this structure is passed into extensions when they are
//	** loaded so that the extension can make calls back into the SQLite
//	** library.
//	**
//	** When adding new APIs, add them to the bottom of this structure
//	** in order to preserve backwards compatibility.
//	**
//	** Extensions that use newer APIs should first call the
//	** sqlite3_libversion_number() to make sure that the API they
//	** intend to use is supported by the library.  Extensions should
//	** also check to make sure that the pointer to the function is
//	** not NULL before calling it.
//	*/
var _sqlite3Apis = Tsqlite3_api_routines{}

// C documentation
//
//	/*
//	** Return a 32-bit integer value extracted from a string.  If the
//	** string is not an integer, just return 0.
//	*/
func _sqlite3Atoi(tls *libc.TLS, z uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var _ /* x at bp+0 */ int32
	**(**int32)(__ccgo_up(bp)) = 0
	_sqlite3GetInt32(tls, z, bp)
	return **(**int32)(__ccgo_up(bp))
}

// C documentation
//
//	/*
//	** Called by the parser to compile an ATTACH statement.
//	**
//	**     ATTACH p AS pDbname KEY pKey
//	*/
func _sqlite3Attach(tls *libc.TLS, pParse uintptr, p uintptr, pDbname uintptr, pKey uintptr) {
	_codeAttach(tls, pParse, int32(SQLITE_ATTACH), uintptr(unsafe.Pointer(&_attach_func)), p, p, pDbname, pKey)
}

// C documentation
//
//	/*
//	** Pop an authorization context that was previously pushed
//	** by sqlite3AuthContextPush
//	*/
func _sqlite3AuthContextPop(tls *libc.TLS, pContext uintptr) {
	if (*TAuthContext)(unsafe.Pointer(pContext)).FpParse != 0 {
		(*TParse)(unsafe.Pointer((*TAuthContext)(unsafe.Pointer(pContext)).FpParse)).FzAuthContext = (*TAuthContext)(unsafe.Pointer(pContext)).FzAuthContext
		(*TAuthContext)(unsafe.Pointer(pContext)).FpParse = uintptr(0)
	}
}

// C documentation
//
//	/*
//	** Push an authorization context.  After this routine is called, the
//	** zArg3 argument to authorization callbacks will be zContext until
//	** popped.  Or if pParse==0, this routine is a no-op.
//	*/
func _sqlite3AuthContextPush(tls *libc.TLS, pParse uintptr, pContext uintptr, zContext uintptr) {
	(*TAuthContext)(unsafe.Pointer(pContext)).FpParse = pParse
	(*TAuthContext)(unsafe.Pointer(pContext)).FzAuthContext = (*TParse)(unsafe.Pointer(pParse)).FzAuthContext
	(*TParse)(unsafe.Pointer(pParse)).FzAuthContext = zContext
}

var _sqlite3Autoext = Tsqlite3AutoExtList{}

func _sqlite3AutoincrementEnd(tls *libc.TLS, pParse uintptr) {
	if (*TParse)(unsafe.Pointer(pParse)).FpAinc != 0 {
		_autoIncrementEnd(tls, pParse)
	}
}

// C documentation
//
//	/*
//	** Restart the backup process. This is called when the pager layer
//	** detects that the database has been modified by an external database
//	** connection. In this case there is no way of knowing which of the
//	** pages that have been copied into the destination database are still
//	** valid and which are not, so the entire process needs to be restarted.
//	**
//	** It is assumed that the mutex associated with the BtShared object
//	** corresponding to the source database is held when this function is
//	** called.
//	*/
func _sqlite3BackupRestart(tls *libc.TLS, pBackup uintptr) {
	var p uintptr
	_ = p /* Iterator variable */
	p = pBackup
	for {
		if !(p != 0) {
			break
		}
		(*Tsqlite3_backup)(unsafe.Pointer(p)).FiNext = uint32(1)
		goto _1
	_1:
		;
		p = (*Tsqlite3_backup)(unsafe.Pointer(p)).FpNext
	}
}

func _sqlite3BackupUpdate(tls *libc.TLS, pBackup uintptr, iPage TPgno, aData uintptr) {
	if pBackup != 0 {
		_backupUpdate(tls, pBackup, iPage, aData)
	}
}

// C documentation
//
//	/*
//	** This (sqlite3EndBenignMalloc()) is called by SQLite code to indicate that
//	** subsequent malloc failures are benign. A call to sqlite3EndBenignMalloc()
//	** indicates that subsequent malloc failures are non-benign.
//	*/
func _sqlite3BeginBenignMalloc(tls *libc.TLS) {
	if _sqlite3Hooks.FxBenignBegin != 0 {
		(*(*func(*libc.TLS))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Hooks.FxBenignBegin})))(tls)
	}
}

// C documentation
//
//	/*
//	** Register hooks to call when sqlite3BeginBenignMalloc() and
//	** sqlite3EndBenignMalloc() are called, respectively.
//	*/
func _sqlite3BenignMallocHooks(tls *libc.TLS, __ccgo_fp_xBenignBegin uintptr, __ccgo_fp_xBenignEnd uintptr) {
	_sqlite3Hooks.FxBenignBegin = __ccgo_fp_xBenignBegin
	_sqlite3Hooks.FxBenignEnd = __ccgo_fp_xBenignEnd
}

// C documentation
//
//	/*
//	** Return a pointer to the collation sequence that should be used by
//	** a binary comparison operator comparing pLeft and pRight.
//	**
//	** If the left hand expression has a collating sequence type, then it is
//	** used. Otherwise the collation sequence for the right hand expression
//	** is used, or the default (BINARY) if neither expression has a collating
//	** type.
//	**
//	** Argument pRight (but not pLeft) may be a null pointer. In this case,
//	** it is not considered.
//	*/
func _sqlite3BinaryCompareCollSeq(tls *libc.TLS, pParse uintptr, pLeft uintptr, pRight uintptr) (r uintptr) {
	var pColl uintptr
	_ = pColl
	if (*TExpr)(unsafe.Pointer(pLeft)).Fflags&uint32(EP_Collate) != 0 {
		pColl = _sqlite3ExprCollSeq(tls, pParse, pLeft)
	} else {
		if pRight != 0 && (*TExpr)(unsafe.Pointer(pRight)).Fflags&uint32(EP_Collate) != uint32(0) {
			pColl = _sqlite3ExprCollSeq(tls, pParse, pRight)
		} else {
			pColl = _sqlite3ExprCollSeq(tls, pParse, pLeft)
			if !(pColl != 0) {
				pColl = _sqlite3ExprCollSeq(tls, pParse, pRight)
			}
		}
	}
	return pColl
}

// C documentation
//
//	/*
//	** Create a new bitmap object able to handle bits between 0 and iSize,
//	** inclusive.  Return a pointer to the new object.  Return NULL if
//	** malloc fails.
//	*/
func _sqlite3BitvecCreate(tls *libc.TLS, iSize Tu32) (r uintptr) {
	var p uintptr
	_ = p
	p = _sqlite3MallocZero(tls, uint64(512))
	if p != 0 {
		(*TBitvec)(unsafe.Pointer(p)).FiSize = iSize
	}
	return p
}

// C documentation
//
//	/*
//	** Return the value of the iSize parameter specified when Bitvec *p
//	** was created.
//	*/
func _sqlite3BitvecSize(tls *libc.TLS, p uintptr) (r Tu32) {
	return (*TBitvec)(unsafe.Pointer(p)).FiSize
}

/*
** Let V[] be an array of unsigned characters sufficient to hold
** up to N bits.  Let I be an integer between 0 and N.  0<=I<N.
** Then the following macros can be used to set, clear, or test
** individual bits within V.
 */

func _sqlite3BitvecTest(tls *libc.TLS, p uintptr, i Tu32) (r int32) {
	return libc.BoolInt32(p != uintptr(0) && _sqlite3BitvecTestNotNull(tls, p, i) != 0)
}

// C documentation
//
//	/*
//	** Head of a linked list of all sqlite3 objects created by this process
//	** for which either sqlite3.pBlockingConnection or sqlite3.pUnlockConnection
//	** is not NULL. This variable may only accessed while the STATIC_MAIN
//	** mutex is held.
//	*/
var _sqlite3BlockedList = uintptr(0)

// C documentation
//
//	/*
//	** Start a statement subtransaction. The subtransaction can be rolled
//	** back independently of the main transaction. You must start a transaction
//	** before starting a subtransaction. The subtransaction is ended automatically
//	** if the main transaction commits or rolls back.
//	**
//	** Statement subtransactions are used around individual SQL statements
//	** that are contained within a BEGIN...COMMIT block.  If a constraint
//	** error occurs within the statement, the effect of that one statement
//	** can be rolled back without having to rollback the entire transaction.
//	**
//	** A statement sub-transaction is implemented as an anonymous savepoint. The
//	** value passed as the second parameter is the total number of savepoints,
//	** including the new anonymous savepoint, open on the B-Tree. i.e. if there
//	** are no active savepoints and no other statement-transactions open,
//	** iStatement is 1. This anonymous savepoint can be released or rolled back
//	** using the sqlite3BtreeSavepoint() function.
//	*/
func _sqlite3BtreeBeginStmt(tls *libc.TLS, p uintptr, iStatement int32) (r int32) {
	var pBt uintptr
	var rc int32
	_, _ = pBt, rc
	pBt = (*TBtree)(unsafe.Pointer(p)).FpBt
	_sqlite3BtreeEnter(tls, p)
	/* At the pager level, a statement transaction is a savepoint with
	 ** an index greater than all savepoints created explicitly using
	 ** SQL statements. It is illegal to open, release or rollback any
	 ** such savepoints while the statement transaction savepoint is active.
	 */
	rc = _sqlite3PagerOpenSavepoint(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, iStatement)
	_sqlite3BtreeLeave(tls, p)
	return rc
}

// C documentation
//
//	/*
//	** Clear the current cursor position.
//	*/
func _sqlite3BtreeClearCursor(tls *libc.TLS, pCur uintptr) {
	Xsqlite3_free(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpKey)
	(*TBtCursor)(unsafe.Pointer(pCur)).FpKey = uintptr(0)
	(*TBtCursor)(unsafe.Pointer(pCur)).FeState = uint8(CURSOR_INVALID)
}

// C documentation
//
//	/*
//	** Close an open database and invalidate all cursors.
//	*/
func _sqlite3BtreeClose(tls *libc.TLS, p uintptr) (r int32) {
	var pBt uintptr
	_ = pBt
	pBt = (*TBtree)(unsafe.Pointer(p)).FpBt
	/* Close all cursors opened via this handle.  */
	_sqlite3BtreeEnter(tls, p)
	/* Verify that no other cursors have this Btree open */
	/* Rollback any active transaction and free the handle structure.
	 ** The call to sqlite3BtreeRollback() drops any table-locks held by
	 ** this handle.
	 */
	_sqlite3BtreeRollback(tls, p, SQLITE_OK, 0)
	_sqlite3BtreeLeave(tls, p)
	/* If there are still other outstanding references to the shared-btree
	 ** structure, return now. The remainder of this procedure cleans
	 ** up the shared-btree.
	 */
	if !((*TBtree)(unsafe.Pointer(p)).Fsharable != 0) || _removeFromSharingList(tls, pBt) != 0 {
		/* The pBt is no longer on the sharing list, so we can access
		 ** it without having to hold the mutex.
		 **
		 ** Clean out and delete the BtShared object.
		 */
		_sqlite3PagerClose(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, (*TBtree)(unsafe.Pointer(p)).Fdb)
		if (*TBtShared)(unsafe.Pointer(pBt)).FxFreeSchema != 0 && (*TBtShared)(unsafe.Pointer(pBt)).FpSchema != 0 {
			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TBtShared)(unsafe.Pointer(pBt)).FxFreeSchema})))(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpSchema)
		}
		_sqlite3DbFree(tls, uintptr(0), (*TBtShared)(unsafe.Pointer(pBt)).FpSchema)
		_freeTempSpace(tls, pBt)
		Xsqlite3_free(tls, pBt)
	}
	if (*TBtree)(unsafe.Pointer(p)).FpPrev != 0 {
		(*TBtree)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpPrev)).FpNext = (*TBtree)(unsafe.Pointer(p)).FpNext
	}
	if (*TBtree)(unsafe.Pointer(p)).FpNext != 0 {
		(*TBtree)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpNext)).FpPrev = (*TBtree)(unsafe.Pointer(p)).FpPrev
	}
	Xsqlite3_free(tls, p)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Do both phases of a commit.
//	*/
func _sqlite3BtreeCommit(tls *libc.TLS, p uintptr) (r int32) {
	var rc int32
	_ = rc
	_sqlite3BtreeEnter(tls, p)
	rc = _sqlite3BtreeCommitPhaseOne(tls, p, uintptr(0))
	if rc == SQLITE_OK {
		rc = _sqlite3BtreeCommitPhaseTwo(tls, p, 0)
	}
	_sqlite3BtreeLeave(tls, p)
	return rc
}

// C documentation
//
//	/*
//	** Return the number of connections to the BtShared object accessed by
//	** the Btree handle passed as the only argument. For private caches
//	** this is always 1. For shared caches it may be 1 or greater.
//	*/
func _sqlite3BtreeConnectionCount(tls *libc.TLS, p uintptr) (r int32) {
	return (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FnRef
}

/*
** THREAD SAFETY NOTES:
**
**   Once it has been created using backup_init(), a single sqlite3_backup
**   structure may be accessed via two groups of thread-safe entry points:
**
**     * Via the sqlite3_backup_XXX() API function backup_step() and
**       backup_finish(). Both these functions obtain the source database
**       handle mutex and the mutex associated with the source BtShared
**       structure, in that order.
**
**     * Via the BackupUpdate() and BackupRestart() functions, which are
**       invoked by the pager layer to report various state changes in
**       the page cache associated with the source database. The mutex
**       associated with the source database BtShared structure will always
**       be held when either of these functions are invoked.
**
**   The other sqlite3_backup_XXX() API functions, backup_remaining() and
**   backup_pagecount() are not thread-safe functions. If they are called
**   while some other thread is calling backup_step() or backup_finish(),
**   the values returned may be invalid. There is no way for a call to
**   BackupUpdate() or BackupRestart() to interfere with backup_remaining()
**   or backup_pagecount().
**
**   Depending on the SQLite configuration, the database handles and/or
**   the Btree objects may have their own mutexes that require locking.
**   Non-sharable Btrees (in-memory databases for example), do not have
**   associated mutexes.
 */

func _sqlite3BtreeCreateTable(tls *libc.TLS, p uintptr, piTable uintptr, flags int32) (r int32) {
	var rc int32
	_ = rc
	_sqlite3BtreeEnter(tls, p)
	rc = _btreeCreateTable(tls, p, piTable, flags)
	_sqlite3BtreeLeave(tls, p)
	return rc
}

func _sqlite3BtreeCursor(tls *libc.TLS, p uintptr, iTable TPgno, wrFlag int32, pKeyInfo uintptr, pCur uintptr) (r int32) {
	if (*TBtree)(unsafe.Pointer(p)).Fsharable != 0 {
		return _btreeCursorWithLock(tls, p, iTable, wrFlag, pKeyInfo, pCur)
	} else {
		return _btreeCursor(tls, p, iTable, wrFlag, pKeyInfo, pCur)
	}
	return r
}

// C documentation
//
//	/*
//	** Return true if the cursor has a hint specified.  This routine is
//	** only used from within assert() statements
//	*/
func _sqlite3BtreeCursorHasHint(tls *libc.TLS, pCsr uintptr, mask uint32) (r int32) {
	return libc.BoolInt32(uint32((*TBtCursor)(unsafe.Pointer(pCsr)).Fhints)&mask != uint32(0))
}

// C documentation
//
//	/*
//	** Provide flag hints to the cursor.
//	*/
func _sqlite3BtreeCursorHintFlags(tls *libc.TLS, pCur uintptr, x uint32) {
	(*TBtCursor)(unsafe.Pointer(pCur)).Fhints = uint8(x)
}

// C documentation
//
//	/*
//	** Pin or unpin a cursor.
//	*/
func _sqlite3BtreeCursorPin(tls *libc.TLS, pCur uintptr) {
	var v1 uintptr
	_ = v1
	v1 = pCur + 1
	*(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTCF_Pinned))
}

func _sqlite3BtreeCursorUnpin(tls *libc.TLS, pCur uintptr) {
	var v1 uintptr
	_ = v1
	v1 = pCur + 1
	*(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) & ^libc.Int32FromInt32(BTCF_Pinned))
}

// C documentation
//
//	/*
//	** Enter a mutex on the given BTree object.
//	**
//	** If the object is not sharable, then no mutex is ever required
//	** and this routine is a no-op.  The underlying mutex is non-recursive.
//	** But we keep a reference count in Btree.wantToLock so the behavior
//	** of this interface is recursive.
//	**
//	** To avoid deadlocks, multiple Btrees are locked in the same order
//	** by all database connections.  The p->pNext is a list of other
//	** Btrees belonging to the same database connection as the p Btree
//	** which need to be locked after p.  If we cannot get a lock on
//	** p, then first unlock all of the others on p->pNext, then wait
//	** for the lock to become available on p, then relock all of the
//	** subsequent Btrees that desire a lock.
//	*/
func _sqlite3BtreeEnter(tls *libc.TLS, p uintptr) {
	/* Some basic sanity checking on the Btree.  The list of Btrees
	 ** connected by pNext and pPrev should be in sorted order by
	 ** Btree.pBt value. All elements of the list should belong to
	 ** the same connection. Only shared Btrees are on the list. */
	/* Check for locking consistency */
	/* We should already hold a lock on the database connection */
	/* Unless the database is sharable and unlocked, then BtShared.db
	 ** should already be set correctly. */
	if !((*TBtree)(unsafe.Pointer(p)).Fsharable != 0) {
		return
	}
	(*TBtree)(unsafe.Pointer(p)).FwantToLock = (*TBtree)(unsafe.Pointer(p)).FwantToLock + 1
	if (*TBtree)(unsafe.Pointer(p)).Flocked != 0 {
		return
	}
	_btreeLockCarefully(tls, p)
}

// C documentation
//
//	/*
//	** Enter a mutex on a Btree given a cursor owned by that Btree.
//	**
//	** These entry points are used by incremental I/O only. Enter() is required
//	** any time OMIT_SHARED_CACHE is not defined, regardless of whether or not
//	** the build is threadsafe. Leave() is only required by threadsafe builds.
//	*/
func _sqlite3BtreeEnterCursor(tls *libc.TLS, pCur uintptr) {
	_sqlite3BtreeEnter(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpBtree)
}

// C documentation
//
//	/*
//	** Return a pointer to a fake BtCursor object that will always answer
//	** false to the sqlite3BtreeCursorHasMoved() routine above.  The fake
//	** cursor returned must not be used with any other Btree interface.
//	*/
func _sqlite3BtreeFakeValidCursor(tls *libc.TLS) (r uintptr) {
	return uintptr(unsafe.Pointer(&_fakeCursor))
}

// C documentation
//
//	/* Move the cursor to the first entry in the table.  Return SQLITE_OK
//	** on success.  Set *pRes to 0 if the cursor actually points to something
//	** or set *pRes to 1 if the table is empty.
//	*/
func _sqlite3BtreeFirst(tls *libc.TLS, pCur uintptr, pRes uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = _moveToRoot(tls, pCur)
	if rc == SQLITE_OK {
		**(**int32)(__ccgo_up(pRes)) = 0
		rc = _moveToLeftmost(tls, pCur)
	} else {
		if rc == int32(SQLITE_EMPTY) {
			**(**int32)(__ccgo_up(pRes)) = int32(1)
			rc = SQLITE_OK
		}
	}
	return rc
}

// C documentation
//
//	/*
//	** Return the value of the 'auto-vacuum' property. If auto-vacuum is
//	** enabled 1 is returned. Otherwise 0.
//	*/
func _sqlite3BtreeGetAutoVacuum(tls *libc.TLS, p uintptr) (r int32) {
	var rc, v1, v2 int32
	_, _, _ = rc, v1, v2
	_sqlite3BtreeEnter(tls, p)
	if !((*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FautoVacuum != 0) {
		v1 = BTREE_AUTOVACUUM_NONE
	} else {
		if !((*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FincrVacuum != 0) {
			v2 = int32(BTREE_AUTOVACUUM_FULL)
		} else {
			v2 = int32(BTREE_AUTOVACUUM_INCR)
		}
		v1 = v2
	}
	rc = v1
	_sqlite3BtreeLeave(tls, p)
	return rc
}

// C documentation
//
//	/*
//	** Return the full pathname of the underlying database file.  Return
//	** an empty string if the database is in-memory or a TEMP database.
//	**
//	** The pager filename is invariant as long as the pager is
//	** open so it is safe to access without the BtShared mutex.
//	*/
func _sqlite3BtreeGetFilename(tls *libc.TLS, p uintptr) (r uintptr) {
	return _sqlite3PagerFilename(tls, (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FpPager, int32(1))
}

// C documentation
//
//	/*
//	** Return the pathname of the journal file for this database. The return
//	** value of this routine is the same regardless of whether the journal file
//	** has been created or not.
//	**
//	** The pager journal filename is invariant as long as the pager is
//	** open so it is safe to access without the BtShared mutex.
//	*/
func _sqlite3BtreeGetJournalname(tls *libc.TLS, p uintptr) (r uintptr) {
	return _sqlite3PagerJournalname(tls, (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FpPager)
}

// C documentation
//
//	/*
//	** This function may only be called if the b-tree connection already
//	** has a read or write transaction open on the database.
//	**
//	** Read the meta-information out of a database file.  Meta[0]
//	** is the number of free pages currently in the database.  Meta[1]
//	** through meta[15] are available for use by higher layers.  Meta[0]
//	** is read-only, the others are read/write.
//	**
//	** The schema layer numbers meta values differently.  At the schema
//	** layer (and the SetCookie and ReadCookie opcodes) the number of
//	** free pages is not visible.  So Cookie[0] is the same as Meta[1].
//	**
//	** This routine treats Meta[BTREE_DATA_VERSION] as a special case.  Instead
//	** of reading the value out of the header, it instead loads the "DataVersion"
//	** from the pager.  The BTREE_DATA_VERSION value is not actually stored in the
//	** database file.  It is a number computed by the pager.  But its access
//	** pattern is the same as header meta values, and so it is convenient to
//	** read it from this routine.
//	*/
func _sqlite3BtreeGetMeta(tls *libc.TLS, p uintptr, idx int32, pMeta uintptr) {
	var pBt uintptr
	_ = pBt
	pBt = (*TBtree)(unsafe.Pointer(p)).FpBt
	_sqlite3BtreeEnter(tls, p)
	if idx == int32(BTREE_DATA_VERSION) {
		**(**Tu32)(__ccgo_up(pMeta)) = _sqlite3PagerDataVersion(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager) + (*TBtree)(unsafe.Pointer(p)).FiBDataVersion
	} else {
		**(**Tu32)(__ccgo_up(pMeta)) = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+uintptr(int32(36)+idx*int32(4)))
	}
	/* If auto-vacuum is disabled in this build and this is an auto-vacuum
	 ** database, mark the database as read-only.  */
	_sqlite3BtreeLeave(tls, p)
}

// C documentation
//
//	/*
//	** A write-transaction must be opened before calling this function.
//	** It performs a single unit of work towards an incremental vacuum.
//	**
//	** If the incremental vacuum is finished after this function has run,
//	** SQLITE_DONE is returned. If it is not finished, but no error occurred,
//	** SQLITE_OK is returned. Otherwise an SQLite error code.
//	*/
func _sqlite3BtreeIncrVacuum(tls *libc.TLS, p uintptr) (r int32) {
	var nFin, nFree, nOrig TPgno
	var pBt uintptr
	var rc int32
	_, _, _, _, _ = nFin, nFree, nOrig, pBt, rc
	pBt = (*TBtree)(unsafe.Pointer(p)).FpBt
	_sqlite3BtreeEnter(tls, p)
	if !((*TBtShared)(unsafe.Pointer(pBt)).FautoVacuum != 0) {
		rc = int32(SQLITE_DONE)
	} else {
		nOrig = _btreePagecount(tls, pBt)
		nFree = _sqlite3Get4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+36)
		nFin = _finalDbSize(tls, pBt, nOrig, nFree)
		if nOrig < nFin || nFree >= nOrig {
			rc = _sqlite3CorruptError(tls, int32(77405))
		} else {
			if nFree > uint32(0) {
				rc = _saveAllCursors(tls, pBt, uint32(0), uintptr(0))
				if rc == SQLITE_OK {
					_invalidateAllOverflowCache(tls, pBt)
					rc = _incrVacuumStep(tls, pBt, nFin, nOrig, 0)
				}
				if rc == SQLITE_OK {
					rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage)
					_sqlite3Put4byte(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData+28, (*TBtShared)(unsafe.Pointer(pBt)).FnPage)
				}
			} else {
				rc = int32(SQLITE_DONE)
			}
		}
	}
	_sqlite3BtreeLeave(tls, p)
	return rc
}

// C documentation
//
//	/*
//	** Mark this cursor as an incremental blob cursor.
//	*/
func _sqlite3BtreeIncrblobCursor(tls *libc.TLS, pCur uintptr) {
	var v1 uintptr
	_ = v1
	v1 = pCur + 1
	*(*Tu8)(unsafe.Pointer(v1)) = Tu8(int32(*(*Tu8)(unsafe.Pointer(v1))) | libc.Int32FromInt32(BTCF_Incrblob))
	(*TBtree)(unsafe.Pointer((*TBtCursor)(unsafe.Pointer(pCur)).FpBtree)).FhasIncrblobCur = uint8(1)
}

// C documentation
//
//	/*
//	** Return the value of the integer key or "rowid" for a table btree.
//	** This routine is only valid for a cursor that is pointing into a
//	** ordinary table btree.  If the cursor points to an index btree or
//	** is invalid, the result of this routine is undefined.
//	*/
func _sqlite3BtreeIntegerKey(tls *libc.TLS, pCur uintptr) (r Ti64) {
	_getCellInfo(tls, pCur)
	return (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnKey
}

// C documentation
//
//	/*
//	** Return true if there is currently a backup running on Btree p.
//	*/
func _sqlite3BtreeIsInBackup(tls *libc.TLS, p uintptr) (r int32) {
	return libc.BoolInt32((*TBtree)(unsafe.Pointer(p)).FnBackup != 0)
}

func _sqlite3BtreeLastPage(tls *libc.TLS, p uintptr) (r TPgno) {
	return _btreePagecount(tls, (*TBtree)(unsafe.Pointer(p)).FpBt)
}

// C documentation
//
//	/*
//	** Exit the recursive mutex on a Btree.
//	*/
func _sqlite3BtreeLeave(tls *libc.TLS, p uintptr) {
	if (*TBtree)(unsafe.Pointer(p)).Fsharable != 0 {
		(*TBtree)(unsafe.Pointer(p)).FwantToLock = (*TBtree)(unsafe.Pointer(p)).FwantToLock - 1
		if (*TBtree)(unsafe.Pointer(p)).FwantToLock == 0 {
			_unlockBtreeMutex(tls, p)
		}
	}
}

func _sqlite3BtreeLeaveCursor(tls *libc.TLS, pCur uintptr) {
	_sqlite3BtreeLeave(tls, (*TBtCursor)(unsafe.Pointer(pCur)).FpBtree)
}

/************** End of btmutex.c *********************************************/
/************** Begin file btree.c *******************************************/
/*
** 2004 April 6
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file implements an external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
** Including a description of file format and an overview of operation.
 */
/* #include "btreeInt.h" */

// C documentation
//
//	/*
//	** Set the maximum page count for a database if mxPage is positive.
//	** No changes are made if mxPage is 0 or negative.
//	** Regardless of the value of mxPage, return the maximum page count.
//	*/
func _sqlite3BtreeMaxPageCount(tls *libc.TLS, p uintptr, mxPage TPgno) (r TPgno) {
	var n TPgno
	_ = n
	_sqlite3BtreeEnter(tls, p)
	n = _sqlite3PagerMaxPageCount(tls, (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FpPager, mxPage)
	_sqlite3BtreeLeave(tls, p)
	return n
}

// C documentation
//
//	/*
//	** Initialize the first page of the database file (creating a database
//	** consisting of a single page and no schema objects). Return SQLITE_OK
//	** if successful, or an SQLite error code otherwise.
//	*/
func _sqlite3BtreeNewDb(tls *libc.TLS, p uintptr) (r int32) {
	var rc int32
	_ = rc
	_sqlite3BtreeEnter(tls, p)
	(*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FnPage = uint32(0)
	rc = _newDatabase(tls, (*TBtree)(unsafe.Pointer(p)).FpBt)
	_sqlite3BtreeLeave(tls, p)
	return rc
}

// C documentation
//
//	/*
//	** Return the pager associated with a BTree.  This routine is used for
//	** testing and debugging only.
//	*/
func _sqlite3BtreePager(tls *libc.TLS, p uintptr) (r uintptr) {
	return (*TBtShared)(unsafe.Pointer((*TBtree)(unsafe.Pointer(p)).FpBt)).FpPager
}

// C documentation
//
//	/*
//	** Read part of the payload for the row at which that cursor pCur is currently
//	** pointing.  "amt" bytes will be transferred into pBuf[].  The transfer
//	** begins at "offset".
//	**
//	** pCur can be pointing to either a table or an index b-tree.
//	** If pointing to a table btree, then the content section is read.  If
//	** pCur is pointing to an index b-tree then the key section is read.
//	**
//	** For sqlite3BtreePayload(), the caller must ensure that pCur is pointing
//	** to a valid row in the table.  For sqlite3BtreePayloadChecked(), the
//	** cursor might be invalid or might need to be restored before being read.
//	**
//	** Return SQLITE_OK on success or an error code if anything goes
//	** wrong.  An error is returned if "offset+amt" is larger than
//	** the available payload.
//	*/
func _sqlite3BtreePayload(tls *libc.TLS, pCur uintptr, offset Tu32, amt Tu32, pBuf uintptr) (r int32) {
	return _accessPayload(tls, pCur, offset, amt, pBuf, 0)
}

// C documentation
//
//	/*
//	** For the entry that cursor pCur is point to, return as
//	** many bytes of the key or data as are available on the local
//	** b-tree page.  Write the number of available bytes into *pAmt.
//	**
//	** The pointer returned is ephemeral.  The key/data may move
//	** or be destroyed on the next call to any Btree routine,
//	** including calls from other threads against the same cache.
//	** Hence, a mutex on the BtShared should be held prior to calling
//	** this routine.
//	**
//	** These routines is used to get quick access to key and data
//	** in the common case where no overflow pages are used.
//	*/
func _sqlite3BtreePayloadFetch(tls *libc.TLS, pCur uintptr, pAmt uintptr) (r uintptr) {
	return _fetchPayload(tls, pCur, pAmt)
}

// C documentation
//
//	/*
//	** Return the number of bytes of payload for the entry that pCur is
//	** currently pointing to.  For table btrees, this will be the amount
//	** of data.  For index btrees, this will be the size of the key.
//	**
//	** The caller must guarantee that the cursor is pointing to a non-NULL
//	** valid entry.  In other words, the calling procedure must guarantee
//	** that the cursor has Cursor.eState==CURSOR_VALID.
//	*/
func _sqlite3BtreePayloadSize(tls *libc.TLS, pCur uintptr) (r Tu32) {
	_getCellInfo(tls, pCur)
	return (*TBtCursor)(unsafe.Pointer(pCur)).Finfo.FnPayload
}

// C documentation
//
//	/*
//	** Return SQLITE_LOCKED_SHAREDCACHE if another user of the same shared
//	** btree as the argument handle holds an exclusive lock on the
//	** sqlite_schema table. Otherwise SQLITE_OK.
//	*/
func _sqlite3BtreeSchemaLocked(tls *libc.TLS, p uintptr) (r int32) {
	var rc int32
	_ = rc
	_ = p /* only used in DEBUG builds */
	_sqlite3BtreeEnter(tls, p)
	rc = _querySharedCacheTableLock(tls, p, uint32(SCHEMA_ROOT), uint8(READ_LOCK))
	_sqlite3BtreeLeave(tls, p)
	return rc
}

// C documentation
//
//	/*
//	** Change the "soft" limit on the number of pages in the cache.
//	** Unused and unmodified pages will be recycled when the number of
//	** pages in the cache exceeds this soft limit.  But the size of the
//	** cache is allowed to grow larger than this limit if it contains
//	** dirty pages or pages still in active use.
//	*/
func _sqlite3BtreeSetCacheSize(tls *libc.TLS, p uintptr, mxPage int32) (r int32) {
	var pBt uintptr
	_ = pBt
	pBt = (*TBtree)(unsafe.Pointer(p)).FpBt
	_sqlite3BtreeEnter(tls, p)
	_sqlite3PagerSetCachesize(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, mxPage)
	_sqlite3BtreeLeave(tls, p)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Change the way data is synced to disk in order to increase or decrease
//	** how well the database resists damage due to OS crashes and power
//	** failures.  Level 1 is the same as asynchronous (no syncs() occur and
//	** there is a high probability of damage)  Level 2 is the default.  There
//	** is a very low but non-zero probability of damage.  Level 3 reduces the
//	** probability of damage to near zero but with a write performance reduction.
//	*/
func _sqlite3BtreeSetPagerFlags(tls *libc.TLS, p uintptr, pgFlags uint32) (r int32) {
	var pBt uintptr
	_ = pBt
	pBt = (*TBtree)(unsafe.Pointer(p)).FpBt
	_sqlite3BtreeEnter(tls, p)
	_sqlite3PagerSetFlags(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, pgFlags)
	_sqlite3BtreeLeave(tls, p)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Change the "spill" limit on the number of pages in the cache.
//	** If the number of pages exceeds this limit during a write transaction,
//	** the pager might attempt to "spill" pages to the journal early in
//	** order to free up memory.
//	**
//	** The value returned is the current spill size.  If zero is passed
//	** as an argument, no changes are made to the spill size setting, so
//	** using mxPage of 0 is a way to query the current spill size.
//	*/
func _sqlite3BtreeSetSpillSize(tls *libc.TLS, p uintptr, mxPage int32) (r int32) {
	var pBt uintptr
	var res int32
	_, _ = pBt, res
	pBt = (*TBtree)(unsafe.Pointer(p)).FpBt
	_sqlite3BtreeEnter(tls, p)
	res = _sqlite3PagerSetSpillsize(tls, (*TBtShared)(unsafe.Pointer(pBt)).FpPager, mxPage)
	_sqlite3BtreeLeave(tls, p)
	return res
}

// C documentation
//
//	/*
//	** Write meta-information back into the database.  Meta[0] is
//	** read-only and may not be written.
//	*/
func _sqlite3BtreeUpdateMeta(tls *libc.TLS, p uintptr, idx int32, iMeta Tu32) (r int32) {
	var pBt, pP1 uintptr
	var rc int32
	_, _, _ = pBt, pP1, rc
	pBt = (*TBtree)(unsafe.Pointer(p)).FpBt
	_sqlite3BtreeEnter(tls, p)
	pP1 = (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FaData
	rc = _sqlite3PagerWrite(tls, (*TMemPage)(unsafe.Pointer((*TBtShared)(unsafe.Pointer(pBt)).FpPage1)).FpDbPage)
	if rc == SQLITE_OK {
		_sqlite3Put4byte(tls, pP1+uintptr(int32(36)+idx*int32(4)), iMeta)
		if idx == int32(BTREE_INCR_VACUUM) {
			(*TBtShared)(unsafe.Pointer(pBt)).FincrVacuum = uint8(iMeta)
		}
	}
	_sqlite3BtreeLeave(tls, p)
	return rc
}

// C documentation
//
//	/*
//	** An array of pointers to extension initializer functions for
//	** built-in extensions.
//	*/
var _sqlite3BuiltinExtensions = [5]uintptr{}

// C documentation
//
//	/*
//	** Hash table for global functions - functions common to all
//	** database connections.  After initialization, this table is
//	** read-only.
//	*/
var _sqlite3BuiltinFunctions TFuncDefHash

// C documentation
//
//	/*
//	** This routine is called on a collation sequence before it is used to
//	** check that it is defined. An undefined collation sequence exists when
//	** a database is loaded that contains references to collation sequences
//	** that have not been defined by sqlite3_create_collation() etc.
//	**
//	** If required, this routine calls the 'collation needed' callback to
//	** request a definition of the collating sequence. If this doesn't work,
//	** an equivalent collating sequence that uses a text encoding different
//	** from the main database is substituted, if one is available.
//	*/
func _sqlite3CheckCollSeq(tls *libc.TLS, pParse uintptr, pColl uintptr) (r int32) {
	var db, p, zName uintptr
	_, _, _ = db, p, zName
	if pColl != 0 && (*TCollSeq)(unsafe.Pointer(pColl)).FxCmp == uintptr(0) {
		zName = (*TCollSeq)(unsafe.Pointer(pColl)).FzName
		db = (*TParse)(unsafe.Pointer(pParse)).Fdb
		p = _sqlite3GetCollSeq(tls, pParse, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, pColl, zName)
		if !(p != 0) {
			return int32(SQLITE_ERROR)
		}
	}
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Clear both elements of an OnOrUsing object
//	*/
func _sqlite3ClearOnOrUsing(tls *libc.TLS, db uintptr, p uintptr) {
	if p == uintptr(0) {
		/* Nothing to clear */
	} else {
		if (*TOnOrUsing)(unsafe.Pointer(p)).FpOn != 0 {
			_sqlite3ExprDeleteNN(tls, db, (*TOnOrUsing)(unsafe.Pointer(p)).FpOn)
		} else {
			if (*TOnOrUsing)(unsafe.Pointer(p)).FpUsing != 0 {
				_sqlite3IdListDelete(tls, db, (*TOnOrUsing)(unsafe.Pointer(p)).FpUsing)
			}
		}
	}
}

// C documentation
//
//	/*
//	** Mark all temporary registers as being unavailable for reuse.
//	**
//	** Always invoke this procedure after coding a subroutine or co-routine
//	** that might be invoked from other parts of the code, to ensure that
//	** the sub/co-routine does not use registers in common with the code that
//	** invokes the sub/co-routine.
//	*/
func _sqlite3ClearTempRegCache(tls *libc.TLS, pParse uintptr) {
	(*TParse)(unsafe.Pointer(pParse)).FnTempReg = uint8(0)
	(*TParse)(unsafe.Pointer(pParse)).FnRangeReg = 0
}

// C documentation
//
//	/*
//	** Close all open savepoints. This function only manipulates fields of the
//	** database handle object, it does not close any savepoints that may be open
//	** at the b-tree/pager level.
//	*/
func _sqlite3CloseSavepoints(tls *libc.TLS, db uintptr) {
	var pTmp uintptr
	_ = pTmp
	for (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint != 0 {
		pTmp = (*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint
		(*Tsqlite3)(unsafe.Pointer(db)).FpSavepoint = (*TSavepoint)(unsafe.Pointer(pTmp)).FpNext
		_sqlite3DbFree(tls, db, pTmp)
	}
	(*Tsqlite3)(unsafe.Pointer(db)).FnSavepoint = 0
	(*Tsqlite3)(unsafe.Pointer(db)).FnStatement = 0
	(*Tsqlite3)(unsafe.Pointer(db)).FisTransactionSavepoint = uint8(0)
}

// C documentation
//
//	/* Generate byte-code that will report the number of rows modified
//	** by a DELETE, INSERT, or UPDATE statement.
//	*/
func _sqlite3CodeChangeCount(tls *libc.TLS, v uintptr, regCounter int32, zColName uintptr) {
	_sqlite3VdbeAddOp0(tls, v, int32(OP_FkCheck))
	_sqlite3VdbeAddOp2(tls, v, int32(OP_ResultRow), regCounter, int32(1))
	_sqlite3VdbeSetNumCols(tls, v, int32(1))
	_sqlite3VdbeSetColName(tls, v, 0, COLNAME_NAME, zColName, libc.UintptrFromInt32(0))
}

func _sqlite3CodeVerifySchema(tls *libc.TLS, pParse uintptr, iDb int32) {
	var v1 uintptr
	_ = v1
	if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 {
		v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel
	} else {
		v1 = pParse
	}
	_sqlite3CodeVerifySchemaAtToplevel(tls, v1, iDb)
}

// C documentation
//
//	/*
//	** This function is called while stepping or preparing a statement
//	** associated with connection db. The operation will return SQLITE_LOCKED
//	** to the user because it requires a lock that will not be available
//	** until connection pBlocker concludes its current transaction.
//	*/
func _sqlite3ConnectionBlocked(tls *libc.TLS, db uintptr, pBlocker uintptr) {
	_enterMutex(tls)
	if (*Tsqlite3)(unsafe.Pointer(db)).FpBlockingConnection == uintptr(0) && (*Tsqlite3)(unsafe.Pointer(db)).FpUnlockConnection == uintptr(0) {
		_addToBlockedList(tls, db)
	}
	(*Tsqlite3)(unsafe.Pointer(db)).FpBlockingConnection = pBlocker
	_leaveMutex(tls)
}

// C documentation
//
//	/*
//	** This is called when the database connection passed as an argument is
//	** being closed. The connection is removed from the blocked list.
//	*/
func _sqlite3ConnectionClosed(tls *libc.TLS, db uintptr) {
	_sqlite3ConnectionUnlocked(tls, db)
	_enterMutex(tls)
	_removeFromBlockedList(tls, db)
	_leaveMutex(tls)
}

/************** End of notify.c **********************************************/
/************** Begin file fts3.c ********************************************/
/*
** 2006 Oct 10
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This is an SQLite module implementing full-text search.
 */

/*
** The code in this file is only compiled if:
**
**     * The FTS3 module is being built as an extension
**       (in which case SQLITE_CORE is not defined), or
**
**     * The FTS3 module is being built into the core of
**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
 */

/* The full-text index is stored in a series of b+tree (-like)
** structures called segments which map terms to doclists.  The
** structures are like b+trees in layout, but are constructed from the
** bottom up in optimal fashion and are not updatable.  Since trees
** are built from the bottom up, things will be described from the
** bottom up.
**
**
**** Varints ****
** The basic unit of encoding is a variable-length integer called a
** varint.  We encode variable-length integers in little-endian order
** using seven bits * per byte as follows:
**
** KEY:
**         A = 0xxxxxxx    7 bits of data and one flag bit
**         B = 1xxxxxxx    7 bits of data and one flag bit
**
**  7 bits - A
** 14 bits - BA
** 21 bits - BBA
** and so on.
**
** This is similar in concept to how sqlite encodes "varints" but
** the encoding is not the same.  SQLite varints are big-endian
** are are limited to 9 bytes in length whereas FTS3 varints are
** little-endian and can be up to 10 bytes in length (in theory).
**
** Example encodings:
**
**     1:    0x01
**   127:    0x7f
**   128:    0x81 0x00
**
**
**** Document lists ****
** A doclist (document list) holds a docid-sorted list of hits for a
** given term.  Doclists hold docids and associated token positions.
** A docid is the unique integer identifier for a single document.
** A position is the index of a word within the document.  The first
** word of the document has a position of 0.
**
** FTS3 used to optionally store character offsets using a compile-time
** option.  But that functionality is no longer supported.
**
** A doclist is stored like this:
**
** array {
**   varint docid;          (delta from previous doclist)
**   array {                (position list for column 0)
**     varint position;     (2 more than the delta from previous position)
**   }
**   array {
**     varint POS_COLUMN;   (marks start of position list for new column)
**     varint column;       (index of new column)
**     array {
**       varint position;   (2 more than the delta from previous position)
**     }
**   }
**   varint POS_END;        (marks end of positions for this document.
** }
**
** Here, array { X } means zero or more occurrences of X, adjacent in
** memory.  A "position" is an index of a token in the token stream
** generated by the tokenizer. Note that POS_END and POS_COLUMN occur
** in the same logical place as the position element, and act as sentinels
** ending a position list array.  POS_END is 0.  POS_COLUMN is 1.
** The positions numbers are not stored literally but rather as two more
** than the difference from the prior position, or the just the position plus
** 2 for the first position.  Example:
**
**   label:       A B C D E  F  G H   I  J K
**   value:     123 5 9 1 1 14 35 0 234 72 0
**
** The 123 value is the first docid.  For column zero in this document
** there are two matches at positions 3 and 10 (5-2 and 9-2+3).  The 1
** at D signals the start of a new column; the 1 at E indicates that the
** new column is column number 1.  There are two positions at 12 and 45
** (14-2 and 35-2+12).  The 0 at H indicate the end-of-document.  The
** 234 at I is the delta to next docid (357).  It has one position 70
** (72-2) and then terminates with the 0 at K.
**
** A "position-list" is the list of positions for multiple columns for
** a single docid.  A "column-list" is the set of positions for a single
** column.  Hence, a position-list consists of one or more column-lists,
** a document record consists of a docid followed by a position-list and
** a doclist consists of one or more document records.
**
** A bare doclist omits the position information, becoming an
** array of varint-encoded docids.
**
**** Segment leaf nodes ****
** Segment leaf nodes store terms and doclists, ordered by term.  Leaf
** nodes are written using LeafWriter, and read using LeafReader (to
** iterate through a single leaf node's data) and LeavesReader (to
** iterate through a segment's entire leaf layer).  Leaf nodes have
** the format:
**
** varint iHeight;             (height from leaf level, always 0)
** varint nTerm;               (length of first term)
** char pTerm[nTerm];          (content of first term)
** varint nDoclist;            (length of term's associated doclist)
** char pDoclist[nDoclist];    (content of doclist)
** array {
**                             (further terms are delta-encoded)
**   varint nPrefix;           (length of prefix shared with previous term)
**   varint nSuffix;           (length of unshared suffix)
**   char pTermSuffix[nSuffix];(unshared suffix of next term)
**   varint nDoclist;          (length of term's associated doclist)
**   char pDoclist[nDoclist];  (content of doclist)
** }
**
** Here, array { X } means zero or more occurrences of X, adjacent in
** memory.
**
** Leaf nodes are broken into blocks which are stored contiguously in
** the %_segments table in sorted order.  This means that when the end
** of a node is reached, the next term is in the node with the next
** greater node id.
**
** New data is spilled to a new leaf node when the current node
** exceeds LEAF_MAX bytes (default 2048).  New data which itself is
** larger than STANDALONE_MIN (default 1024) is placed in a standalone
** node (a leaf node with a single term and doclist).  The goal of
** these settings is to pack together groups of small doclists while
** making it efficient to directly access large doclists.  The
** assumption is that large doclists represent terms which are more
** likely to be query targets.
**
** TODO(shess) It may be useful for blocking decisions to be more
** dynamic.  For instance, it may make more sense to have a 2.5k leaf
** node rather than splitting into 2k and .5k nodes.  My intuition is
** that this might extend through 2x or 4x the pagesize.
**
**
**** Segment interior nodes ****
** Segment interior nodes store blockids for subtree nodes and terms
** to describe what data is stored by the each subtree.  Interior
** nodes are written using InteriorWriter, and read using
** InteriorReader.  InteriorWriters are created as needed when
** SegmentWriter creates new leaf nodes, or when an interior node
** itself grows too big and must be split.  The format of interior
** nodes:
**
** varint iHeight;           (height from leaf level, always >0)
** varint iBlockid;          (block id of node's leftmost subtree)
** optional {
**   varint nTerm;           (length of first term)
**   char pTerm[nTerm];      (content of first term)
**   array {
**                                (further terms are delta-encoded)
**     varint nPrefix;            (length of shared prefix with previous term)
**     varint nSuffix;            (length of unshared suffix)
**     char pTermSuffix[nSuffix]; (unshared suffix of next term)
**   }
** }
**
** Here, optional { X } means an optional element, while array { X }
** means zero or more occurrences of X, adjacent in memory.
**
** An interior node encodes n terms separating n+1 subtrees.  The
** subtree blocks are contiguous, so only the first subtree's blockid
** is encoded.  The subtree at iBlockid will contain all terms less
** than the first term encoded (or all terms if no term is encoded).
** Otherwise, for terms greater than or equal to pTerm[i] but less
** than pTerm[i+1], the subtree for that term will be rooted at
** iBlockid+i.  Interior nodes only store enough term data to
** distinguish adjacent children (if the rightmost term of the left
** child is "something", and the leftmost term of the right child is
** "wicked", only "w" is stored).
**
** New data is spilled to a new interior node at the same height when
** the current node exceeds INTERIOR_MAX bytes (default 2048).
** INTERIOR_MIN_TERMS (default 7) keeps large terms from monopolizing
** interior nodes and making the tree too skinny.  The interior nodes
** at a given height are naturally tracked by interior nodes at
** height+1, and so on.
**
**
**** Segment directory ****
** The segment directory in table %_segdir stores meta-information for
** merging and deleting segments, and also the root node of the
** segment's tree.
**
** The root node is the top node of the segment's tree after encoding
** the entire segment, restricted to ROOT_MAX bytes (default 1024).
** This could be either a leaf node or an interior node.  If the top
** node requires more than ROOT_MAX bytes, it is flushed to %_segments
** and a new root interior node is generated (which should always fit
** within ROOT_MAX because it only needs space for 2 varints, the
** height and the blockid of the previous root).
**
** The meta-information in the segment directory is:
**   level               - segment level (see below)
**   idx                 - index within level
**                       - (level,idx uniquely identify a segment)
**   start_block         - first leaf node
**   leaves_end_block    - last leaf node
**   end_block           - last block (including interior nodes)
**   root                - contents of root node
**
** If the root node is a leaf node, then start_block,
** leaves_end_block, and end_block are all 0.
**
**
**** Segment merging ****
** To amortize update costs, segments are grouped into levels and
** merged in batches.  Each increase in level represents exponentially
** more documents.
**
** New documents (actually, document updates) are tokenized and
** written individually (using LeafWriter) to a level 0 segment, with
** incrementing idx.  When idx reaches MERGE_COUNT (default 16), all
** level 0 segments are merged into a single level 1 segment.  Level 1
** is populated like level 0, and eventually MERGE_COUNT level 1
** segments are merged to a single level 2 segment (representing
** MERGE_COUNT^2 updates), and so on.
**
** A segment merge traverses all segments at a given level in
** parallel, performing a straightforward sorted merge.  Since segment
** leaf nodes are written in to the %_segments table in order, this
** merge traverses the underlying sqlite disk structures efficiently.
** After the merge, all segment blocks from the merged level are
** deleted.
**
** MERGE_COUNT controls how often we merge segments.  16 seems to be
** somewhat of a sweet spot for insertion performance.  32 and 64 show
** very similar performance numbers to 16 on insertion, though they're
** a tiny bit slower (perhaps due to more overhead in merge-time
** sorting).  8 is about 20% slower than 16, 4 about 50% slower than
** 16, 2 about 66% slower than 16.
**
** At query time, high MERGE_COUNT increases the number of segments
** which need to be scanned and merged.  For instance, with 100k docs
** inserted:
**
**    MERGE_COUNT   segments
**       16           25
**        8           12
**        4           10
**        2            6
**
** This appears to have only a moderate impact on queries for very
** frequent terms (which are somewhat dominated by segment merge
** costs), and infrequent and non-existent terms still seem to be fast
** even with many segments.
**
** TODO(shess) That said, it would be nice to have a better query-side
** argument for MERGE_COUNT of 16.  Also, it is possible/likely that
** optimizations to things like doclist merging will swing the sweet
** spot around.
**
**
**
**** Handling of deletions and updates ****
** Since we're using a segmented structure, with no docid-oriented
** index into the term index, we clearly cannot simply update the term
** index when a document is deleted or updated.  For deletions, we
** write an empty doclist (varint(docid) varint(POS_END)), for updates
** we simply write the new doclist.  Segment merges overwrite older
** data for a particular docid with newer data, so deletes or updates
** will eventually overtake the earlier data and knock it out.  The
** query logic likewise merges doclists so that newer data knocks out
** older data.
 */

/************** Include fts3Int.h in the middle of fts3.c ********************/
/************** Begin file fts3Int.h *****************************************/
/*
** 2009 Nov 12
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
 */

/*
** Activate assert() only if SQLITE_TEST is enabled.
 */

/* #include <assert.h> */
/* #include <stdlib.h> */
/* #include <stddef.h> */
/* #include <stdio.h> */
/* #include <string.h> */
/* #include <stdarg.h> */

/* FTS3/FTS4 require virtual tables */

/*
** FTS4 is really an extension for FTS3.  It is enabled using the
** SQLITE_ENABLE_FTS3 macro.  But to avoid confusion we also all
** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.
 */

/************** End of fts3Int.h *********************************************/
/************** Continuing where we left off in fts3.c ***********************/

/************** End of fts3.c ************************************************/
/************** Begin file fts3_aux.c ****************************************/
/*
** 2011 Jan 27
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
 */
/* #include "fts3Int.h" */

/************** End of fts3_aux.c ********************************************/
/************** Begin file fts3_expr.c ***************************************/
/*
** 2008 Nov 28
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This module contains code that implements a parser for fts3 query strings
** (the right-hand argument to the MATCH operator). Because the supported
** syntax is relatively simple, the whole tokenizer/parser system is
** hand-coded.
 */
/* #include "fts3Int.h" */

/************** End of fts3_expr.c *******************************************/
/************** Begin file fts3_hash.c ***************************************/
/*
** 2001 September 22
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This is the implementation of generic hash-tables used in SQLite.
** We've modified it slightly to serve as a standalone hash table
** implementation for the full-text indexing module.
 */

/*
** The code in this file is only compiled if:
**
**     * The FTS3 module is being built as an extension
**       (in which case SQLITE_CORE is not defined), or
**
**     * The FTS3 module is being built into the core of
**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
 */
/* #include "fts3Int.h" */

/************** End of fts3_hash.c *******************************************/
/************** Begin file fts3_porter.c *************************************/
/*
** 2006 September 30
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Implementation of the full-text-search tokenizer that implements
** a Porter stemmer.
 */

/*
** The code in this file is only compiled if:
**
**     * The FTS3 module is being built as an extension
**       (in which case SQLITE_CORE is not defined), or
**
**     * The FTS3 module is being built into the core of
**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
 */
/* #include "fts3Int.h" */

/************** End of fts3_porter.c *****************************************/
/************** Begin file fts3_tokenizer.c **********************************/
/*
** 2007 June 22
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This is part of an SQLite module implementing full-text search.
** This particular file implements the generic tokenizer interface.
 */

/*
** The code in this file is only compiled if:
**
**     * The FTS3 module is being built as an extension
**       (in which case SQLITE_CORE is not defined), or
**
**     * The FTS3 module is being built into the core of
**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
 */
/* #include "fts3Int.h" */

/************** End of fts3_tokenizer.c **************************************/
/************** Begin file fts3_tokenizer1.c *********************************/
/*
** 2006 Oct 10
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** Implementation of the "simple" full-text-search tokenizer.
 */

/*
** The code in this file is only compiled if:
**
**     * The FTS3 module is being built as an extension
**       (in which case SQLITE_CORE is not defined), or
**
**     * The FTS3 module is being built into the core of
**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).
 */
/* #include "fts3Int.h" */

/************** End of fts3_tokenizer1.c *************************************/
/************** Begin file fts3_tokenize_vtab.c ******************************/
/*
** 2013 Apr 22
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file contains code for the "fts3tokenize" virtual table module.
** An fts3tokenize virtual table is created as follows:
**
**   CREATE VIRTUAL TABLE <tbl> USING fts3tokenize(
**       <tokenizer-name>, <arg-1>, ...
**   );
**
** The table created has the following schema:
**
**   CREATE TABLE <tbl>(input, token, start, end, position)
**
** When queried, the query must include a WHERE clause of type:
**
**   input = <string>
**
** The virtual table module tokenizes this <string>, using the FTS3
** tokenizer specified by the arguments to the CREATE VIRTUAL TABLE
** statement and returns one row for each token in the result. With
** fields set as follows:
**
**   input:   Always set to a copy of <string>
**   token:   A token from the input.
**   start:   Byte offset of the token within the input <string>.
**   end:     Byte offset of the byte immediately following the end of the
**            token within the input string.
**   pos:     Token offset of token within input.
**
 */
/* #include "fts3Int.h" */

/************** End of fts3_tokenize_vtab.c **********************************/
/************** Begin file fts3_write.c **************************************/
/*
** 2009 Oct 23
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This file is part of the SQLite FTS3 extension module. Specifically,
** this file contains code to insert, update and delete rows from FTS3
** tables. It also contains code to merge FTS3 b-tree segments. Some
** of the sub-routines used to merge segments are also used by the query
** code in fts3.c.
 */

/* #include "fts3Int.h" */

/************** End of fts3_write.c ******************************************/
/************** Begin file fts3_snippet.c ************************************/
/*
** 2009 Oct 23
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
 */

/* #include "fts3Int.h" */

/************** End of fts3_snippet.c ****************************************/
/************** Begin file fts3_unicode.c ************************************/
/*
** 2012 May 24
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** Implementation of the "unicode" full-text-search tokenizer.
 */

/* #include "fts3Int.h" */

/************** End of fts3_unicode.c ****************************************/
/************** Begin file fts3_unicode2.c ***********************************/
/*
** 2012-05-25
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
 */

/*
** DO NOT EDIT THIS MACHINE GENERATED FILE.
 */

/************** End of fts3_unicode2.c ***************************************/
/************** Begin file json.c ********************************************/
/*
** 2015-08-12
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** SQLite JSON functions.
**
** This file began as an extension in ext/misc/json1.c in 2015.  That
** extension proved so useful that it has now been moved into the core.
**
** The original design stored all JSON as pure text, canonical RFC-8259.
** Support for JSON-5 extensions was added with version 3.42.0 (2023-05-16).
** All generated JSON text still conforms strictly to RFC-8259, but text
** with JSON-5 extensions is accepted as input.
**
** Beginning with version 3.45.0 (circa 2024-01-01), these routines also
** accept BLOB values that have JSON encoded using a binary representation
** called "JSONB".  The name JSONB comes from PostgreSQL, however the on-disk
** format for SQLite-JSONB is completely different and incompatible with
** PostgreSQL-JSONB.
**
** Decoding and interpreting JSONB is still O(N) where N is the size of
** the input, the same as text JSON.  However, the constant of proportionality
** for JSONB is much smaller due to faster parsing.  The size of each
** element in JSONB is encoded in its header, so there is no need to search
** for delimiters using persnickety syntax rules.  JSONB seems to be about
** 3x faster than text JSON as a result.  JSONB is also tends to be slightly
** smaller than text JSON, by 5% or 10%, but there are corner cases where
** JSONB can be slightly larger.  So you are not far mistaken to say that
** a JSONB blob is the same size as the equivalent RFC-8259 text.
**
**
** THE JSONB ENCODING:
**
** Every JSON element is encoded in JSONB as a header and a payload.
** The header is between 1 and 9 bytes in size.  The payload is zero
** or more bytes.
**
** The lower 4 bits of the first byte of the header determines the
** element type:
**
**    0:   NULL
**    1:   TRUE
**    2:   FALSE
**    3:   INT        -- RFC-8259 integer literal
**    4:   INT5       -- JSON5 integer literal
**    5:   FLOAT      -- RFC-8259 floating point literal
**    6:   FLOAT5     -- JSON5 floating point literal
**    7:   TEXT       -- Text literal acceptable to both SQL and JSON
**    8:   TEXTJ      -- Text containing RFC-8259 escapes
**    9:   TEXT5      -- Text containing JSON5 and/or RFC-8259 escapes
**   10:   TEXTRAW    -- Text containing unescaped syntax characters
**   11:   ARRAY
**   12:   OBJECT
**
** The other three possible values (13-15) are reserved for future
** enhancements.
**
** The upper 4 bits of the first byte determine the size of the header
** and sometimes also the size of the payload.  If X is the first byte
** of the element and if X>>4 is between 0 and 11, then the payload
** will be that many bytes in size and the header is exactly one byte
** in size.  Other four values for X>>4 (12-15) indicate that the header
** is more than one byte in size and that the payload size is determined
** by the remainder of the header, interpreted as a unsigned big-endian
** integer.
**
**   Value of X>>4         Size integer        Total header size
**   -------------     --------------------    -----------------
**        12           1 byte (0-255)                2
**        13           2 byte (0-65535)              3
**        14           4 byte (0-4294967295)         5
**        15           8 byte (0-1.8e19)             9
**
** The payload size need not be expressed in its minimal form.  For example,
** if the payload size is 10, the size can be expressed in any of 5 different
** ways: (1) (X>>4)==10, (2) (X>>4)==12 following by one 0x0a byte,
** (3) (X>>4)==13 followed by 0x00 and 0x0a, (4) (X>>4)==14 followed by
** 0x00 0x00 0x00 0x0a, or (5) (X>>4)==15 followed by 7 bytes of 0x00 and
** a single byte of 0x0a.  The shorter forms are preferred, of course, but
** sometimes when generating JSONB, the payload size is not known in advance
** and it is convenient to reserve sufficient header space to cover the
** largest possible payload size and then come back later and patch up
** the size when it becomes known, resulting in a non-minimal encoding.
**
** The value (X>>4)==15 is not actually used in the current implementation
** (as SQLite is currently unable to handle BLOBs larger than about 2GB)
** but is included in the design to allow for future enhancements.
**
** The payload follows the header.  NULL, TRUE, and FALSE have no payload and
** their payload size must always be zero.  The payload for INT, INT5,
** FLOAT, FLOAT5, TEXT, TEXTJ, TEXT5, and TEXTROW is text.  Note that the
** "..." or '...' delimiters are omitted from the various text encodings.
** The payload for ARRAY and OBJECT is a list of additional elements that
** are the content for the array or object.  The payload for an OBJECT
** must be an even number of elements.  The first element of each pair is
** the label and must be of type TEXT, TEXTJ, TEXT5, or TEXTRAW.
**
** A valid JSONB blob consists of a single element, as described above.
** Usually this will be an ARRAY or OBJECT element which has many more
** elements as its content.  But the overall blob is just a single element.
**
** Input validation for JSONB blobs simply checks that the element type
** code is between 0 and 12 and that the total size of the element
** (header plus payload) is the same as the size of the BLOB.  If those
** checks are true, the BLOB is assumed to be JSONB and processing continues.
** Errors are only raised if some other miscoding is discovered during
** processing.
**
** Additional information can be found in the doc/jsonb.md file of the
** canonical SQLite source tree.
 */
/* #include "sqliteInt.h" */

/* JSONB element types
 */

// C documentation
//
//	/*
//	** Free the contents of the CTE object passed as the second argument.
//	*/
func _sqlite3CteDelete(tls *libc.TLS, db uintptr, pCte uintptr) {
	_cteClear(tls, db, pCte)
	_sqlite3DbFree(tls, db, pCte)
}

// C documentation
//
//	/*
//	** The following 256 byte lookup table is used to support SQLites built-in
//	** equivalents to the following standard library functions:
//	**
//	**   isspace()                        0x01
//	**   isalpha()                        0x02
//	**   isdigit()                        0x04
//	**   isalnum()                        0x06
//	**   isxdigit()                       0x08
//	**   toupper()                        0x20
//	**   SQLite identifier character      0x40   $, _, or non-ascii
//	**   Quote character                  0x80
//	**
//	** Bit 0x20 is set if the mapped character requires translation to upper
//	** case. i.e. if the character is a lower-case ASCII character.
//	** If x is a lower-case ASCII character, then its upper-case equivalent
//	** is (x - 0x20). Therefore toupper() can be implemented as:
//	**
//	**   (x & ~(map[x]&0x20))
//	**
//	** The equivalent of tolower() is implemented using the sqlite3UpperToLower[]
//	** array. tolower() is used more often than toupper() by SQLite.
//	**
//	** Bit 0x40 is set if the character is non-alphanumeric and can be used in an
//	** SQLite identifier.  Identifiers are alphanumerics, "_", "$", and any
//	** non-ASCII UTF character. Hence the test for whether or not a character is
//	** part of an identifier is 0x46.
//	*/
var _sqlite3CtypeMap = [256]uint8{
	9:   uint8(0x01),
	10:  uint8(0x01),
	11:  uint8(0x01),
	12:  uint8(0x01),
	13:  uint8(0x01),
	32:  uint8(0x01),
	34:  uint8(0x80),
	36:  uint8(0x40),
	39:  uint8(0x80),
	48:  uint8(0x0c),
	49:  uint8(0x0c),
	50:  uint8(0x0c),
	51:  uint8(0x0c),
	52:  uint8(0x0c),
	53:  uint8(0x0c),
	54:  uint8(0x0c),
	55:  uint8(0x0c),
	56:  uint8(0x0c),
	57:  uint8(0x0c),
	65:  uint8(0x0a),
	66:  uint8(0x0a),
	67:  uint8(0x0a),
	68:  uint8(0x0a),
	69:  uint8(0x0a),
	70:  uint8(0x0a),
	71:  uint8(0x02),
	72:  uint8(0x02),
	73:  uint8(0x02),
	74:  uint8(0x02),
	75:  uint8(0x02),
	76:  uint8(0x02),
	77:  uint8(0x02),
	78:  uint8(0x02),
	79:  uint8(0x02),
	80:  uint8(0x02),
	81:  uint8(0x02),
	82:  uint8(0x02),
	83:  uint8(0x02),
	84:  uint8(0x02),
	85:  uint8(0x02),
	86:  uint8(0x02),
	87:  uint8(0x02),
	88:  uint8(0x02),
	89:  uint8(0x02),
	90:  uint8(0x02),
	91:  uint8(0x80),
	95:  uint8(0x40),
	96:  uint8(0x80),
	97:  uint8(0x2a),
	98:  uint8(0x2a),
	99:  uint8(0x2a),
	100: uint8(0x2a),
	101: uint8(0x2a),
	102: uint8(0x2a),
	103: uint8(0x22),
	104: uint8(0x22),
	105: uint8(0x22),
	106: uint8(0x22),
	107: uint8(0x22),
	108: uint8(0x22),
	109: uint8(0x22),
	110: uint8(0x22),
	111: uint8(0x22),
	112: uint8(0x22),
	113: uint8(0x22),
	114: uint8(0x22),
	115: uint8(0x22),
	116: uint8(0x22),
	117: uint8(0x22),
	118: uint8(0x22),
	119: uint8(0x22),
	120: uint8(0x22),
	121: uint8(0x22),
	122: uint8(0x22),
	128: uint8(0x40),
	129: uint8(0x40),
	130: uint8(0x40),
	131: uint8(0x40),
	132: uint8(0x40),
	133: uint8(0x40),
	134: uint8(0x40),
	135: uint8(0x40),
	136: uint8(0x40),
	137: uint8(0x40),
	138: uint8(0x40),
	139: uint8(0x40),
	140: uint8(0x40),
	141: uint8(0x40),
	142: uint8(0x40),
	143: uint8(0x40),
	144: uint8(0x40),
	145: uint8(0x40),
	146: uint8(0x40),
	147: uint8(0x40),
	148: uint8(0x40),
	149: uint8(0x40),
	150: uint8(0x40),
	151: uint8(0x40),
	152: uint8(0x40),
	153: uint8(0x40),
	154: uint8(0x40),
	155: uint8(0x40),
	156: uint8(0x40),
	157: uint8(0x40),
	158: uint8(0x40),
	159: uint8(0x40),
	160: uint8(0x40),
	161: uint8(0x40),
	162: uint8(0x40),
	163: uint8(0x40),
	164: uint8(0x40),
	165: uint8(0x40),
	166: uint8(0x40),
	167: uint8(0x40),
	168: uint8(0x40),
	169: uint8(0x40),
	170: uint8(0x40),
	171: uint8(0x40),
	172: uint8(0x40),
	173: uint8(0x40),
	174: uint8(0x40),
	175: uint8(0x40),
	176: uint8(0x40),
	177: uint8(0x40),
	178: uint8(0x40),
	179: uint8(0x40),
	180: uint8(0x40),
	181: uint8(0x40),
	182: uint8(0x40),
	183: uint8(0x40),
	184: uint8(0x40),
	185: uint8(0x40),
	186: uint8(0x40),
	187: uint8(0x40),
	188: uint8(0x40),
	189: uint8(0x40),
	190: uint8(0x40),
	191: uint8(0x40),
	192: uint8(0x40),
	193: uint8(0x40),
	194: uint8(0x40),
	195: uint8(0x40),
	196: uint8(0x40),
	197: uint8(0x40),
	198: uint8(0x40),
	199: uint8(0x40),
	200: uint8(0x40),
	201: uint8(0x40),
	202: uint8(0x40),
	203: uint8(0x40),
	204: uint8(0x40),
	205: uint8(0x40),
	206: uint8(0x40),
	207: uint8(0x40),
	208: uint8(0x40),
	209: uint8(0x40),
	210: uint8(0x40),
	211: uint8(0x40),
	212: uint8(0x40),
	213: uint8(0x40),
	214: uint8(0x40),
	215: uint8(0x40),
	216: uint8(0x40),
	217: uint8(0x40),
	218: uint8(0x40),
	219: uint8(0x40),
	220: uint8(0x40),
	221: uint8(0x40),
	222: uint8(0x40),
	223: uint8(0x40),
	224: uint8(0x40),
	225: uint8(0x40),
	226: uint8(0x40),
	227: uint8(0x40),
	228: uint8(0x40),
	229: uint8(0x40),
	230: uint8(0x40),
	231: uint8(0x40),
	232: uint8(0x40),
	233: uint8(0x40),
	234: uint8(0x40),
	235: uint8(0x40),
	236: uint8(0x40),
	237: uint8(0x40),
	238: uint8(0x40),
	239: uint8(0x40),
	240: uint8(0x40),
	241: uint8(0x40),
	242: uint8(0x40),
	243: uint8(0x40),
	244: uint8(0x40),
	245: uint8(0x40),
	246: uint8(0x40),
	247: uint8(0x40),
	248: uint8(0x40),
	249: uint8(0x40),
	250: uint8(0x40),
	251: uint8(0x40),
	252: uint8(0x40),
	253: uint8(0x40),
	254: uint8(0x40),
	255: uint8(0x40),
}

/* EVIDENCE-OF: R-02982-34736 In order to maintain full backwards
** compatibility for legacy applications, the URI filename capability is
** disabled by default.
**
** EVIDENCE-OF: R-38799-08373 URI filenames can be enabled or disabled
** using the SQLITE_USE_URI=1 or SQLITE_USE_URI=0 compile-time options.
**
** EVIDENCE-OF: R-43642-56306 By default, URI handling is globally
** disabled. The default value may be changed by compiling with the
** SQLITE_USE_URI symbol defined.
 */

/* EVIDENCE-OF: R-38720-18127 The default setting is determined by the
** SQLITE_ALLOW_COVERING_INDEX_SCAN compile-time option, or is "on" if
** that compile-time option is omitted.
 */

/* The minimum PMA size is set to this value multiplied by the database
** page size in bytes.
 */

/* Statement journals spill to disk when their size exceeds the following
** threshold (in bytes). 0 means that statement journals are created and
** written to disk immediately (the default behavior for SQLite versions
** before 3.12.0).  -1 means always keep the entire statement journal in
** memory.  (The statement journal is also always held entirely in memory
** if journal_mode=MEMORY or if temp_store=MEMORY, regardless of this
** setting.)
 */

/*
** The default lookaside-configuration, the format "SZ,N".  SZ is the
** number of bytes in each lookaside slot (should be a multiple of 8)
** and N is the number of slots.  The lookaside-configuration can be
** changed as start-time using sqlite3_config(SQLITE_CONFIG_LOOKASIDE)
** or at run-time for an individual database connection using
** sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE);
**
** With the two-size-lookaside enhancement, less lookaside is required.
** The default configuration of 1200,40 actually provides 30 1200-byte slots
** and 93 128-byte slots, which is more lookaside than is available
** using the older 1200,100 configuration without two-size-lookaside.
 */

/* The default maximum size of an in-memory database created using
** sqlite3_deserialize()
 */

func _sqlite3DbFree(tls *libc.TLS, db uintptr, p uintptr) {
	if p != 0 {
		_sqlite3DbFreeNN(tls, db, p)
	}
}

// C documentation
//
//	/*
//	** Allocate memory, either lookaside (if possible) or heap.
//	** If the allocation fails, set the mallocFailed flag in
//	** the connection pointer.
//	**
//	** If db!=0 and db->mallocFailed is true (indicating a prior malloc
//	** failure on the same database connection) then always return 0.
//	** Hence for a particular database connection, once malloc starts
//	** failing, it fails consistently until mallocFailed is reset.
//	** This is an important assumption.  There are many places in the
//	** code that do things like this:
//	**
//	**         int *a = (int*)sqlite3DbMallocRaw(db, 100);
//	**         int *b = (int*)sqlite3DbMallocRaw(db, 200);
//	**         if( b ) a[10] = 9;
//	**
//	** In other words, if a subsequent malloc (ex: "b") worked, it is assumed
//	** that all prior mallocs (ex: "a") worked too.
//	**
//	** The sqlite3MallocRawNN() variant guarantees that the "db" parameter is
//	** not a NULL pointer.
//	*/
func _sqlite3DbMallocRaw(tls *libc.TLS, db uintptr, n Tu64) (r uintptr) {
	var p uintptr
	_ = p
	if db != 0 {
		return _sqlite3DbMallocRawNN(tls, db, n)
	}
	p = _sqlite3Malloc(tls, n)
	return p
}

// C documentation
//
//	/*
//	** Attempt to reallocate p.  If the reallocation fails, then free p
//	** and set the mallocFailed flag in the database connection.
//	*/
func _sqlite3DbReallocOrFree(tls *libc.TLS, db uintptr, p uintptr, n Tu64) (r uintptr) {
	var pNew uintptr
	_ = pNew
	pNew = _sqlite3DbRealloc(tls, db, p, n)
	if !(pNew != 0) {
		_sqlite3DbFree(tls, db, p)
	}
	return pNew
}

func _sqlite3DeleteTableGeneric(tls *libc.TLS, db uintptr, pTable uintptr) {
	_sqlite3DeleteTable(tls, db, pTable)
}

// C documentation
//
//	/*
//	** Recursively delete a Trigger structure
//	*/
func _sqlite3DeleteTrigger(tls *libc.TLS, db uintptr, pTrigger uintptr) {
	if pTrigger == uintptr(0) || (*TTrigger)(unsafe.Pointer(pTrigger)).FbReturning != 0 {
		return
	}
	_sqlite3DeleteTriggerStep(tls, db, (*TTrigger)(unsafe.Pointer(pTrigger)).Fstep_list)
	_sqlite3DbFree(tls, db, (*TTrigger)(unsafe.Pointer(pTrigger)).FzName)
	_sqlite3DbFree(tls, db, (*TTrigger)(unsafe.Pointer(pTrigger)).Ftable)
	_sqlite3ExprDelete(tls, db, (*TTrigger)(unsafe.Pointer(pTrigger)).FpWhen)
	_sqlite3IdListDelete(tls, db, (*TTrigger)(unsafe.Pointer(pTrigger)).FpColumns)
	_sqlite3DbFree(tls, db, pTrigger)
}

// C documentation
//
//	/*
//	** Delete a linked list of TriggerStep structures.
//	*/
func _sqlite3DeleteTriggerStep(tls *libc.TLS, db uintptr, pTriggerStep uintptr) {
	var pTmp uintptr
	_ = pTmp
	for pTriggerStep != 0 {
		pTmp = pTriggerStep
		pTriggerStep = (*TTriggerStep)(unsafe.Pointer(pTriggerStep)).FpNext
		_sqlite3ExprDelete(tls, db, (*TTriggerStep)(unsafe.Pointer(pTmp)).FpWhere)
		_sqlite3ExprListDelete(tls, db, (*TTriggerStep)(unsafe.Pointer(pTmp)).FpExprList)
		_sqlite3SelectDelete(tls, db, (*TTriggerStep)(unsafe.Pointer(pTmp)).FpSelect)
		_sqlite3IdListDelete(tls, db, (*TTriggerStep)(unsafe.Pointer(pTmp)).FpIdList)
		_sqlite3UpsertDelete(tls, db, (*TTriggerStep)(unsafe.Pointer(pTmp)).FpUpsert)
		_sqlite3SrcListDelete(tls, db, (*TTriggerStep)(unsafe.Pointer(pTmp)).FpSrc)
		_sqlite3DbFree(tls, db, (*TTriggerStep)(unsafe.Pointer(pTmp)).FzSpan)
		_sqlite3DbFree(tls, db, pTmp)
	}
}

// C documentation
//
//	/*
//	** Called by the parser to compile a DETACH statement.
//	**
//	**     DETACH pDbname
//	*/
func _sqlite3Detach(tls *libc.TLS, pParse uintptr, pDbname uintptr) {
	_codeAttach(tls, pParse, int32(SQLITE_DETACH), uintptr(unsafe.Pointer(&_detach_func)), pDbname, uintptr(0), uintptr(0), pDbname)
}

func _sqlite3EndBenignMalloc(tls *libc.TLS) {
	if _sqlite3Hooks.FxBenignEnd != 0 {
		(*(*func(*libc.TLS))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Hooks.FxBenignEnd})))(tls)
	}
}

/************** End of fault.c ***********************************************/
/************** Begin file mem0.c ********************************************/
/*
** 2008 October 28
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains a no-op memory allocation drivers for use when
** SQLITE_ZERO_MALLOC is defined.  The allocation drivers implemented
** here always fail.  SQLite will not operate with these drivers.  These
** are merely placeholders.  Real drivers must be substituted using
** sqlite3_config() before SQLite will operate.
 */
/* #include "sqliteInt.h" */

/*
** This version of the memory allocator is the default.  It is
** used when no other memory allocator is specified using compile-time
** macros.
 */

/************** End of mem0.c ************************************************/
/************** Begin file mem1.c ********************************************/
/*
** 2007 August 14
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains low-level memory allocation drivers for when
** SQLite will use the standard C-library malloc/realloc/free interface
** to obtain the memory it needs.
**
** This file contains implementations of the low-level memory allocation
** routines specified in the sqlite3_mem_methods object.  The content of
** this file is only used if SQLITE_SYSTEM_MALLOC is defined.  The
** SQLITE_SYSTEM_MALLOC macro is defined automatically if neither the
** SQLITE_MEMDEBUG nor the SQLITE_WIN32_MALLOC macros are defined.  The
** default configuration is to use memory allocation routines in this
** file.
**
** C-preprocessor macro summary:
**
**    HAVE_MALLOC_USABLE_SIZE     The configure script sets this symbol if
**                                the malloc_usable_size() interface exists
**                                on the target platform.  Or, this symbol
**                                can be set manually, if desired.
**                                If an equivalent interface exists by
**                                a different name, using a separate -D
**                                option to rename it.
**
**    SQLITE_WITHOUT_ZONEMALLOC   Some older macs lack support for the zone
**                                memory allocator.  Set this symbol to enable
**                                building on older macs.
**
**    SQLITE_WITHOUT_MSIZE        Set this symbol to disable the use of
**                                _msize() on windows systems.  This might
**                                be necessary when compiling for Delphi,
**                                for example.
 */
/* #include "sqliteInt.h" */

/*
** This version of the memory allocator is the default.  It is
** used when no other memory allocator is specified using compile-time
** macros.
 */

/*
** Use standard C library malloc and free on non-Apple systems.
** Also used by Apple systems if SQLITE_WITHOUT_ZONEMALLOC is defined.
 */

/*
** The malloc.h header file is needed for malloc_usable_size() function
** on some systems (e.g. Linux).
 */

/*
** Include the malloc.h header file, if necessary.  Also set define macro
** SQLITE_MALLOCSIZE to the appropriate function name, which is _msize()
** for MSVC and malloc_usable_size() for most other systems (e.g. Linux).
** The memory size function can always be overridden manually by defining
** the macro SQLITE_MALLOCSIZE to the desired function name.
 */

// C documentation
//
//	/*
//	** Set the current error code to err_code and clear any prior error message.
//	** Also set iSysErrno (by calling sqlite3System) if the err_code indicates
//	** that would be appropriate.
//	*/
func _sqlite3Error(tls *libc.TLS, db uintptr, err_code int32) {
	(*Tsqlite3)(unsafe.Pointer(db)).FerrCode = err_code
	if err_code != 0 || (*Tsqlite3)(unsafe.Pointer(db)).FpErr != 0 {
		_sqlite3ErrorFinish(tls, db, err_code)
	} else {
		(*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset = -int32(1)
	}
}

// C documentation
//
//	/*
//	** The equivalent of sqlite3Error(db, SQLITE_OK).  Clear the error state
//	** and error message.
//	*/
func _sqlite3ErrorClear(tls *libc.TLS, db uintptr) {
	(*Tsqlite3)(unsafe.Pointer(db)).FerrCode = SQLITE_OK
	(*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset = -int32(1)
	if (*Tsqlite3)(unsafe.Pointer(db)).FpErr != 0 {
		_sqlite3ValueSetNull(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr)
	}
}

// C documentation
//
//	/*
//	** Helper function for sqlite3Error() - called rarely.  Broken out into
//	** a separate routine to avoid unnecessary register saves on entry to
//	** sqlite3Error().
//	*/
func _sqlite3ErrorFinish(tls *libc.TLS, db uintptr, err_code int32) {
	if (*Tsqlite3)(unsafe.Pointer(db)).FpErr != 0 {
		_sqlite3ValueSetNull(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr)
	}
	_sqlite3SystemError(tls, db, err_code)
}

// C documentation
//
//	/*
//	** Add an error message to pParse->zErrMsg and increment pParse->nErr.
//	**
//	** This function should be used to report any error that occurs while
//	** compiling an SQL statement (i.e. within sqlite3_prepare()). The
//	** last thing the sqlite3_prepare() function does is copy the error
//	** stored by this function into the database handle using sqlite3Error().
//	** Functions sqlite3Error() or sqlite3ErrorWithMsg() should be used
//	** during statement execution (sqlite3_step() etc.).
//	*/
func _sqlite3ErrorMsg(tls *libc.TLS, pParse uintptr, zFormat uintptr, va uintptr) {
	var ap Tva_list
	var db, zMsg uintptr
	_, _, _ = ap, db, zMsg
	db = (*TParse)(unsafe.Pointer(pParse)).Fdb
	(*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset = -int32(2)
	ap = va
	zMsg = _sqlite3VMPrintf(tls, db, zFormat, ap)
	_ = ap
	if (*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset < -int32(1) {
		(*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset = -int32(1)
	}
	if (*Tsqlite3)(unsafe.Pointer(db)).FsuppressErr != 0 {
		_sqlite3DbFree(tls, db, zMsg)
		if (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
			(*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1
			(*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_NOMEM)
		}
	} else {
		(*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1
		_sqlite3DbFree(tls, db, (*TParse)(unsafe.Pointer(pParse)).FzErrMsg)
		(*TParse)(unsafe.Pointer(pParse)).FzErrMsg = zMsg
		(*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_ERROR)
		(*TParse)(unsafe.Pointer(pParse)).FpWith = uintptr(0)
	}
}

// C documentation
//
//	/*
//	** If database connection db is currently parsing SQL, then transfer
//	** error code errCode to that parser if the parser has not already
//	** encountered some other kind of error.
//	*/
func _sqlite3ErrorToParser(tls *libc.TLS, db uintptr, errCode int32) (r int32) {
	var pParse, v1 uintptr
	var v2 bool
	_, _, _ = pParse, v1, v2
	if v2 = db == uintptr(0); !v2 {
		v1 = (*Tsqlite3)(unsafe.Pointer(db)).FpParse
		pParse = v1
	}
	if v2 || v1 == uintptr(0) {
		return errCode
	}
	(*TParse)(unsafe.Pointer(pParse)).Frc = errCode
	(*TParse)(unsafe.Pointer(pParse)).FnErr = (*TParse)(unsafe.Pointer(pParse)).FnErr + 1
	return errCode
}

// C documentation
//
//	/*
//	** Set the most recent error code and error string for the sqlite
//	** handle "db". The error code is set to "err_code".
//	**
//	** If it is not NULL, string zFormat specifies the format of the
//	** error string.  zFormat and any string tokens that follow it are
//	** assumed to be encoded in UTF-8.
//	**
//	** To clear the most recent error for sqlite handle "db", sqlite3Error
//	** should be called with err_code set to SQLITE_OK and zFormat set
//	** to NULL.
//	*/
func _sqlite3ErrorWithMsg(tls *libc.TLS, db uintptr, err_code int32, zFormat uintptr, va uintptr) {
	var ap Tva_list
	var z, v1 uintptr
	var v2 bool
	_, _, _, _ = ap, z, v1, v2
	(*Tsqlite3)(unsafe.Pointer(db)).FerrCode = err_code
	_sqlite3SystemError(tls, db, err_code)
	if zFormat == uintptr(0) {
		_sqlite3Error(tls, db, err_code)
	} else {
		if v2 = (*Tsqlite3)(unsafe.Pointer(db)).FpErr != 0; !v2 {
			v1 = _sqlite3ValueNew(tls, db)
			(*Tsqlite3)(unsafe.Pointer(db)).FpErr = v1
		}
		if v2 || v1 != uintptr(0) {
			ap = va
			z = _sqlite3VMPrintf(tls, db, zFormat, ap)
			_ = ap
			_sqlite3ValueSetStr(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr, -int32(1), z, uint8(SQLITE_UTF8), __ccgo_fp(_sqlite3RowSetClear))
		}
	}
}

func _sqlite3ExprAddCollateString(tls *libc.TLS, pParse uintptr, pExpr uintptr, zC uintptr) (r uintptr) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var _ /* s at bp+0 */ TToken
	_sqlite3TokenInit(tls, bp, zC)
	return _sqlite3ExprAddCollateToken(tls, pParse, pExpr, bp, 0)
}

// C documentation
//
//	/*
//	** Make a transient copy of expression pExpr and then code it using
//	** sqlite3ExprCode().  This routine works just like sqlite3ExprCode()
//	** except that the input expression is guaranteed to be unchanged.
//	*/
func _sqlite3ExprCodeCopy(tls *libc.TLS, pParse uintptr, pExpr uintptr, target int32) {
	var db uintptr
	_ = db
	db = (*TParse)(unsafe.Pointer(pParse)).Fdb
	pExpr = _sqlite3ExprDup(tls, db, pExpr, 0)
	if !((*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0) {
		_sqlite3ExprCode(tls, pParse, pExpr, target)
	}
	_sqlite3ExprDelete(tls, db, pExpr)
}

// C documentation
//
//	/*
//	** Generate code to move content from registers iFrom...iFrom+nReg-1
//	** over to iTo..iTo+nReg-1.
//	*/
func _sqlite3ExprCodeMove(tls *libc.TLS, pParse uintptr, iFrom int32, iTo int32, nReg int32) {
	_sqlite3VdbeAddOp3(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, int32(OP_Move), iFrom, iTo, nReg)
}

// C documentation
//
//	/*
//	** Return TRUE if the two expressions have equivalent collating sequences.
//	*/
func _sqlite3ExprCollSeqMatch(tls *libc.TLS, pParse uintptr, pE1 uintptr, pE2 uintptr) (r int32) {
	var pColl1, pColl2 uintptr
	_, _ = pColl1, pColl2
	pColl1 = _sqlite3ExprNNCollSeq(tls, pParse, pE1)
	pColl2 = _sqlite3ExprNNCollSeq(tls, pParse, pE2)
	return libc.BoolInt32(_sqlite3StrICmp(tls, (*TCollSeq)(unsafe.Pointer(pColl1)).FzName, (*TCollSeq)(unsafe.Pointer(pColl2)).FzName) == 0)
}

// C documentation
//
//	/*
//	** Like sqlite3ExprCompare() except COLLATE operators at the top-level
//	** are ignored.
//	*/
func _sqlite3ExprCompareSkip(tls *libc.TLS, pA uintptr, pB uintptr, iTab int32) (r int32) {
	return _sqlite3ExprCompare(tls, uintptr(0), _sqlite3ExprSkipCollate(tls, pA), _sqlite3ExprSkipCollate(tls, pB), iTab)
}

// C documentation
//
//	/*
//	** Arrange to cause pExpr to be deleted when the pParse is deleted.
//	** This is similar to sqlite3ExprDelete() except that the delete is
//	** deferred until the pParse is deleted.
//	**
//	** The pExpr might be deleted immediately on an OOM error.
//	**
//	** Return 0 if the delete was successfully deferred.  Return non-zero
//	** if the delete happened immediately because of an OOM.
//	*/
func _sqlite3ExprDeferredDelete(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r int32) {
	return libc.BoolInt32(uintptr(0) == _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3ExprDeleteGeneric), pExpr))
}

func _sqlite3ExprDelete(tls *libc.TLS, db uintptr, p uintptr) {
	if p != 0 {
		_sqlite3ExprDeleteNN(tls, db, p)
	}
}

func _sqlite3ExprDeleteGeneric(tls *libc.TLS, db uintptr, p uintptr) {
	if p != 0 {
		_sqlite3ExprDeleteNN(tls, db, p)
	}
}

// C documentation
//
//	/*
//	** The following group of routines make deep copies of expressions,
//	** expression lists, ID lists, and select statements.  The copies can
//	** be deleted (by being passed to their respective ...Delete() routines)
//	** without effecting the originals.
//	**
//	** The expression list, ID, and source lists return by sqlite3ExprListDup(),
//	** sqlite3IdListDup(), and sqlite3SrcListDup() can not be further expanded
//	** by subsequent calls to sqlite*ListAppend() routines.
//	**
//	** Any tables that the SrcList might point to are not duplicated.
//	**
//	** The flags parameter contains a combination of the EXPRDUP_XXX flags.
//	** If the EXPRDUP_REDUCE flag is set, then the structure returned is a
//	** truncated version of the usual Expr structure that will be stored as
//	** part of the in-memory representation of the database schema.
//	*/
func _sqlite3ExprDup(tls *libc.TLS, db uintptr, p uintptr, flags int32) (r uintptr) {
	var v1 uintptr
	_ = v1
	if p != 0 {
		v1 = _exprDup(tls, db, p, flags, uintptr(0))
	} else {
		v1 = uintptr(0)
	}
	return v1
}

// C documentation
//
//	/*
//	** Walk an expression tree.  Return non-zero if the expression is constant
//	** or return zero if the expression involves variables or function calls.
//	**
//	** For the purposes of this function, a double-quoted string (ex: "abc")
//	** is considered a variable but a single-quoted string (ex: 'abc') is
//	** a constant.
//	**
//	** The pParse parameter may be NULL.  But if it is NULL, there is no way
//	** to determine if function calls are constant or not, and hence all
//	** function calls will be considered to be non-constant.  If pParse is
//	** not NULL, then a function call might be constant, depending on the
//	** function and on its parameters.
//	*/
func _sqlite3ExprIsConstant(tls *libc.TLS, pParse uintptr, p uintptr) (r int32) {
	return _exprIsConst(tls, pParse, p, int32(1))
}

// C documentation
//
//	/*
//	** Walk an expression tree.  Return non-zero if
//	**
//	**   (1) the expression is constant, and
//	**   (2) the expression does originate in the ON or USING clause
//	**       of a LEFT JOIN, and
//	**   (3) the expression does not contain any EP_FixedCol TK_COLUMN
//	**       operands created by the constant propagation optimization.
//	**
//	** When this routine returns true, it indicates that the expression
//	** can be added to the pParse->pConstExpr list and evaluated once when
//	** the prepared statement starts up.  See sqlite3ExprCodeRunJustOnce().
//	*/
func _sqlite3ExprIsConstantNotJoin(tls *libc.TLS, pParse uintptr, p uintptr) (r int32) {
	return _exprIsConst(tls, pParse, p, int32(2))
}

// C documentation
//
//	/*
//	** Return true if expression pExpr is a vector, or false otherwise.
//	**
//	** A vector is defined as any expression that results in two or more
//	** columns of result.  Every TK_VECTOR node is an vector because the
//	** parser will not generate a TK_VECTOR with fewer than two entries.
//	** But a TK_SELECT might be either a vector or a scalar. It is only
//	** considered a vector if it has two or more result columns.
//	*/
func _sqlite3ExprIsVector(tls *libc.TLS, pExpr uintptr) (r int32) {
	return libc.BoolInt32(_sqlite3ExprVectorSize(tls, pExpr) > int32(1))
}

func _sqlite3ExprListDelete(tls *libc.TLS, db uintptr, pList uintptr) {
	if pList != 0 {
		_exprListDeleteNN(tls, db, pList)
	}
}

func _sqlite3ExprListDeleteGeneric(tls *libc.TLS, db uintptr, pList uintptr) {
	if pList != 0 {
		_exprListDeleteNN(tls, db, pList)
	}
}

// C documentation
//
//	/*
//	** Return the collation sequence for the expression pExpr. If
//	** there is no defined collating sequence, return a pointer to the
//	** default collation sequence.
//	**
//	** See also: sqlite3ExprCollSeq()
//	**
//	** The sqlite3ExprCollSeq() routine works the same except that it
//	** returns NULL if there is no defined collation.
//	*/
func _sqlite3ExprNNCollSeq(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r uintptr) {
	var p uintptr
	_ = p
	p = _sqlite3ExprCollSeq(tls, pParse, pExpr)
	if p == uintptr(0) {
		p = (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FpDfltColl
	}
	return p
}

// C documentation
//
//	/*
//	** Set the Expr.nHeight variable using the exprSetHeight() function. If
//	** the height is greater than the maximum allowed expression depth,
//	** leave an error in pParse.
//	**
//	** Also propagate all EP_Propagate flags from the Expr.x.pList into
//	** Expr.flags.
//	*/
func _sqlite3ExprSetHeightAndFlags(tls *libc.TLS, pParse uintptr, p uintptr) {
	if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 {
		return
	}
	_exprSetHeight(tls, p)
	_sqlite3ExprCheckHeight(tls, pParse, (*TExpr)(unsafe.Pointer(p)).FnHeight)
}

// C documentation
//
//	/*
//	** No-op routine for the parse-tree walker.
//	**
//	** When this routine is the Walker.xExprCallback then expression trees
//	** are walked without any actions being taken at each node.  Presumably,
//	** when this routine is used for Walker.xExprCallback then
//	** Walker.xSelectCallback is set to do something useful for every
//	** subquery in the parser tree.
//	*/
func _sqlite3ExprWalkNoop(tls *libc.TLS, NotUsed uintptr, NotUsed2 uintptr) (r int32) {
	_ = NotUsed
	_ = NotUsed2
	return WRC_Continue
}

// C documentation
//
//	/*
//	** Calls to sqlite3FaultSim() are used to simulate a failure during testing,
//	** or to bypass normal error detection during testing in order to let
//	** execute proceed further downstream.
//	**
//	** In deployment, sqlite3FaultSim() *always* return SQLITE_OK (0).  The
//	** sqlite3FaultSim() function only returns non-zero during testing.
//	**
//	** During testing, if the test harness has set a fault-sim callback using
//	** a call to sqlite3_test_control(SQLITE_TESTCTRL_FAULT_INSTALL), then
//	** each call to sqlite3FaultSim() is relayed to that application-supplied
//	** callback and the integer return value form the application-supplied
//	** callback is returned by sqlite3FaultSim().
//	**
//	** The integer argument to sqlite3FaultSim() is a code to identify which
//	** sqlite3FaultSim() instance is being invoked. Each call to sqlite3FaultSim()
//	** should have a unique code.  To prevent legacy testing applications from
//	** breaking, the codes should not be changed or reused.
//	*/
func _sqlite3FaultSim(tls *libc.TLS, iTest int32) (r int32) {
	var xCallback uintptr
	var v1 int32
	_, _ = xCallback, v1
	xCallback = _sqlite3Config.FxTestCallback
	if xCallback != 0 {
		v1 = (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(&struct{ uintptr }{xCallback})))(tls, iTest)
	} else {
		v1 = SQLITE_OK
	}
	return v1
}

// C documentation
//
//	/*
//	** The token *pName contains the name of a database (either "main" or
//	** "temp" or the name of an attached db). This routine returns the
//	** index of the named database in db->aDb[], or -1 if the named db
//	** does not exist.
//	*/
func _sqlite3FindDb(tls *libc.TLS, db uintptr, pName uintptr) (r int32) {
	var i int32
	var zName uintptr
	_, _ = i, zName /* Name we are searching for */
	zName = _sqlite3NameFromToken(tls, db, pName)
	i = _sqlite3FindDbName(tls, db, zName)
	_sqlite3DbFree(tls, db, zName)
	return i
}

// C documentation
//
//	/*
//	** This function is called when deleting or updating a row to implement
//	** any required CASCADE, SET NULL or SET DEFAULT actions.
//	*/
func _sqlite3FkActions(tls *libc.TLS, pParse uintptr, pTab uintptr, pChanges uintptr, regOld int32, aChange uintptr, bChngRowid int32) {
	var pAct, pFKey uintptr
	_, _ = pAct, pFKey
	/* If foreign-key support is enabled, iterate through all FKs that
	 ** refer to table pTab. If there is an action associated with the FK
	 ** for this operation (either update or delete), invoke the associated
	 ** trigger sub-program.  */
	if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_ForeignKeys) != 0 { /* Iterator variable */
		pFKey = _sqlite3FkReferences(tls, pTab)
		for {
			if !(pFKey != 0) {
				break
			}
			if aChange == uintptr(0) || _fkParentIsModified(tls, pTab, pFKey, aChange, bChngRowid) != 0 {
				pAct = _fkActionTrigger(tls, pParse, pTab, pFKey, pChanges)
				if pAct != 0 {
					_sqlite3CodeRowTriggerDirect(tls, pParse, pAct, pTab, regOld, int32(OE_Abort), 0)
				}
			}
			goto _1
		_1:
			;
			pFKey = (*TFKey)(unsafe.Pointer(pFKey)).FpNextTo
		}
	}
}

// C documentation
//
//	/*
//	** Argument zFmt is a printf() style format string. This function performs
//	** the printf() style processing, then appends the results to buffer pBuf.
//	**
//	** Like sqlite3Fts5BufferAppendString(), this function ensures that the byte
//	** following the buffer data is set to 0x00, even though this byte is not
//	** included in the pBuf->n count.
//	*/
func _sqlite3Fts5BufferAppendPrintf(tls *libc.TLS, pRc uintptr, pBuf uintptr, zFmt uintptr, va uintptr) {
	var ap Tva_list
	var zTmp uintptr
	_, _ = ap, zTmp
	if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK {
		ap = va
		zTmp = Xsqlite3_vmprintf(tls, zFmt, ap)
		_ = ap
		if zTmp == uintptr(0) {
			**(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM)
		} else {
			_sqlite3Fts5BufferAppendString(tls, pRc, pBuf, zTmp)
			Xsqlite3_free(tls, zTmp)
		}
	}
}

// C documentation
//
//	/*
//	** Zero the contents of the buffer object. But do not free the associated
//	** memory allocation.
//	*/
func _sqlite3Fts5BufferZero(tls *libc.TLS, pBuf uintptr) {
	(*TFts5Buffer)(unsafe.Pointer(pBuf)).Fn = 0
}

// C documentation
//
//	/*
//	** Clear any locale configured by an earlier call to sqlite3Fts5SetLocale().
//	*/
func _sqlite3Fts5ClearLocale(tls *libc.TLS, pConfig uintptr) {
	_sqlite3Fts5SetLocale(tls, pConfig, uintptr(0), 0)
}

// C documentation
//
//	/*
//	** Set (*pConfig->pzErrmsg) to point to an sqlite3_malloc()ed buffer
//	** containing the error message created using printf() style formatting
//	** string zFmt and its trailing arguments.
//	*/
func _sqlite3Fts5ConfigErrmsg(tls *libc.TLS, pConfig uintptr, zFmt uintptr, va uintptr) {
	var ap Tva_list
	var zMsg uintptr
	_, _ = ap, zMsg /* ... printf arguments */
	zMsg = uintptr(0)
	ap = va
	zMsg = Xsqlite3_vmprintf(tls, zFmt, ap)
	if (*TFts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg != 0 {
		**(**uintptr)(__ccgo_up((*TFts5Config)(unsafe.Pointer(pConfig)).FpzErrmsg)) = zMsg
	} else {
		Xsqlite3_free(tls, zMsg)
	}
	_ = ap
}

/*
** 2014 May 31
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
 */

/* #include "fts5Int.h" */
/* #include "fts5parse.h" */

/*
** All token types in the generated fts5parse.h file are greater than 0.
 */

func _sqlite3Fts5ExprCheckPoslists(tls *libc.TLS, pExpr uintptr, iRowid Ti64) {
	_fts5ExprCheckPoslists(tls, (*TFts5Expr)(unsafe.Pointer(pExpr)).FpRoot, iRowid)
}

func _sqlite3Fts5ExprEof(tls *libc.TLS, p uintptr) (r int32) {
	return (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(p)).FpRoot)).FbEof
}

// C documentation
//
//	/*
//	** Begin iterating through the set of documents in index pIdx matched by
//	** the MATCH expression passed as the first argument. If the "bDesc"
//	** parameter is passed a non-zero value, iteration is in descending rowid
//	** order. Or, if it is zero, in ascending order.
//	**
//	** If iterating in ascending rowid order (bDesc==0), the first document
//	** visited is that with the smallest rowid that is larger than or equal
//	** to parameter iFirst. Or, if iterating in ascending order (bDesc==1),
//	** then the first document visited must have a rowid smaller than or
//	** equal to iFirst.
//	**
//	** Return SQLITE_OK if successful, or an SQLite error code otherwise. It
//	** is not considered an error if the query does not match any documents.
//	*/
func _sqlite3Fts5ExprFirst(tls *libc.TLS, p uintptr, pIdx uintptr, iFirst Ti64, iLast Ti64, bDesc int32) (r int32) {
	var pRoot uintptr
	var rc int32
	_, _ = pRoot, rc
	pRoot = (*TFts5Expr)(unsafe.Pointer(p)).FpRoot /* Return code */
	(*TFts5Expr)(unsafe.Pointer(p)).FpIndex = pIdx
	(*TFts5Expr)(unsafe.Pointer(p)).FbDesc = bDesc
	rc = _fts5ExprNodeFirst(tls, p, pRoot)
	/* If not at EOF but the current rowid occurs earlier than iFirst in
	 ** the iteration order, move to document iFirst or later. */
	if rc == SQLITE_OK && 0 == (*TFts5ExprNode)(unsafe.Pointer(pRoot)).FbEof && _fts5RowidCmp(tls, p, (*TFts5ExprNode)(unsafe.Pointer(pRoot)).FiRowid, iFirst) < 0 {
		rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Ti64) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExprNode)(unsafe.Pointer(pRoot)).FxNext})))(tls, p, pRoot, int32(1), iFirst)
	}
	/* If the iterator is not at a real match, skip forward until it is. */
	for (*TFts5ExprNode)(unsafe.Pointer(pRoot)).FbNomatch != 0 && rc == SQLITE_OK {
		rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Ti64) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExprNode)(unsafe.Pointer(pRoot)).FxNext})))(tls, p, pRoot, 0, int64(libc.Int32FromInt32(0)))
	}
	if _fts5RowidCmp(tls, p, (*TFts5ExprNode)(unsafe.Pointer(pRoot)).FiRowid, iLast) > 0 {
		(*TFts5ExprNode)(unsafe.Pointer(pRoot)).FbEof = int32(1)
	}
	return rc
}

// C documentation
//
//	/*
//	** Free the expression object passed as the only argument.
//	*/
func _sqlite3Fts5ExprFree(tls *libc.TLS, p uintptr) {
	if p != 0 {
		_sqlite3Fts5ParseNodeFree(tls, (*TFts5Expr)(unsafe.Pointer(p)).FpRoot)
		Xsqlite3_free(tls, (*TFts5Expr)(unsafe.Pointer(p)).FapExprPhrase)
		Xsqlite3_free(tls, p)
	}
}

// C documentation
//
//	/*
//	** This is called during initialization to register the fts5_expr() scalar
//	** UDF with the SQLite handle passed as the only argument.
//	*/
func _sqlite3Fts5ExprInit(tls *libc.TLS, pGlobal uintptr, db uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = SQLITE_OK
	_ = pGlobal
	_ = db
	/* Avoid warnings indicating that sqlite3Fts5ParserTrace() and
	 ** sqlite3Fts5ParserFallback() are unused */
	_ = __ccgo_fp(_sqlite3Fts5ParserFallback)
	return rc
}

// C documentation
//
//	/*
//	** Move to the next document
//	**
//	** Return SQLITE_OK if successful, or an SQLite error code otherwise. It
//	** is not considered an error if the query does not match any documents.
//	*/
func _sqlite3Fts5ExprNext(tls *libc.TLS, p uintptr, iLast Ti64) (r int32) {
	var pRoot uintptr
	var rc int32
	_, _ = pRoot, rc
	pRoot = (*TFts5Expr)(unsafe.Pointer(p)).FpRoot
	for cond := true; cond; cond = (*TFts5ExprNode)(unsafe.Pointer(pRoot)).FbNomatch != 0 {
		rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, Ti64) int32)(unsafe.Pointer(&struct{ uintptr }{(*TFts5ExprNode)(unsafe.Pointer(pRoot)).FxNext})))(tls, p, pRoot, 0, int64(libc.Int32FromInt32(0)))
	}
	if _fts5RowidCmp(tls, p, (*TFts5ExprNode)(unsafe.Pointer(pRoot)).FiRowid, iLast) > 0 {
		(*TFts5ExprNode)(unsafe.Pointer(pRoot)).FbEof = int32(1)
	}
	return rc
}

// C documentation
//
//	/*
//	** Return the number of phrases in expression pExpr.
//	*/
func _sqlite3Fts5ExprPhraseCount(tls *libc.TLS, pExpr uintptr) (r int32) {
	var v1 int32
	_ = v1
	if pExpr != 0 {
		v1 = (*TFts5Expr)(unsafe.Pointer(pExpr)).FnPhrase
	} else {
		v1 = 0
	}
	return v1
}

func _sqlite3Fts5ExprRowid(tls *libc.TLS, p uintptr) (r Ti64) {
	return (*TFts5ExprNode)(unsafe.Pointer((*TFts5Expr)(unsafe.Pointer(p)).FpRoot)).FiRowid
}

func _sqlite3Fts5FlushToDisk(tls *libc.TLS, pTab uintptr) (r int32) {
	_fts5TripCursors(tls, pTab)
	return _sqlite3Fts5StorageSync(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
}

// C documentation
//
//	/*
//	** Read a 64-bit variable-length integer from memory starting at p[0].
//	** Return the number of bytes read.  The value is stored in *v.
//	*/
func _sqlite3Fts5GetVarint(tls *libc.TLS, p uintptr, v uintptr) (r Tu8) {
	var a, b, s Tu32
	_, _, _ = a, b, s
	a = uint32(**(**uint8)(__ccgo_up(p)))
	/* a: p0 (unmasked) */
	if !(a&libc.Uint32FromInt32(0x80) != 0) {
		**(**Tu64)(__ccgo_up(v)) = uint64(a)
		return uint8(1)
	}
	p = p + 1
	b = uint32(**(**uint8)(__ccgo_up(p)))
	/* b: p1 (unmasked) */
	if !(b&libc.Uint32FromInt32(0x80) != 0) {
		a = a & uint32(0x7f)
		a = a << int32(7)
		a = a | b
		**(**Tu64)(__ccgo_up(v)) = uint64(a)
		return uint8(2)
	}
	/* Verify that constants are precomputed correctly */
	p = p + 1
	a = a << int32(14)
	a = a | uint32(**(**uint8)(__ccgo_up(p)))
	/* a: p0<<14 | p2 (unmasked) */
	if !(a&libc.Uint32FromInt32(0x80) != 0) {
		a = a & uint32(SLOT_2_0)
		b = b & uint32(0x7f)
		b = b << int32(7)
		a = a | b
		**(**Tu64)(__ccgo_up(v)) = uint64(a)
		return uint8(3)
	}
	/* CSE1 from below */
	a = a & uint32(SLOT_2_0)
	p = p + 1
	b = b << int32(14)
	b = b | uint32(**(**uint8)(__ccgo_up(p)))
	/* b: p1<<14 | p3 (unmasked) */
	if !(b&libc.Uint32FromInt32(0x80) != 0) {
		b = b & uint32(SLOT_2_0)
		/* moved CSE1 up */
		/* a &= (0x7f<<14)|(0x7f); */
		a = a << int32(7)
		a = a | b
		**(**Tu64)(__ccgo_up(v)) = uint64(a)
		return uint8(4)
	}
	/* a: p0<<14 | p2 (masked) */
	/* b: p1<<14 | p3 (unmasked) */
	/* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */
	/* moved CSE1 up */
	/* a &= (0x7f<<14)|(0x7f); */
	b = b & uint32(SLOT_2_0)
	s = a
	/* s: p0<<14 | p2 (masked) */
	p = p + 1
	a = a << int32(14)
	a = a | uint32(**(**uint8)(__ccgo_up(p)))
	/* a: p0<<28 | p2<<14 | p4 (unmasked) */
	if !(a&libc.Uint32FromInt32(0x80) != 0) {
		/* we can skip these cause they were (effectively) done above in calc'ing s */
		/* a &= (0x7f<<28)|(0x7f<<14)|(0x7f); */
		/* b &= (0x7f<<14)|(0x7f); */
		b = b << int32(7)
		a = a | b
		s = s >> int32(18)
		**(**Tu64)(__ccgo_up(v)) = uint64(s)<<int32(32) | uint64(a)
		return uint8(5)
	}
	/* 2:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */
	s = s << int32(7)
	s = s | b
	/* s: p0<<21 | p1<<14 | p2<<7 | p3 (masked) */
	p = p + 1
	b = b << int32(14)
	b = b | uint32(**(**uint8)(__ccgo_up(p)))
	/* b: p1<<28 | p3<<14 | p5 (unmasked) */
	if !(b&libc.Uint32FromInt32(0x80) != 0) {
		/* we can skip this cause it was (effectively) done above in calc'ing s */
		/* b &= (0x7f<<28)|(0x7f<<14)|(0x7f); */
		a = a & uint32(SLOT_2_0)
		a = a << int32(7)
		a = a | b
		s = s >> int32(18)
		**(**Tu64)(__ccgo_up(v)) = uint64(s)<<int32(32) | uint64(a)
		return uint8(6)
	}
	p = p + 1
	a = a << int32(14)
	a = a | uint32(**(**uint8)(__ccgo_up(p)))
	/* a: p2<<28 | p4<<14 | p6 (unmasked) */
	if !(a&libc.Uint32FromInt32(0x80) != 0) {
		a = a & uint32(SLOT_4_2_0)
		b = b & uint32(SLOT_2_0)
		b = b << int32(7)
		a = a | b
		s = s >> int32(11)
		**(**Tu64)(__ccgo_up(v)) = uint64(s)<<int32(32) | uint64(a)
		return uint8(7)
	}
	/* CSE2 from below */
	a = a & uint32(SLOT_2_0)
	p = p + 1
	b = b << int32(14)
	b = b | uint32(**(**uint8)(__ccgo_up(p)))
	/* b: p3<<28 | p5<<14 | p7 (unmasked) */
	if !(b&libc.Uint32FromInt32(0x80) != 0) {
		b = b & uint32(SLOT_4_2_0)
		/* moved CSE2 up */
		/* a &= (0x7f<<14)|(0x7f); */
		a = a << int32(7)
		a = a | b
		s = s >> int32(4)
		**(**Tu64)(__ccgo_up(v)) = uint64(s)<<int32(32) | uint64(a)
		return uint8(8)
	}
	p = p + 1
	a = a << int32(15)
	a = a | uint32(**(**uint8)(__ccgo_up(p)))
	/* a: p4<<29 | p6<<15 | p8 (unmasked) */
	/* moved CSE2 up */
	/* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */
	b = b & uint32(SLOT_2_0)
	b = b << int32(8)
	a = a | b
	s = s << int32(4)
	b = uint32(**(**uint8)(__ccgo_up(p + uintptr(-libc.Int32FromInt32(4)))))
	b = b & uint32(0x7f)
	b = b >> int32(3)
	s = s | b
	**(**Tu64)(__ccgo_up(v)) = uint64(s)<<int32(32) | uint64(a)
	return uint8(9)
}

/*
** The variable-length integer encoding is as follows:
**
** KEY:
**         A = 0xxxxxxx    7 bits of data and one flag bit
**         B = 1xxxxxxx    7 bits of data and one flag bit
**         C = xxxxxxxx    8 bits of data
**
**  7 bits - A
** 14 bits - BA
** 21 bits - BBA
** 28 bits - BBBA
** 35 bits - BBBBA
** 42 bits - BBBBBA
** 49 bits - BBBBBBA
** 56 bits - BBBBBBBA
** 64 bits - BBBBBBBBC
 */

// C documentation
//
//	/*
//	** Free a hash table object.
//	*/
func _sqlite3Fts5HashFree(tls *libc.TLS, pHash uintptr) {
	if pHash != 0 {
		_sqlite3Fts5HashClear(tls, pHash)
		Xsqlite3_free(tls, (*TFts5Hash)(unsafe.Pointer(pHash)).FaSlot)
		Xsqlite3_free(tls, pHash)
	}
}

// C documentation
//
//	/*
//	** Return true if the hash table is empty, false otherwise.
//	*/
func _sqlite3Fts5HashIsEmpty(tls *libc.TLS, pHash uintptr) (r int32) {
	return libc.BoolInt32((*TFts5Hash)(unsafe.Pointer(pHash)).FnEntry == 0)
}

func _sqlite3Fts5HashScanEof(tls *libc.TLS, p uintptr) (r int32) {
	return libc.BoolInt32((*TFts5Hash)(unsafe.Pointer(p)).FpScan == uintptr(0))
}

func _sqlite3Fts5HashScanNext(tls *libc.TLS, p uintptr) {
	(*TFts5Hash)(unsafe.Pointer(p)).FpScan = (*TFts5HashEntry)(unsafe.Pointer((*TFts5Hash)(unsafe.Pointer(p)).FpScan)).FpScanNext
}

// C documentation
//
//	/*
//	** Close a handle opened by an earlier call to sqlite3Fts5IndexOpen().
//	*/
func _sqlite3Fts5IndexClose(tls *libc.TLS, p uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = SQLITE_OK
	if p != 0 {
		_fts5StructureInvalidate(tls, p)
		Xsqlite3_finalize(tls, (*TFts5Index)(unsafe.Pointer(p)).FpWriter)
		Xsqlite3_finalize(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleter)
		Xsqlite3_finalize(tls, (*TFts5Index)(unsafe.Pointer(p)).FpIdxWriter)
		Xsqlite3_finalize(tls, (*TFts5Index)(unsafe.Pointer(p)).FpIdxDeleter)
		Xsqlite3_finalize(tls, (*TFts5Index)(unsafe.Pointer(p)).FpIdxSelect)
		Xsqlite3_finalize(tls, (*TFts5Index)(unsafe.Pointer(p)).FpIdxNextSelect)
		Xsqlite3_finalize(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDataVersion)
		Xsqlite3_finalize(tls, (*TFts5Index)(unsafe.Pointer(p)).FpDeleteFromIdx)
		_sqlite3Fts5HashFree(tls, (*TFts5Index)(unsafe.Pointer(p)).FpHash)
		Xsqlite3_free(tls, (*TFts5Index)(unsafe.Pointer(p)).FzDataTbl)
		Xsqlite3_free(tls, p)
	}
	return rc
}

// C documentation
//
//	/*
//	** Close the read-only blob handle, if it is open.
//	*/
func _sqlite3Fts5IndexCloseReader(tls *libc.TLS, p uintptr) {
	_fts5IndexCloseReader(tls, p)
	_fts5IndexReturn(tls, p)
}

// C documentation
//
//	/*
//	** This is called as part of registering the FTS5 module with database
//	** connection db. It registers several user-defined scalar functions useful
//	** with FTS5.
//	**
//	** If successful, SQLITE_OK is returned. If an error occurs, some other
//	** SQLite error code is returned instead.
//	*/
func _sqlite3Fts5IndexInit(tls *libc.TLS, db uintptr) (r int32) {
	return SQLITE_OK
	_ = db
	return r
}

// C documentation
//
//	/*
//	** Clear any existing entries from the token-map associated with the
//	** iterator passed as the only argument.
//	*/
func _sqlite3Fts5IndexIterClearTokendata(tls *libc.TLS, pIndexIter uintptr) {
	var pIter uintptr
	_ = pIter
	pIter = pIndexIter
	if pIter != 0 && (*TFts5Iter)(unsafe.Pointer(pIter)).FpTokenDataIter != 0 && ((*TFts5Iter)(unsafe.Pointer(pIter)).FnSeg == 0 || (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer((*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex)).FpConfig)).FeDetail != FTS5_DETAIL_FULL) {
		(*TFts5TokenDataIter)(unsafe.Pointer((*TFts5Iter)(unsafe.Pointer(pIter)).FpTokenDataIter)).FnMap = 0
	}
}

func _sqlite3Fts5IndexLoadConfig(tls *libc.TLS, p uintptr) (r int32) {
	var pStruct uintptr
	_ = pStruct
	pStruct = _fts5StructureRead(tls, p)
	_fts5StructureRelease(tls, pStruct)
	return _fts5IndexReturn(tls, p)
}

// C documentation
//
//	/*
//	** This is called to implement the special "VALUES('merge', $nMerge)"
//	** INSERT command.
//	*/
func _sqlite3Fts5IndexMerge(tls *libc.TLS, p uintptr, nMerge int32) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var nMin, v1 int32
	var pNew uintptr
	var _ /* pStruct at bp+0 */ uintptr
	_, _, _ = nMin, pNew, v1
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
	_fts5IndexFlush(tls, p)
	**(**uintptr)(__ccgo_up(bp)) = _fts5StructureRead(tls, p)
	if **(**uintptr)(__ccgo_up(bp)) != 0 {
		nMin = (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(p)).FpConfig)).FnUsermerge
		_fts5StructureInvalidate(tls, p)
		if nMerge < 0 {
			pNew = _fts5IndexOptimizeStruct(tls, p, **(**uintptr)(__ccgo_up(bp)))
			_fts5StructureRelease(tls, **(**uintptr)(__ccgo_up(bp)))
			**(**uintptr)(__ccgo_up(bp)) = pNew
			nMin = int32(1)
			if nMerge == -libc.Int32FromInt32(1)-libc.Int32FromInt32(0x7fffffff) {
				v1 = libc.Int32FromInt32(0x7fffffff)
			} else {
				v1 = nMerge * -int32(1)
			}
			nMerge = v1
		}
		if **(**uintptr)(__ccgo_up(bp)) != 0 && (*TFts5Structure)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FnLevel != 0 {
			if _fts5IndexMerge(tls, p, bp, nMerge, nMin) != 0 {
				_fts5StructureWrite(tls, p, **(**uintptr)(__ccgo_up(bp)))
			}
		}
		_fts5StructureRelease(tls, **(**uintptr)(__ccgo_up(bp)))
	}
	return _fts5IndexReturn(tls, p)
}

// C documentation
//
//	/*
//	** Return the total number of blocks this module has read from the %_data
//	** table since it was created.
//	*/
func _sqlite3Fts5IndexReads(tls *libc.TLS, p uintptr) (r int32) {
	return (*TFts5Index)(unsafe.Pointer(p)).FnRead
}

func _sqlite3Fts5IndexReset(tls *libc.TLS, p uintptr) (r int32) {
	if _fts5IndexDataVersion(tls, p) != (*TFts5Index)(unsafe.Pointer(p)).FiStructVersion {
		_fts5StructureInvalidate(tls, p)
	}
	return _fts5IndexReturn(tls, p)
}

/*
** 2014 Jun 09
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** This is an SQLite module implementing full-text search.
 */

/* #include "fts5Int.h" */

/*
** This variable is set to false when running tests for which the on disk
** structures should not be corrupt. Otherwise, true. If it is false, extra
** assert() conditions in the fts5 code are activated - conditions that are
** only true if it is guaranteed that the fts5 database is not corrupt.
 */

// C documentation
//
//	/*
//	** Discard any data stored in the in-memory hash tables. Do not write it
//	** to the database. Additionally, assume that the contents of the %_data
//	** table may have changed on disk. So any in-memory caches of %_data
//	** records must be invalidated.
//	*/
func _sqlite3Fts5IndexRollback(tls *libc.TLS, p uintptr) (r int32) {
	_fts5IndexCloseReader(tls, p)
	_fts5IndexDiscardData(tls, p)
	_fts5StructureInvalidate(tls, p)
	return _fts5IndexReturn(tls, p)
}

// C documentation
//
//	/*
//	** Replace the current "averages" record with the contents of the buffer
//	** supplied as the second argument.
//	*/
func _sqlite3Fts5IndexSetAverages(tls *libc.TLS, p uintptr, pData uintptr, nData int32) (r int32) {
	_fts5DataWrite(tls, p, int64(FTS5_AVERAGES_ROWID), pData, nData)
	return _fts5IndexReturn(tls, p)
}

// C documentation
//
//	/*
//	** Commit data to disk.
//	*/
func _sqlite3Fts5IndexSync(tls *libc.TLS, p uintptr) (r int32) {
	_fts5IndexFlush(tls, p)
	_fts5IndexCloseReader(tls, p)
	return _fts5IndexReturn(tls, p)
}

// C documentation
//
//	/*
//	** The following functions are used to register the module with SQLite. If
//	** this module is being built as part of the SQLite core (SQLITE_CORE is
//	** defined), then sqlite3_open() will call sqlite3Fts5Init() directly.
//	**
//	** Or, if this module is being built as a loadable extension,
//	** sqlite3Fts5Init() is omitted and the two standard entry points
//	** sqlite3_fts_init() and sqlite3_fts5_init() defined instead.
//	*/
func _sqlite3Fts5Init(tls *libc.TLS, db uintptr) (r int32) {
	return _fts5Init(tls, db)
}

// C documentation
//
//	/*
//	** Close an iterator opened by an earlier call to sqlite3Fts5IndexQuery().
//	*/
func _sqlite3Fts5IterClose(tls *libc.TLS, pIndexIter uintptr) {
	var pIndex uintptr
	_ = pIndex
	if pIndexIter != 0 {
		pIndex = (*TFts5Iter)(unsafe.Pointer(pIndexIter)).FpIndex
		_fts5IterClose(tls, pIndexIter)
		_fts5IndexReturn(tls, pIndex)
	}
}

// C documentation
//
//	/*
//	** Return true if the iterator passed as the only argument is at EOF.
//	*/
//	/*
//	** Move to the next matching rowid.
//	*/
func _sqlite3Fts5IterNext(tls *libc.TLS, pIndexIter uintptr) (r int32) {
	var pIter uintptr
	_ = pIter
	pIter = pIndexIter
	if (*TFts5Iter)(unsafe.Pointer(pIter)).FnSeg == 0 {
		_fts5TokendataIterNext(tls, pIter, 0, 0)
	} else {
		_fts5MultiIterNext(tls, (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex, pIter, 0, 0)
	}
	return _fts5IndexReturn(tls, (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex)
}

// C documentation
//
//	/*
//	** Move to the next matching rowid that occurs at or after iMatch. The
//	** definition of "at or after" depends on whether this iterator iterates
//	** in ascending or descending rowid order.
//	*/
func _sqlite3Fts5IterNextFrom(tls *libc.TLS, pIndexIter uintptr, iMatch Ti64) (r int32) {
	var pIter uintptr
	_ = pIter
	pIter = pIndexIter
	if (*TFts5Iter)(unsafe.Pointer(pIter)).FnSeg == 0 {
		_fts5TokendataIterNext(tls, pIter, int32(1), iMatch)
	} else {
		_fts5MultiIterNextFrom(tls, (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex, pIter, iMatch)
	}
	return _fts5IndexReturn(tls, (*TFts5Iter)(unsafe.Pointer(pIter)).FpIndex)
}

// C documentation
//
//	/*
//	** Return the current term.
//	*/
func _sqlite3Fts5IterTerm(tls *libc.TLS, pIndexIter uintptr, pn uintptr) (r uintptr) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var z, v1 uintptr
	var _ /* n at bp+0 */ int32
	_, _ = z, v1
	z = _fts5MultiIterTerm(tls, pIndexIter, bp)
	**(**int32)(__ccgo_up(pn)) = **(**int32)(__ccgo_up(bp)) - int32(1)
	if z != 0 {
		v1 = z + 1
	} else {
		v1 = uintptr(0)
	}
	return v1
}

func _sqlite3Fts5Mprintf(tls *libc.TLS, pRc uintptr, zFmt uintptr, va uintptr) (r uintptr) {
	var ap Tva_list
	var zRet uintptr
	_, _ = ap, zRet
	zRet = uintptr(0)
	if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK {
		ap = va
		zRet = Xsqlite3_vmprintf(tls, zFmt, ap)
		_ = ap
		if zRet == uintptr(0) {
			**(**int32)(__ccgo_up(pRc)) = int32(SQLITE_NOMEM)
		}
	}
	return zRet
}

func _sqlite3Fts5ParseError(tls *libc.TLS, pParse uintptr, zFmt uintptr, va uintptr) {
	var ap Tva_list
	_ = ap
	ap = va
	if (*TFts5Parse)(unsafe.Pointer(pParse)).Frc == SQLITE_OK {
		(*TFts5Parse)(unsafe.Pointer(pParse)).FzErr = Xsqlite3_vmprintf(tls, zFmt, ap)
		(*TFts5Parse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_ERROR)
	}
	_ = ap
}

func _sqlite3Fts5ParseFinished(tls *libc.TLS, pParse uintptr, p uintptr) {
	(*TFts5Parse)(unsafe.Pointer(pParse)).FpExpr = p
}

// C documentation
//
//	/*
//	** Free the phrase object passed as the only argument.
//	*/
func _sqlite3Fts5ParsePhraseFree(tls *libc.TLS, pPhrase uintptr) {
	_fts5ExprPhraseFree(tls, pPhrase)
}

// C documentation
//
//	/*
//	** Deallocate and destroy a parser.  Destructors are called for
//	** all stack elements before shutting the parser down.
//	**
//	** If the fts5YYPARSEFREENEVERNULL macro exists (for example because it
//	** is defined in a %include section of the input grammar) then it is
//	** assumed that the input pointer is never NULL.
//	*/
func _sqlite3Fts5ParserFree(tls *libc.TLS, p uintptr, __ccgo_fp_freeProc uintptr) {
	if p == uintptr(0) {
		return
	}
	_sqlite3Fts5ParserFinalize(tls, p)
	(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_freeProc})))(tls, p)
}

/*
** Return the peak depth of the stack for a parser.
 */

/* This array of booleans keeps track of the parser statement
** coverage.  The element fts5yycoverage[X][Y] is set when the parser
** is in state X and has a lookahead token Y.  In a well-tested
** systems, every element of this matrix should end up being set.
 */

/*
** Write into out a description of every state/lookahead combination that
**
**   (1)  has not been used by the parser, and
**   (2)  is not a syntax error.
**
** Return the number of missed state/lookahead combinations.
 */

func _sqlite3Fts5PutVarint(tls *libc.TLS, p uintptr, v Tu64) (r int32) {
	if v <= uint64(0x7f) {
		**(**uint8)(__ccgo_up(p)) = uint8(v & uint64(0x7f))
		return int32(1)
	}
	if v <= uint64(0x3fff) {
		**(**uint8)(__ccgo_up(p)) = uint8(v>>libc.Int32FromInt32(7)&uint64(0x7f) | uint64(0x80))
		**(**uint8)(__ccgo_up(p + 1)) = uint8(v & uint64(0x7f))
		return int32(2)
	}
	return _fts5PutVarint64(tls, p, v)
}

func _sqlite3Fts5StorageConfigValue(tls *libc.TLS, p uintptr, z uintptr, pVal uintptr, iVal int32) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var iNew, rc int32
	var _ /* pReplace at bp+0 */ uintptr
	_, _ = iNew, rc
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
	rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_REPLACE_CONFIG), bp, uintptr(0))
	if rc == SQLITE_OK {
		Xsqlite3_bind_text(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), z, -int32(1), libc.UintptrFromInt32(0))
		if pVal != 0 {
			Xsqlite3_bind_value(tls, **(**uintptr)(__ccgo_up(bp)), int32(2), pVal)
		} else {
			Xsqlite3_bind_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(2), iVal)
		}
		Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp)))
		rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp)))
		Xsqlite3_bind_null(tls, **(**uintptr)(__ccgo_up(bp)), int32(1))
	}
	if rc == SQLITE_OK && pVal != 0 {
		iNew = (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FiCookie + int32(1)
		rc = _sqlite3Fts5IndexSetCookie(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex, iNew)
		if rc == SQLITE_OK {
			(*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FiCookie = iNew
		}
	}
	return rc
}

/*
** 2014 May 31
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
 */

/* #include "fts5Int.h" */

/**************************************************************************
** Start of ascii tokenizer implementation.
 */

// C documentation
//
//	/*
//	** Remove a row from the FTS table.
//	*/
func _sqlite3Fts5StorageDelete(tls *libc.TLS, p uintptr, iDel Ti64, apVal uintptr, bSaveRow int32) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var pConfig uintptr
	var rc int32
	var _ /* pDel at bp+0 */ uintptr
	_, _ = pConfig, rc
	pConfig = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
	rc = _fts5StorageLoadTotals(tls, p, int32(1))
	/* Delete the index records */
	if rc == SQLITE_OK {
		rc = _sqlite3Fts5IndexBeginWrite(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex, int32(1), iDel)
	}
	if rc == SQLITE_OK {
		if (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FbContentlessDelete != 0 {
			rc = _fts5StorageContentlessDelete(tls, p, iDel)
			if rc == SQLITE_OK && bSaveRow != 0 && (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FeContent == int32(FTS5_CONTENT_UNINDEXED) {
				rc = _sqlite3Fts5StorageFindDeleteRow(tls, p, iDel)
			}
		} else {
			rc = _fts5StorageDeleteFromIndex(tls, p, iDel, apVal, bSaveRow)
		}
	}
	/* Delete the %_docsize record */
	if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 {
		rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_DELETE_DOCSIZE), bp, uintptr(0))
		if rc == SQLITE_OK {
			Xsqlite3_bind_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), iDel)
			Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp)))
			rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp)))
		}
	}
	/* Delete the %_content record */
	if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL || (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == int32(FTS5_CONTENT_UNINDEXED) {
		if rc == SQLITE_OK {
			rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_DELETE_CONTENT), bp, uintptr(0))
		}
		if rc == SQLITE_OK {
			Xsqlite3_bind_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), iDel)
			Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp)))
			rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp)))
		}
	}
	return rc
}

// C documentation
//
//	/*
//	** Argument aCol points to an array of integers containing one entry for
//	** each table column. This function reads the %_docsize record for the
//	** specified rowid and populates aCol[] with the results.
//	**
//	** An SQLite error code is returned if an error occurs, or SQLITE_OK
//	** otherwise.
//	*/
func _sqlite3Fts5StorageDocsize(tls *libc.TLS, p uintptr, iRowid Ti64, aCol uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var aBlob uintptr
	var bCorrupt, nBlob, nCol, rc int32
	var _ /* pLookup at bp+0 */ uintptr
	_, _, _, _, _ = aBlob, bCorrupt, nBlob, nCol, rc
	nCol = (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FnCol /* Number of user columns in table */
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0)                                                /* Return Code */
	rc = _fts5StorageGetStmt(tls, p, int32(FTS5_STMT_LOOKUP_DOCSIZE), bp, uintptr(0))
	if **(**uintptr)(__ccgo_up(bp)) != 0 {
		bCorrupt = int32(1)
		Xsqlite3_bind_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), iRowid)
		if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) {
			aBlob = Xsqlite3_column_blob(tls, **(**uintptr)(__ccgo_up(bp)), 0)
			nBlob = Xsqlite3_column_bytes(tls, **(**uintptr)(__ccgo_up(bp)), 0)
			if 0 == _fts5StorageDecodeSizeArray(tls, aCol, nCol, aBlob, nBlob) {
				bCorrupt = 0
			}
		}
		rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp)))
		if bCorrupt != 0 && rc == SQLITE_OK {
			rc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<<libc.Int32FromInt32(8)
		}
	} else {
	}
	return rc
}

// C documentation
//
//	/*
//	** This function is used as part of an UPDATE statement that modifies the
//	** rowid of a row. In that case, this function is called first to set
//	** Fts5Storage.pSavedRow to point to a statement that may be used to
//	** access the original values of the row being deleted - iDel.
//	**
//	** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
//	** It is not considered an error if row iDel does not exist. In this case
//	** pSavedRow is not set and SQLITE_OK returned.
//	*/
func _sqlite3Fts5StorageFindDeleteRow(tls *libc.TLS, p uintptr, iDel Ti64) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var rc int32
	var _ /* pSeek at bp+0 */ uintptr
	_ = rc
	rc = SQLITE_OK
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
	rc = _fts5StorageGetStmt(tls, p, libc.Int32FromInt32(FTS5_STMT_LOOKUP)+libc.Int32FromInt32(1), bp, uintptr(0))
	if rc == SQLITE_OK {
		Xsqlite3_bind_int64(tls, **(**uintptr)(__ccgo_up(bp)), int32(1), iDel)
		if Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) != int32(SQLITE_ROW) {
			rc = Xsqlite3_reset(tls, **(**uintptr)(__ccgo_up(bp)))
		} else {
			(*TFts5Storage)(unsafe.Pointer(p)).FpSavedRow = **(**uintptr)(__ccgo_up(bp))
		}
	}
	return rc
}

func _sqlite3Fts5StorageMerge(tls *libc.TLS, p uintptr, nMerge int32) (r int32) {
	return _sqlite3Fts5IndexMerge(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex, nMerge)
}

func _sqlite3Fts5StorageOptimize(tls *libc.TLS, p uintptr) (r int32) {
	return _sqlite3Fts5IndexOptimize(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex)
}

// C documentation
//
//	/*
//	** Reset any saved statement pSavedRow. Zero pSavedRow as well. This
//	** should be called by the xUpdate() method of the fts5 table before
//	** returning from any operation that may have set Fts5Storage.pSavedRow.
//	*/
func _sqlite3Fts5StorageReleaseDeleteRow(tls *libc.TLS, pStorage uintptr) {
	Xsqlite3_reset(tls, (*TFts5Storage)(unsafe.Pointer(pStorage)).FpSavedRow)
	(*TFts5Storage)(unsafe.Pointer(pStorage)).FpSavedRow = uintptr(0)
}

func _sqlite3Fts5StorageReset(tls *libc.TLS, p uintptr) (r int32) {
	return _sqlite3Fts5IndexReset(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex)
}

func _sqlite3Fts5StorageRollback(tls *libc.TLS, p uintptr) (r int32) {
	(*TFts5Storage)(unsafe.Pointer(p)).FbTotalsValid = 0
	return _sqlite3Fts5IndexRollback(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex)
}

func _sqlite3Fts5StorageRowCount(tls *libc.TLS, p uintptr, pnRow uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = _fts5StorageLoadTotals(tls, p, 0)
	if rc == SQLITE_OK {
		/* nTotalRow being zero does not necessarily indicate a corrupt
		 ** database - it might be that the FTS5 table really does contain zero
		 ** rows. However this function is only called from the xRowCount() API,
		 ** and there is no way for that API to be invoked if the table contains
		 ** no rows. Hence the FTS5_CORRUPT return.  */
		**(**Ti64)(__ccgo_up(pnRow)) = (*TFts5Storage)(unsafe.Pointer(p)).FnTotalRow
		if (*TFts5Storage)(unsafe.Pointer(p)).FnTotalRow <= 0 {
			rc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<<libc.Int32FromInt32(8)
		}
	}
	return rc
}

func _sqlite3Fts5StorageSize(tls *libc.TLS, p uintptr, iCol int32, pnToken uintptr) (r int32) {
	var i, rc int32
	_, _ = i, rc
	rc = _fts5StorageLoadTotals(tls, p, 0)
	if rc == SQLITE_OK {
		**(**Ti64)(__ccgo_up(pnToken)) = 0
		if iCol < 0 {
			i = 0
			for {
				if !(i < (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FnCol) {
					break
				}
				**(**Ti64)(__ccgo_up(pnToken)) += **(**Ti64)(__ccgo_up((*TFts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(i)*8))
				goto _1
			_1:
				;
				i = i + 1
			}
		} else {
			if iCol < (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).FnCol {
				**(**Ti64)(__ccgo_up(pnToken)) = **(**Ti64)(__ccgo_up((*TFts5Storage)(unsafe.Pointer(p)).FaTotalSize + uintptr(iCol)*8))
			} else {
				rc = int32(SQLITE_RANGE)
			}
		}
	}
	return rc
}

// C documentation
//
//	/*
//	** Flush any data currently held in-memory to disk.
//	*/
func _sqlite3Fts5StorageSync(tls *libc.TLS, p uintptr) (r int32) {
	var iLastRowid Ti64
	var rc int32
	_, _ = iLastRowid, rc
	rc = SQLITE_OK
	iLastRowid = Xsqlite3_last_insert_rowid(tls, (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).Fdb)
	if (*TFts5Storage)(unsafe.Pointer(p)).FbTotalsValid != 0 {
		rc = _fts5StorageSaveTotals(tls, p)
		if rc == SQLITE_OK {
			(*TFts5Storage)(unsafe.Pointer(p)).FbTotalsValid = 0
		}
	}
	if rc == SQLITE_OK {
		rc = _sqlite3Fts5IndexSync(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex)
	}
	Xsqlite3_set_last_insert_rowid(tls, (*TFts5Config)(unsafe.Pointer((*TFts5Storage)(unsafe.Pointer(p)).FpConfig)).Fdb, iLastRowid)
	return rc
}

func _sqlite3Fts5StructureRef(tls *libc.TLS, p uintptr) (r uintptr) {
	_fts5StructureRef(tls, (*TFts5Index)(unsafe.Pointer(p)).FpStruct)
	return (*TFts5Index)(unsafe.Pointer(p)).FpStruct
}

func _sqlite3Fts5StructureRelease(tls *libc.TLS, p uintptr) {
	if p != 0 {
		_fts5StructureRelease(tls, p)
	}
}

func _sqlite3Fts5StructureTest(tls *libc.TLS, p uintptr, pStruct uintptr) (r int32) {
	if (*TFts5Index)(unsafe.Pointer(p)).FpStruct != pStruct {
		return int32(SQLITE_ABORT)
	}
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Given cursor id iId, return a pointer to the corresponding Fts5Table
//	** object. Or NULL If the cursor id does not exist.
//	*/
func _sqlite3Fts5TableFromCsrid(tls *libc.TLS, pGlobal uintptr, iCsrId Ti64) (r uintptr) {
	var pCsr uintptr
	_ = pCsr
	pCsr = _fts5CursorFromCsrid(tls, pGlobal, iCsrId)
	if pCsr != 0 {
		return (*TFts5Cursor)(unsafe.Pointer(pCsr)).Fbase.FpVtab
	}
	return uintptr(0)
}

// C documentation
//
//	/*
//	** Tokenize the text passed via the second and third arguments.
//	**
//	** The callback is invoked once for each token in the input text. The
//	** arguments passed to it are, in order:
//	**
//	**     void *pCtx          // Copy of 4th argument to sqlite3Fts5Tokenize()
//	**     const char *pToken  // Pointer to buffer containing token
//	**     int nToken          // Size of token in bytes
//	**     int iStart          // Byte offset of start of token within input text
//	**     int iEnd            // Byte offset of end of token within input text
//	**     int iPos            // Position of token in input (first token is 0)
//	**
//	** If the callback returns a non-zero value the tokenization is abandoned
//	** and no further callbacks are issued.
//	**
//	** This function returns SQLITE_OK if successful or an SQLite error code
//	** if an error occurs. If the tokenization was abandoned early because
//	** the callback returned SQLITE_DONE, this is not an error and this function
//	** still returns SQLITE_OK. Or, if the tokenization was abandoned early
//	** because the callback returned another non-zero value, it is assumed
//	** to be an SQLite error code and returned to the caller.
//	*/
func _sqlite3Fts5Tokenize(tls *libc.TLS, pConfig uintptr, flags int32, pText uintptr, nText int32, pCtx uintptr, __ccgo_fp_xToken uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = SQLITE_OK
	if pText != 0 {
		if (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpTok == uintptr(0) {
			rc = _sqlite3Fts5LoadTokenizer(tls, pConfig)
		}
		if rc == SQLITE_OK {
			if (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpApi1 != 0 {
				rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tfts5_tokenizer)(unsafe.Pointer((*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpApi1)).FxTokenize})))(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpTok, pCtx, flags, pText, nText, __ccgo_fp_xToken)
			} else {
				rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tfts5_tokenizer_v2)(unsafe.Pointer((*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpApi2)).FxTokenize})))(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpTok, pCtx, flags, pText, nText, (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FpLocale, (*TFts5Config)(unsafe.Pointer(pConfig)).Ft.FnLocale, __ccgo_fp_xToken)
			}
		}
	}
	return rc
}

// C documentation
//
//	/*
//	** Argument xCreate is a pointer to a constructor function for a tokenizer.
//	** pTok is a tokenizer previously created using the same method. This function
//	** returns one of FTS5_PATTERN_NONE, FTS5_PATTERN_LIKE or FTS5_PATTERN_GLOB
//	** indicating the style of pattern matching that the tokenizer can support.
//	** In practice, this is:
//	**
//	**     "trigram" tokenizer, case_sensitive=1 - FTS5_PATTERN_GLOB
//	**     "trigram" tokenizer, case_sensitive=0 (the default) - FTS5_PATTERN_LIKE
//	**     all other tokenizers - FTS5_PATTERN_NONE
//	*/
func _sqlite3Fts5TokenizerPattern(tls *libc.TLS, __ccgo_fp_xCreate uintptr, pTok uintptr) (r int32) {
	var p uintptr
	var v1 int32
	_, _ = p, v1
	if __ccgo_fp_xCreate == __ccgo_fp(_fts5TriCreate) {
		p = pTok
		if (*TTrigramTokenizer)(unsafe.Pointer(p)).FiFoldParam == 0 {
			if (*TTrigramTokenizer)(unsafe.Pointer(p)).FbFold != 0 {
				v1 = int32(FTS5_PATTERN_LIKE)
			} else {
				v1 = int32(FTS5_PATTERN_GLOB)
			}
			return v1
		}
	}
	return FTS5_PATTERN_NONE
}

// C documentation
//
//	/*
//	** Code an OP_Halt that causes the vdbe to return an SQLITE_CONSTRAINT
//	** error. The onError parameter determines which (if any) of the statement
//	** and/or current transaction is rolled back.
//	*/
func _sqlite3HaltConstraint(tls *libc.TLS, pParse uintptr, errCode int32, onError int32, p4 uintptr, p4type Ti8, p5Errmsg Tu8) {
	var v uintptr
	_ = v
	v = _sqlite3GetVdbe(tls, pParse)
	if onError == int32(OE_Abort) {
		_sqlite3MayAbort(tls, pParse)
	}
	_sqlite3VdbeAddOp4(tls, v, int32(OP_Halt), errCode, onError, 0, p4, int32(p4type))
	_sqlite3VdbeChangeP5(tls, v, uint16(p5Errmsg))
}

// C documentation
//
//	/* Remove all entries from a hash table.  Reclaim all memory.
//	** Call this routine to delete a hash table or to reset a hash table
//	** to the empty state.
//	*/
func _sqlite3HashClear(tls *libc.TLS, pH uintptr) {
	var elem, next_elem uintptr
	_, _ = elem, next_elem /* For looping over all elements of the table */
	elem = (*THash)(unsafe.Pointer(pH)).Ffirst
	(*THash)(unsafe.Pointer(pH)).Ffirst = uintptr(0)
	Xsqlite3_free(tls, (*THash)(unsafe.Pointer(pH)).Fht)
	(*THash)(unsafe.Pointer(pH)).Fht = uintptr(0)
	(*THash)(unsafe.Pointer(pH)).Fhtsize = uint32(0)
	for elem != 0 {
		next_elem = (*THashElem)(unsafe.Pointer(elem)).Fnext
		Xsqlite3_free(tls, elem)
		elem = next_elem
	}
	(*THash)(unsafe.Pointer(pH)).Fcount = uint32(0)
}

// C documentation
//
//	/* Attempt to locate an element of the hash table pH with a key
//	** that matches pKey.  Return the data for this element if it is
//	** found, or NULL if there is no match.
//	*/
func _sqlite3HashFind(tls *libc.TLS, pH uintptr, pKey uintptr) (r uintptr) {
	return (*THashElem)(unsafe.Pointer(_findElementWithHash(tls, pH, pKey, uintptr(0)))).Fdata
}

// C documentation
//
//	/* Turn bulk memory into a hash table object by initializing the
//	** fields of the Hash structure.
//	**
//	** "pNew" is a pointer to the hash table that is to be initialized.
//	*/
func _sqlite3HashInit(tls *libc.TLS, pNew uintptr) {
	(*THash)(unsafe.Pointer(pNew)).Ffirst = uintptr(0)
	(*THash)(unsafe.Pointer(pNew)).Fcount = uint32(0)
	(*THash)(unsafe.Pointer(pNew)).Fhtsize = uint32(0)
	(*THash)(unsafe.Pointer(pNew)).Fht = uintptr(0)
}

var _sqlite3Hooks = TBenignMallocHooks{}

/* The "wsdHooks" macro will resolve to the appropriate BenignMallocHooks
** structure.  If writable static data is unsupported on the target,
** we have to locate the state vector at run-time.  In the more common
** case where writable static data is supported, wsdHooks can refer directly
** to the "sqlite3Hooks" state vector declared above.
 */

// C documentation
//
//	/*
//	** The argument is an IN operator with a list (not a subquery) on the
//	** right-hand side.  Return TRUE if that list is constant.
//	*/
func _sqlite3InRhsIsConstant(tls *libc.TLS, pParse uintptr, pIn uintptr) (r int32) {
	var pLHS uintptr
	var res int32
	_, _ = pLHS, res
	pLHS = (*TExpr)(unsafe.Pointer(pIn)).FpLeft
	(*TExpr)(unsafe.Pointer(pIn)).FpLeft = uintptr(0)
	res = _sqlite3ExprIsConstant(tls, pParse, pIn)
	(*TExpr)(unsafe.Pointer(pIn)).FpLeft = pLHS
	return res
}

func _sqlite3IndexAffinityStr(tls *libc.TLS, db uintptr, pIdx uintptr) (r uintptr) {
	if !((*TIndex)(unsafe.Pointer(pIdx)).FzColAff != 0) {
		return _computeIndexAffStr(tls, db, pIdx)
	}
	return (*TIndex)(unsafe.Pointer(pIdx)).FzColAff
}

// C documentation
//
//	/*
//	** Check to see if any sibling index (another index on the same table)
//	** of pIndex has the same root page number, and if it does, return true.
//	** This would indicate a corrupt schema.
//	*/
func _sqlite3IndexHasDuplicateRootPage(tls *libc.TLS, pIndex uintptr) (r int32) {
	var p uintptr
	_ = p
	p = (*TTable)(unsafe.Pointer((*TIndex)(unsafe.Pointer(pIndex)).FpTable)).FpIndex
	for {
		if !(p != 0) {
			break
		}
		if (*TIndex)(unsafe.Pointer(p)).Ftnum == (*TIndex)(unsafe.Pointer(pIndex)).Ftnum && p != pIndex {
			return int32(1)
		}
		goto _1
	_1:
		;
		p = (*TIndex)(unsafe.Pointer(p)).FpNext
	}
	return 0
}

// C documentation
//
//	/*
//	** Do a comparison between a 64-bit signed integer and a 64-bit floating-point
//	** number.  Return negative, zero, or positive if the first (i64) is less than,
//	** equal to, or greater than the second (double).
//	*/
func _sqlite3IntFloatCompare(tls *libc.TLS, i Ti64, r float64) (r1 int32) {
	var y Ti64
	var v1 int32
	_, _ = y, v1
	if _sqlite3IsNaN(tls, r) != 0 {
		/* SQLite considers NaN to be a NULL. And all integer values are greater
		 ** than NULL */
		return int32(1)
	} else {
		if r < -libc.Float64FromFloat64(9.223372036854776e+18) {
			return +libc.Int32FromInt32(1)
		}
		if r >= float64(9.223372036854776e+18) {
			return -int32(1)
		}
		y = int64(r)
		if i < y {
			return -int32(1)
		}
		if i > y {
			return +libc.Int32FromInt32(1)
		}
		if float64(i) < r {
			v1 = -int32(1)
		} else {
			v1 = libc.BoolInt32(float64(i) > r)
		}
		return v1
	}
	return r1
}

// C documentation
//
//	/*
//	** Invoke the given busy handler.
//	**
//	** This routine is called when an operation failed to acquire a
//	** lock on VFS file pFile.
//	**
//	** If this routine returns non-zero, the lock is retried.  If it
//	** returns 0, the operation aborts with an SQLITE_BUSY error.
//	*/
func _sqlite3InvokeBusyHandler(tls *libc.TLS, p uintptr) (r int32) {
	var rc int32
	_ = rc
	if (*TBusyHandler)(unsafe.Pointer(p)).FxBusyHandler == uintptr(0) || (*TBusyHandler)(unsafe.Pointer(p)).FnBusy < 0 {
		return 0
	}
	rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TBusyHandler)(unsafe.Pointer(p)).FxBusyHandler})))(tls, (*TBusyHandler)(unsafe.Pointer(p)).FpBusyArg, (*TBusyHandler)(unsafe.Pointer(p)).FnBusy)
	if rc == 0 {
		(*TBusyHandler)(unsafe.Pointer(p)).FnBusy = -int32(1)
	} else {
		(*TBusyHandler)(unsafe.Pointer(p)).FnBusy = (*TBusyHandler)(unsafe.Pointer(p)).FnBusy + 1
	}
	return rc
}

// C documentation
//
//	/*
//	** Return true if CollSeq is the default built-in BINARY.
//	*/
func _sqlite3IsBinary(tls *libc.TLS, p uintptr) (r int32) {
	return libc.BoolInt32(p == uintptr(0) || (*TCollSeq)(unsafe.Pointer(p)).FxCmp == __ccgo_fp(_binCollFunc))
}

// C documentation
//
//	/*
//	** Return true if the VFS is the memvfs.
//	*/
func _sqlite3IsMemdb(tls *libc.TLS, pVfs uintptr) (r int32) {
	return libc.BoolInt32(pVfs == uintptr(unsafe.Pointer(&_memdb_vfs)))
}

// C documentation
//
//	/*
//	** The file-handle passed as the only argument is open on a journal file.
//	** Return true if this "journal file" is currently stored in heap memory,
//	** or false otherwise.
//	*/
func _sqlite3JournalIsInMemory(tls *libc.TLS, p uintptr) (r int32) {
	return libc.BoolInt32((*Tsqlite3_file)(unsafe.Pointer(p)).FpMethods == uintptr(unsafe.Pointer(&_MemJournalMethods)))
}

// C documentation
//
//	/*
//	** Make a new pointer to a KeyInfo object
//	*/
func _sqlite3KeyInfoRef(tls *libc.TLS, p uintptr) (r uintptr) {
	if p != 0 {
		(*TKeyInfo)(unsafe.Pointer(p)).FnRef = (*TKeyInfo)(unsafe.Pointer(p)).FnRef + 1
	}
	return p
}

// C documentation
//
//	/*
//	** Deallocate a KeyInfo object
//	*/
func _sqlite3KeyInfoUnref(tls *libc.TLS, p uintptr) {
	if p != 0 {
		(*TKeyInfo)(unsafe.Pointer(p)).FnRef = (*TKeyInfo)(unsafe.Pointer(p)).FnRef - 1
		if (*TKeyInfo)(unsafe.Pointer(p)).FnRef == uint32(0) {
			_sqlite3DbNNFreeNN(tls, (*TKeyInfo)(unsafe.Pointer(p)).Fdb, p)
		}
	}
}

func _sqlite3KeywordCode(tls *libc.TLS, z uintptr, n int32) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var _ /* id at bp+0 */ int32
	**(**int32)(__ccgo_up(bp)) = int32(TK_ID)
	if n >= int32(2) {
		_keywordCode(tls, z, int64(n), bp)
	}
	return **(**int32)(__ccgo_up(bp))
}

func _sqlite3LockAndPrepare(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags Tu32, pOld uintptr, ppStmt uintptr, pzTail uintptr) (r int32) {
	var cnt, rc int32
	var v1, v2 bool
	_, _, _, _ = cnt, rc, v1, v2
	cnt = 0
	**(**uintptr)(__ccgo_up(ppStmt)) = uintptr(0)
	if !(_sqlite3SafetyCheckOk(tls, db) != 0) || zSql == uintptr(0) {
		return _sqlite3MisuseError(tls, int32(148751))
	}
	Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	_sqlite3BtreeEnterAll(tls, db)
	for {
		/* Make multiple attempts to compile the SQL, until it either succeeds
		 ** or encounters a permanent error.  A schema problem after one schema
		 ** reset is considered a permanent error. */
		rc = _sqlite3Prepare(tls, db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail)
		if rc == SQLITE_OK || (*Tsqlite3)(unsafe.Pointer(db)).FmallocFailed != 0 {
			break
		}
		cnt = cnt + 1
		goto _3
	_3:
		;
		if v2 = rc == libc.Int32FromInt32(SQLITE_ERROR)|libc.Int32FromInt32(2)<<libc.Int32FromInt32(8) && cnt <= int32(SQLITE_MAX_PREPARE_RETRY); !v2 {
			if v1 = rc == int32(SQLITE_SCHEMA); v1 {
				_sqlite3ResetOneSchema(tls, db, -int32(1))
			}
		}
		if !(v2 || v1 && cnt == int32(1)) {
			break
		}
	}
	_sqlite3BtreeLeaveAll(tls, db)
	rc = _sqlite3ApiExit(tls, db, rc)
	(*Tsqlite3)(unsafe.Pointer(db)).FbusyHandler.FnBusy = 0
	Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
	return rc
}

// C documentation
//
//	/*
//	** Convert an integer into a LogEst.  In other words, compute an
//	** approximation for 10*log2(x).
//	*/
func _sqlite3LogEst(tls *libc.TLS, x Tu64) (r TLogEst) {
	var y TLogEst
	_ = y
	y = int16(40)
	if x < uint64(8) {
		if x < uint64(2) {
			return 0
		}
		for x < uint64(8) {
			y = int16(int32(y) - libc.Int32FromInt32(10))
			x = x << uint64(1)
		}
	} else {
		for x > uint64(255) {
			y = int16(int32(y) + libc.Int32FromInt32(40))
			x = x >> uint64(4)
		} /*OPTIMIZATION-IF-TRUE*/
		for x > uint64(15) {
			y = int16(int32(y) + libc.Int32FromInt32(10))
			x = x >> uint64(1)
		}
	}
	return int16(int32(_a[x&uint64(7)]) + int32(y) - int32(10))
}

// C documentation
//
//	/*
//	** Print into memory obtained from sqliteMalloc().  Use the internal
//	** %-conversion extensions.
//	*/
func _sqlite3MPrintf(tls *libc.TLS, db uintptr, zFormat uintptr, va uintptr) (r uintptr) {
	var ap Tva_list
	var z uintptr
	_, _ = ap, z
	ap = va
	z = _sqlite3VMPrintf(tls, db, zFormat, ap)
	_ = ap
	return z
}

// C documentation
//
//	/*
//	** Trigger the alarm
//	*/
func _sqlite3MallocAlarm(tls *libc.TLS, nByte int32) {
	if _mem0.FalarmThreshold <= 0 {
		return
	}
	Xsqlite3_mutex_leave(tls, _mem0.Fmutex)
	Xsqlite3_release_memory(tls, nByte)
	Xsqlite3_mutex_enter(tls, _mem0.Fmutex)
}

// C documentation
//
//	/*
//	** Return the memory allocator mutex. sqlite3_status() needs it.
//	*/
func _sqlite3MallocMutex(tls *libc.TLS) (r uintptr) {
	return _mem0.Fmutex
}

// C documentation
//
//	/*
//	** Return the size of a memory allocation previously obtained from
//	** sqlite3Malloc() or sqlite3_malloc().
//	*/
func _sqlite3MallocSize(tls *libc.TLS, p uintptr) (r int32) {
	return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fm.FxSize})))(tls, p)
}

// C documentation
//
//	/*
//	** Like free() but works for allocations obtained from sqlite3MemMalloc()
//	** or sqlite3MemRealloc().
//	**
//	** For this low-level routine, we already know that pPrior!=0 since
//	** cases where pPrior==0 will have been intercepted and dealt with
//	** by higher-level routines.
//	*/
func _sqlite3MemFree(tls *libc.TLS, pPrior uintptr) {
	var p uintptr
	_ = p
	p = pPrior
	p -= 8
	libc.Xfree(tls, p)
}

// C documentation
//
//	/*
//	** Initialize this module.
//	*/
func _sqlite3MemInit(tls *libc.TLS, NotUsed uintptr) (r int32) {
	_ = NotUsed
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Open an in-memory journal file.
//	*/
func _sqlite3MemJournalOpen(tls *libc.TLS, pJfd uintptr) {
	_sqlite3JournalOpen(tls, uintptr(0), uintptr(0), pJfd, 0, -int32(1))
}

// C documentation
//
//	/*
//	** This routine acts as a bridge from sqlite3VdbeRealValue() to
//	** sqlite3VdbeRealValueRC, allowing sqlite3VdbeRealValue() to avoid
//	** stuffing values onto the stack.
//	*/
func _sqlite3MemRealValueNoRC(tls *libc.TLS, pMem uintptr) (r float64) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var _ /* r at bp+0 */ float64
	_sqlite3MemRealValueRC(tls, pMem, bp)
	return **(**float64)(__ccgo_up(bp))
}

// C documentation
//
//	/*
//	** Round up a request size to the next valid allocation size.
//	*/
func _sqlite3MemRoundup(tls *libc.TLS, n int32) (r int32) {
	return (n + int32(7)) & ^libc.Int32FromInt32(7)
}

// C documentation
//
//	/*
//	** This routine is the only routine in this file with external linkage.
//	**
//	** Populate the low-level memory allocation function pointers in
//	** sqlite3GlobalConfig.m with pointers to the routines in this file.
//	*/
func _sqlite3MemSetDefault(tls *libc.TLS) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	Xsqlite3_config(tls, int32(SQLITE_CONFIG_MALLOC), libc.VaList(bp+8, uintptr(unsafe.Pointer(&_defaultMethods))))
}

// C documentation
//
//	/*
//	** Deinitialize this module.
//	*/
func _sqlite3MemShutdown(tls *libc.TLS, NotUsed uintptr) {
	_ = NotUsed
	return
}

// C documentation
//
//	/*
//	** Report the allocated size of a prior return from xMalloc()
//	** or xRealloc().
//	*/
func _sqlite3MemSize(tls *libc.TLS, pPrior uintptr) (r int32) {
	var p uintptr
	_ = p
	p = pPrior
	p -= 8
	return int32(**(**Tsqlite3_int64)(__ccgo_up(p)))
}

func _sqlite3MulInt64(tls *libc.TLS, pA uintptr, iB Ti64) (r int32) {
	var iA Ti64
	_ = iA
	iA = **(**Ti64)(__ccgo_up(pA))
	if iB > 0 {
		if iA > (libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<<libc.Int32FromInt32(32))/iB {
			return int32(1)
		}
		if iA < (int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<<libc.Int32FromInt32(32)))/iB {
			return int32(1)
		}
	} else {
		if iB < 0 {
			if iA > 0 {
				if iB < (int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<<libc.Int32FromInt32(32)))/iA {
					return int32(1)
				}
			} else {
				if iA < 0 {
					if iB == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<<libc.Int32FromInt32(32)) {
						return int32(1)
					}
					if iA == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<<libc.Int32FromInt32(32)) {
						return int32(1)
					}
					if -iA > (libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<<libc.Int32FromInt32(32))/-iB {
						return int32(1)
					}
				}
			}
		}
	}
	**(**Ti64)(__ccgo_up(pA)) = iA * iB
	return 0
}

// C documentation
//
//	/*
//	** Indicate that the statement currently under construction might write
//	** more than one entry (example: deleting one row then inserting another,
//	** inserting multiple rows in a table, or inserting a row and index entries.)
//	** If an abort occurs after some of these writes have completed, then it will
//	** be necessary to undo the completed writes.
//	*/
func _sqlite3MultiWrite(tls *libc.TLS, pParse uintptr) {
	var pToplevel, v1 uintptr
	_, _ = pToplevel, v1
	if (*TParse)(unsafe.Pointer(pParse)).FpToplevel != 0 {
		v1 = (*TParse)(unsafe.Pointer(pParse)).FpToplevel
	} else {
		v1 = pParse
	}
	pToplevel = v1
	(*TParse)(unsafe.Pointer(pToplevel)).FisMultiWrite = uint8(1)
}

// C documentation
//
//	/*
//	** A is an unsigned 96-bit integer formed by (a<<32)+aLo.
//	** B is an unsigned 64-bit integer.
//	**
//	** Compute the upper 96 bits of 160-bit result of A*B.
//	**
//	** Write ((A*B)>>64 & 0xffffffff) (the middle 32 bits of A*B)
//	** into *pLo.  Return the upper 64 bits of A*B.
//	**
//	** The lower 64 bits of A*B are discarded.
//	*/
func _sqlite3Multiply160(tls *libc.TLS, a Tu64, aLo Tu32, b Tu64, pLo uintptr) (r Tu64) {
	var r1, r2, r3, r4, x0, x0y0, x0y1, x1, x1y0, x1y1, x2, x2y0, x2y1, y0, y1 Tu64
	_, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = r1, r2, r3, r4, x0, x0y0, x0y1, x1, x1y0, x1y1, x2, x2y0, x2y1, y0, y1
	x2 = a >> int32(32)
	x1 = a & uint64(0xffffffff)
	x0 = uint64(aLo)
	y1 = b >> int32(32)
	y0 = b & uint64(0xffffffff)
	x2y1 = x2 * y1
	r4 = x2y1 >> int32(32)
	x2y0 = x2 * y0
	x1y1 = x1 * y1
	r3 = x2y1&uint64(0xffffffff) + x2y0>>libc.Int32FromInt32(32) + x1y1>>libc.Int32FromInt32(32)
	x1y0 = x1 * y0
	x0y1 = x0 * y1
	r2 = x2y0&uint64(0xffffffff) + x1y1&uint64(0xffffffff) + x1y0>>libc.Int32FromInt32(32) + x0y1>>libc.Int32FromInt32(32)
	x0y0 = x0 * y0
	r1 = x1y0&uint64(0xffffffff) + x0y1&uint64(0xffffffff) + x0y0>>libc.Int32FromInt32(32)
	r2 = r2 + r1>>int32(32)
	r3 = r3 + r2>>int32(32)
	**(**Tu32)(__ccgo_up(pLo)) = uint32(r2 & uint64(0xffffffff))
	return r4<<libc.Int32FromInt32(32) + r3
}

/*
** Return a u64 with the N-th bit set.
 */

/*
** Range of powers of 10 that we need to deal with when converting
** IEEE754 doubles to and from decimal.
 */

func _sqlite3MutexAlloc(tls *libc.TLS, id int32) (r uintptr) {
	if !(_sqlite3Config.FbCoreMutex != 0) {
		return uintptr(0)
	}
	return (*(*func(*libc.TLS, int32) uintptr)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fmutex.FxMutexAlloc})))(tls, id)
}

// C documentation
//
//	/*
//	** Shutdown the mutex system. This call frees resources allocated by
//	** sqlite3MutexInit().
//	*/
func _sqlite3MutexEnd(tls *libc.TLS) (r int32) {
	var rc int32
	_ = rc
	rc = SQLITE_OK
	if _sqlite3Config.Fmutex.FxMutexEnd != 0 {
		rc = (*(*func(*libc.TLS) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fmutex.FxMutexEnd})))(tls)
	}
	return rc
}

// C documentation
//
//	/*
//	** Given a token, return a string that consists of the text of that
//	** token.  Space to hold the returned string
//	** is obtained from sqliteMalloc() and must be freed by the calling
//	** function.
//	**
//	** Any quotation marks (ex:  "name", 'name', [name], or `name`) that
//	** surround the body of the token are removed.
//	**
//	** Tokens are often just pointers into the original SQL text and so
//	** are not \000 terminated and are not persistent.  The returned string
//	** is \000 terminated and is persistent.
//	*/
func _sqlite3NameFromToken(tls *libc.TLS, db uintptr, pName uintptr) (r uintptr) {
	var zName uintptr
	_ = zName
	if pName != 0 {
		zName = _sqlite3DbStrNDup(tls, db, (*TToken)(unsafe.Pointer(pName)).Fz, uint64((*TToken)(unsafe.Pointer(pName)).Fn))
		_sqlite3Dequote(tls, zName)
	} else {
		zName = uintptr(0)
	}
	return zName
}

// C documentation
//
//	/* A no-op destructor */
func _sqlite3NoopDestructor(tls *libc.TLS, p uintptr) {
	_ = p
}

func _sqlite3NoopMutex(tls *libc.TLS) (r uintptr) {
	return uintptr(unsafe.Pointer(&_sMutex))
}

// C documentation
//
//	/*
//	** This singleton is an sqlite3_str object that is returned if
//	** sqlite3_malloc() fails to provide space for a real one.  This
//	** sqlite3_str object accepts no new text and always returns
//	** an SQLITE_NOMEM error.
//	*/
var _sqlite3OomStr = Tsqlite3_str{
	FaccError: uint8(SQLITE_NOMEM),
}

// C documentation
//
//	/************** End of hash.c ************************************************/
//	/************** Begin file opcodes.c *****************************************/
//	/* Automatically generated.  Do not edit */
//	/* See the tool/mkopcodec.tcl script for details. */
func _sqlite3OpcodeName(tls *libc.TLS, i int32) (r uintptr) {
	return _azName[i]
}

// C documentation
//
//	/* #include "opcodes.h" */
//	/*
//	** Properties of opcodes.  The OPFLG_INITIALIZER macro is
//	** created by mkopcodeh.awk during compilation.  Data is obtained
//	** from the comments following the "case OP_xxxx:" statements in
//	** the vdbe.c file.
//	*/
var _sqlite3OpcodeProperty = [192]uint8{
	4:   uint8(0x10),
	6:   uint8(0x41),
	8:   uint8(0x81),
	9:   uint8(0x01),
	10:  uint8(0x01),
	11:  uint8(0x81),
	12:  uint8(0x83),
	13:  uint8(0x83),
	14:  uint8(0x01),
	15:  uint8(0x01),
	16:  uint8(0x03),
	17:  uint8(0x03),
	18:  uint8(0x01),
	19:  uint8(0x12),
	20:  uint8(0x01),
	21:  uint8(0xc9),
	22:  uint8(0xc9),
	23:  uint8(0xc9),
	24:  uint8(0xc9),
	25:  uint8(0x01),
	26:  uint8(0x49),
	27:  uint8(0x49),
	28:  uint8(0x49),
	29:  uint8(0x49),
	30:  uint8(0xc9),
	31:  uint8(0x49),
	32:  uint8(0xc1),
	33:  uint8(0x01),
	34:  uint8(0x41),
	35:  uint8(0x41),
	36:  uint8(0xc1),
	37:  uint8(0x01),
	38:  uint8(0x01),
	39:  uint8(0x41),
	40:  uint8(0x41),
	41:  uint8(0x41),
	42:  uint8(0x41),
	43:  uint8(0x26),
	44:  uint8(0x26),
	45:  uint8(0x41),
	46:  uint8(0x41),
	47:  uint8(0x09),
	48:  uint8(0x23),
	49:  uint8(0x0b),
	50:  uint8(0x81),
	51:  uint8(0x03),
	52:  uint8(0x03),
	53:  uint8(0x0b),
	54:  uint8(0x0b),
	55:  uint8(0x0b),
	56:  uint8(0x0b),
	57:  uint8(0x0b),
	58:  uint8(0x0b),
	59:  uint8(0x01),
	60:  uint8(0x01),
	61:  uint8(0x03),
	62:  uint8(0x03),
	63:  uint8(0x03),
	64:  uint8(0x01),
	65:  uint8(0x41),
	66:  uint8(0x01),
	69:  uint8(0x02),
	70:  uint8(0x02),
	71:  uint8(0x08),
	73:  uint8(0x10),
	74:  uint8(0x10),
	75:  uint8(0x10),
	77:  uint8(0x10),
	79:  uint8(0x10),
	80:  uint8(0x10),
	83:  uint8(0x10),
	84:  uint8(0x10),
	88:  uint8(0x02),
	89:  uint8(0x02),
	90:  uint8(0x02),
	93:  uint8(0x12),
	94:  uint8(0x1e),
	95:  uint8(0x20),
	96:  uint8(0x40),
	100: uint8(0x10),
	101: uint8(0x10),
	103: uint8(0x26),
	104: uint8(0x26),
	105: uint8(0x26),
	106: uint8(0x26),
	107: uint8(0x26),
	108: uint8(0x26),
	109: uint8(0x26),
	110: uint8(0x26),
	111: uint8(0x26),
	112: uint8(0x26),
	113: uint8(0x40),
	114: uint8(0x40),
	115: uint8(0x12),
	117: uint8(0x40),
	118: uint8(0x10),
	119: uint8(0x40),
	120: uint8(0x40),
	124: uint8(0x40),
	126: uint8(0x40),
	127: uint8(0x40),
	128: uint8(0x10),
	129: uint8(0x10),
	135: uint8(0x40),
	137: uint8(0x50),
	139: uint8(0x40),
	140: uint8(0x04),
	141: uint8(0x04),
	143: uint8(0x40),
	144: uint8(0x50),
	145: uint8(0x40),
	146: uint8(0x10),
	149: uint8(0x10),
	154: uint8(0x10),
	158: uint8(0x06),
	159: uint8(0x10),
	161: uint8(0x04),
	162: uint8(0x1a),
	175: uint8(0x40),
	176: uint8(0x10),
	177: uint8(0x50),
	178: uint8(0x40),
	180: uint8(0x10),
	181: uint8(0x10),
	182: uint8(0x02),
	183: uint8(0x12),
	184: uint8(0x12),
}

func _sqlite3OsAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) (r int32) {
	return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxAccess})))(tls, pVfs, zPath, flags, pResOut)
}

func _sqlite3OsCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) (r int32) {
	return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxCheckReservedLock})))(tls, id, pResOut)
}

// C documentation
//
//	/*
//	** The following routines are convenience wrappers around methods
//	** of the sqlite3_file object.  This is mostly just syntactic sugar. All
//	** of this would be completely automatic if SQLite were coded using
//	** C++ instead of plain old C.
//	*/
func _sqlite3OsClose(tls *libc.TLS, pId uintptr) {
	if (*Tsqlite3_file)(unsafe.Pointer(pId)).FpMethods != 0 {
		(*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pId)).FpMethods)).FxClose})))(tls, pId)
		(*Tsqlite3_file)(unsafe.Pointer(pId)).FpMethods = uintptr(0)
	}
}

func _sqlite3OsCloseFree(tls *libc.TLS, pFile uintptr) {
	_sqlite3OsClose(tls, pFile)
	Xsqlite3_free(tls, pFile)
}

func _sqlite3OsDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) (r int32) {
	var v1 int32
	_ = v1
	if (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxDelete != uintptr(0) {
		v1 = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxDelete})))(tls, pVfs, zPath, dirSync)
	} else {
		v1 = SQLITE_OK
	}
	return v1
}

func _sqlite3OsDeviceCharacteristics(tls *libc.TLS, id uintptr) (r int32) {
	if (*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods == uintptr(0) {
		return 0
	}
	return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxDeviceCharacteristics})))(tls, id)
}

func _sqlite3OsDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) {
	(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxDlClose})))(tls, pVfs, pHandle)
}

func _sqlite3OsDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) {
	(*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxDlError})))(tls, pVfs, nByte, zBufOut)
}

func _sqlite3OsDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) (r uintptr) {
	/* tag-20210611-1 */
	return (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxDlOpen})))(tls, pVfs, zPath)
}

func _sqlite3OsDlSym(tls *libc.TLS, pVfs uintptr, pHdle uintptr, zSym uintptr) (r uintptr) {
	return (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxDlSym})))(tls, pVfs, pHdle, zSym)
}

// C documentation
//
//	/*
//	** Use sqlite3OsFileControl() when we are doing something that might fail
//	** and we need to know about the failures.  Use sqlite3OsFileControlHint()
//	** when simply tossing information over the wall to the VFS and we do not
//	** really care if the VFS receives and understands the information since it
//	** is only a hint and can be safely ignored.  The sqlite3OsFileControlHint()
//	** routine has no return value since the return value would be meaningless.
//	*/
func _sqlite3OsFileControl(tls *libc.TLS, id uintptr, op int32, pArg uintptr) (r int32) {
	if (*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods == uintptr(0) {
		return int32(SQLITE_NOTFOUND)
	}
	return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxFileControl})))(tls, id, op, pArg)
}

func _sqlite3OsFileControlHint(tls *libc.TLS, id uintptr, op int32, pArg uintptr) {
	if (*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods != 0 {
		(*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxFileControl})))(tls, id, op, pArg)
	}
}

func _sqlite3OsFileSize(tls *libc.TLS, id uintptr, pSize uintptr) (r int32) {
	return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxFileSize})))(tls, id, pSize)
}

func _sqlite3OsGetLastError(tls *libc.TLS, pVfs uintptr) (r int32) {
	var v1 int32
	_ = v1
	if (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxGetLastError != 0 {
		v1 = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxGetLastError})))(tls, pVfs, 0, uintptr(0))
	} else {
		v1 = 0
	}
	return v1
}

// C documentation
//
//	/*
//	** This function is a wrapper around the OS specific implementation of
//	** sqlite3_os_init(). The purpose of the wrapper is to provide the
//	** ability to simulate a malloc failure, so that the handling of an
//	** error in sqlite3_os_init() by the upper layers can be tested.
//	*/
func _sqlite3OsInit(tls *libc.TLS) (r int32) {
	var p uintptr
	_ = p
	p = Xsqlite3_malloc(tls, int32(10))
	if p == uintptr(0) {
		return int32(SQLITE_NOMEM)
	}
	Xsqlite3_free(tls, p)
	return Xsqlite3_os_init(tls)
}

func _sqlite3OsLock(tls *libc.TLS, id uintptr, lockType int32) (r int32) {
	return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxLock})))(tls, id, lockType)
}

// C documentation
//
//	/*
//	** The next group of routines are convenience wrappers around the
//	** VFS methods.
//	*/
func _sqlite3OsOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr, pFile uintptr, flags int32, pFlagsOut uintptr) (r int32) {
	var rc int32
	_ = rc
	/* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed
	 ** down into the VFS layer.  Some SQLITE_OPEN_ flags (for example,
	 ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before
	 ** reaching the VFS. */
	rc = (*(*func(*libc.TLS, uintptr, Tsqlite3_filename, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxOpen})))(tls, pVfs, zPath, pFile, flags&int32(0x1087f7f), pFlagsOut)
	return rc
}

func _sqlite3OsRead(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset Ti64) (r int32) {
	return (*(*func(*libc.TLS, uintptr, uintptr, int32, Tsqlite3_int64) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxRead})))(tls, id, pBuf, amt, offset)
}

func _sqlite3OsSectorSize(tls *libc.TLS, id uintptr) (r int32) {
	var xSectorSize uintptr
	var v1 int32
	_, _ = xSectorSize, v1
	xSectorSize = (*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxSectorSize
	if xSectorSize != 0 {
		v1 = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xSectorSize})))(tls, id)
	} else {
		v1 = int32(SQLITE_DEFAULT_SECTOR_SIZE)
	}
	return v1
}

func _sqlite3OsShmBarrier(tls *libc.TLS, id uintptr) {
	(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxShmBarrier})))(tls, id)
}

func _sqlite3OsShmLock(tls *libc.TLS, id uintptr, offset int32, n int32, flags int32) (r int32) {
	return (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxShmLock})))(tls, id, offset, n, flags)
}

func _sqlite3OsShmMap(tls *libc.TLS, id uintptr, iPage int32, pgsz int32, bExtend int32, pp uintptr) (r int32) {
	return (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxShmMap})))(tls, id, iPage, pgsz, bExtend, pp)
}

func _sqlite3OsShmUnmap(tls *libc.TLS, id uintptr, deleteFlag int32) (r int32) {
	return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxShmUnmap})))(tls, id, deleteFlag)
}

func _sqlite3OsSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) (r int32) {
	return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FxSleep})))(tls, pVfs, nMicro)
}

func _sqlite3OsSync(tls *libc.TLS, id uintptr, flags int32) (r int32) {
	var v1 int32
	_ = v1
	if flags != 0 {
		v1 = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxSync})))(tls, id, flags)
	} else {
		v1 = SQLITE_OK
	}
	return v1
}

func _sqlite3OsTruncate(tls *libc.TLS, id uintptr, size Ti64) (r int32) {
	return (*(*func(*libc.TLS, uintptr, Tsqlite3_int64) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxTruncate})))(tls, id, size)
}

func _sqlite3OsUnlock(tls *libc.TLS, id uintptr, lockType int32) (r int32) {
	return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxUnlock})))(tls, id, lockType)
}

func _sqlite3OsWrite(tls *libc.TLS, id uintptr, pBuf uintptr, amt int32, offset Ti64) (r int32) {
	return (*(*func(*libc.TLS, uintptr, uintptr, int32, Tsqlite3_int64) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(id)).FpMethods)).FxWrite})))(tls, id, pBuf, amt, offset)
}

// C documentation
//
//	/*
//	** Return true if there are one or more dirty pages in the cache. Else false.
//	*/
func _sqlite3PCacheIsDirty(tls *libc.TLS, pCache uintptr) (r int32) {
	return libc.BoolInt32((*TPCache)(unsafe.Pointer(pCache)).FpDirty != uintptr(0))
}

/************** End of pcache.c **********************************************/
/************** Begin file pcache1.c *****************************************/
/*
** 2008 November 05
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file implements the default page cache implementation (the
** sqlite3_pcache interface). It also contains part of the implementation
** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features.
** If the default page cache implementation is overridden, then neither of
** these two features are available.
**
** A Page cache line looks like this:
**
**  -------------------------------------------------------------
**  |  database page content   |  PgHdr1  |  MemPage  |  PgHdr  |
**  -------------------------------------------------------------
**
** The database page content is up front (so that buffer overreads tend to
** flow harmlessly into the PgHdr1, MemPage, and PgHdr extensions).   MemPage
** is the extension added by the btree.c module containing information such
** as the database page number and how that database page is used.  PgHdr
** is added by the pcache.c layer and contains information used to keep track
** of which pages are "dirty".  PgHdr1 is an extension added by this
** module (pcache1.c).  The PgHdr1 header is a subclass of sqlite3_pcache_page.
** PgHdr1 contains information needed to look up a page by its page number.
** The superclass sqlite3_pcache_page.pBuf points to the start of the
** database page content and sqlite3_pcache_page.pExtra points to PgHdr.
**
** The size of the extension (MemPage+PgHdr+PgHdr1) can be determined at
** runtime using sqlite3_config(SQLITE_CONFIG_PCACHE_HDRSZ, &size).  The
** sizes of the extensions sum to 272 bytes on x64 for 3.8.10, but this
** size can vary according to architecture, compile-time options, and
** SQLite library version number.
**
** Historical note:  It used to be that if the SQLITE_PCACHE_SEPARATE_HEADER
** was defined, then the page content would be held in a separate memory
** allocation from the PgHdr1.  This was intended to avoid clownshoe memory
** allocations.  However, the btree layer needs a small (16-byte) overrun
** area after the page content buffer.  The header serves as that overrun
** area.  Therefore SQLITE_PCACHE_SEPARATE_HEADER was discontinued to avoid
** any possibility of a memory error.
**
** This module tracks pointers to PgHdr1 objects.  Only pcache.c communicates
** with this module.  Information is passed back and forth as PgHdr1 pointers.
**
** The pcache.c and pager.c modules deal pointers to PgHdr objects.
** The btree.c module deals with pointers to MemPage objects.
**
** SOURCE OF PAGE CACHE MEMORY:
**
** Memory for a page might come from any of three sources:
**
**    (1)  The general-purpose memory allocator - sqlite3Malloc()
**    (2)  Global page-cache memory provided using sqlite3_config() with
**         SQLITE_CONFIG_PAGECACHE.
**    (3)  PCache-local bulk allocation.
**
** The third case is a chunk of heap memory (defaulting to 100 pages worth)
** that is allocated when the page cache is created.  The size of the local
** bulk allocation can be adjusted using
**
**     sqlite3_config(SQLITE_CONFIG_PAGECACHE, (void*)0, 0, N).
**
** If N is positive, then N pages worth of memory are allocated using a single
** sqlite3Malloc() call and that memory is used for the first N pages allocated.
** Or if N is negative, then -1024*N bytes of memory are allocated and used
** for as many pages as can be accommodated.
**
** Only one of (2) or (3) can be used.  Once the memory available to (2) or
** (3) is exhausted, subsequent allocations fail over to the general-purpose
** memory allocator (1).
**
** Earlier versions of SQLite used only methods (1) and (2).  But experiments
** show that method (3) with N==100 provides about a 5% performance boost for
** common workloads.
 */
/* #include "sqliteInt.h" */

// C documentation
//
//	/*
//	** Return the number of dirty pages currently in the cache, as a percentage
//	** of the configured cache size.
//	*/
func _sqlite3PCachePercentDirty(tls *libc.TLS, pCache uintptr) (r int32) {
	var nCache, nDirty, v2 int32
	var pDirty uintptr
	_, _, _, _ = nCache, nDirty, pDirty, v2
	nDirty = 0
	nCache = _numberOfCachePages(tls, pCache)
	pDirty = (*TPCache)(unsafe.Pointer(pCache)).FpDirty
	for {
		if !(pDirty != 0) {
			break
		}
		nDirty = nDirty + 1
		goto _1
	_1:
		;
		pDirty = (*TPgHdr)(unsafe.Pointer(pDirty)).FpDirtyNext
	}
	if nCache != 0 {
		v2 = int32(int64(nDirty) * libc.Int64FromInt32(100) / int64(nCache))
	} else {
		v2 = 0
	}
	return v2
}

// C documentation
//
//	/*
//	** This function is called during initialization (sqlite3_initialize()) to
//	** install the default pluggable cache module, assuming the user has not
//	** already provided an alternative.
//	*/
func _sqlite3PCacheSetDefault(tls *libc.TLS) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	Xsqlite3_config(tls, int32(SQLITE_CONFIG_PCACHE2), libc.VaList(bp+8, uintptr(unsafe.Pointer(&_defaultMethods1))))
}

// C documentation
//
//	/*
//	** Free an allocated buffer obtained from sqlite3PageMalloc().
//	*/
func _sqlite3PageFree(tls *libc.TLS, p uintptr) {
	_pcache1Free(tls, p)
}

// C documentation
//
//	/*
//	** Malloc function used by SQLite to obtain space from the buffer configured
//	** using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no such buffer
//	** exists, this function falls back to sqlite3Malloc().
//	*/
func _sqlite3PageMalloc(tls *libc.TLS, sz int32) (r uintptr) {
	/* These allocations are never very large */
	return _pcache1Alloc(tls, sz)
}

// C documentation
//
//	/*
//	** Return the pPager->iDataVersion value
//	*/
func _sqlite3PagerDataVersion(tls *libc.TLS, pPager uintptr) (r Tu32) {
	return (*TPager)(unsafe.Pointer(pPager)).FiDataVersion
}

// C documentation
//
//	/*
//	** Return true if page pgno can be read directly from the database file
//	** by the b-tree layer. This is the case if:
//	**
//	**   (1)  the database file is open
//	**   (2)  the VFS for the database is able to do unaligned sub-page reads
//	**   (3)  there are no dirty pages in the cache, and
//	**   (4)  the desired page is not currently in the wal file.
//	*/
func _sqlite3PagerDirectReadOk(tls *libc.TLS, pPager uintptr, pgno TPgno) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var _ /* iRead at bp+0 */ Tu32
	if (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods == uintptr(0) {
		return 0
	} /* Case (1) */
	if _sqlite3PCacheIsDirty(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache) != 0 {
		return 0
	} /* Failed (3) */
	if (*TPager)(unsafe.Pointer(pPager)).FpWal != 0 {
		**(**Tu32)(__ccgo_up(bp)) = uint32(0)
		_sqlite3WalFindFrame(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, pgno, bp)
		if **(**Tu32)(__ccgo_up(bp)) != 0 {
			return 0
		} /* Case (4) */
	}
	if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods)).FxDeviceCharacteristics})))(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd)&int32(SQLITE_IOCAP_SUBPAGE_READ) == 0 {
		return 0 /* Case (2) */
	}
	return int32(1)
}

// C documentation
//
//	/*
//	** This function may only be called while a write-transaction is active in
//	** rollback. If the connection is in WAL mode, this call is a no-op.
//	** Otherwise, if the connection does not already have an EXCLUSIVE lock on
//	** the database file, an attempt is made to obtain one.
//	**
//	** If the EXCLUSIVE lock is already held or the attempt to obtain it is
//	** successful, or the connection is in WAL mode, SQLITE_OK is returned.
//	** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is
//	** returned.
//	*/
func _sqlite3PagerExclusiveLock(tls *libc.TLS, pPager uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = (*TPager)(unsafe.Pointer(pPager)).FerrCode
	if rc == SQLITE_OK {
		if 0 == libc.BoolInt32((*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0)) {
			rc = _pager_wait_on_lock(tls, pPager, int32(EXCLUSIVE_LOCK))
		}
	}
	return rc
}

// C documentation
//
//	/*
//	** Return the file handle for the database file associated
//	** with the pager.  This might return NULL if the file has
//	** not yet been opened.
//	*/
func _sqlite3PagerFile(tls *libc.TLS, pPager uintptr) (r uintptr) {
	return (*TPager)(unsafe.Pointer(pPager)).Ffd
}

// C documentation
//
//	/*
//	** Return the full pathname of the database file.
//	**
//	** Except, if the pager is in-memory only, then return an empty string if
//	** nullIfMemDb is true.  This routine is called with nullIfMemDb==1 when
//	** used to report the filename to the user, for compatibility with legacy
//	** behavior.  But when the Btree needs to know the filename for matching to
//	** shared cache, it uses nullIfMemDb==0 so that in-memory databases can
//	** participate in shared-cache.
//	**
//	** The return value to this routine is always safe to use with
//	** sqlite3_uri_parameter() and sqlite3_filename_database() and friends.
//	*/
func _sqlite3PagerFilename(tls *libc.TLS, pPager uintptr, nullIfMemDb int32) (r uintptr) {
	if nullIfMemDb != 0 && ((*TPager)(unsafe.Pointer(pPager)).FmemDb != 0 || _sqlite3IsMemdb(tls, (*TPager)(unsafe.Pointer(pPager)).FpVfs) != 0) {
		return uintptr(unsafe.Pointer(&_zFake)) + 4
	} else {
		return (*TPager)(unsafe.Pointer(pPager)).FzFilename
	}
	return r
}

// C documentation
//
//	/*
//	** Flush all unreferenced dirty pages to disk.
//	*/
func _sqlite3PagerFlush(tls *libc.TLS, pPager uintptr) (r int32) {
	var pList, pNext uintptr
	var rc int32
	_, _, _ = pList, pNext, rc
	rc = (*TPager)(unsafe.Pointer(pPager)).FerrCode
	if !((*TPager)(unsafe.Pointer(pPager)).FmemDb != 0) {
		pList = _sqlite3PcacheDirtyList(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache)
		for rc == SQLITE_OK && pList != 0 {
			pNext = (*TPgHdr)(unsafe.Pointer(pList)).FpDirty
			if (*TPgHdr)(unsafe.Pointer(pList)).FnRef == 0 {
				rc = _pagerStress(tls, pPager, pList)
			}
			pList = pNext
		}
	}
	return rc
}

// C documentation
//
//	/* Dispatch all page fetch requests to the appropriate getter method.
//	*/
func _sqlite3PagerGet(tls *libc.TLS, pPager uintptr, pgno TPgno, ppPage uintptr, flags int32) (r int32) {
	/* Normal, high-speed version of sqlite3PagerGet() */
	return (*(*func(*libc.TLS, uintptr, TPgno, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*TPager)(unsafe.Pointer(pPager)).FxGet})))(tls, pPager, pgno, ppPage, flags)
}

// C documentation
//
//	/*
//	** Return a pointer to the data for the specified page.
//	*/
func _sqlite3PagerGetData(tls *libc.TLS, pPg uintptr) (r uintptr) {
	return (*TDbPage)(unsafe.Pointer(pPg)).FpData
}

// C documentation
//
//	/*
//	** Return a pointer to the Pager.nExtra bytes of "extra" space
//	** allocated along with the specified page.
//	*/
func _sqlite3PagerGetExtra(tls *libc.TLS, pPg uintptr) (r uintptr) {
	return (*TDbPage)(unsafe.Pointer(pPg)).FpExtra
}

// C documentation
//
//	/*
//	** Return true if this is an in-memory or temp-file backed pager.
//	*/
func _sqlite3PagerIsMemdb(tls *libc.TLS, pPager uintptr) (r int32) {
	return libc.BoolInt32((*TPager)(unsafe.Pointer(pPager)).FtempFile != 0 || (*TPager)(unsafe.Pointer(pPager)).FmemVfs != 0)
}

// C documentation
//
//	/*
//	** Return TRUE if the database file is opened read-only.  Return FALSE
//	** if the database is (in theory) writable.
//	*/
func _sqlite3PagerIsreadonly(tls *libc.TLS, pPager uintptr) (r Tu8) {
	return (*TPager)(unsafe.Pointer(pPager)).FreadOnly
}

// C documentation
//
//	/*
//	** Get/set the size-limit used for persistent journal files.
//	**
//	** Setting the size limit to -1 means no limit is enforced.
//	** An attempt to set a limit smaller than -1 is a no-op.
//	*/
func _sqlite3PagerJournalSizeLimit(tls *libc.TLS, pPager uintptr, iLimit Ti64) (r Ti64) {
	if iLimit >= int64(-int32(1)) {
		(*TPager)(unsafe.Pointer(pPager)).FjournalSizeLimit = iLimit
		_sqlite3WalLimit(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, iLimit)
	}
	return (*TPager)(unsafe.Pointer(pPager)).FjournalSizeLimit
}

// C documentation
//
//	/*
//	** Return the full pathname of the journal file.
//	*/
func _sqlite3PagerJournalname(tls *libc.TLS, pPager uintptr) (r uintptr) {
	return (*TPager)(unsafe.Pointer(pPager)).FzJournal
}

// C documentation
//
//	/*
//	** Return the file handle for the journal file (if it exists).
//	** This will be either the rollback journal or the WAL file.
//	*/
func _sqlite3PagerJrnlFile(tls *libc.TLS, pPager uintptr) (r uintptr) {
	var v1 uintptr
	_ = v1
	if (*TPager)(unsafe.Pointer(pPager)).FpWal != 0 {
		v1 = _sqlite3WalFile(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal)
	} else {
		v1 = (*TPager)(unsafe.Pointer(pPager)).Fjfd
	}
	return v1
}

// C documentation
//
//	/*
//	** Acquire a page if it is already in the in-memory cache.  Do
//	** not read the page from disk.  Return a pointer to the page,
//	** or 0 if the page is not in cache.
//	**
//	** See also sqlite3PagerGet().  The difference between this routine
//	** and sqlite3PagerGet() is that _get() will go to the disk and read
//	** in the page if the page is not already in cache.  This routine
//	** returns NULL if the page is not in cache or if a disk I/O error
//	** has ever happened.
//	*/
func _sqlite3PagerLookup(tls *libc.TLS, pPager uintptr, pgno TPgno) (r uintptr) {
	var pPage uintptr
	_ = pPage
	pPage = _sqlite3PcacheFetch(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache, pgno, 0)
	if pPage == uintptr(0) {
		return uintptr(0)
	}
	return _sqlite3PcacheFetchFinish(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache, pgno, pPage)
}

// C documentation
//
//	/*
//	** Attempt to set the maximum database page count if mxPage is positive.
//	** Make no changes if mxPage is zero or negative.  And never reduce the
//	** maximum page count below the current size of the database.
//	**
//	** Regardless of mxPage, return the current maximum page count.
//	*/
func _sqlite3PagerMaxPageCount(tls *libc.TLS, pPager uintptr, mxPage TPgno) (r TPgno) {
	if mxPage > uint32(0) {
		(*TPager)(unsafe.Pointer(pPager)).FmxPgno = mxPage
	}
	/* Called only by OP_MaxPgcnt */
	/* assert( pPager->mxPgno>=pPager->dbSize ); */
	/* OP_MaxPgcnt ensures that the parameter passed to this function is not
	 ** less than the total number of valid pages in the database. But this
	 ** may be less than Pager.dbSize, and so the assert() above is not valid */
	return (*TPager)(unsafe.Pointer(pPager)).FmxPgno
}

/*
** The following set of routines are used to disable the simulated
** I/O error mechanism.  These routines are used to avoid simulated
** errors in places where we do not care about errors.
**
** Unless -DSQLITE_TEST=1 is used, these routines are all no-ops
** and generate no code.
 */

func _sqlite3PagerOpenSavepoint(tls *libc.TLS, pPager uintptr, nSavepoint int32) (r int32) {
	if nSavepoint > (*TPager)(unsafe.Pointer(pPager)).FnSavepoint && (*TPager)(unsafe.Pointer(pPager)).FuseJournal != 0 {
		return _pagerOpenSavepoint(tls, pPager, nSavepoint)
	} else {
		return SQLITE_OK
	}
	return r
}

// C documentation
//
//	/*
//	** The caller must be holding a SHARED lock on the database file to call
//	** this function.
//	**
//	** If the pager passed as the first argument is open on a real database
//	** file (not a temp file or an in-memory database), and the WAL file
//	** is not already open, make an attempt to open it now. If successful,
//	** return SQLITE_OK. If an error occurs or the VFS used by the pager does
//	** not support the xShmXXX() methods, return an error code. *pbOpen is
//	** not modified in either case.
//	**
//	** If the pager is open on a temp-file (or in-memory database), or if
//	** the WAL file is already open, set *pbOpen to 1 and return SQLITE_OK
//	** without doing anything.
//	*/
func _sqlite3PagerOpenWal(tls *libc.TLS, pPager uintptr, pbOpen uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = SQLITE_OK /* Return code */
	if !((*TPager)(unsafe.Pointer(pPager)).FtempFile != 0) && !((*TPager)(unsafe.Pointer(pPager)).FpWal != 0) {
		if !(_sqlite3PagerWalSupported(tls, pPager) != 0) {
			return int32(SQLITE_CANTOPEN)
		}
		/* Close any rollback journal previously open */
		_sqlite3OsClose(tls, (*TPager)(unsafe.Pointer(pPager)).Fjfd)
		rc = _pagerOpenWal(tls, pPager)
		if rc == SQLITE_OK {
			(*TPager)(unsafe.Pointer(pPager)).FjournalMode = uint8(PAGER_JOURNALMODE_WAL)
			(*TPager)(unsafe.Pointer(pPager)).FeState = uint8(PAGER_OPEN)
		}
	} else {
		**(**int32)(__ccgo_up(pbOpen)) = int32(1)
	}
	return rc
}

// C documentation
//
//	/*
//	** Return the number of references to the specified page.
//	*/
func _sqlite3PagerPageRefcount(tls *libc.TLS, pPage uintptr) (r int32) {
	return int32(_sqlite3PcachePageRefcount(tls, pPage))
}

// C documentation
//
//	/*
//	** Increment the reference count for page pPg.
//	*/
func _sqlite3PagerRef(tls *libc.TLS, pPg uintptr) {
	_sqlite3PcacheRef(tls, pPg)
}

// C documentation
//
//	/*
//	** The page handle passed as the first argument refers to a dirty page
//	** with a page number other than iNew. This function changes the page's
//	** page number to iNew and sets the value of the PgHdr.flags field to
//	** the value passed as the third parameter.
//	*/
func _sqlite3PagerRekey(tls *libc.TLS, pPg uintptr, iNew TPgno, flags Tu16) {
	(*TDbPage)(unsafe.Pointer(pPg)).Fflags = flags
	_sqlite3PcacheMove(tls, pPg, iNew)
}

// C documentation
//
//	/*
//	** Change the maximum number of in-memory pages that are allowed
//	** before attempting to recycle clean and unused pages.
//	*/
func _sqlite3PagerSetCachesize(tls *libc.TLS, pPager uintptr, mxPage int32) {
	_sqlite3PcacheSetCachesize(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache, mxPage)
}

// C documentation
//
//	/*
//	** Change the maximum size of any memory mapping made of the database file.
//	*/
func _sqlite3PagerSetMmapLimit(tls *libc.TLS, pPager uintptr, szMmap Tsqlite3_int64) {
	(*TPager)(unsafe.Pointer(pPager)).FszMmap = szMmap
	_pagerFixMaplimit(tls, pPager)
}

// C documentation
//
//	/*
//	** Change the maximum number of in-memory pages that are allowed
//	** before attempting to spill pages to journal.
//	*/
func _sqlite3PagerSetSpillsize(tls *libc.TLS, pPager uintptr, mxPage int32) (r int32) {
	return _sqlite3PcacheSetSpillsize(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache, mxPage)
}

// C documentation
//
//	/*
//	** Free as much memory as possible from the pager.
//	*/
func _sqlite3PagerShrink(tls *libc.TLS, pPager uintptr) {
	_sqlite3PcacheShrink(tls, (*TPager)(unsafe.Pointer(pPager)).FpPCache)
}

// C documentation
//
//	/*
//	** The caller currently has a read transaction open on the database.
//	** If this is not a WAL database, SQLITE_ERROR is returned. Otherwise,
//	** this function takes a SHARED lock on the CHECKPOINTER slot and then
//	** checks if the snapshot passed as the second argument is still
//	** available. If so, SQLITE_OK is returned.
//	**
//	** If the snapshot is not available, SQLITE_ERROR is returned. Or, if
//	** the CHECKPOINTER lock cannot be obtained, SQLITE_BUSY. If any error
//	** occurs (any value other than SQLITE_OK is returned), the CHECKPOINTER
//	** lock is released before returning.
//	*/
func _sqlite3PagerSnapshotCheck(tls *libc.TLS, pPager uintptr, pSnapshot uintptr) (r int32) {
	var rc int32
	_ = rc
	if (*TPager)(unsafe.Pointer(pPager)).FpWal != 0 {
		rc = _sqlite3WalSnapshotCheck(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, pSnapshot)
	} else {
		rc = int32(SQLITE_ERROR)
	}
	return rc
}

// C documentation
//
//	/*
//	** If this is a WAL database, obtain a snapshot handle for the snapshot
//	** currently open. Otherwise, return an error.
//	*/
func _sqlite3PagerSnapshotGet(tls *libc.TLS, pPager uintptr, ppSnapshot uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = int32(SQLITE_ERROR)
	if (*TPager)(unsafe.Pointer(pPager)).FpWal != 0 {
		rc = _sqlite3WalSnapshotGet(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, ppSnapshot)
	}
	return rc
}

// C documentation
//
//	/*
//	** If this is a WAL database, store a pointer to pSnapshot. Next time a
//	** read transaction is opened, attempt to read from the snapshot it
//	** identifies. If this is not a WAL database, return an error.
//	*/
func _sqlite3PagerSnapshotOpen(tls *libc.TLS, pPager uintptr, pSnapshot uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = SQLITE_OK
	if (*TPager)(unsafe.Pointer(pPager)).FpWal != 0 {
		_sqlite3WalSnapshotOpen(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, pSnapshot)
	} else {
		rc = int32(SQLITE_ERROR)
	}
	return rc
}

// C documentation
//
//	/*
//	** If this is a WAL database, call sqlite3WalSnapshotRecover(). If this
//	** is not a WAL database, return an error.
//	*/
func _sqlite3PagerSnapshotRecover(tls *libc.TLS, pPager uintptr) (r int32) {
	var rc int32
	_ = rc
	if (*TPager)(unsafe.Pointer(pPager)).FpWal != 0 {
		rc = _sqlite3WalSnapshotRecover(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal)
	} else {
		rc = int32(SQLITE_ERROR)
	}
	return rc
}

// C documentation
//
//	/*
//	** Release a lock obtained by an earlier successful call to
//	** sqlite3PagerSnapshotCheck().
//	*/
func _sqlite3PagerSnapshotUnlock(tls *libc.TLS, pPager uintptr) {
	_sqlite3WalSnapshotUnlock(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal)
}

/************** End of pager.c ***********************************************/
/************** Begin file wal.c *********************************************/
/*
** 2010 February 1
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains the implementation of a write-ahead log (WAL) used in
** "journal_mode=WAL" mode.
**
** WRITE-AHEAD LOG (WAL) FILE FORMAT
**
** A WAL file consists of a header followed by zero or more "frames".
** Each frame records the revised content of a single page from the
** database file.  All changes to the database are recorded by writing
** frames into the WAL.  Transactions commit when a frame is written that
** contains a commit marker.  A single WAL can and usually does record
** multiple transactions.  Periodically, the content of the WAL is
** transferred back into the database file in an operation called a
** "checkpoint".
**
** A single WAL file can be used multiple times.  In other words, the
** WAL can fill up with frames and then be checkpointed and then new
** frames can overwrite the old ones.  A WAL always grows from beginning
** toward the end.  Checksums and counters attached to each frame are
** used to determine which frames within the WAL are valid and which
** are leftovers from prior checkpoints.
**
** The WAL header is 32 bytes in size and consists of the following eight
** big-endian 32-bit unsigned integer values:
**
**     0: Magic number.  0x377f0682 or 0x377f0683
**     4: File format version.  Currently 3007000
**     8: Database page size.  Example: 1024
**    12: Checkpoint sequence number
**    16: Salt-1, random integer incremented with each checkpoint
**    20: Salt-2, a different random integer changing with each ckpt
**    24: Checksum-1 (first part of checksum for first 24 bytes of header).
**    28: Checksum-2 (second part of checksum for first 24 bytes of header).
**
** Immediately following the wal-header are zero or more frames. Each
** frame consists of a 24-byte frame-header followed by <page-size> bytes
** of page data. The frame-header is six big-endian 32-bit unsigned
** integer values, as follows:
**
**     0: Page number.
**     4: For commit records, the size of the database image in pages
**        after the commit. For all other records, zero.
**     8: Salt-1 (copied from the header)
**    12: Salt-2 (copied from the header)
**    16: Checksum-1.
**    20: Checksum-2.
**
** A frame is considered valid if and only if the following conditions are
** true:
**
**    (1) The salt-1 and salt-2 values in the frame-header match
**        salt values in the wal-header
**
**    (2) The checksum values in the final 8 bytes of the frame-header
**        exactly match the checksum computed consecutively on the
**        WAL header and the first 8 bytes and the content of all frames
**        up to and including the current frame.
**
** The checksum is computed using 32-bit big-endian integers if the
** magic number in the first 4 bytes of the WAL is 0x377f0683 and it
** is computed using little-endian if the magic number is 0x377f0682.
** The checksum values are always stored in the frame header in a
** big-endian format regardless of which byte order is used to compute
** the checksum.  The checksum is computed by interpreting the input as
** an even number of unsigned 32-bit integers: x[0] through x[N].  The
** algorithm used for the checksum is as follows:
**
**   for i from 0 to n-1 step 2:
**     s0 += x[i] + s1;
**     s1 += x[i+1] + s0;
**   endfor
**
** Note that s0 and s1 are both weighted checksums using fibonacci weights
** in reverse order (the largest fibonacci weight occurs on the first element
** of the sequence being summed.)  The s1 value spans all 32-bit
** terms of the sequence whereas s0 omits the final term.
**
** On a checkpoint, the WAL is first VFS.xSync-ed, then valid content of the
** WAL is transferred into the database, then the database is VFS.xSync-ed.
** The VFS.xSync operations serve as write barriers - all writes launched
** before the xSync must complete before any write that launches after the
** xSync begins.
**
** After each checkpoint, the salt-1 value is incremented and the salt-2
** value is randomized.  This prevents old and new frames in the WAL from
** being considered valid at the same time and being checkpointing together
** following a crash.
**
** READER ALGORITHM
**
** To read a page from the database (call it page number P), a reader
** first checks the WAL to see if it contains page P.  If so, then the
** last valid instance of page P that is a followed by a commit frame
** or is a commit frame itself becomes the value read.  If the WAL
** contains no copies of page P that are valid and which are a commit
** frame or are followed by a commit frame, then page P is read from
** the database file.
**
** To start a read transaction, the reader records the index of the last
** valid frame in the WAL.  The reader uses this recorded "mxFrame" value
** for all subsequent read operations.  New transactions can be appended
** to the WAL, but as long as the reader uses its original mxFrame value
** and ignores the newly appended content, it will see a consistent snapshot
** of the database from a single point in time.  This technique allows
** multiple concurrent readers to view different versions of the database
** content simultaneously.
**
** The reader algorithm in the previous paragraphs works correctly, but
** because frames for page P can appear anywhere within the WAL, the
** reader has to scan the entire WAL looking for page P frames.  If the
** WAL is large (multiple megabytes is typical) that scan can be slow,
** and read performance suffers.  To overcome this problem, a separate
** data structure called the wal-index is maintained to expedite the
** search for frames of a particular page.
**
** WAL-INDEX FORMAT
**
** Conceptually, the wal-index is shared memory, though VFS implementations
** might choose to implement the wal-index using a mmapped file.  Because
** the wal-index is shared memory, SQLite does not support journal_mode=WAL
** on a network filesystem.  All users of the database must be able to
** share memory.
**
** In the default unix and windows implementation, the wal-index is a mmapped
** file whose name is the database name with a "-shm" suffix added.  For that
** reason, the wal-index is sometimes called the "shm" file.
**
** The wal-index is transient.  After a crash, the wal-index can (and should
** be) reconstructed from the original WAL file.  In fact, the VFS is required
** to either truncate or zero the header of the wal-index when the last
** connection to it closes.  Because the wal-index is transient, it can
** use an architecture-specific format; it does not have to be cross-platform.
** Hence, unlike the database and WAL file formats which store all values
** as big endian, the wal-index can store multi-byte values in the native
** byte order of the host computer.
**
** The purpose of the wal-index is to answer this question quickly:  Given
** a page number P and a maximum frame index M, return the index of the
** last frame in the wal before frame M for page P in the WAL, or return
** NULL if there are no frames for page P in the WAL prior to M.
**
** The wal-index consists of a header region, followed by an one or
** more index blocks.
**
** The wal-index header contains the total number of frames within the WAL
** in the mxFrame field.
**
** Each index block except for the first contains information on
** HASHTABLE_NPAGE frames. The first index block contains information on
** HASHTABLE_NPAGE_ONE frames. The values of HASHTABLE_NPAGE_ONE and
** HASHTABLE_NPAGE are selected so that together the wal-index header and
** first index block are the same size as all other index blocks in the
** wal-index.  The values are:
**
**   HASHTABLE_NPAGE      4096
**   HASHTABLE_NPAGE_ONE  4062
**
** Each index block contains two sections, a page-mapping that contains the
** database page number associated with each wal frame, and a hash-table
** that allows readers to query an index block for a specific page number.
** The page-mapping is an array of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE
** for the first index block) 32-bit page numbers. The first entry in the
** first index-block contains the database page number corresponding to the
** first frame in the WAL file. The first entry in the second index block
** in the WAL file corresponds to the (HASHTABLE_NPAGE_ONE+1)th frame in
** the log, and so on.
**
** The last index block in a wal-index usually contains less than the full
** complement of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE) page-numbers,
** depending on the contents of the WAL file. This does not change the
** allocated size of the page-mapping array - the page-mapping array merely
** contains unused entries.
**
** Even without using the hash table, the last frame for page P
** can be found by scanning the page-mapping sections of each index block
** starting with the last index block and moving toward the first, and
** within each index block, starting at the end and moving toward the
** beginning.  The first entry that equals P corresponds to the frame
** holding the content for that page.
**
** The hash table consists of HASHTABLE_NSLOT 16-bit unsigned integers.
** HASHTABLE_NSLOT = 2*HASHTABLE_NPAGE, and there is one entry in the
** hash table for each page number in the mapping section, so the hash
** table is never more than half full.  The expected number of collisions
** prior to finding a match is 1.  Each entry of the hash table is an
** 1-based index of an entry in the mapping section of the same
** index block.   Let K be the 1-based index of the largest entry in
** the mapping section.  (For index blocks other than the last, K will
** always be exactly HASHTABLE_NPAGE (4096) and for the last index block
** K will be (mxFrame%HASHTABLE_NPAGE).)  Unused slots of the hash table
** contain a value of 0.
**
** To look for page P in the hash table, first compute a hash iKey on
** P as follows:
**
**      iKey = (P * 383) % HASHTABLE_NSLOT
**
** Then start scanning entries of the hash table, starting with iKey
** (wrapping around to the beginning when the end of the hash table is
** reached) until an unused hash slot is found. Let the first unused slot
** be at index iUnused.  (iUnused might be less than iKey if there was
** wrap-around.) Because the hash table is never more than half full,
** the search is guaranteed to eventually hit an unused entry.  Let
** iMax be the value between iKey and iUnused, closest to iUnused,
** where aHash[iMax]==P.  If there is no iMax entry (if there exists
** no hash slot such that aHash[i]==p) then page P is not in the
** current index block.  Otherwise the iMax-th mapping entry of the
** current index block corresponds to the last entry that references
** page P.
**
** A hash search begins with the last index block and moves toward the
** first index block, looking for entries corresponding to page P.  On
** average, only two or three slots in each index block need to be
** examined in order to either find the last entry for page P, or to
** establish that no such entry exists in the block.  Each index block
** holds over 4000 entries.  So two or three index blocks are sufficient
** to cover a typical 10 megabyte WAL file, assuming 1K pages.  8 or 10
** comparisons (on average) suffice to either locate a frame in the
** WAL or to establish that the frame does not exist in the WAL.  This
** is much faster than scanning the entire 10MB WAL.
**
** Note that entries are added in order of increasing K.  Hence, one
** reader might be using some value K0 and a second reader that started
** at a later time (after additional transactions were added to the WAL
** and to the wal-index) might be using a different value K1, where K1>K0.
** Both readers can use the same hash table and mapping section to get
** the correct result.  There may be entries in the hash table with
** K>K0 but to the first reader, those entries will appear to be unused
** slots in the hash table and so the first reader will get an answer as
** if no values greater than K0 had ever been inserted into the hash table
** in the first place - which is what reader one wants.  Meanwhile, the
** second reader using K1 will see additional values that were inserted
** later, which is exactly what reader two wants.
**
** When a rollback occurs, the value of K is decreased. Hash table entries
** that correspond to frames greater than the new K value are removed
** from the hash table at this point.
 */

/* #include "wal.h" */

/*
** Trace output macros
 */

/*
** The maximum (and only) versions of the wal and wal-index formats
** that may be interpreted by this version of SQLite.
**
** If a client begins recovering a WAL file and finds that (a) the checksum
** values in the wal-header are correct and (b) the version field is not
** WAL_MAX_VERSION, recovery fails and SQLite returns SQLITE_CANTOPEN.
**
** Similarly, if a client successfully reads a wal-index header (i.e. the
** checksum test is successful) and finds that the version field is not
** WALINDEX_MAX_VERSION, then no read-transaction is opened and SQLite
** returns SQLITE_CANTOPEN.
 */

/*
** Index numbers for various locking bytes.   WAL_NREADER is the number
** of available reader locks and should be at least 3.  The default
** is SQLITE_SHM_NLOCK==8 and  WAL_NREADER==5.
**
** Technically, the various VFSes are free to implement these locks however
** they see fit.  However, compatibility is encouraged so that VFSes can
** interoperate.  The standard implementation used on both unix and windows
** is for the index number to indicate a byte offset into the
** WalCkptInfo.aLock[] array in the wal-index header.  In other words, all
** locks are on the shm file.  The WALINDEX_LOCK_OFFSET constant (which
** should be 120) is the location in the shm file for the first locking
** byte.
 */

// C documentation
//
//	/*
//	** Return a pointer to the "temporary page" buffer held internally
//	** by the pager.  This is a buffer that is big enough to hold the
//	** entire content of a database page.  This buffer is used internally
//	** during rollback and will be overwritten whenever a rollback
//	** occurs.  But other modules are free to use it too, as long as
//	** no rollbacks are happening.
//	*/
func _sqlite3PagerTempSpace(tls *libc.TLS, pPager uintptr) (r uintptr) {
	return (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace
}

// C documentation
//
//	/*
//	** Truncate the in-memory database file image to nPage pages. This
//	** function does not actually modify the database file on disk. It
//	** just sets the internal state of the pager object so that the
//	** truncation will be done when the current transaction is committed.
//	**
//	** This function is only called right before committing a transaction.
//	** Once this function has been called, the transaction must either be
//	** rolled back or committed. It is not safe to call this function and
//	** then continue writing to the database.
//	*/
func _sqlite3PagerTruncateImage(tls *libc.TLS, pPager uintptr, nPage TPgno) {
	(*TPager)(unsafe.Pointer(pPager)).FdbSize = nPage
	/* At one point the code here called assertTruncateConstraint() to
	 ** ensure that all pages being truncated away by this operation are,
	 ** if one or more savepoints are open, present in the savepoint
	 ** journal so that they can be restored if the savepoint is rolled
	 ** back. This is no longer necessary as this function is now only
	 ** called right before committing a transaction. So although the
	 ** Pager object may still have open savepoints (Pager.nSavepoint!=0),
	 ** they cannot be rolled back. So the assertTruncateConstraint() call
	 ** is no longer correct. */
}

func _sqlite3PagerUnref(tls *libc.TLS, pPg uintptr) {
	if pPg != 0 {
		_sqlite3PagerUnrefNotNull(tls, pPg)
	}
}

func _sqlite3PagerUnrefPageOne(tls *libc.TLS, pPg uintptr) {
	var pPager uintptr
	_ = pPager
	/* Page1 is never memory mapped */
	pPager = (*TDbPage)(unsafe.Pointer(pPg)).FpPager
	_sqlite3PcacheRelease(tls, pPg)
	_pagerUnlockIfUnused(tls, pPager)
}

// C documentation
//
//	/*
//	** Return the VFS structure for the pager.
//	*/
func _sqlite3PagerVfs(tls *libc.TLS, pPager uintptr) (r uintptr) {
	return (*TPager)(unsafe.Pointer(pPager)).FpVfs
}

func _sqlite3PagerWalCallback(tls *libc.TLS, pPager uintptr) (r int32) {
	return _sqlite3WalCallback(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal)
}

// C documentation
//
//	/*
//	** Return true if the underlying VFS for the given pager supports the
//	** primitives necessary for write-ahead logging.
//	*/
func _sqlite3PagerWalSupported(tls *libc.TLS, pPager uintptr) (r int32) {
	var pMethods uintptr
	_ = pMethods
	pMethods = (*Tsqlite3_file)(unsafe.Pointer((*TPager)(unsafe.Pointer(pPager)).Ffd)).FpMethods
	if (*TPager)(unsafe.Pointer(pPager)).FnoLock != 0 {
		return 0
	}
	return libc.BoolInt32((*TPager)(unsafe.Pointer(pPager)).FexclusiveMode != 0 || (*Tsqlite3_io_methods)(unsafe.Pointer(pMethods)).FiVersion >= int32(2) && (*Tsqlite3_io_methods)(unsafe.Pointer(pMethods)).FxShmMap != 0)
}

// C documentation
//
//	/*
//	** Return the global mutex used by this PCACHE implementation.  The
//	** sqlite3_status() routine needs access to this mutex.
//	*/
func _sqlite3Pcache1Mutex(tls *libc.TLS) (r uintptr) {
	return _pcache1_g.Fmutex
}

// C documentation
//
//	/*
//	** Make every page in the cache clean.
//	*/
func _sqlite3PcacheCleanAll(tls *libc.TLS, pCache uintptr) {
	var p, v1 uintptr
	_, _ = p, v1
	for {
		v1 = (*TPCache)(unsafe.Pointer(pCache)).FpDirty
		p = v1
		if !(v1 != uintptr(0)) {
			break
		}
		_sqlite3PcacheMakeClean(tls, p)
	}
}

// C documentation
//
//	/*
//	** Discard the contents of the cache.
//	*/
func _sqlite3PcacheClear(tls *libc.TLS, pCache uintptr) {
	_sqlite3PcacheTruncate(tls, pCache, uint32(0))
}

// C documentation
//
//	/*
//	** Close a cache.
//	*/
func _sqlite3PcacheClose(tls *libc.TLS, pCache uintptr) {
	(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxDestroy})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache)
}

// C documentation
//
//	/*
//	** Return a list of all dirty pages in the cache, sorted by page number.
//	*/
func _sqlite3PcacheDirtyList(tls *libc.TLS, pCache uintptr) (r uintptr) {
	var p uintptr
	_ = p
	p = (*TPCache)(unsafe.Pointer(pCache)).FpDirty
	for {
		if !(p != 0) {
			break
		}
		(*TPgHdr)(unsafe.Pointer(p)).FpDirty = (*TPgHdr)(unsafe.Pointer(p)).FpDirtyNext
		goto _1
	_1:
		;
		p = (*TPgHdr)(unsafe.Pointer(p)).FpDirtyNext
	}
	return _pcacheSortDirtyList(tls, (*TPCache)(unsafe.Pointer(pCache)).FpDirty)
}

// C documentation
//
//	/*
//	** This routine converts the sqlite3_pcache_page object returned by
//	** sqlite3PcacheFetch() into an initialized PgHdr object.  This routine
//	** must be called after sqlite3PcacheFetch() in order to get a usable
//	** result.
//	*/
func _sqlite3PcacheFetchFinish(tls *libc.TLS, pCache uintptr, pgno TPgno, pPage uintptr) (r uintptr) {
	var pPgHdr uintptr
	_ = pPgHdr
	pPgHdr = (*Tsqlite3_pcache_page)(unsafe.Pointer(pPage)).FpExtra
	if !((*TPgHdr)(unsafe.Pointer(pPgHdr)).FpPage != 0) {
		return _pcacheFetchFinishWithInit(tls, pCache, pgno, pPage)
	}
	(*TPCache)(unsafe.Pointer(pCache)).FnRefSum = (*TPCache)(unsafe.Pointer(pCache)).FnRefSum + 1
	(*TPgHdr)(unsafe.Pointer(pPgHdr)).FnRef = (*TPgHdr)(unsafe.Pointer(pPgHdr)).FnRef + 1
	return pPgHdr
}

// C documentation
//
//	/*************************************************** General Interfaces ******
//	**
//	** Initialize and shutdown the page cache subsystem. Neither of these
//	** functions are threadsafe.
//	*/
func _sqlite3PcacheInitialize(tls *libc.TLS) (r int32) {
	if _sqlite3Config.Fpcache2.FxInit == uintptr(0) {
		/* IMPLEMENTATION-OF: R-26801-64137 If the xInit() method is NULL, then the
		 ** built-in default page cache is used instead of the application defined
		 ** page cache. */
		_sqlite3PCacheSetDefault(tls)
	}
	return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxInit})))(tls, _sqlite3Config.Fpcache2.FpArg)
}

// C documentation
//
//	/*
//	** Return the number of references to the page supplied as an argument.
//	*/
func _sqlite3PcachePageRefcount(tls *libc.TLS, p uintptr) (r Ti64) {
	return (*TPgHdr)(unsafe.Pointer(p)).FnRef
}

// C documentation
//
//	/*
//	** Return the total number of pages in the cache.
//	*/
func _sqlite3PcachePagecount(tls *libc.TLS, pCache uintptr) (r int32) {
	return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxPagecount})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache)
}

// C documentation
//
//	/*
//	** Increase the reference count of a supplied page by 1.
//	*/
func _sqlite3PcacheRef(tls *libc.TLS, p uintptr) {
	(*TPgHdr)(unsafe.Pointer(p)).FnRef = (*TPgHdr)(unsafe.Pointer(p)).FnRef + 1
	(*TPCache)(unsafe.Pointer((*TPgHdr)(unsafe.Pointer(p)).FpCache)).FnRefSum = (*TPCache)(unsafe.Pointer((*TPgHdr)(unsafe.Pointer(p)).FpCache)).FnRefSum + 1
}

// C documentation
//
//	/*
//	** Return the total number of references to all pages held by the cache.
//	**
//	** This is not the total number of pages referenced, but the sum of the
//	** reference count for all pages.
//	*/
func _sqlite3PcacheRefCount(tls *libc.TLS, pCache uintptr) (r Ti64) {
	return (*TPCache)(unsafe.Pointer(pCache)).FnRefSum
}

// C documentation
//
//	/*
//	** Set the suggested cache-size value.
//	*/
func _sqlite3PcacheSetCachesize(tls *libc.TLS, pCache uintptr, mxPage int32) {
	(*TPCache)(unsafe.Pointer(pCache)).FszCache = mxPage
	(*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxCachesize})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache, _numberOfCachePages(tls, pCache))
}

// C documentation
//
//	/*
//	** Set the suggested cache-spill value.  Make no changes if if the
//	** argument is zero.  Return the effective cache-spill size, which will
//	** be the larger of the szSpill and szCache.
//	*/
func _sqlite3PcacheSetSpillsize(tls *libc.TLS, p uintptr, mxPage int32) (r int32) {
	var res int32
	_ = res
	if mxPage != 0 {
		if mxPage < 0 {
			mxPage = int32(int64(-libc.Int32FromInt32(1024)) * int64(mxPage) / int64((*TPCache)(unsafe.Pointer(p)).FszPage+(*TPCache)(unsafe.Pointer(p)).FszExtra))
		}
		(*TPCache)(unsafe.Pointer(p)).FszSpill = mxPage
	}
	res = _numberOfCachePages(tls, p)
	if res < (*TPCache)(unsafe.Pointer(p)).FszSpill {
		res = (*TPCache)(unsafe.Pointer(p)).FszSpill
	}
	return res
}

// C documentation
//
//	/*
//	** Free up as much memory as possible from the page cache.
//	*/
func _sqlite3PcacheShrink(tls *libc.TLS, pCache uintptr) {
	(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxShrink})))(tls, (*TPCache)(unsafe.Pointer(pCache)).FpCache)
}

func _sqlite3PcacheShutdown(tls *libc.TLS) {
	if _sqlite3Config.Fpcache2.FxShutdown != 0 {
		/* IMPLEMENTATION-OF: R-26000-56589 The xShutdown() method may be NULL. */
		(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{_sqlite3Config.Fpcache2.FxShutdown})))(tls, _sqlite3Config.Fpcache2.FpArg)
	}
}

// C documentation
//
//	/*
//	** The value of the "pending" byte must be 0x40000000 (1 byte past the
//	** 1-gibabyte boundary) in a compatible database.  SQLite never uses
//	** the database page that contains the pending byte.  It never attempts
//	** to read or write that page.  The pending byte page is set aside
//	** for use by the VFS layers as space for managing file locks.
//	**
//	** During testing, it is often desirable to move the pending byte to
//	** a different position in the file.  This allows code that has to
//	** deal with the pending byte to run on files that are much smaller
//	** than 1 GiB.  The sqlite3_test_control() interface can be used to
//	** move the pending byte.
//	**
//	** IMPORTANT:  Changing the pending byte to any value other than
//	** 0x40000000 results in an incompatible database file format!
//	** Changing the pending byte during operation will result in undefined
//	** and incorrect behavior.
//	*/
var _sqlite3PendingByte = int32(0x40000000)

// C documentation
//
//	/* All threads share a single random number generator.
//	** This structure is the current state of the generator.
//	*/
var _sqlite3Prng Tsqlite3PrngType

func _sqlite3PutVarint(tls *libc.TLS, p uintptr, v Tu64) (r int32) {
	if v <= uint64(0x7f) {
		**(**uint8)(__ccgo_up(p)) = uint8(v & uint64(0x7f))
		return int32(1)
	}
	if v <= uint64(0x3fff) {
		**(**uint8)(__ccgo_up(p)) = uint8(v>>libc.Int32FromInt32(7)&uint64(0x7f) | uint64(0x80))
		**(**uint8)(__ccgo_up(p + 1)) = uint8(v & uint64(0x7f))
		return int32(2)
	}
	return _putVarint64(tls, p, v)
}

/*
** Bitmasks used by sqlite3GetVarint().  These precomputed constants
** are defined here rather than simply putting the constant expressions
** inline in order to work around bugs in the RVT compiler.
**
** SLOT_2_0     A mask for  (0x7f<<14) | 0x7f
**
** SLOT_4_2_0   A mask for  (0x7f<<28) | SLOT_2_0
 */

// C documentation
//
//	/*
//	** Create a new string that is capable of holding N bytes of text, not counting
//	** the zero byte at the end.  The string is uninitialized.
//	**
//	** The reference count is initially 1.  Call sqlite3RCStrUnref() to free the
//	** newly allocated string.
//	**
//	** This routine returns 0 on an OOM.
//	*/
func _sqlite3RCStrNew(tls *libc.TLS, N Tu64) (r uintptr) {
	var p uintptr
	_ = p
	p = Xsqlite3_malloc64(tls, N+uint64(8)+uint64(1))
	if p == uintptr(0) {
		return uintptr(0)
	}
	(*TRCStr)(unsafe.Pointer(p)).FnRCRef = uint64(1)
	return p + 1*8
}

// C documentation
//
//	/*
//	** Increase the reference count of the string by one.
//	**
//	** The input parameter is returned.
//	*/
func _sqlite3RCStrRef(tls *libc.TLS, z uintptr) (r uintptr) {
	var p uintptr
	_ = p
	p = z
	p -= 8
	(*TRCStr)(unsafe.Pointer(p)).FnRCRef = (*TRCStr)(unsafe.Pointer(p)).FnRCRef + 1
	return z
}

// C documentation
//
//	/*
//	** Change the size of the string so that it is able to hold N bytes.
//	** The string might be reallocated, so return the new allocation.
//	*/
func _sqlite3RCStrResize(tls *libc.TLS, z uintptr, N Tu64) (r uintptr) {
	var p, pNew uintptr
	_, _ = p, pNew
	p = z
	p -= 8
	pNew = Xsqlite3_realloc64(tls, p, N+uint64(8)+uint64(1))
	if pNew == uintptr(0) {
		Xsqlite3_free(tls, p)
		return uintptr(0)
	} else {
		return pNew + 1*8
	}
	return r
}

/************** End of printf.c **********************************************/
/************** Begin file treeview.c ****************************************/
/*
** 2015-06-08
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains C code to implement the TreeView debugging routines.
** These routines print a parse tree to standard output for debugging and
** analysis.
**
** The interfaces in this file is only available when compiling
** with SQLITE_DEBUG.
 */
/* #include "sqliteInt.h" */

/************** End of treeview.c ********************************************/
/************** Begin file random.c ******************************************/
/*
** 2001 September 15
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code to implement a pseudo-random number
** generator (PRNG) for SQLite.
**
** Random numbers are used by some of the database backends in order
** to generate random integer keys for tables or random filenames.
 */
/* #include "sqliteInt.h" */

// C documentation
//
//	/*
//	** Decrease the reference count by one.  Free the string when the
//	** reference count reaches zero.
//	*/
func _sqlite3RCStrUnref(tls *libc.TLS, z uintptr) {
	var p uintptr
	_ = p
	p = z
	p -= 8
	if (*TRCStr)(unsafe.Pointer(p)).FnRCRef >= uint64(2) {
		(*TRCStr)(unsafe.Pointer(p)).FnRCRef = (*TRCStr)(unsafe.Pointer(p)).FnRCRef - 1
	} else {
		Xsqlite3_free(tls, p)
	}
}

// C documentation
//
//	/*
//	** Return TRUE if shadow tables should be read-only in the current
//	** context.
//	*/
func _sqlite3ReadOnlyShadowTables(tls *libc.TLS, db uintptr) (r int32) {
	if (*Tsqlite3)(unsafe.Pointer(db)).Fflags&uint64(SQLITE_Defensive) != uint64(0) && (*Tsqlite3)(unsafe.Pointer(db)).FpVtabCtx == uintptr(0) && (*Tsqlite3)(unsafe.Pointer(db)).FnVdbeExec == 0 && !((*Tsqlite3)(unsafe.Pointer(db)).FnVTrans > 0 && (*Tsqlite3)(unsafe.Pointer(db)).FaVTrans == uintptr(0)) {
		return int32(1)
	}
	return 0
}

// C documentation
//
//	/* Convert a floating point value to its closest integer.  Do so in
//	** a way that avoids 'outside the range of representable values' warnings
//	** from UBSAN.
//	*/
func _sqlite3RealToI64(tls *libc.TLS, r float64) (r1 Ti64) {
	if r < -libc.Float64FromFloat64(9.223372036854775e+18) {
		return int64(-libc.Int32FromInt32(1)) - (libc.Int64FromUint32(0xffffffff) | libc.Int64FromInt32(0x7fffffff)<<libc.Int32FromInt32(32))
	}
	if r > +libc.Float64FromFloat64(9.223372036854775e+18) {
		return libc.Int64FromUint32(0xffffffff) | libc.Int64FromInt32(0x7fffffff)<<libc.Int32FromInt32(32)
	}
	return int64(r)
}

func _sqlite3ReleaseTempRange(tls *libc.TLS, pParse uintptr, iReg int32, nReg int32) {
	if nReg == int32(1) {
		_sqlite3ReleaseTempReg(tls, pParse, iReg)
		return
	}
	if nReg > (*TParse)(unsafe.Pointer(pParse)).FnRangeReg {
		(*TParse)(unsafe.Pointer(pParse)).FnRangeReg = nReg
		(*TParse)(unsafe.Pointer(pParse)).FiRangeReg = iReg
	}
}

// C documentation
//
//	/*
//	** It is assumed that there is already a RenameToken object associated
//	** with parse tree element pFrom. This function remaps the associated token
//	** to parse tree element pTo.
//	*/
func _sqlite3RenameTokenRemap(tls *libc.TLS, pParse uintptr, pTo uintptr, pFrom uintptr) {
	var p uintptr
	_ = p
	p = (*TParse)(unsafe.Pointer(pParse)).FpRename
	for {
		if !(p != 0) {
			break
		}
		if (*TRenameToken)(unsafe.Pointer(p)).Fp == pFrom {
			(*TRenameToken)(unsafe.Pointer(p)).Fp = pTo
			break
		}
		goto _1
	_1:
		;
		p = (*TRenameToken)(unsafe.Pointer(p)).FpNext
	}
}

// C documentation
//
//	/*
//	** Rerun the compilation of a statement after a schema change.
//	**
//	** If the statement is successfully recompiled, return SQLITE_OK. Otherwise,
//	** if the statement cannot be recompiled because another connection has
//	** locked the sqlite3_schema table, return SQLITE_LOCKED. If any other error
//	** occurs, return SQLITE_SCHEMA.
//	*/
func _sqlite3Reprepare(tls *libc.TLS, p uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var db, zSql uintptr
	var prepFlags Tu8
	var rc int32
	var _ /* pNew at bp+0 */ uintptr
	_, _, _, _ = db, prepFlags, rc, zSql
	zSql = Xsqlite3_sql(tls, p)
	/* Reprepare only called for prepare_v2() statements */
	db = _sqlite3VdbeDb(tls, p)
	prepFlags = _sqlite3VdbePrepareFlags(tls, p)
	rc = _sqlite3LockAndPrepare(tls, db, zSql, -int32(1), uint32(prepFlags), p, bp, uintptr(0))
	if rc != 0 {
		if rc == int32(SQLITE_NOMEM) {
			_sqlite3OomFault(tls, db)
		}
		return rc
	} else {
	}
	_sqlite3VdbeSwap(tls, **(**uintptr)(__ccgo_up(bp)), p)
	_sqlite3TransferBindings(tls, **(**uintptr)(__ccgo_up(bp)), p)
	_sqlite3VdbeResetStepResult(tls, **(**uintptr)(__ccgo_up(bp)))
	_sqlite3VdbeFinalize(tls, **(**uintptr)(__ccgo_up(bp)))
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** If a prior call to sqlite3GenerateIndexKey() generated a jump-over label
//	** because it was a partial index, then this routine should be called to
//	** resolve that label.
//	*/
func _sqlite3ResolvePartIdxLabel(tls *libc.TLS, pParse uintptr, iLabel int32) {
	if iLabel != 0 {
		_sqlite3VdbeResolveLabel(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, iLabel)
	}
}

/************** End of delete.c **********************************************/
/************** Begin file func.c ********************************************/
/*
** 2002 February 23
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains the C-language implementations for many of the SQL
** functions of SQLite.  (Some function, and in particular the date and
** time functions, are implemented separately.)
 */
/* #include "sqliteInt.h" */
/* #include <stdlib.h> */
/* #include <assert.h> */
/* #include <math.h> */
/* #include "vdbeInt.h" */

// C documentation
//
//	/*
//	** Deallocate all chunks from a RowSet.  This frees all memory that
//	** the RowSet has allocated over its lifetime.  This routine is
//	** the destructor for the RowSet.
//	*/
func _sqlite3RowSetClear(tls *libc.TLS, pArg uintptr) {
	var p, pChunk, pNextChunk uintptr
	_, _, _ = p, pChunk, pNextChunk
	p = pArg
	pChunk = (*TRowSet)(unsafe.Pointer(p)).FpChunk
	for {
		if !(pChunk != 0) {
			break
		}
		pNextChunk = (*TRowSetChunk)(unsafe.Pointer(pChunk)).FpNextChunk
		_sqlite3DbFree(tls, (*TRowSet)(unsafe.Pointer(p)).Fdb, pChunk)
		goto _1
	_1:
		;
		pChunk = pNextChunk
	}
	(*TRowSet)(unsafe.Pointer(p)).FpChunk = uintptr(0)
	(*TRowSet)(unsafe.Pointer(p)).FnFresh = uint16(0)
	(*TRowSet)(unsafe.Pointer(p)).FpEntry = uintptr(0)
	(*TRowSet)(unsafe.Pointer(p)).FpLast = uintptr(0)
	(*TRowSet)(unsafe.Pointer(p)).FpForest = uintptr(0)
	(*TRowSet)(unsafe.Pointer(p)).FrsFlags = uint16(ROWSET_SORTED)
}

// C documentation
//
//	/*
//	** Deallocate all chunks from a RowSet.  This frees all memory that
//	** the RowSet has allocated over its lifetime.  This routine is
//	** the destructor for the RowSet.
//	*/
func _sqlite3RowSetDelete(tls *libc.TLS, pArg uintptr) {
	_sqlite3RowSetClear(tls, pArg)
	_sqlite3DbFree(tls, (*TRowSet)(unsafe.Pointer(pArg)).Fdb, pArg)
}

// C documentation
//
//	/*
//	** For testing purposes, we sometimes want to preserve the state of
//	** PRNG and restore the PRNG to its saved state at a later time, or
//	** to reset the PRNG to its initial state.  These routines accomplish
//	** those tasks.
//	**
//	** The sqlite3_test_control() interface calls these routines to
//	** control the PRNG.
//	*/
var _sqlite3SavedPrng Tsqlite3PrngType

// C documentation
//
//	/*
//	** This function is called by the parser when it parses a command to create,
//	** release or rollback an SQL savepoint.
//	*/
func _sqlite3Savepoint(tls *libc.TLS, pParse uintptr, op int32, pName uintptr) {
	var v, zName uintptr
	_, _ = v, zName
	zName = _sqlite3NameFromToken(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pName)
	if zName != 0 {
		v = _sqlite3GetVdbe(tls, pParse)
		if !(v != 0) || _sqlite3AuthCheck(tls, pParse, int32(SQLITE_SAVEPOINT), _az[op], zName, uintptr(0)) != 0 {
			_sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, zName)
			return
		}
		_sqlite3VdbeAddOp4(tls, v, OP_Savepoint, op, 0, 0, zName, -int32(7))
	}
}

// C documentation
//
//	/*
//	** Return a sanitized version of the sector-size of OS file pFile. The
//	** return value is guaranteed to lie between 32 and MAX_SECTOR_SIZE.
//	*/
func _sqlite3SectorSize(tls *libc.TLS, pFile uintptr) (r int32) {
	var iRet int32
	_ = iRet
	iRet = _sqlite3OsSectorSize(tls, pFile)
	if iRet < int32(32) {
		iRet = int32(512)
	} else {
		if iRet > int32(MAX_SECTOR_SIZE) {
			iRet = int32(MAX_SECTOR_SIZE)
		}
	}
	return iRet
}

// C documentation
//
//	/*
//	** Delete the given Select structure and all of its substructures.
//	*/
func _sqlite3SelectDelete(tls *libc.TLS, db uintptr, p uintptr) {
	if p != 0 {
		_clearSelect(tls, db, p, int32(1))
	}
}

func _sqlite3SelectDeleteGeneric(tls *libc.TLS, db uintptr, p uintptr) {
	if p != 0 {
		_clearSelect(tls, db, p, int32(1))
	}
}

// C documentation
//
//	/*
//	** Return the maximum height of any expression tree referenced
//	** by the select statement passed as an argument.
//	*/
func _sqlite3SelectExprHeight(tls *libc.TLS, p uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var _ /* nHeight at bp+0 */ int32
	**(**int32)(__ccgo_up(bp)) = 0
	_heightOfSelect(tls, p, bp)
	return **(**int32)(__ccgo_up(bp))
}

// C documentation
//
//	/*
//	** If the SELECT passed as the second argument has an associated WITH
//	** clause, pop it from the stack stored as part of the Parse object.
//	**
//	** This function is used as the xSelectCallback2() callback by
//	** sqlite3SelectExpand() when walking a SELECT tree to resolve table
//	** names and other FROM clause elements.
//	*/
func _sqlite3SelectPopWith(tls *libc.TLS, pWalker uintptr, p uintptr) {
	var pParse, pWith uintptr
	_, _ = pParse, pWith
	pParse = (*TWalker)(unsafe.Pointer(pWalker)).FpParse
	if (*TParse)(unsafe.Pointer(pParse)).FpWith != 0 && (*TSelect)(unsafe.Pointer(p)).FpPrior == uintptr(0) {
		pWith = (*TSelect)(unsafe.Pointer(_findRightmost(tls, p))).FpWith
		if pWith != uintptr(0) {
			(*TParse)(unsafe.Pointer(pParse)).FpWith = (*TWith)(unsafe.Pointer(pWith)).FpOuter
		}
	}
}

// C documentation
//
//	/*
//	** This routine sets up a SELECT statement for processing.  The
//	** following is accomplished:
//	**
//	**     *  VDBE Cursor numbers are assigned to all FROM-clause terms.
//	**     *  Ephemeral Table objects are created for all FROM-clause subqueries.
//	**     *  ON and USING clauses are shifted into WHERE statements
//	**     *  Wildcards "*" and "TABLE.*" in result sets are expanded.
//	**     *  Identifiers in expression are matched to tables.
//	**
//	** This routine acts recursively on all subqueries within the SELECT.
//	*/
func _sqlite3SelectPrep(tls *libc.TLS, pParse uintptr, p uintptr, pOuterNC uintptr) {
	if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FmallocFailed != 0 {
		return
	}
	if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_HasTypeInfo) != 0 {
		return
	}
	_sqlite3SelectExpand(tls, pParse, p)
	if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 {
		return
	}
	_sqlite3ResolveSelectNames(tls, pParse, p, pOuterNC)
	if (*TParse)(unsafe.Pointer(pParse)).FnErr != 0 {
		return
	}
	_sqlite3SelectAddTypeInfo(tls, pParse, p)
}

// C documentation
//
//	/*
//	** This is a SELECT-node callback for the expression walker that
//	** always "fails".  By "fail" in this case, we mean set
//	** pWalker->eCode to zero and abort.
//	**
//	** This callback is used by multiple expression walkers.
//	*/
func _sqlite3SelectWalkFail(tls *libc.TLS, pWalker uintptr, NotUsed uintptr) (r int32) {
	_ = NotUsed
	(*TWalker)(unsafe.Pointer(pWalker)).FeCode = uint16(0)
	return int32(WRC_Abort)
}

// C documentation
//
//	/*
//	** No-op routine for the parse-tree walker for SELECT statements.
//	** subquery in the parser tree.
//	*/
func _sqlite3SelectWalkNoop(tls *libc.TLS, NotUsed uintptr, NotUsed2 uintptr) (r int32) {
	_ = NotUsed
	_ = NotUsed2
	return WRC_Continue
}

/************** End of walker.c **********************************************/
/************** Begin file resolve.c *****************************************/
/*
** 2008 August 18
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains routines used for walking the parser tree and
** resolve all identifiers by associating them with a particular
** table and column.
 */
/* #include "sqliteInt.h" */

/*
** Magic table number to mean the EXCLUDED table in an UPSERT statement.
 */

// C documentation
//
//	/*
//	** Generate code that checks the left-most column of index table iCur to see if
//	** it contains any NULL entries.  Cause the register at regHasNull to be set
//	** to a non-NULL value if iCur contains no NULLs.  Cause register regHasNull
//	** to be set to NULL if iCur contains one or more NULL values.
//	*/
func _sqlite3SetHasNullFlag(tls *libc.TLS, v uintptr, iCur int32, regHasNull int32) {
	var addr1 int32
	_ = addr1
	_sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regHasNull)
	addr1 = _sqlite3VdbeAddOp1(tls, v, int32(OP_Rewind), iCur)
	_sqlite3VdbeAddOp3(tls, v, int32(OP_Column), iCur, 0, regHasNull)
	_sqlite3VdbeChangeP5(tls, v, uint16(OPFLAG_TYPEOFARG))
	_sqlite3VdbeJumpHere(tls, v, addr1)
}

// C documentation
//
//	/*
//	** Free any prior content in *pz and replace it with a copy of zNew.
//	*/
func _sqlite3SetString(tls *libc.TLS, pz uintptr, db uintptr, zNew uintptr) {
	var z uintptr
	_ = z
	z = _sqlite3DbStrDup(tls, db, zNew)
	_sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(pz)))
	**(**uintptr)(__ccgo_up(pz)) = z
}

// C documentation
//
//	/*
//	** Change the text encoding for a database connection. This means that
//	** the pDfltColl must change as well.
//	*/
func _sqlite3SetTextEncoding(tls *libc.TLS, db uintptr, enc Tu8) {
	(*Tsqlite3)(unsafe.Pointer(db)).Fenc = enc
	/* EVIDENCE-OF: R-08308-17224 The default collating function for all
	 ** strings is BINARY.
	 */
	(*Tsqlite3)(unsafe.Pointer(db)).FpDfltColl = _sqlite3FindCollSeq(tls, db, enc, uintptr(unsafe.Pointer(&_sqlite3StrBINARY)), 0)
	_sqlite3ExpirePreparedStatements(tls, db, int32(1))
}

// C documentation
//
//	/*
//	** A list of BtShared objects that are eligible for participation
//	** in shared cache.  This variable has file scope during normal builds,
//	** but the test harness needs to access it so we make it global for
//	** test builds.
//	**
//	** Access to this variable is protected by SQLITE_MUTEX_STATIC_MAIN.
//	*/
var _sqlite3SharedCacheList = uintptr(0)

// C documentation
//
//	/*
//	** Indicate that the accumulator load should be skipped on this
//	** iteration of the aggregate loop.
//	*/
func _sqlite3SkipAccumulatorLoad(tls *libc.TLS, context uintptr) {
	(*Tsqlite3_context)(unsafe.Pointer(context)).FisError = -int32(1)
	(*Tsqlite3_context)(unsafe.Pointer(context)).FskipFlag = uint8(1)
}

// C documentation
//
//	/*
//	** The sizes for serial types less than 128
//	*/
var _sqlite3SmallTypeSizes = [128]Tu8{
	1:   uint8(1),
	2:   uint8(2),
	3:   uint8(3),
	4:   uint8(4),
	5:   uint8(6),
	6:   uint8(8),
	7:   uint8(8),
	14:  uint8(1),
	15:  uint8(1),
	16:  uint8(2),
	17:  uint8(2),
	18:  uint8(3),
	19:  uint8(3),
	20:  uint8(4),
	21:  uint8(4),
	22:  uint8(5),
	23:  uint8(5),
	24:  uint8(6),
	25:  uint8(6),
	26:  uint8(7),
	27:  uint8(7),
	28:  uint8(8),
	29:  uint8(8),
	30:  uint8(9),
	31:  uint8(9),
	32:  uint8(10),
	33:  uint8(10),
	34:  uint8(11),
	35:  uint8(11),
	36:  uint8(12),
	37:  uint8(12),
	38:  uint8(13),
	39:  uint8(13),
	40:  uint8(14),
	41:  uint8(14),
	42:  uint8(15),
	43:  uint8(15),
	44:  uint8(16),
	45:  uint8(16),
	46:  uint8(17),
	47:  uint8(17),
	48:  uint8(18),
	49:  uint8(18),
	50:  uint8(19),
	51:  uint8(19),
	52:  uint8(20),
	53:  uint8(20),
	54:  uint8(21),
	55:  uint8(21),
	56:  uint8(22),
	57:  uint8(22),
	58:  uint8(23),
	59:  uint8(23),
	60:  uint8(24),
	61:  uint8(24),
	62:  uint8(25),
	63:  uint8(25),
	64:  uint8(26),
	65:  uint8(26),
	66:  uint8(27),
	67:  uint8(27),
	68:  uint8(28),
	69:  uint8(28),
	70:  uint8(29),
	71:  uint8(29),
	72:  uint8(30),
	73:  uint8(30),
	74:  uint8(31),
	75:  uint8(31),
	76:  uint8(32),
	77:  uint8(32),
	78:  uint8(33),
	79:  uint8(33),
	80:  uint8(34),
	81:  uint8(34),
	82:  uint8(35),
	83:  uint8(35),
	84:  uint8(36),
	85:  uint8(36),
	86:  uint8(37),
	87:  uint8(37),
	88:  uint8(38),
	89:  uint8(38),
	90:  uint8(39),
	91:  uint8(39),
	92:  uint8(40),
	93:  uint8(40),
	94:  uint8(41),
	95:  uint8(41),
	96:  uint8(42),
	97:  uint8(42),
	98:  uint8(43),
	99:  uint8(43),
	100: uint8(44),
	101: uint8(44),
	102: uint8(45),
	103: uint8(45),
	104: uint8(46),
	105: uint8(46),
	106: uint8(47),
	107: uint8(47),
	108: uint8(48),
	109: uint8(48),
	110: uint8(49),
	111: uint8(49),
	112: uint8(50),
	113: uint8(50),
	114: uint8(51),
	115: uint8(51),
	116: uint8(52),
	117: uint8(52),
	118: uint8(53),
	119: uint8(53),
	120: uint8(54),
	121: uint8(54),
	122: uint8(55),
	123: uint8(55),
	124: uint8(56),
	125: uint8(56),
	126: uint8(57),
	127: uint8(57),
}

var _sqlite3Stat = Tsqlite3StatType{}

// C documentation
//
//	/*
//	** Attempt to extract a value from expression pExpr using the methods
//	** as described for sqlite3Stat4ProbeSetValue() above.
//	**
//	** If successful, set *ppVal to point to a new value object and return
//	** SQLITE_OK. If no value can be extracted, but no other error occurs
//	** (e.g. OOM), return SQLITE_OK and set *ppVal to NULL. Or, if an error
//	** does occur, return an SQLite error code. The final value of *ppVal
//	** is undefined in this case.
//	*/
func _sqlite3Stat4ValueFromExpr(tls *libc.TLS, pParse uintptr, pExpr uintptr, affinity Tu8, ppVal uintptr) (r int32) {
	return _stat4ValueFromExpr(tls, pParse, pExpr, affinity, uintptr(0), ppVal)
}

// C documentation
//
//	/*
//	** Standard typenames.  These names must match the COLTYPE_* definitions.
//	** Adjust the SQLITE_N_STDTYPE value if adding or removing entries.
//	**
//	**    sqlite3StdType[]            The actual names of the datatypes.
//	**
//	**    sqlite3StdTypeLen[]         The length (in bytes) of each entry
//	**                                in sqlite3StdType[].
//	**
//	**    sqlite3StdTypeAffinity[]    The affinity associated with each entry
//	**                                in sqlite3StdType[].
//	*/
var _sqlite3StdTypeLen = [6]uint8{
	0: uint8(3),
	1: uint8(4),
	2: uint8(3),
	3: uint8(7),
	4: uint8(4),
	5: uint8(4),
}

func _sqlite3SubInt64(tls *libc.TLS, pA uintptr, iB Ti64) (r int32) {
	if iB == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<<libc.Int32FromInt32(32)) {
		if **(**Ti64)(__ccgo_up(pA)) >= 0 {
			return int32(1)
		}
		**(**Ti64)(__ccgo_up(pA)) -= iB
		return 0
	} else {
		return _sqlite3AddInt64(tls, pA, -iB)
	}
	return r
}

// C documentation
//
//	/*
//	** Delete a Subquery object and its substructure.
//	*/
func _sqlite3SubqueryDelete(tls *libc.TLS, db uintptr, pSubq uintptr) {
	_sqlite3SelectDelete(tls, db, (*TSubquery)(unsafe.Pointer(pSubq)).FpSelect)
	_sqlite3DbFree(tls, db, pSubq)
}

// C documentation
//
//	/*
//	** Load the sqlite3.iSysErrno field if that is an appropriate thing
//	** to do based on the SQLite error code in rc.
//	*/
func _sqlite3SystemError(tls *libc.TLS, db uintptr, rc int32) {
	if rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(12)<<libc.Int32FromInt32(8) {
		return
	}
	rc = rc & int32(0xff)
	if rc == int32(SQLITE_CANTOPEN) || rc == int32(SQLITE_IOERR) {
		(*Tsqlite3)(unsafe.Pointer(db)).FiSysErrno = _sqlite3OsGetLastError(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpVfs)
	}
}

// C documentation
//
//	/*
//	** This is an extension initializer that is a no-op and always
//	** succeeds, except that it fails if the fault-simulation is set
//	** to 500.
//	*/
func _sqlite3TestExtInit(tls *libc.TLS, db uintptr) (r int32) {
	_ = db
	return _sqlite3FaultSim(tls, int32(500))
}

// C documentation
//
//	/*
//	** Make sure sufficient registers have been allocated so that
//	** iReg is a valid register number.
//	*/
func _sqlite3TouchRegister(tls *libc.TLS, pParse uintptr, iReg int32) {
	if (*TParse)(unsafe.Pointer(pParse)).FnMem < iReg {
		(*TParse)(unsafe.Pointer(pParse)).FnMem = iReg
	}
}

// C documentation
//
//	/*
//	** Tracing flags set by SQLITE_TESTCTRL_TRACEFLAGS.
//	*/
var _sqlite3TreeTrace = uint32(0)

// C documentation
//
//	/* An array to map all upper-case characters into their corresponding
//	** lower-case character.
//	**
//	** SQLite only considers US-ASCII (or EBCDIC) characters.  We do not
//	** handle case conversions for the UTF character set since the tables
//	** involved are nearly as big or bigger than SQLite itself.
//	*/
var _sqlite3UpperToLower = [274]uint8{
	1:   uint8(1),
	2:   uint8(2),
	3:   uint8(3),
	4:   uint8(4),
	5:   uint8(5),
	6:   uint8(6),
	7:   uint8(7),
	8:   uint8(8),
	9:   uint8(9),
	10:  uint8(10),
	11:  uint8(11),
	12:  uint8(12),
	13:  uint8(13),
	14:  uint8(14),
	15:  uint8(15),
	16:  uint8(16),
	17:  uint8(17),
	18:  uint8(18),
	19:  uint8(19),
	20:  uint8(20),
	21:  uint8(21),
	22:  uint8(22),
	23:  uint8(23),
	24:  uint8(24),
	25:  uint8(25),
	26:  uint8(26),
	27:  uint8(27),
	28:  uint8(28),
	29:  uint8(29),
	30:  uint8(30),
	31:  uint8(31),
	32:  uint8(32),
	33:  uint8(33),
	34:  uint8(34),
	35:  uint8(35),
	36:  uint8(36),
	37:  uint8(37),
	38:  uint8(38),
	39:  uint8(39),
	40:  uint8(40),
	41:  uint8(41),
	42:  uint8(42),
	43:  uint8(43),
	44:  uint8(44),
	45:  uint8(45),
	46:  uint8(46),
	47:  uint8(47),
	48:  uint8(48),
	49:  uint8(49),
	50:  uint8(50),
	51:  uint8(51),
	52:  uint8(52),
	53:  uint8(53),
	54:  uint8(54),
	55:  uint8(55),
	56:  uint8(56),
	57:  uint8(57),
	58:  uint8(58),
	59:  uint8(59),
	60:  uint8(60),
	61:  uint8(61),
	62:  uint8(62),
	63:  uint8(63),
	64:  uint8(64),
	65:  uint8(97),
	66:  uint8(98),
	67:  uint8(99),
	68:  uint8(100),
	69:  uint8(101),
	70:  uint8(102),
	71:  uint8(103),
	72:  uint8(104),
	73:  uint8(105),
	74:  uint8(106),
	75:  uint8(107),
	76:  uint8(108),
	77:  uint8(109),
	78:  uint8(110),
	79:  uint8(111),
	80:  uint8(112),
	81:  uint8(113),
	82:  uint8(114),
	83:  uint8(115),
	84:  uint8(116),
	85:  uint8(117),
	86:  uint8(118),
	87:  uint8(119),
	88:  uint8(120),
	89:  uint8(121),
	90:  uint8(122),
	91:  uint8(91),
	92:  uint8(92),
	93:  uint8(93),
	94:  uint8(94),
	95:  uint8(95),
	96:  uint8(96),
	97:  uint8(97),
	98:  uint8(98),
	99:  uint8(99),
	100: uint8(100),
	101: uint8(101),
	102: uint8(102),
	103: uint8(103),
	104: uint8(104),
	105: uint8(105),
	106: uint8(106),
	107: uint8(107),
	108: uint8(108),
	109: uint8(109),
	110: uint8(110),
	111: uint8(111),
	112: uint8(112),
	113: uint8(113),
	114: uint8(114),
	115: uint8(115),
	116: uint8(116),
	117: uint8(117),
	118: uint8(118),
	119: uint8(119),
	120: uint8(120),
	121: uint8(121),
	122: uint8(122),
	123: uint8(123),
	124: uint8(124),
	125: uint8(125),
	126: uint8(126),
	127: uint8(127),
	128: uint8(128),
	129: uint8(129),
	130: uint8(130),
	131: uint8(131),
	132: uint8(132),
	133: uint8(133),
	134: uint8(134),
	135: uint8(135),
	136: uint8(136),
	137: uint8(137),
	138: uint8(138),
	139: uint8(139),
	140: uint8(140),
	141: uint8(141),
	142: uint8(142),
	143: uint8(143),
	144: uint8(144),
	145: uint8(145),
	146: uint8(146),
	147: uint8(147),
	148: uint8(148),
	149: uint8(149),
	150: uint8(150),
	151: uint8(151),
	152: uint8(152),
	153: uint8(153),
	154: uint8(154),
	155: uint8(155),
	156: uint8(156),
	157: uint8(157),
	158: uint8(158),
	159: uint8(159),
	160: uint8(160),
	161: uint8(161),
	162: uint8(162),
	163: uint8(163),
	164: uint8(164),
	165: uint8(165),
	166: uint8(166),
	167: uint8(167),
	168: uint8(168),
	169: uint8(169),
	170: uint8(170),
	171: uint8(171),
	172: uint8(172),
	173: uint8(173),
	174: uint8(174),
	175: uint8(175),
	176: uint8(176),
	177: uint8(177),
	178: uint8(178),
	179: uint8(179),
	180: uint8(180),
	181: uint8(181),
	182: uint8(182),
	183: uint8(183),
	184: uint8(184),
	185: uint8(185),
	186: uint8(186),
	187: uint8(187),
	188: uint8(188),
	189: uint8(189),
	190: uint8(190),
	191: uint8(191),
	192: uint8(192),
	193: uint8(193),
	194: uint8(194),
	195: uint8(195),
	196: uint8(196),
	197: uint8(197),
	198: uint8(198),
	199: uint8(199),
	200: uint8(200),
	201: uint8(201),
	202: uint8(202),
	203: uint8(203),
	204: uint8(204),
	205: uint8(205),
	206: uint8(206),
	207: uint8(207),
	208: uint8(208),
	209: uint8(209),
	210: uint8(210),
	211: uint8(211),
	212: uint8(212),
	213: uint8(213),
	214: uint8(214),
	215: uint8(215),
	216: uint8(216),
	217: uint8(217),
	218: uint8(218),
	219: uint8(219),
	220: uint8(220),
	221: uint8(221),
	222: uint8(222),
	223: uint8(223),
	224: uint8(224),
	225: uint8(225),
	226: uint8(226),
	227: uint8(227),
	228: uint8(228),
	229: uint8(229),
	230: uint8(230),
	231: uint8(231),
	232: uint8(232),
	233: uint8(233),
	234: uint8(234),
	235: uint8(235),
	236: uint8(236),
	237: uint8(237),
	238: uint8(238),
	239: uint8(239),
	240: uint8(240),
	241: uint8(241),
	242: uint8(242),
	243: uint8(243),
	244: uint8(244),
	245: uint8(245),
	246: uint8(246),
	247: uint8(247),
	248: uint8(248),
	249: uint8(249),
	250: uint8(250),
	251: uint8(251),
	252: uint8(252),
	253: uint8(253),
	254: uint8(254),
	255: uint8(255),
	256: uint8(1),
	259: uint8(1),
	260: uint8(1),
	263: uint8(1),
	265: uint8(1),
	267: uint8(1),
	268: uint8(1),
	270: uint8(1),
	273: uint8(1),
}

func _sqlite3UpsertDelete(tls *libc.TLS, db uintptr, p uintptr) {
	if p != 0 {
		_upsertDelete(tls, db, p)
	}
}

// C documentation
//
//	/*
//	** Duplicate an Upsert object.
//	*/
func _sqlite3UpsertDup(tls *libc.TLS, db uintptr, p uintptr) (r uintptr) {
	if p == uintptr(0) {
		return uintptr(0)
	}
	return _sqlite3UpsertNew(tls, db, _sqlite3ExprListDup(tls, db, (*TUpsert)(unsafe.Pointer(p)).FpUpsertTarget, 0), _sqlite3ExprDup(tls, db, (*TUpsert)(unsafe.Pointer(p)).FpUpsertTargetWhere, 0), _sqlite3ExprListDup(tls, db, (*TUpsert)(unsafe.Pointer(p)).FpUpsertSet, 0), _sqlite3ExprDup(tls, db, (*TUpsert)(unsafe.Pointer(p)).FpUpsertWhere, 0), _sqlite3UpsertDup(tls, db, (*TUpsert)(unsafe.Pointer(p)).FpNextUpsert))
}

// C documentation
//
//	/*
//	** Return true if pUpsert is the last ON CONFLICT clause with a
//	** conflict target, or if pUpsert is followed by another ON CONFLICT
//	** clause that targets the INTEGER PRIMARY KEY.
//	*/
func _sqlite3UpsertNextIsIPK(tls *libc.TLS, pUpsert uintptr) (r int32) {
	var pNext uintptr
	_ = pNext
	if pUpsert == uintptr(0) {
		return 0
	}
	pNext = (*TUpsert)(unsafe.Pointer(pUpsert)).FpNextUpsert
	for int32(1) != 0 {
		if pNext == uintptr(0) {
			return int32(1)
		}
		if (*TUpsert)(unsafe.Pointer(pNext)).FpUpsertTarget == uintptr(0) {
			return int32(1)
		}
		if (*TUpsert)(unsafe.Pointer(pNext)).FpUpsertIdx == uintptr(0) {
			return int32(1)
		}
		if !((*TUpsert)(unsafe.Pointer(pNext)).FisDup != 0) {
			return 0
		}
		pNext = (*TUpsert)(unsafe.Pointer(pNext)).FpNextUpsert
	}
	return 0
}

// C documentation
//
//	/*
//	** Given the list of ON CONFLICT clauses described by pUpsert, and
//	** a particular index pIdx, return a pointer to the particular ON CONFLICT
//	** clause that applies to the index.  Or, if the index is not subject to
//	** any ON CONFLICT clause, return NULL.
//	*/
func _sqlite3UpsertOfIndex(tls *libc.TLS, pUpsert uintptr, pIdx uintptr) (r uintptr) {
	for pUpsert != 0 && (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertTarget != uintptr(0) && (*TUpsert)(unsafe.Pointer(pUpsert)).FpUpsertIdx != pIdx {
		pUpsert = (*TUpsert)(unsafe.Pointer(pUpsert)).FpNextUpsert
	}
	return pUpsert
}

// C documentation
//
//	/*
//	** This lookup table is used to help decode the first byte of
//	** a multi-byte UTF8 character.
//	*/
var _sqlite3Utf8Trans1 = [64]uint8{
	1:  uint8(0x01),
	2:  uint8(0x02),
	3:  uint8(0x03),
	4:  uint8(0x04),
	5:  uint8(0x05),
	6:  uint8(0x06),
	7:  uint8(0x07),
	8:  uint8(0x08),
	9:  uint8(0x09),
	10: uint8(0x0a),
	11: uint8(0x0b),
	12: uint8(0x0c),
	13: uint8(0x0d),
	14: uint8(0x0e),
	15: uint8(0x0f),
	16: uint8(0x10),
	17: uint8(0x11),
	18: uint8(0x12),
	19: uint8(0x13),
	20: uint8(0x14),
	21: uint8(0x15),
	22: uint8(0x16),
	23: uint8(0x17),
	24: uint8(0x18),
	25: uint8(0x19),
	26: uint8(0x1a),
	27: uint8(0x1b),
	28: uint8(0x1c),
	29: uint8(0x1d),
	30: uint8(0x1e),
	31: uint8(0x1f),
	33: uint8(0x01),
	34: uint8(0x02),
	35: uint8(0x03),
	36: uint8(0x04),
	37: uint8(0x05),
	38: uint8(0x06),
	39: uint8(0x07),
	40: uint8(0x08),
	41: uint8(0x09),
	42: uint8(0x0a),
	43: uint8(0x0b),
	44: uint8(0x0c),
	45: uint8(0x0d),
	46: uint8(0x0e),
	47: uint8(0x0f),
	49: uint8(0x01),
	50: uint8(0x02),
	51: uint8(0x03),
	52: uint8(0x04),
	53: uint8(0x05),
	54: uint8(0x06),
	55: uint8(0x07),
	57: uint8(0x01),
	58: uint8(0x02),
	59: uint8(0x03),
	61: uint8(0x01),
}

// C documentation
//
//	/*
//	** Return a pointer to the name of a variable in the given VList that
//	** has the value iVal.  Or return a NULL if there is no such variable in
//	** the list
//	*/
func _sqlite3VListNumToName(tls *libc.TLS, pIn uintptr, iVal int32) (r uintptr) {
	var i, mx int32
	_, _ = i, mx
	if pIn == uintptr(0) {
		return uintptr(0)
	}
	mx = **(**TVList)(__ccgo_up(pIn + 1*4))
	i = int32(2)
	for cond := true; cond; cond = i < mx {
		if **(**TVList)(__ccgo_up(pIn + uintptr(i)*4)) == iVal {
			return pIn + uintptr(i+int32(2))*4
		}
		i = i + **(**TVList)(__ccgo_up(pIn + uintptr(i+int32(1))*4))
	}
	return uintptr(0)
}

// C documentation
//
//	/*
//	** Free an sqlite3_value object
//	*/
func _sqlite3ValueFree(tls *libc.TLS, v uintptr) {
	if !(v != 0) {
		return
	}
	_sqlite3VdbeMemRelease(tls, v)
	_sqlite3DbFreeNN(tls, (*TMem)(unsafe.Pointer(v)).Fdb, v)
}

// C documentation
//
//	/*
//	** Create a new sqlite3_value object, containing the value of pExpr.
//	**
//	** This only works for very simple expressions that consist of one constant
//	** token (i.e. "5", "5.1", "'a string'"). If the expression can
//	** be converted directly into a value, then the value is allocated and
//	** a pointer written to *ppVal. The caller is responsible for deallocating
//	** the value by passing it to sqlite3ValueFree() later on. If the expression
//	** cannot be converted to a value, then *ppVal is set to NULL.
//	*/
func _sqlite3ValueFromExpr(tls *libc.TLS, db uintptr, pExpr uintptr, enc Tu8, affinity Tu8, ppVal uintptr) (r int32) {
	var v1 int32
	_ = v1
	if pExpr != 0 {
		v1 = _valueFromExpr(tls, db, pExpr, enc, affinity, ppVal, uintptr(0))
	} else {
		v1 = 0
	}
	return v1
}

func _sqlite3ValueSetNull(tls *libc.TLS, p uintptr) {
	_sqlite3VdbeMemSetNull(tls, p)
}

// C documentation
//
//	/*
//	** Change the string value of an sqlite3_value object
//	*/
func _sqlite3ValueSetStr(tls *libc.TLS, v uintptr, n int32, z uintptr, enc Tu8, __ccgo_fp_xDel uintptr) {
	if v != 0 {
		_sqlite3VdbeMemSetStr(tls, v, z, int64(n), enc, __ccgo_fp_xDel)
	}
}

// C documentation
//
//	/*
//	** Return the number of bytes that will be needed to store the given
//	** 64-bit integer.
//	*/
func _sqlite3VarintLen(tls *libc.TLS, v Tu64) (r int32) {
	var i int32
	_ = i
	i = int32(1)
	for {
		v = v >> uint64(7)
		if !(v != uint64(0)) {
			break
		}
		goto _1
	_1:
		;
		i = i + 1
	}
	return i
}

// C documentation
//
//	/*
//	** Add a new instruction to the list of instructions current in the
//	** VDBE.  Return the address of the new instruction.
//	**
//	** Parameters:
//	**
//	**    p               Pointer to the VDBE
//	**
//	**    op              The opcode for this instruction
//	**
//	**    p1, p2, p3, p4  Operands
//	*/
func _sqlite3VdbeAddOp0(tls *libc.TLS, p uintptr, op int32) (r int32) {
	return _sqlite3VdbeAddOp3(tls, p, op, 0, 0, 0)
}

func _sqlite3VdbeAddOp1(tls *libc.TLS, p uintptr, op int32, p1 int32) (r int32) {
	return _sqlite3VdbeAddOp3(tls, p, op, p1, 0, 0)
}

func _sqlite3VdbeAddOp2(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32) (r int32) {
	return _sqlite3VdbeAddOp3(tls, p, op, p1, p2, 0)
}

// C documentation
//
//	/*
//	** Add an opcode that includes the p4 value as a pointer.
//	*/
func _sqlite3VdbeAddOp4(tls *libc.TLS, p uintptr, op int32, p1 int32, p2 int32, p3 int32, zP4 uintptr, p4type int32) (r int32) {
	var addr int32
	_ = addr
	addr = _sqlite3VdbeAddOp3(tls, p, op, p1, p2, p3)
	_sqlite3VdbeChangeP4(tls, p, addr, zP4, p4type)
	return addr
}

// C documentation
//
//	/*
//	** Add an OP_ParseSchema opcode.  This routine is broken out from
//	** sqlite3VdbeAddOp4() since it needs to also needs to mark all btrees
//	** as having been used.
//	**
//	** The zWhere string must have been obtained from sqlite3_malloc().
//	** This routine will take ownership of the allocated memory.
//	*/
func _sqlite3VdbeAddParseSchemaOp(tls *libc.TLS, p uintptr, iDb int32, zWhere uintptr, p5 Tu16) {
	var j int32
	_ = j
	_sqlite3VdbeAddOp4(tls, p, int32(OP_ParseSchema), iDb, 0, 0, zWhere, -int32(7))
	_sqlite3VdbeChangeP5(tls, p, p5)
	j = 0
	for {
		if !(j < (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).FnDb) {
			break
		}
		_sqlite3VdbeUsesBtree(tls, p, j)
		goto _1
	_1:
		;
		j = j + 1
	}
	_sqlite3MayAbort(tls, (*TVdbe)(unsafe.Pointer(p)).FpParse)
}

// C documentation
//
//	/*
//	** Change the value of the opcode, or P1, P2, P3, or P5 operands
//	** for a specific instruction.
//	*/
func _sqlite3VdbeChangeOpcode(tls *libc.TLS, p uintptr, addr int32, iNewOpcode Tu8) {
	(*TVdbeOp)(unsafe.Pointer(_sqlite3VdbeGetOp(tls, p, addr))).Fopcode = iNewOpcode
}

func _sqlite3VdbeChangeP1(tls *libc.TLS, p uintptr, addr int32, val int32) {
	(*TVdbeOp)(unsafe.Pointer(_sqlite3VdbeGetOp(tls, p, addr))).Fp1 = val
}

func _sqlite3VdbeChangeP2(tls *libc.TLS, p uintptr, addr int32, val int32) {
	(*TVdbeOp)(unsafe.Pointer(_sqlite3VdbeGetOp(tls, p, addr))).Fp2 = val
}

func _sqlite3VdbeChangeP3(tls *libc.TLS, p uintptr, addr int32, val int32) {
	(*TVdbeOp)(unsafe.Pointer(_sqlite3VdbeGetOp(tls, p, addr))).Fp3 = val
}

func _sqlite3VdbeCheckFkDeferred(tls *libc.TLS, p uintptr) (r int32) {
	var db uintptr
	_ = db
	db = (*TVdbe)(unsafe.Pointer(p)).Fdb
	if (*Tsqlite3)(unsafe.Pointer(db)).FnDeferredCons+(*Tsqlite3)(unsafe.Pointer(db)).FnDeferredImmCons == 0 {
		return SQLITE_OK
	}
	return _vdbeFkError(tls, p)
}

func _sqlite3VdbeCheckFkImmediate(tls *libc.TLS, p uintptr) (r int32) {
	if (*TVdbe)(unsafe.Pointer(p)).FnFkConstraint == 0 {
		return SQLITE_OK
	}
	return _vdbeFkError(tls, p)
}

func _sqlite3VdbeCloseStatement(tls *libc.TLS, p uintptr, eOp int32) (r int32) {
	if (*Tsqlite3)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).Fdb)).FnStatement != 0 && (*TVdbe)(unsafe.Pointer(p)).FiStatement != 0 {
		return _vdbeCloseStatement(tls, p, eOp)
	}
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Return the address of the next instruction to be inserted.
//	*/
func _sqlite3VdbeCurrentAddr(tls *libc.TLS, p uintptr) (r int32) {
	return (*TVdbe)(unsafe.Pointer(p)).FnOp
}

/*
** Verify that at least N opcode slots are available in p without
** having to malloc for more space (except when compiled using
** SQLITE_TEST_REALLOC_STRESS).  This interface is used during testing
** to verify that certain calls to sqlite3VdbeAddOpList() can never
** fail due to a OOM fault and hence that the return value from
** sqlite3VdbeAddOpList() will always be non-NULL.
 */

/*
** Verify that the VM passed as the only argument does not contain
** an OP_ResultRow opcode. Fail an assert() if it does. This is used
** by code in pragma.c to ensure that the implementation of certain
** pragmas comports with the flags specified in the mkpragmatab.tcl
** script.
 */

/*
** Generate code (a single OP_Abortable opcode) that will
** verify that the VDBE program can safely call Abort in the current
** context.
 */

// C documentation
//
//	/*
//	** Return the database associated with the Vdbe.
//	*/
func _sqlite3VdbeDb(tls *libc.TLS, v uintptr) (r uintptr) {
	return (*TVdbe)(unsafe.Pointer(v)).Fdb
}

// C documentation
//
//	/*
//	** Delete an entire VDBE.
//	*/
func _sqlite3VdbeDelete(tls *libc.TLS, p uintptr) {
	var db uintptr
	_ = db
	db = (*TVdbe)(unsafe.Pointer(p)).Fdb
	_sqlite3VdbeClearObject(tls, db, p)
	if (*Tsqlite3)(unsafe.Pointer(db)).FpnBytesFreed == uintptr(0) {
		**(**uintptr)(__ccgo_up((*TVdbe)(unsafe.Pointer(p)).FppVPrev)) = (*TVdbe)(unsafe.Pointer(p)).FpVNext
		if (*TVdbe)(unsafe.Pointer(p)).FpVNext != 0 {
			(*TVdbe)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(p)).FpVNext)).FppVPrev = (*TVdbe)(unsafe.Pointer(p)).FppVPrev
		}
	}
	_sqlite3DbNNFreeNN(tls, db, p)
}

// C documentation
//
//	/* Insert the end of a co-routine
//	*/
func _sqlite3VdbeEndCoroutine(tls *libc.TLS, v uintptr, regYield int32) {
	_sqlite3VdbeAddOp1(tls, v, int32(OP_EndCoroutine), regYield)
	/* Clear the temporary register cache, thereby ensuring that each
	 ** co-routine has its own independent set of registers, because co-routines
	 ** might expect their registers to be preserved across an OP_Yield, and
	 ** that could cause problems if two or more co-routines are using the same
	 ** temporary register.
	 */
	(*TParse)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(v)).FpParse)).FnTempReg = uint8(0)
	(*TParse)(unsafe.Pointer((*TVdbe)(unsafe.Pointer(v)).FpParse)).FnRangeReg = 0
}

// C documentation
//
//	/*
//	** Change the error string stored in Vdbe.zErrMsg
//	*/
func _sqlite3VdbeError(tls *libc.TLS, p uintptr, zFormat uintptr, va uintptr) {
	var ap Tva_list
	_ = ap
	_sqlite3DbFree(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, (*TVdbe)(unsafe.Pointer(p)).FzErrMsg)
	ap = va
	(*TVdbe)(unsafe.Pointer(p)).FzErrMsg = _sqlite3VMPrintf(tls, (*TVdbe)(unsafe.Pointer(p)).Fdb, zFormat, ap)
	_ = ap
}

// C documentation
//
//	/*
//	** Return the address of the current EXPLAIN QUERY PLAN baseline.
//	** 0 means "none".
//	*/
func _sqlite3VdbeExplainParent(tls *libc.TLS, pParse uintptr) (r int32) {
	var pOp uintptr
	_ = pOp
	if (*TParse)(unsafe.Pointer(pParse)).FaddrExplain == 0 {
		return 0
	}
	pOp = _sqlite3VdbeGetOp(tls, (*TParse)(unsafe.Pointer(pParse)).FpVdbe, (*TParse)(unsafe.Pointer(pParse)).FaddrExplain)
	return (*TVdbeOp)(unsafe.Pointer(pOp)).Fp2
}

/*
** Set a debugger breakpoint on the following routine in order to
** monitor the EXPLAIN QUERY PLAN code generation.
 */

// C documentation
//
//	/*
//	** Pop the EXPLAIN QUERY PLAN stack one level.
//	*/
func _sqlite3VdbeExplainPop(tls *libc.TLS, pParse uintptr) {
	(*TParse)(unsafe.Pointer(pParse)).FaddrExplain = _sqlite3VdbeExplainParent(tls, pParse)
}

// C documentation
//
//	/*
//	** This is a destructor on a Mem object (which is really an sqlite3_value)
//	** that deletes the Frame object that is attached to it as a blob.
//	**
//	** This routine does not delete the Frame right away.  It merely adds the
//	** frame to a list of frames to be deleted when the Vdbe halts.
//	*/
func _sqlite3VdbeFrameMemDel(tls *libc.TLS, pArg uintptr) {
	var pFrame uintptr
	_ = pFrame
	pFrame = pArg
	(*TVdbeFrame)(unsafe.Pointer(pFrame)).FpParent = (*TVdbe)(unsafe.Pointer((*TVdbeFrame)(unsafe.Pointer(pFrame)).Fv)).FpDelFrame
	(*TVdbe)(unsafe.Pointer((*TVdbeFrame)(unsafe.Pointer(pFrame)).Fv)).FpDelFrame = pFrame
}

// C documentation
//
//	/*
//	** Close a VDBE cursor and release all the resources that cursor
//	** happens to hold.
//	*/
func _sqlite3VdbeFreeCursor(tls *libc.TLS, p uintptr, pCx uintptr) {
	if pCx != 0 {
		_sqlite3VdbeFreeCursorNN(tls, p, pCx)
	}
}

// C documentation
//
//	/* Return the most recently added opcode
//	*/
func _sqlite3VdbeGetLastOp(tls *libc.TLS, p uintptr) (r uintptr) {
	return _sqlite3VdbeGetOp(tls, p, (*TVdbe)(unsafe.Pointer(p)).FnOp-int32(1))
}

// C documentation
//
//	/* Generate code for an unconditional jump to instruction iDest
//	*/
func _sqlite3VdbeGoto(tls *libc.TLS, p uintptr, iDest int32) (r int32) {
	return _sqlite3VdbeAddOp3(tls, p, int32(OP_Goto), 0, iDest, 0)
}

// C documentation
//
//	/*
//	** Return true if the given Vdbe has any SubPrograms.
//	*/
func _sqlite3VdbeHasSubProgram(tls *libc.TLS, pVdbe uintptr) (r int32) {
	return libc.BoolInt32((*TVdbe)(unsafe.Pointer(pVdbe)).FpProgram != uintptr(0))
}

// C documentation
//
//	/*
//	** Change the P2 operand of instruction addr so that it points to
//	** the address of the next instruction to be coded.
//	*/
func _sqlite3VdbeJumpHere(tls *libc.TLS, p uintptr, addr int32) {
	_sqlite3VdbeChangeP2(tls, p, addr, (*TVdbe)(unsafe.Pointer(p)).FnOp)
}

// C documentation
//
//	/*
//	** Change the P2 operand of the jump instruction at addr so that
//	** the jump lands on the next opcode.  Or if the jump instruction was
//	** the previous opcode (and is thus a no-op) then simply back up
//	** the next instruction counter by one slot so that the jump is
//	** overwritten by the next inserted opcode.
//	**
//	** This routine is an optimization of sqlite3VdbeJumpHere() that
//	** strives to omit useless byte-code like this:
//	**
//	**        7   Once 0 8 0
//	**        8   ...
//	*/
func _sqlite3VdbeJumpHereOrPopInst(tls *libc.TLS, p uintptr, addr int32) {
	if addr == (*TVdbe)(unsafe.Pointer(p)).FnOp-int32(1) {
		(*TVdbe)(unsafe.Pointer(p)).FnOp = (*TVdbe)(unsafe.Pointer(p)).FnOp - 1
	} else {
		_sqlite3VdbeChangeP2(tls, p, addr, (*TVdbe)(unsafe.Pointer(p)).FnOp)
	}
}

func _sqlite3VdbeLeave(tls *libc.TLS, p uintptr) {
	if (*TVdbe)(unsafe.Pointer(p)).FlockMask == uint32(0) {
		return
	} /* The common case */
	_vdbeLeave(tls, p)
}

// C documentation
//
//	/*
//	** Link the SubProgram object passed as the second argument into the linked
//	** list at Vdbe.pSubProgram. This list is used to delete all sub-program
//	** objects when the VM is no longer required.
//	*/
func _sqlite3VdbeLinkSubProgram(tls *libc.TLS, pVdbe uintptr, p uintptr) {
	(*TSubProgram)(unsafe.Pointer(p)).FpNext = (*TVdbe)(unsafe.Pointer(pVdbe)).FpProgram
	(*TVdbe)(unsafe.Pointer(pVdbe)).FpProgram = p
}

// C documentation
//
//	/* Generate code to cause the string zStr to be loaded into
//	** register iDest
//	*/
func _sqlite3VdbeLoadString(tls *libc.TLS, p uintptr, iDest int32, zStr uintptr) (r int32) {
	return _sqlite3VdbeAddOp4(tls, p, int32(OP_String8), 0, iDest, 0, zStr, 0)
}

// C documentation
//
//	/*
//	** Initialize bulk memory to be a consistent Mem object.
//	**
//	** The minimum amount of initialization feasible is performed.
//	*/
func _sqlite3VdbeMemInit(tls *libc.TLS, pMem uintptr, db uintptr, flags Tu16) {
	(*TMem)(unsafe.Pointer(pMem)).Fflags = flags
	(*TMem)(unsafe.Pointer(pMem)).Fdb = db
	(*TMem)(unsafe.Pointer(pMem)).FszMalloc = 0
}

// C documentation
//
//	/* Like sqlite3VdbeMemRelease() but faster for cases where we
//	** know in advance that the Mem is not MEM_Dyn or MEM_Agg.
//	*/
func _sqlite3VdbeMemReleaseMalloc(tls *libc.TLS, p uintptr) {
	if (*TMem)(unsafe.Pointer(p)).FszMalloc != 0 {
		_vdbeMemClear(tls, p)
	}
}

// C documentation
//
//	/*
//	** Delete any previous value and set the value stored in *pMem to val,
//	** manifest type REAL.
//	*/
func _sqlite3VdbeMemSetDouble(tls *libc.TLS, pMem uintptr, val float64) {
	_sqlite3VdbeMemSetNull(tls, pMem)
	if !(_sqlite3IsNaN(tls, val) != 0) {
		*(*float64)(unsafe.Pointer(pMem)) = val
		(*TMem)(unsafe.Pointer(pMem)).Fflags = uint16(MEM_Real)
	}
}

func _sqlite3VdbeOneByteSerialTypeLen(tls *libc.TLS, serial_type Tu8) (r Tu8) {
	return _sqlite3SmallTypeSizes[serial_type]
}

/*
** If we are on an architecture with mixed-endian floating
** points (ex: ARM7) then swap the lower 4 bytes with the
** upper 4 bytes.  Return the result.
**
** For most architectures, this is a no-op.
**
** (later):  It is reported to me that the mixed-endian problem
** on ARM7 is an issue with GCC, not with the ARM7 chip.  It seems
** that early versions of GCC stored the two words of a 64-bit
** float in the wrong order.  And that error has been propagated
** ever since.  The blame is not necessarily with GCC, though.
** GCC might have just copying the problem from a prior compiler.
** I am also told that newer versions of GCC that follow a different
** ABI get the byte order right.
**
** Developers using SQLite on an ARM7 should compile and run their
** application using -DSQLITE_DEBUG=1 at least once.  With DEBUG
** enabled, some asserts below will ensure that the byte order of
** floating point values is correct.
**
** (2007-08-30)  Frank van Vugt has studied this problem closely
** and has send his findings to the SQLite developers.  Frank
** writes that some Linux kernels offer floating point hardware
** emulation that uses only 32-bit mantissas instead of a full
** 48-bits as required by the IEEE standard.  (This is the
** CONFIG_FPE_FASTFPE option.)  On such systems, floating point
** byte swapping becomes very complicated.  To avoid problems,
** the necessary byte swapping is carried out using a 64-bit integer
** rather than a 64-bit float.  Frank assures us that the code here
** works for him.  We, the developers, have no way to independently
** verify this, but Frank seems to know what he is talking about
** so we trust him.
 */

/* Input "x" is a sequence of unsigned characters that represent a
** big-endian integer.  Return the equivalent native integer
 */

// C documentation
//
//	/*
//	** Given a wildcard parameter name, return the index of the variable
//	** with that name.  If there is no variable with the given name,
//	** return 0.
//	*/
func _sqlite3VdbeParameterIndex(tls *libc.TLS, p uintptr, zName uintptr, nName int32) (r int32) {
	if p == uintptr(0) || zName == uintptr(0) {
		return 0
	}
	return _sqlite3VListNameToNum(tls, (*TVdbe)(unsafe.Pointer(p)).FpVList, zName, nName)
}

// C documentation
//
//	/*
//	** Return the Parse object that owns a Vdbe object.
//	*/
func _sqlite3VdbeParser(tls *libc.TLS, p uintptr) (r uintptr) {
	return (*TVdbe)(unsafe.Pointer(p)).FpParse
}

// C documentation
//
//	/*
//	** Return the SQLITE_PREPARE flags for a Vdbe.
//	*/
func _sqlite3VdbePrepareFlags(tls *libc.TLS, v uintptr) (r Tu8) {
	return (*TVdbe)(unsafe.Pointer(v)).FprepFlags
}

func _sqlite3VdbeRecordCompare(tls *libc.TLS, nKey1 int32, pKey1 uintptr, pPKey2 uintptr) (r int32) {
	return _sqlite3VdbeRecordCompareWithSkip(tls, nKey1, pKey1, pPKey2, 0)
}

// C documentation
//
//	/*
//	** Each VDBE holds the result of the most recent sqlite3_step() call
//	** in p->rc.  This routine sets that result back to SQLITE_OK.
//	*/
func _sqlite3VdbeResetStepResult(tls *libc.TLS, p uintptr) {
	(*TVdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK
}

func _sqlite3VdbeResolveLabel(tls *libc.TLS, v uintptr, x int32) {
	var j int32
	var p uintptr
	_, _ = j, p
	p = (*TVdbe)(unsafe.Pointer(v)).FpParse
	j = ^x
	if (*TParse)(unsafe.Pointer(p)).FnLabelAlloc+(*TParse)(unsafe.Pointer(p)).FnLabel < 0 {
		_resizeResolveLabel(tls, p, v, j)
	} else {
		/* Labels may only be resolved once */
		**(**int32)(__ccgo_up((*TParse)(unsafe.Pointer(p)).FaLabel + uintptr(j)*4)) = (*TVdbe)(unsafe.Pointer(v)).FnOp
	}
}

// C documentation
//
//	/*
//	** Rewind the VDBE back to the beginning in preparation for
//	** running it.
//	*/
func _sqlite3VdbeRewind(tls *libc.TLS, p uintptr) {
	/* There should be at least one opcode.
	 */
	(*TVdbe)(unsafe.Pointer(p)).FeVdbeState = uint8(VDBE_READY_STATE)
	(*TVdbe)(unsafe.Pointer(p)).Fpc = -int32(1)
	(*TVdbe)(unsafe.Pointer(p)).Frc = SQLITE_OK
	(*TVdbe)(unsafe.Pointer(p)).FerrorAction = uint8(OE_Abort)
	(*TVdbe)(unsafe.Pointer(p)).FnChange = 0
	(*TVdbe)(unsafe.Pointer(p)).FcacheCtr = uint32(1)
	(*TVdbe)(unsafe.Pointer(p)).FminWriteFileFormat = uint8(255)
	(*TVdbe)(unsafe.Pointer(p)).FiStatement = 0
	(*TVdbe)(unsafe.Pointer(p)).FnFkConstraint = 0
}

// C documentation
//
//	/*
//	** Mark the VDBE as one that can only be run one time.
//	*/
func _sqlite3VdbeRunOnlyOnce(tls *libc.TLS, p uintptr) {
	_sqlite3VdbeAddOp2(tls, p, int32(OP_Expire), int32(1), int32(1))
}

// C documentation
//
//	/*
//	** Return the length of the data corresponding to the supplied serial-type.
//	*/
func _sqlite3VdbeSerialTypeLen(tls *libc.TLS, serial_type Tu32) (r Tu32) {
	if serial_type >= uint32(128) {
		return (serial_type - uint32(12)) / uint32(2)
	} else {
		return uint32(_sqlite3SmallTypeSizes[serial_type])
	}
	return r
}

// C documentation
//
//	/*
//	** Set the P4 on the most recently added opcode to the KeyInfo for the
//	** index given.
//	*/
func _sqlite3VdbeSetP4KeyInfo(tls *libc.TLS, pParse uintptr, pIdx uintptr) {
	var pKeyInfo, v uintptr
	_, _ = pKeyInfo, v
	v = (*TParse)(unsafe.Pointer(pParse)).FpVdbe
	pKeyInfo = _sqlite3KeyInfoOfIndex(tls, pParse, pIdx)
	if pKeyInfo != 0 {
		_sqlite3VdbeAppendP4(tls, v, pKeyInfo, -int32(9))
	}
}

// C documentation
//
//	/*
//	** This function returns a pointer to the array of opcodes associated with
//	** the Vdbe passed as the first argument. It is the callers responsibility
//	** to arrange for the returned array to be eventually freed using the
//	** vdbeFreeOpArray() function.
//	**
//	** Before returning, *pnOp is set to the number of entries in the returned
//	** array. Also, *pnMaxArg is set to the larger of its current value and
//	** the number of entries in the Vdbe.apArg[] array required to execute the
//	** returned program.
//	*/
func _sqlite3VdbeTakeOpArray(tls *libc.TLS, p uintptr, pnOp uintptr, pnMaxArg uintptr) (r uintptr) {
	var aOp uintptr
	_ = aOp
	aOp = (*TVdbe)(unsafe.Pointer(p)).FaOp
	/* Check that sqlite3VdbeUsesBtree() was not called on this VM */
	_resolveP2Values(tls, p, pnMaxArg)
	**(**int32)(__ccgo_up(pnOp)) = (*TVdbe)(unsafe.Pointer(p)).FnOp
	(*TVdbe)(unsafe.Pointer(p)).FaOp = uintptr(0)
	return aOp
}

// C documentation
//
//	/*
//	** Copy the error code and error message belonging to the VDBE passed
//	** as the first argument to its database handle (so that they will be
//	** returned by calls to sqlite3_errcode() and sqlite3_errmsg()).
//	**
//	** This function does not clear the VDBE error code or message, just
//	** copies them to the database handle.
//	*/
func _sqlite3VdbeTransferError(tls *libc.TLS, p uintptr) (r int32) {
	var db uintptr
	var rc int32
	_, _ = db, rc
	db = (*TVdbe)(unsafe.Pointer(p)).Fdb
	rc = (*TVdbe)(unsafe.Pointer(p)).Frc
	if (*TVdbe)(unsafe.Pointer(p)).FzErrMsg != 0 {
		(*Tsqlite3)(unsafe.Pointer(db)).FbBenignMalloc = (*Tsqlite3)(unsafe.Pointer(db)).FbBenignMalloc + 1
		_sqlite3BeginBenignMalloc(tls)
		if (*Tsqlite3)(unsafe.Pointer(db)).FpErr == uintptr(0) {
			(*Tsqlite3)(unsafe.Pointer(db)).FpErr = _sqlite3ValueNew(tls, db)
		}
		_sqlite3ValueSetStr(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr, -int32(1), (*TVdbe)(unsafe.Pointer(p)).FzErrMsg, uint8(SQLITE_UTF8), uintptr(-libc.Int32FromInt32(1)))
		_sqlite3EndBenignMalloc(tls)
		(*Tsqlite3)(unsafe.Pointer(db)).FbBenignMalloc = (*Tsqlite3)(unsafe.Pointer(db)).FbBenignMalloc - 1
	} else {
		if (*Tsqlite3)(unsafe.Pointer(db)).FpErr != 0 {
			_sqlite3ValueSetNull(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpErr)
		}
	}
	(*Tsqlite3)(unsafe.Pointer(db)).FerrCode = rc
	(*Tsqlite3)(unsafe.Pointer(db)).FerrByteOffset = -int32(1)
	return rc
}

// C documentation
//
//	/*
//	** The destructor function for a ValueList object.  This needs to be
//	** a separate function, unknowable to the application, to ensure that
//	** calls to sqlite3_vtab_in_first()/sqlite3_vtab_in_next() that are not
//	** preceded by activation of IN processing via sqlite3_vtab_int() do not
//	** try to access a fake ValueList object inserted by a hostile extension.
//	*/
func _sqlite3VdbeValueListFree(tls *libc.TLS, pToDelete uintptr) {
	Xsqlite3_free(tls, pToDelete)
}

// C documentation
//
//	/*
//	** The parser calls this routine when it sees the first token
//	** of an argument to the module name in a CREATE VIRTUAL TABLE statement.
//	*/
func _sqlite3VtabArgInit(tls *libc.TLS, pParse uintptr) {
	_addArgumentToVtab(tls, pParse)
	(*TParse)(unsafe.Pointer(pParse)).FsArg.Fz = uintptr(0)
	(*TParse)(unsafe.Pointer(pParse)).FsArg.Fn = uint32(0)
}

// C documentation
//
//	/*
//	** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored
//	** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored
//	** in memory obtained from sqlite3DbMalloc).
//	*/
func _sqlite3VtabImportErrmsg(tls *libc.TLS, p uintptr, pVtab uintptr) {
	var db uintptr
	_ = db
	if (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg != 0 {
		db = (*TVdbe)(unsafe.Pointer(p)).Fdb
		_sqlite3DbFree(tls, db, (*TVdbe)(unsafe.Pointer(p)).FzErrMsg)
		(*TVdbe)(unsafe.Pointer(p)).FzErrMsg = _sqlite3DbStrDup(tls, db, (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg)
		Xsqlite3_free(tls, (*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg)
		(*Tsqlite3_vtab)(unsafe.Pointer(pVtab)).FzErrMsg = uintptr(0)
	}
}

// C documentation
//
//	/*
//	** Lock the virtual table so that it cannot be disconnected.
//	** Locks nest.  Every lock should have a corresponding unlock.
//	** If an unlock is omitted, resources leaks will occur.
//	**
//	** If a disconnect is attempted while a virtual table is locked,
//	** the disconnect is deferred until all locks have been removed.
//	*/
func _sqlite3VtabLock(tls *libc.TLS, pVTab uintptr) {
	(*TVTable)(unsafe.Pointer(pVTab)).FnRef = (*TVTable)(unsafe.Pointer(pVTab)).FnRef + 1
}

// C documentation
//
//	/*
//	** Decrement the reference count on a Module object.  Destroy the
//	** module when the reference count reaches zero.
//	*/
func _sqlite3VtabModuleUnref(tls *libc.TLS, db uintptr, pMod uintptr) {
	(*TModule)(unsafe.Pointer(pMod)).FnRefModule = (*TModule)(unsafe.Pointer(pMod)).FnRefModule - 1
	if (*TModule)(unsafe.Pointer(pMod)).FnRefModule == 0 {
		if (*TModule)(unsafe.Pointer(pMod)).FxDestroy != 0 {
			(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TModule)(unsafe.Pointer(pMod)).FxDestroy})))(tls, (*TModule)(unsafe.Pointer(pMod)).FpAux)
		}
		_sqlite3DbFree(tls, db, pMod)
	}
}

// C documentation
//
//	/*
//	** Decrement the ref-count on a virtual table object. When the ref-count
//	** reaches zero, call the xDisconnect() method to delete the object.
//	*/
func _sqlite3VtabUnlock(tls *libc.TLS, pVTab uintptr) {
	var db, p uintptr
	_, _ = db, p
	db = (*TVTable)(unsafe.Pointer(pVTab)).Fdb
	(*TVTable)(unsafe.Pointer(pVTab)).FnRef = (*TVTable)(unsafe.Pointer(pVTab)).FnRef - 1
	if (*TVTable)(unsafe.Pointer(pVTab)).FnRef == 0 {
		p = (*TVTable)(unsafe.Pointer(pVTab)).FpVtab
		if p != 0 {
			(*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_module)(unsafe.Pointer((*Tsqlite3_vtab)(unsafe.Pointer(p)).FpModule)).FxDisconnect})))(tls, p)
		}
		_sqlite3VtabModuleUnref(tls, (*TVTable)(unsafe.Pointer(pVTab)).Fdb, (*TVTable)(unsafe.Pointer(pVTab)).FpMod)
		_sqlite3DbFree(tls, db, pVTab)
	}
}

// C documentation
//
//	/*
//	** Disconnect all the virtual table objects in the sqlite3.pDisconnect list.
//	**
//	** This function may only be called when the mutexes associated with all
//	** shared b-tree databases opened using connection db are held by the
//	** caller. This is done to protect the sqlite3.pDisconnect list. The
//	** sqlite3.pDisconnect list is accessed only as follows:
//	**
//	**   1) By this function. In this case, all BtShared mutexes and the mutex
//	**      associated with the database handle itself must be held.
//	**
//	**   2) By function vtabDisconnectAll(), when it adds a VTable entry to
//	**      the sqlite3.pDisconnect list. In this case either the BtShared mutex
//	**      associated with the database the virtual table is stored in is held
//	**      or, if the virtual table is stored in a non-sharable database, then
//	**      the database handle mutex is held.
//	**
//	** As a result, a sqlite3.pDisconnect cannot be accessed simultaneously
//	** by multiple threads. It is thread-safe.
//	*/
func _sqlite3VtabUnlockList(tls *libc.TLS, db uintptr) {
	var p, pNext uintptr
	_, _ = p, pNext
	p = (*Tsqlite3)(unsafe.Pointer(db)).FpDisconnect
	if p != 0 {
		(*Tsqlite3)(unsafe.Pointer(db)).FpDisconnect = uintptr(0)
		for cond := true; cond; cond = p != 0 {
			pNext = (*TVTable)(unsafe.Pointer(p)).FpNext
			_sqlite3VtabUnlock(tls, p)
			p = pNext
		}
	}
}

// C documentation
//
//	/*
//	** Cause the prepared statement that is associated with a call to
//	** xBestIndex to potentially use all schemas.  If the statement being
//	** prepared is read-only, then just start read transactions on all
//	** schemas.  But if this is a write operation, start writes on all
//	** schemas.
//	**
//	** This is used by the (built-in) sqlite_dbpage virtual table.
//	*/
func _sqlite3VtabUsesAllSchemas(tls *libc.TLS, pParse uintptr) {
	var i, nDb int32
	_, _ = i, nDb
	nDb = (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).FnDb
	i = 0
	for {
		if !(i < nDb) {
			break
		}
		_sqlite3CodeVerifySchema(tls, pParse, i)
		goto _1
	_1:
		;
		i = i + 1
	}
	if (*TParse)(unsafe.Pointer(pParse)).FwriteMask != uint32(0) {
		i = 0
		for {
			if !(i < nDb) {
				break
			}
			_sqlite3BeginWriteOperation(tls, pParse, 0, i)
			goto _2
		_2:
			;
			i = i + 1
		}
	}
}

// C documentation
//
//	/*
//	** Begin a read transaction on the database.
//	**
//	** This routine used to be called sqlite3OpenSnapshot() and with good reason:
//	** it takes a snapshot of the state of the WAL and wal-index for the current
//	** instant in time.  The current thread will continue to use this snapshot.
//	** Other threads might append new content to the WAL and wal-index but
//	** that extra content is ignored by the current thread.
//	**
//	** If the database contents have changes since the previous read
//	** transaction, then *pChanged is set to 1 before returning.  The
//	** Pager layer will use this to know that its cache is stale and
//	** needs to be flushed.
//	*/
func _sqlite3WalBeginReadTransaction(tls *libc.TLS, pWal uintptr, pChanged uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = _walBeginReadTransaction(tls, pWal, pChanged)
	return rc
}

// C documentation
//
//	/*
//	** Return the size of the database in pages (or zero, if unknown).
//	*/
func _sqlite3WalDbsize(tls *libc.TLS, pWal uintptr) (r TPgno) {
	if pWal != 0 && int32((*TWal)(unsafe.Pointer(pWal)).FreadLock) >= 0 {
		return (*TWal)(unsafe.Pointer(pWal)).Fhdr.FnPage
	}
	return uint32(0)
}

// C documentation
//
//	/*
//	** Finish with a read transaction.  All this does is release the
//	** read-lock.
//	*/
func _sqlite3WalEndReadTransaction(tls *libc.TLS, pWal uintptr) {
	if int32((*TWal)(unsafe.Pointer(pWal)).FreadLock) >= 0 {
		_sqlite3WalEndWriteTransaction(tls, pWal)
		_walUnlockShared(tls, pWal, int32(3)+int32((*TWal)(unsafe.Pointer(pWal)).FreadLock))
		(*TWal)(unsafe.Pointer(pWal)).FreadLock = int16(-int32(1))
	}
}

// C documentation
//
//	/*
//	** End a write transaction.  The commit has already been done.  This
//	** routine merely releases the lock.
//	*/
func _sqlite3WalEndWriteTransaction(tls *libc.TLS, pWal uintptr) (r int32) {
	if (*TWal)(unsafe.Pointer(pWal)).FwriteLock != 0 {
		_walUnlockExclusive(tls, pWal, WAL_WRITE_LOCK, int32(1))
		(*TWal)(unsafe.Pointer(pWal)).FwriteLock = uint8(0)
		(*TWal)(unsafe.Pointer(pWal)).FiReCksum = uint32(0)
		(*TWal)(unsafe.Pointer(pWal)).FtruncateOnCommit = uint8(0)
	}
	return SQLITE_OK
}

// C documentation
//
//	/* Return the sqlite3_file object for the WAL file
//	*/
func _sqlite3WalFile(tls *libc.TLS, pWal uintptr) (r uintptr) {
	return (*TWal)(unsafe.Pointer(pWal)).FpWalFd
}

/************** End of wal.c *************************************************/
/************** Begin file btmutex.c *****************************************/
/*
** 2007 August 27
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains code used to implement mutexes on Btree objects.
** This code really belongs in btree.c.  But btree.c is getting too
** big and we want to break it down some.  This packaged seemed like
** a good breakout.
 */
/************** Include btreeInt.h in the middle of btmutex.c ****************/
/************** Begin file btreeInt.h ****************************************/
/*
** 2004 April 6
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file implements an external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
**
**     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:
**     "Sorting And Searching", pages 473-480. Addison-Wesley
**     Publishing Company, Reading, Massachusetts.
**
** The basic idea is that each page of the file contains N database
** entries and N+1 pointers to subpages.
**
**   ----------------------------------------------------------------
**   |  Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N-1) | Ptr(N) |
**   ----------------------------------------------------------------
**
** All of the keys on the page that Ptr(0) points to have values less
** than Key(0).  All of the keys on page Ptr(1) and its subpages have
** values greater than Key(0) and less than Key(1).  All of the keys
** on Ptr(N) and its subpages have values greater than Key(N-1).  And
** so forth.
**
** Finding a particular key requires reading O(log(M)) pages from the
** disk where M is the number of entries in the tree.
**
** In this implementation, a single file can hold one or more separate
** BTrees.  Each BTree is identified by the index of its root page.  The
** key and data for any entry are combined to form the "payload".  A
** fixed amount of payload can be carried directly on the database
** page.  If the payload is larger than the preset amount then surplus
** bytes are stored on overflow pages.  The payload for an entry
** and the preceding pointer are combined to form a "Cell".  Each
** page has a small header which contains the Ptr(N) pointer and other
** information such as the size of key and data.
**
** FORMAT DETAILS
**
** The file is divided into pages.  The first page is called page 1,
** the second is page 2, and so forth.  A page number of zero indicates
** "no such page".  The page size can be any power of 2 between 512 and 65536.
** Each page can be either a btree page, a freelist page, an overflow
** page, or a pointer-map page.
**
** The first page is always a btree page.  The first 100 bytes of the first
** page contain a special header (the "file header") that describes the file.
** The format of the file header is as follows:
**
**   OFFSET   SIZE    DESCRIPTION
**      0      16     Header string: "SQLite format 3\000"
**     16       2     Page size in bytes.  (1 means 65536)
**     18       1     File format write version
**     19       1     File format read version
**     20       1     Bytes of unused space at the end of each page
**     21       1     Max embedded payload fraction (must be 64)
**     22       1     Min embedded payload fraction (must be 32)
**     23       1     Min leaf payload fraction (must be 32)
**     24       4     File change counter
**     28       4     The size of the database in pages
**     32       4     First freelist page
**     36       4     Number of freelist pages in the file
**     40      60     15 4-byte meta values passed to higher layers
**
**     40       4     Schema cookie
**     44       4     File format of schema layer
**     48       4     Size of page cache
**     52       4     Largest root-page (auto/incr_vacuum)
**     56       4     1=UTF-8 2=UTF16le 3=UTF16be
**     60       4     User version
**     64       4     Incremental vacuum mode
**     68       4     Application-ID
**     72      20     unused
**     92       4     The version-valid-for number
**     96       4     SQLITE_VERSION_NUMBER
**
** All of the integer values are big-endian (most significant byte first).
**
** The file change counter is incremented when the database is changed
** This counter allows other processes to know when the file has changed
** and thus when they need to flush their cache.
**
** The max embedded payload fraction is the amount of the total usable
** space in a page that can be consumed by a single cell for standard
** B-tree (non-LEAFDATA) tables.  A value of 255 means 100%.  The default
** is to limit the maximum cell size so that at least 4 cells will fit
** on one page.  Thus the default max embedded payload fraction is 64.
**
** If the payload for a cell is larger than the max payload, then extra
** payload is spilled to overflow pages.  Once an overflow page is allocated,
** as many bytes as possible are moved into the overflow pages without letting
** the cell size drop below the min embedded payload fraction.
**
** The min leaf payload fraction is like the min embedded payload fraction
** except that it applies to leaf nodes in a LEAFDATA tree.  The maximum
** payload fraction for a LEAFDATA tree is always 100% (or 255) and it
** not specified in the header.
**
** Each btree pages is divided into three sections:  The header, the
** cell pointer array, and the cell content area.  Page 1 also has a 100-byte
** file header that occurs before the page header.
**
**      |----------------|
**      | file header    |   100 bytes.  Page 1 only.
**      |----------------|
**      | page header    |   8 bytes for leaves.  12 bytes for interior nodes
**      |----------------|
**      | cell pointer   |   |  2 bytes per cell.  Sorted order.
**      | array          |   |  Grows downward
**      |                |   v
**      |----------------|
**      | unallocated    |
**      | space          |
**      |----------------|   ^  Grows upwards
**      | cell content   |   |  Arbitrary order interspersed with freeblocks.
**      | area           |   |  and free space fragments.
**      |----------------|
**
** The page headers looks like this:
**
**   OFFSET   SIZE     DESCRIPTION
**      0       1      Flags. 1: intkey, 2: zerodata, 4: leafdata, 8: leaf
**      1       2      byte offset to the first freeblock
**      3       2      number of cells on this page
**      5       2      first byte of the cell content area
**      7       1      number of fragmented free bytes
**      8       4      Right child (the Ptr(N) value).  Omitted on leaves.
**
** The flags define the format of this btree page.  The leaf flag means that
** this page has no children.  The zerodata flag means that this page carries
** only keys and no data.  The intkey flag means that the key is an integer
** which is stored in the key size entry of the cell header rather than in
** the payload area.
**
** The cell pointer array begins on the first byte after the page header.
** The cell pointer array contains zero or more 2-byte numbers which are
** offsets from the beginning of the page to the cell content in the cell
** content area.  The cell pointers occur in sorted order.  The system strives
** to keep free space after the last cell pointer so that new cells can
** be easily added without having to defragment the page.
**
** Cell content is stored at the very end of the page and grows toward the
** beginning of the page.
**
** Unused space within the cell content area is collected into a linked list of
** freeblocks.  Each freeblock is at least 4 bytes in size.  The byte offset
** to the first freeblock is given in the header.  Freeblocks occur in
** increasing order.  Because a freeblock must be at least 4 bytes in size,
** any group of 3 or fewer unused bytes in the cell content area cannot
** exist on the freeblock chain.  A group of 3 or fewer free bytes is called
** a fragment.  The total number of bytes in all fragments is recorded.
** in the page header at offset 7.
**
**    SIZE    DESCRIPTION
**      2     Byte offset of the next freeblock
**      2     Bytes in this freeblock
**
** Cells are of variable length.  Cells are stored in the cell content area at
** the end of the page.  Pointers to the cells are in the cell pointer array
** that immediately follows the page header.  Cells is not necessarily
** contiguous or in order, but cell pointers are contiguous and in order.
**
** Cell content makes use of variable length integers.  A variable
** length integer is 1 to 9 bytes where the lower 7 bits of each
** byte are used.  The integer consists of all bytes that have bit 8 set and
** the first byte with bit 8 clear.  The most significant byte of the integer
** appears first.  A variable-length integer may not be more than 9 bytes long.
** As a special case, all 8 bits of the 9th byte are used as data.  This
** allows a 64-bit integer to be encoded in 9 bytes.
**
**    0x00                      becomes  0x00000000
**    0x7f                      becomes  0x0000007f
**    0x81 0x00                 becomes  0x00000080
**    0x82 0x00                 becomes  0x00000100
**    0x80 0x7f                 becomes  0x0000007f
**    0x81 0x91 0xd1 0xac 0x78  becomes  0x12345678
**    0x81 0x81 0x81 0x81 0x01  becomes  0x10204081
**
** Variable length integers are used for rowids and to hold the number of
** bytes of key and data in a btree cell.
**
** The content of a cell looks like this:
**
**    SIZE    DESCRIPTION
**      4     Page number of the left child. Omitted if leaf flag is set.
**     var    Number of bytes of data. Omitted if the zerodata flag is set.
**     var    Number of bytes of key. Or the key itself if intkey flag is set.
**      *     Payload
**      4     First page of the overflow chain.  Omitted if no overflow
**
** Overflow pages form a linked list.  Each page except the last is completely
** filled with data (pagesize - 4 bytes).  The last page can have as little
** as 1 byte of data.
**
**    SIZE    DESCRIPTION
**      4     Page number of next overflow page
**      *     Data
**
** Freelist pages come in two subtypes: trunk pages and leaf pages.  The
** file header points to the first in a linked list of trunk page.  Each trunk
** page points to multiple leaf pages.  The content of a leaf page is
** unspecified.  A trunk page looks like this:
**
**    SIZE    DESCRIPTION
**      4     Page number of next trunk page
**      4     Number of leaf pointers on this page
**      *     zero or more pages numbers of leaves
 */
/* #include "sqliteInt.h" */

/* The following value is the maximum cell size assuming a maximum page
** size give above.
 */

/* The maximum number of cells on a single page of the database.  This
** assumes a minimum cell size of 6 bytes  (4 bytes for the cell itself
** plus 2 bytes for the index to the cell in the page header).  Such
** small cells will be rare, but they are possible.
 */

// C documentation
//
//	/*
//	** Search the wal file for page pgno. If found, set *piRead to the frame that
//	** contains the page. Otherwise, if pgno is not in the wal file, set *piRead
//	** to zero.
//	**
//	** Return SQLITE_OK if successful, or an error code if an error occurs. If an
//	** error does occur, the final value of *piRead is undefined.
//	**
//	** The difference between this function and walFindFrame() is that this
//	** function wraps walFindFrame() in an SEH_TRY{...} block.
//	*/
func _sqlite3WalFindFrame(tls *libc.TLS, pWal uintptr, pgno TPgno, piRead uintptr) (r int32) {
	var rc int32
	_ = rc
	rc = _walFindFrame(tls, pWal, pgno, piRead)
	return rc
}

// C documentation
//
//	/*
//	** Write a set of frames to the log. The caller must hold the write-lock
//	** on the log file (obtained using sqlite3WalBeginWriteTransaction()).
//	**
//	** The difference between this function and walFrames() is that this
//	** function wraps walFrames() in an SEH_TRY{...} block.
//	*/
func _sqlite3WalFrames(tls *libc.TLS, pWal uintptr, szPage int32, pList uintptr, nTruncate TPgno, isCommit int32, sync_flags int32) (r int32) {
	var rc int32
	_ = rc
	rc = _walFrames(tls, pWal, szPage, pList, nTruncate, isCommit, sync_flags)
	return rc
}

// C documentation
//
//	/*
//	** Change the size to which the WAL file is truncated on each reset.
//	*/
func _sqlite3WalLimit(tls *libc.TLS, pWal uintptr, iLimit Ti64) {
	if pWal != 0 {
		(*TWal)(unsafe.Pointer(pWal)).FmxWalSize = iLimit
	}
}

// C documentation
//
//	/* Try to open on pSnapshot when the next read-transaction starts
//	*/
func _sqlite3WalSnapshotOpen(tls *libc.TLS, pWal uintptr, pSnapshot uintptr) {
	if pSnapshot != 0 && (*TWalIndexHdr)(unsafe.Pointer(pSnapshot)).FiVersion == uint32(0) {
		/* iVersion==0 means that this is a call to sqlite3_snapshot_get().  In
		 ** this case set the bGetSnapshot flag so that if the call to
		 ** sqlite3_snapshot_get() is about to read transaction on this wal
		 ** file, it does not take read-lock 0 if the wal file has been completely
		 ** checkpointed. Taking read-lock 0 would work, but then it would be
		 ** possible for a subsequent writer to destroy the snapshot even while
		 ** this connection is holding its read-transaction open. This is contrary
		 ** to user expectations, so we avoid it by not taking read-lock 0. */
		(*TWal)(unsafe.Pointer(pWal)).FbGetSnapshot = int32(1)
	} else {
		(*TWal)(unsafe.Pointer(pWal)).FpSnapshot = pSnapshot
		(*TWal)(unsafe.Pointer(pWal)).FbGetSnapshot = 0
	}
}

// C documentation
//
//	/*
//	** Release a lock obtained by an earlier successful call to
//	** sqlite3WalSnapshotCheck().
//	*/
func _sqlite3WalSnapshotUnlock(tls *libc.TLS, pWal uintptr) {
	_walUnlockShared(tls, pWal, int32(WAL_CKPT_LOCK))
}

func _sqlite3WalkExpr(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) {
	var v1 int32
	_ = v1
	if pExpr != 0 {
		v1 = _sqlite3WalkExprNN(tls, pWalker, pExpr)
	} else {
		v1 = WRC_Continue
	}
	return v1
}

// C documentation
//
//	/*
//	** Call sqlite3WalkExpr() for every expression in Select statement p.
//	** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and
//	** on the compound select chain, p->pPrior.
//	**
//	** If it is not NULL, the xSelectCallback() callback is invoked before
//	** the walk of the expressions and FROM clause. The xSelectCallback2()
//	** method is invoked following the walk of the expressions and FROM clause,
//	** but only if both xSelectCallback and xSelectCallback2 are both non-NULL
//	** and if the expressions and FROM clause both return WRC_Continue;
//	**
//	** Return WRC_Continue under normal conditions.  Return WRC_Abort if
//	** there is an abort request.
//	**
//	** If the Walker does not have an xSelectCallback() then this routine
//	** is a no-op returning WRC_Continue.
//	*/
func _sqlite3WalkSelect(tls *libc.TLS, pWalker uintptr, p uintptr) (r int32) {
	var rc int32
	_ = rc
	if p == uintptr(0) {
		return WRC_Continue
	}
	if (*TWalker)(unsafe.Pointer(pWalker)).FxSelectCallback == uintptr(0) {
		return WRC_Continue
	}
	for cond := true; cond; cond = p != uintptr(0) {
		rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*TWalker)(unsafe.Pointer(pWalker)).FxSelectCallback})))(tls, pWalker, p)
		if rc != 0 {
			return rc & int32(WRC_Abort)
		}
		if _sqlite3WalkSelectExpr(tls, pWalker, p) != 0 || _sqlite3WalkSelectFrom(tls, pWalker, p) != 0 {
			return int32(WRC_Abort)
		}
		if (*TWalker)(unsafe.Pointer(pWalker)).FxSelectCallback2 != 0 {
			(*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TWalker)(unsafe.Pointer(pWalker)).FxSelectCallback2})))(tls, pWalker, p)
		}
		p = (*TSelect)(unsafe.Pointer(p)).FpPrior
	}
	return WRC_Continue
}

// C documentation
//
//	/*
//	** This is a no-op callback for Walker->xSelectCallback2.  If this
//	** callback is set, then the Select->pWinDefn list is traversed.
//	*/
func _sqlite3WalkWinDefnDummyCallback(tls *libc.TLS, pWalker uintptr, p uintptr) {
	_ = pWalker
	_ = p
	/* No-op */
}

func _sqlite3WalkerDepthDecrease(tls *libc.TLS, pWalker uintptr, pSelect uintptr) {
	_ = pSelect
	(*TWalker)(unsafe.Pointer(pWalker)).FwalkerDepth = (*TWalker)(unsafe.Pointer(pWalker)).FwalkerDepth - 1
}

// C documentation
//
//	/* Increase the walkerDepth when entering a subquery, and
//	** decrease when leaving the subquery.
//	*/
func _sqlite3WalkerDepthIncrease(tls *libc.TLS, pWalker uintptr, pSelect uintptr) (r int32) {
	_ = pSelect
	(*TWalker)(unsafe.Pointer(pWalker)).FwalkerDepth = (*TWalker)(unsafe.Pointer(pWalker)).FwalkerDepth + 1
	return WRC_Continue
}

// C documentation
//
//	/*
//	** Return the VDBE address or label to jump to in order to break
//	** out of a WHERE loop.
//	*/
func _sqlite3WhereBreakLabel(tls *libc.TLS, pWInfo uintptr) (r int32) {
	return (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiBreak
}

// C documentation
//
//	/*
//	** Return the VDBE address or label to jump to in order to continue
//	** immediately with the next row of a WHERE clause.
//	*/
func _sqlite3WhereContinueLabel(tls *libc.TLS, pWInfo uintptr) (r int32) {
	return (*TWhereInfo)(unsafe.Pointer(pWInfo)).FiContinue
}

// C documentation
//
//	/*
//	** Call exprAnalyze on all terms in a WHERE clause.
//	**
//	** Note that exprAnalyze() might add new virtual terms onto the
//	** end of the WHERE clause.  We do not want to analyze these new
//	** virtual terms, so start analyzing at the end and work forward
//	** so that the added virtual terms are never processed.
//	*/
func _sqlite3WhereExprAnalyze(tls *libc.TLS, pTabList uintptr, pWC uintptr) {
	var i int32
	_ = i
	i = (*TWhereClause)(unsafe.Pointer(pWC)).FnTerm - int32(1)
	for {
		if !(i >= 0) {
			break
		}
		_exprAnalyze(tls, pTabList, pWC, i)
		goto _1
	_1:
		;
		i = i - 1
	}
}

func _sqlite3WhereExprUsage(tls *libc.TLS, pMaskSet uintptr, p uintptr) (r TBitmask) {
	var v1 uint64
	_ = v1
	if p != 0 {
		v1 = _sqlite3WhereExprUsageNN(tls, pMaskSet, p)
	} else {
		v1 = uint64(0)
	}
	return v1
}

// C documentation
//
//	/*
//	** Return the bitmask for the given cursor number.  Return 0 if
//	** iCursor is not in the set.
//	*/
func _sqlite3WhereGetMask(tls *libc.TLS, pMaskSet uintptr, iCursor int32) (r TBitmask) {
	var i int32
	_ = i
	if **(**int32)(__ccgo_up(pMaskSet + 8)) == iCursor {
		return uint64(1)
	}
	i = int32(1)
	for {
		if !(i < (*TWhereMaskSet)(unsafe.Pointer(pMaskSet)).Fn) {
			break
		}
		if **(**int32)(__ccgo_up(pMaskSet + 8 + uintptr(i)*4)) == iCursor {
			return libc.Uint64FromInt32(1) << i
		}
		goto _1
	_1:
		;
		i = i + 1
	}
	return uint64(0)
}

// C documentation
//
//	/*
//	** Return the number of ORDER BY terms that are satisfied by the
//	** WHERE clause.  A return of 0 means that the output must be
//	** completely sorted.  A return equal to the number of ORDER BY
//	** terms means that no sorting is needed at all.  A return that
//	** is positive but less than the number of ORDER BY terms means that
//	** block sorting is required.
//	*/
func _sqlite3WhereIsOrdered(tls *libc.TLS, pWInfo uintptr) (r int32) {
	var v1 int32
	_ = v1
	if int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat) < 0 {
		v1 = 0
	} else {
		v1 = int32((*TWhereInfo)(unsafe.Pointer(pWInfo)).FnOBSat)
	}
	return v1
}

// C documentation
//
//	/*
//	** Return the estimated number of output rows from a WHERE clause
//	*/
func _sqlite3WhereOutputRowCount(tls *libc.TLS, pWInfo uintptr) (r TLogEst) {
	return (*TWhereInfo)(unsafe.Pointer(pWInfo)).FnRowOut
}

var _sqlite3WhereTrace = uint32(0)

// C documentation
//
//	/*
//	** Attach PARTITION and ORDER BY clauses pPartition and pOrderBy to window
//	** pWin. Also, if parameter pBase is not NULL, set pWin->zBase to the
//	** equivalent nul-terminated string.
//	*/
func _sqlite3WindowAssemble(tls *libc.TLS, pParse uintptr, pWin uintptr, pPartition uintptr, pOrderBy uintptr, pBase uintptr) (r uintptr) {
	if pWin != 0 {
		(*TWindow)(unsafe.Pointer(pWin)).FpPartition = pPartition
		(*TWindow)(unsafe.Pointer(pWin)).FpOrderBy = pOrderBy
		if pBase != 0 {
			(*TWindow)(unsafe.Pointer(pWin)).FzBase = _sqlite3DbStrNDup(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TToken)(unsafe.Pointer(pBase)).Fz, uint64((*TToken)(unsafe.Pointer(pBase)).Fn))
		}
	} else {
		_sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pPartition)
		_sqlite3ExprListDelete(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pOrderBy)
	}
	return pWin
}

// C documentation
//
//	/*
//	** Free the Window object passed as the second argument.
//	*/
func _sqlite3WindowDelete(tls *libc.TLS, db uintptr, p uintptr) {
	if p != 0 {
		_sqlite3WindowUnlinkFromSelect(tls, p)
		_sqlite3ExprDelete(tls, db, (*TWindow)(unsafe.Pointer(p)).FpFilter)
		_sqlite3ExprListDelete(tls, db, (*TWindow)(unsafe.Pointer(p)).FpPartition)
		_sqlite3ExprListDelete(tls, db, (*TWindow)(unsafe.Pointer(p)).FpOrderBy)
		_sqlite3ExprDelete(tls, db, (*TWindow)(unsafe.Pointer(p)).FpEnd)
		_sqlite3ExprDelete(tls, db, (*TWindow)(unsafe.Pointer(p)).FpStart)
		_sqlite3DbFree(tls, db, (*TWindow)(unsafe.Pointer(p)).FzName)
		_sqlite3DbFree(tls, db, (*TWindow)(unsafe.Pointer(p)).FzBase)
		_sqlite3DbFree(tls, db, p)
	}
}

// C documentation
//
//	/*
//	** Free the linked list of Window objects starting at the second argument.
//	*/
func _sqlite3WindowListDelete(tls *libc.TLS, db uintptr, p uintptr) {
	var pNext uintptr
	_ = pNext
	for p != 0 {
		pNext = (*TWindow)(unsafe.Pointer(p)).FpNextWin
		_sqlite3WindowDelete(tls, db, p)
		p = pNext
	}
}

// C documentation
//
//	/*
//	** Unlink the Window object from the Select to which it is attached,
//	** if it is attached.
//	*/
func _sqlite3WindowUnlinkFromSelect(tls *libc.TLS, p uintptr) {
	if (*TWindow)(unsafe.Pointer(p)).FppThis != 0 {
		**(**uintptr)(__ccgo_up((*TWindow)(unsafe.Pointer(p)).FppThis)) = (*TWindow)(unsafe.Pointer(p)).FpNextWin
		if (*TWindow)(unsafe.Pointer(p)).FpNextWin != 0 {
			(*TWindow)(unsafe.Pointer((*TWindow)(unsafe.Pointer(p)).FpNextWin)).FppThis = (*TWindow)(unsafe.Pointer(p)).FppThis
		}
		(*TWindow)(unsafe.Pointer(p)).FppThis = uintptr(0)
	}
}

func _sqlite3WithDeleteGeneric(tls *libc.TLS, db uintptr, pWith uintptr) {
	_sqlite3WithDelete(tls, db, pWith)
}

/************** End of build.c ***********************************************/
/************** Begin file callback.c ****************************************/
/*
** 2005 May 23
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains functions used to access the internal hash tables
** of user defined functions and collation sequences.
 */

/* #include "sqliteInt.h" */

// C documentation
//
//	/* The code generator maintains a stack of active WITH clauses
//	** with the inner-most WITH clause being at the top of the stack.
//	**
//	** This routine pushes the WITH clause passed as the second argument
//	** onto the top of the stack. If argument bFree is true, then this
//	** WITH clause will never be popped from the stack but should instead
//	** be freed along with the Parse object. In other cases, when
//	** bFree==0, the With object will be freed along with the SELECT
//	** statement with which it is associated.
//	**
//	** This routine returns a copy of pWith.  Or, if bFree is true and
//	** the pWith object is destroyed immediately due to an OOM condition,
//	** then this routine return NULL.
//	**
//	** If bFree is true, do not continue to use the pWith pointer after
//	** calling this routine,  Instead, use only the return value.
//	*/
func _sqlite3WithPush(tls *libc.TLS, pParse uintptr, pWith uintptr, bFree Tu8) (r uintptr) {
	if pWith != 0 {
		if bFree != 0 {
			pWith = _sqlite3ParserAddCleanup(tls, pParse, __ccgo_fp(_sqlite3WithDeleteGeneric), pWith)
			if pWith == uintptr(0) {
				return uintptr(0)
			}
		}
		if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 {
			(*TWith)(unsafe.Pointer(pWith)).FpOuter = (*TParse)(unsafe.Pointer(pParse)).FpWith
			(*TParse)(unsafe.Pointer(pParse)).FpWith = pWith
		}
	}
	return pWith
}

var _sqlite3aEQb = uintptr(unsafe.Pointer(&_sqlite3UpperToLower)) + uintptr(libc.Int32FromInt32(256)+libc.Int32FromInt32(6)-libc.Int32FromInt32(OP_Ne))

var _sqlite3aGTb = uintptr(unsafe.Pointer(&_sqlite3UpperToLower)) + uintptr(libc.Int32FromInt32(256)+libc.Int32FromInt32(12)-libc.Int32FromInt32(OP_Ne))

var _sqlite3aLTb = uintptr(unsafe.Pointer(&_sqlite3UpperToLower)) + uintptr(libc.Int32FromInt32(256)-libc.Int32FromInt32(OP_Ne))

// C documentation
//
//	/*
//	** Close a DBSTAT cursor.
//	*/
func _statClose(tls *libc.TLS, pCursor uintptr) (r int32) {
	var pCsr uintptr
	_ = pCsr
	pCsr = pCursor
	_statResetCsr(tls, pCsr)
	Xsqlite3_finalize(tls, (*TStatCursor)(unsafe.Pointer(pCsr)).FpStmt)
	Xsqlite3_free(tls, pCsr)
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Disconnect from or destroy the DBSTAT virtual table.
//	*/
func _statDisconnect(tls *libc.TLS, pVtab uintptr) (r int32) {
	Xsqlite3_free(tls, pVtab)
	return SQLITE_OK
}

// C documentation
//
//	/* Resize the space-used counters inside of the cursor */
func _statResetCounts(tls *libc.TLS, pCsr uintptr) {
	(*TStatCursor)(unsafe.Pointer(pCsr)).FnCell = 0
	(*TStatCursor)(unsafe.Pointer(pCsr)).FnMxPayload = 0
	(*TStatCursor)(unsafe.Pointer(pCsr)).FnUnused = 0
	(*TStatCursor)(unsafe.Pointer(pCsr)).FnPayload = 0
	(*TStatCursor)(unsafe.Pointer(pCsr)).FszPage = 0
	(*TStatCursor)(unsafe.Pointer(pCsr)).FnPage = 0
}

func _subjournalPageIfRequired(tls *libc.TLS, pPg uintptr) (r int32) {
	if _subjRequiresPage(tls, pPg) != 0 {
		return _subjournalPage(tls, pPg)
	} else {
		return SQLITE_OK
	}
	return r
}

// C documentation
//
//	/*
//	** Return a pointer to the Table structure for the table that a trigger
//	** is set on.
//	*/
func _tableOfTrigger(tls *libc.TLS, pTrigger uintptr) (r uintptr) {
	return _sqlite3HashFind(tls, (*TTrigger)(unsafe.Pointer(pTrigger)).FpTabSchema+8, (*TTrigger)(unsafe.Pointer(pTrigger)).Ftable)
}

// C documentation
//
//	/*
//	** Should table pTab be skipped when doing an integrity_check?
//	** Return true or false.
//	**
//	** If pObjTab is not null, the return true if pTab matches pObjTab.
//	**
//	** If pObjTab is null, then return true only if pTab is an imposter table.
//	*/
func _tableSkipIntegrityCheck(tls *libc.TLS, pTab uintptr, pObjTab uintptr) (r int32) {
	if pObjTab != 0 {
		return libc.BoolInt32(pTab != pObjTab)
	} else {
		return libc.BoolInt32((*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Imposter) != uint32(0))
	}
	return r
}

func _totalFinalize(tls *libc.TLS, context uintptr) {
	var p uintptr
	var r float64
	_, _ = p, r
	r = float64(0)
	p = Xsqlite3_aggregate_context(tls, context, 0)
	if p != 0 {
		if (*TSumCtx)(unsafe.Pointer(p)).Fapprox != 0 {
			r = (*TSumCtx)(unsafe.Pointer(p)).FrSum
			if !(_sqlite3IsOverflow(tls, (*TSumCtx)(unsafe.Pointer(p)).FrErr) != 0) {
				r = r + (*TSumCtx)(unsafe.Pointer(p)).FrErr
			}
		} else {
			r = float64((*TSumCtx)(unsafe.Pointer(p)).FiSum)
		}
	}
	Xsqlite3_result_double(tls, context, r)
}

// C documentation
//
//	/*
//	** Implementation of the total_changes() SQL function.  The return value is
//	** the same as the sqlite3_total_changes64() API function.
//	*/
func _total_changes(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
	var db uintptr
	_ = db
	db = Xsqlite3_context_db_handle(tls, context)
	_ = NotUsed
	_ = NotUsed2
	/* IMP: R-11217-42568 This function is a wrapper around the
	 ** sqlite3_total_changes64() C/C++ interface. */
	Xsqlite3_result_int64(tls, context, Xsqlite3_total_changes64(tls, db))
}

var _totals = [12]Tu8{
	1:  uint8(1),
	2:  uint8(3),
	3:  uint8(8),
	4:  uint8(18),
	5:  uint8(33),
	6:  uint8(53),
	7:  uint8(78),
	8:  uint8(103),
	9:  uint8(128),
	10: uint8(178),
	11: uint8(228),
}

/* A complex statement machine used to detect the end of a CREATE TRIGGER
 ** statement.  This is the normal case.
 */
var _trans = [8][8]Tu8{
	0: {
		0: uint8(1),
		2: uint8(2),
		3: uint8(3),
		4: uint8(4),
		5: uint8(2),
		6: uint8(2),
		7: uint8(2),
	},
	1: {
		0: uint8(1),
		1: uint8(1),
		2: uint8(2),
		3: uint8(3),
		4: uint8(4),
		5: uint8(2),
		6: uint8(2),
		7: uint8(2),
	},
	2: {
		0: uint8(1),
		1: uint8(2),
		2: uint8(2),
		3: uint8(2),
		4: uint8(2),
		5: uint8(2),
		6: uint8(2),
		7: uint8(2),
	},
	3: {
		0: uint8(1),
		1: uint8(3),
		2: uint8(3),
		3: uint8(2),
		4: uint8(4),
		5: uint8(2),
		6: uint8(2),
		7: uint8(2),
	},
	4: {
		0: uint8(1),
		1: uint8(4),
		2: uint8(2),
		3: uint8(2),
		4: uint8(2),
		5: uint8(4),
		6: uint8(5),
		7: uint8(2),
	},
	5: {
		0: uint8(6),
		1: uint8(5),
		2: uint8(5),
		3: uint8(5),
		4: uint8(5),
		5: uint8(5),
		6: uint8(5),
		7: uint8(5),
	},
	6: {
		0: uint8(6),
		1: uint8(6),
		2: uint8(5),
		3: uint8(5),
		4: uint8(5),
		5: uint8(5),
		6: uint8(5),
		7: uint8(7),
	},
	7: {
		0: uint8(1),
		1: uint8(7),
		2: uint8(5),
		3: uint8(5),
		4: uint8(5),
		5: uint8(5),
		6: uint8(5),
		7: uint8(5),
	},
}

// C documentation
//
//	/*
//	** Parse context structure pFrom has just been used to create a sub-vdbe
//	** (trigger program). If an error has occurred, transfer error information
//	** from pFrom to pTo.
//	*/
func _transferParseError(tls *libc.TLS, pTo uintptr, pFrom uintptr) {
	if (*TParse)(unsafe.Pointer(pTo)).FnErr == 0 {
		(*TParse)(unsafe.Pointer(pTo)).FzErrMsg = (*TParse)(unsafe.Pointer(pFrom)).FzErrMsg
		(*TParse)(unsafe.Pointer(pTo)).FnErr = (*TParse)(unsafe.Pointer(pFrom)).FnErr
		(*TParse)(unsafe.Pointer(pTo)).Frc = (*TParse)(unsafe.Pointer(pFrom)).Frc
	} else {
		_sqlite3DbFree(tls, (*TParse)(unsafe.Pointer(pFrom)).Fdb, (*TParse)(unsafe.Pointer(pFrom)).FzErrMsg)
	}
}

// C documentation
//
//	/*
//	** Return the type of the argument.
//	*/
func _typeofFunc(tls *libc.TLS, context uintptr, NotUsed int32, argv uintptr) {
	var i int32
	_ = i
	i = Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) - int32(1)
	_ = NotUsed
	/* EVIDENCE-OF: R-01470-60482 The sqlite3_value_type(V) interface returns
	 ** the datatype code for the initial datatype of the sqlite3_value object
	 ** V. The returned value is one of SQLITE_INTEGER, SQLITE_FLOAT,
	 ** SQLITE_TEXT, SQLITE_BLOB, or SQLITE_NULL. */
	Xsqlite3_result_text(tls, context, _azType2[i], -int32(1), libc.UintptrFromInt32(0))
}

// C documentation
//
//	/*
//	**    unixepoch( TIMESTRING, MOD, MOD, ...)
//	**
//	** Return the number of seconds (including fractional seconds) since
//	** the unix epoch of 1970-01-01 00:00:00 GMT.
//	*/
func _unixepochFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
	bp := tls.Alloc(48)
	defer tls.Free(48)
	var _ /* x at bp+0 */ TDateTime
	if _isDate(tls, context, argc, argv, bp) == 0 {
		_computeJD(tls, bp)
		if int32(uint32(*(*uint8)(unsafe.Pointer(bp + 44))&0x4>>2)) != 0 {
			Xsqlite3_result_double(tls, context, float64((**(**TDateTime)(__ccgo_up(bp))).FiJD-libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000000))/float64(1000))
		} else {
			Xsqlite3_result_int64(tls, context, (**(**TDateTime)(__ccgo_up(bp))).FiJD/int64(1000)-libc.Int64FromInt32(21086676)*libc.Int64FromInt32(10000))
		}
	}
}

// C documentation
//
//	/*
//	** Release the BtShared mutex associated with B-Tree handle p and
//	** clear the p->locked boolean.
//	*/
func _unlockBtreeMutex(tls *libc.TLS, p uintptr) {
	var pBt uintptr
	_ = pBt
	pBt = (*TBtree)(unsafe.Pointer(p)).FpBt
	Xsqlite3_mutex_leave(tls, (*TBtShared)(unsafe.Pointer(pBt)).Fmutex)
	(*TBtree)(unsafe.Pointer(p)).Flocked = uint8(0)
}

func _updateMapping(tls *libc.TLS, pRtree uintptr, iRowid Ti64, pNode uintptr, iHeight int32) (r int32) {
	var p, pChild, xSetMapping, v1 uintptr
	_, _, _, _ = p, pChild, xSetMapping, v1
	if iHeight == 0 {
		v1 = __ccgo_fp(_rowidWrite)
	} else {
		v1 = __ccgo_fp(_parentWrite)
	}
	xSetMapping = v1
	if iHeight > 0 {
		pChild = _nodeHashLookup(tls, pRtree, iRowid)
		p = pNode
		for {
			if !(p != 0) {
				break
			}
			if p == pChild {
				return libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<<libc.Int32FromInt32(8)
			}
			goto _2
		_2:
			;
			p = (*TRtreeNode)(unsafe.Pointer(p)).FpParent
		}
		if pChild != 0 {
			_nodeRelease(tls, pRtree, (*TRtreeNode)(unsafe.Pointer(pChild)).FpParent)
			_nodeReference(tls, pNode)
			(*TRtreeNode)(unsafe.Pointer(pChild)).FpParent = pNode
		}
	}
	if pNode == uintptr(0) {
		return int32(SQLITE_ERROR)
	}
	return (*(*func(*libc.TLS, uintptr, Tsqlite3_int64, Tsqlite3_int64) int32)(unsafe.Pointer(&struct{ uintptr }{xSetMapping})))(tls, pRtree, iRowid, (*TRtreeNode)(unsafe.Pointer(pNode)).FiNode)
}

// C documentation
//
//	/*
//	** Free a list of Upsert objects
//	*/
func _upsertDelete(tls *libc.TLS, db uintptr, p uintptr) {
	var pNext uintptr
	_ = pNext
	for cond := true; cond; cond = p != 0 {
		pNext = (*TUpsert)(unsafe.Pointer(p)).FpNextUpsert
		_sqlite3ExprListDelete(tls, db, (*TUpsert)(unsafe.Pointer(p)).FpUpsertTarget)
		_sqlite3ExprDelete(tls, db, (*TUpsert)(unsafe.Pointer(p)).FpUpsertTargetWhere)
		_sqlite3ExprListDelete(tls, db, (*TUpsert)(unsafe.Pointer(p)).FpUpsertSet)
		_sqlite3ExprDelete(tls, db, (*TUpsert)(unsafe.Pointer(p)).FpUpsertWhere)
		_sqlite3DbFree(tls, db, (*TUpsert)(unsafe.Pointer(p)).FpToFree)
		_sqlite3DbFree(tls, db, p)
		p = pNext
	}
}

// C documentation
//
//	/*
//	** Return TRUE if the given julian day number is within range.
//	**
//	** The input is the JulianDay times 86400000.
//	*/
func _validJulianDay(tls *libc.TLS, iJD Tsqlite3_int64) (r int32) {
	return libc.BoolInt32(iJD >= 0 && iJD <= libc.Int64FromInt32(0x1a640)<<libc.Int32FromInt32(32)|libc.Int64FromInt32(0x1072fdff))
}

// C documentation
//
//	/*
//	** The sqlite3ValueBytes() routine returns the number of bytes in the
//	** sqlite3_value object assuming that it uses the encoding "enc".
//	** The valueBytes() routine is a helper function.
//	*/
func _valueBytes(tls *libc.TLS, pVal uintptr, enc Tu8) (r int32) {
	var v1 int32
	_ = v1
	if _valueToText(tls, pVal, enc) != uintptr(0) {
		v1 = (*Tsqlite3_value)(unsafe.Pointer(pVal)).Fn
	} else {
		v1 = 0
	}
	return v1
}

// C documentation
//
//	/*
//	** Make an shallow copy of pFrom into pTo.  Prior contents of
//	** pTo are freed.  The pFrom->z field is not duplicated.  If
//	** pFrom->z is used, then pTo->z points to the same thing as pFrom->z
//	** and flags gets srcType (either MEM_Ephem or MEM_Static).
//	*/
func _vdbeClrCopy(tls *libc.TLS, pTo uintptr, pFrom uintptr, eType int32) {
	_vdbeMemClearExternAndSetNull(tls, pTo)
	_sqlite3VdbeMemShallowCopy(tls, pTo, pFrom, eType)
}

// C documentation
//
//	/*
//	** Launch a background thread to populate aFile[1] of pIncr.
//	*/
func _vdbeIncrBgPopulate(tls *libc.TLS, pIncr uintptr) (r int32) {
	var p uintptr
	_ = p
	p = pIncr
	return _vdbeSorterCreateThread(tls, (*TIncrMerger)(unsafe.Pointer(pIncr)).FpTask, __ccgo_fp(_vdbeIncrPopulateThread), p)
}

// C documentation
//
//	/*
//	** Set the "use-threads" flag on object pIncr.
//	*/
func _vdbeIncrMergerSetThreads(tls *libc.TLS, pIncr uintptr) {
	(*TIncrMerger)(unsafe.Pointer(pIncr)).FbUseThread = int32(1)
	(*TSortSubtask)(unsafe.Pointer((*TIncrMerger)(unsafe.Pointer(pIncr)).FpTask)).Ffile2.FiEof -= int64((*TIncrMerger)(unsafe.Pointer(pIncr)).FmxSz)
}

// C documentation
//
//	/*
//	** Return the symbolic name for the data type of a pMem
//	*/
func _vdbeMemTypeName(tls *libc.TLS, pMem uintptr) (r uintptr) {
	return _azTypes[Xsqlite3_value_type(tls, pMem)-int32(1)]
}

// C documentation
//
//	/*
//	** If the PmaReader passed as the first argument is not an incremental-reader
//	** (if pReadr->pIncr==0), then this function is a no-op. Otherwise, it invokes
//	** the vdbePmaReaderIncrMergeInit() function with the parameters passed to
//	** this routine to initialize the incremental merge.
//	**
//	** If the IncrMerger object is multi-threaded (IncrMerger.bUseThread==1),
//	** then a background thread is launched to call vdbePmaReaderIncrMergeInit().
//	** Or, if the IncrMerger is single threaded, the same function is called
//	** using the current thread.
//	*/
func _vdbePmaReaderIncrInit(tls *libc.TLS, pReadr uintptr, eMode int32) (r int32) {
	var pCtx, pIncr uintptr
	var rc int32
	_, _, _ = pCtx, pIncr, rc
	pIncr = (*TPmaReader)(unsafe.Pointer(pReadr)).FpIncr /* Incremental merger */
	rc = SQLITE_OK                                       /* Return code */
	if pIncr != 0 {
		if (*TIncrMerger)(unsafe.Pointer(pIncr)).FbUseThread != 0 {
			pCtx = pReadr
			rc = _vdbeSorterCreateThread(tls, (*TIncrMerger)(unsafe.Pointer(pIncr)).FpTask, __ccgo_fp(_vdbePmaReaderBgIncrInit), pCtx)
		} else {
			rc = _vdbePmaReaderIncrMergeInit(tls, pReadr, eMode)
		}
	}
	return rc
}

// C documentation
//
//	/*
//	** Write value iVal encoded as a varint to the PMA. Return
//	** SQLITE_OK if successful, or an SQLite error code if an error occurs.
//	*/
func _vdbePmaWriteVarint(tls *libc.TLS, p uintptr, iVal Tu64) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var nByte int32
	var _ /* aByte at bp+0 */ [10]Tu8
	_ = nByte
	nByte = _sqlite3PutVarint(tls, bp, iVal)
	_vdbePmaWriteBlob(tls, p, bp, nByte)
}

// C documentation
//
//	/*
//	** The pMem is known to contain content that needs to be destroyed prior
//	** to a value change.  So invoke the destructor, then set the value to
//	** a 64-bit integer.
//	*/
func _vdbeReleaseAndSetInt64(tls *libc.TLS, pMem uintptr, val Ti64) {
	_sqlite3VdbeMemSetNull(tls, pMem)
	*(*Ti64)(unsafe.Pointer(pMem)) = val
	(*TMem)(unsafe.Pointer(pMem)).Fflags = uint16(MEM_Int)
}

// C documentation
//
//	/*
//	** If it has not already been allocated, allocate the UnpackedRecord
//	** structure at pTask->pUnpacked. Return SQLITE_OK if successful (or
//	** if no allocation was required), or SQLITE_NOMEM otherwise.
//	*/
func _vdbeSortAllocUnpacked(tls *libc.TLS, pTask uintptr) (r int32) {
	if (*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked == uintptr(0) {
		(*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked = _sqlite3VdbeAllocUnpackedRecord(tls, (*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)
		if (*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked == uintptr(0) {
			return int32(SQLITE_NOMEM)
		}
		(*TUnpackedRecord)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FnField = (*TKeyInfo)(unsafe.Pointer((*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).FpKeyInfo)).FnKeyField
		(*TUnpackedRecord)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked)).FerrCode = uint8(0)
	}
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** Compare key1 (buffer pKey1, size nKey1 bytes) with key2 (buffer pKey2,
//	** size nKey2 bytes). Use (pTask->pKeyInfo) for the collation sequences
//	** used by the comparison. Return the result of the comparison.
//	**
//	** If IN/OUT parameter *pbKey2Cached is true when this function is called,
//	** it is assumed that (pTask->pUnpacked) contains the unpacked version
//	** of key2. If it is false, (pTask->pUnpacked) is populated with the unpacked
//	** version of key2 and *pbKey2Cached set to true before returning.
//	**
//	** If an OOM error is encountered, (pTask->pUnpacked->error_rc) is set
//	** to SQLITE_NOMEM.
//	*/
func _vdbeSorterCompare(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, pKey1 uintptr, nKey1 int32, pKey2 uintptr, nKey2 int32) (r int32) {
	var r2 uintptr
	_ = r2
	r2 = (*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked
	if !(**(**int32)(__ccgo_up(pbKey2Cached)) != 0) {
		_sqlite3VdbeRecordUnpack(tls, nKey2, pKey2, r2)
		**(**int32)(__ccgo_up(pbKey2Cached)) = int32(1)
	}
	return _sqlite3VdbeRecordCompare(tls, nKey1, pKey1, r2)
}

// C documentation
//
//	/*
//	** A version of vdbeSorterCompare() that assumes that it has already been
//	** determined that the first field of key1 is equal to the first field of
//	** key2.
//	*/
func _vdbeSorterCompareTail(tls *libc.TLS, pTask uintptr, pbKey2Cached uintptr, pKey1 uintptr, nKey1 int32, pKey2 uintptr, nKey2 int32) (r int32) {
	var r2 uintptr
	_ = r2
	r2 = (*TSortSubtask)(unsafe.Pointer(pTask)).FpUnpacked
	if **(**int32)(__ccgo_up(pbKey2Cached)) == 0 {
		_sqlite3VdbeRecordUnpack(tls, nKey2, pKey2, r2)
		**(**int32)(__ccgo_up(pbKey2Cached)) = int32(1)
	}
	return _sqlite3VdbeRecordCompareWithSkip(tls, nKey1, pKey1, r2, int32(1))
}

// C documentation
//
//	/*
//	** Launch a background thread to run xTask(pIn).
//	*/
func _vdbeSorterCreateThread(tls *libc.TLS, pTask uintptr, __ccgo_fp_xTask uintptr, pIn uintptr) (r int32) {
	return _sqlite3ThreadCreate(tls, pTask, __ccgo_fp_xTask, pIn)
}

// C documentation
//
//	/*
//	** Attempt to memory map file pFile. If successful, set *pp to point to the
//	** new mapping and return SQLITE_OK. If the mapping is not attempted
//	** (because the file is too large or the VFS layer is configured not to use
//	** mmap), return SQLITE_OK and set *pp to NULL.
//	**
//	** Or, if an error occurs, return an SQLite error code. The final value of
//	** *pp is undefined in this case.
//	*/
func _vdbeSorterMapFile(tls *libc.TLS, pTask uintptr, pFile uintptr, pp uintptr) (r int32) {
	var pFd uintptr
	var rc int32
	_, _ = pFd, rc
	rc = SQLITE_OK
	if (*TSorterFile)(unsafe.Pointer(pFile)).FiEof <= int64((*Tsqlite3)(unsafe.Pointer((*TVdbeSorter)(unsafe.Pointer((*TSortSubtask)(unsafe.Pointer(pTask)).FpSorter)).Fdb)).FnMaxSorterMmap) {
		pFd = (*TSorterFile)(unsafe.Pointer(pFile)).FpFd
		if (*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pFd)).FpMethods)).FiVersion >= int32(3) {
			rc = _sqlite3OsFetch(tls, pFd, 0, int32((*TSorterFile)(unsafe.Pointer(pFile)).FiEof), pp)
		}
	}
	return rc
}

// C documentation
//
//	/*
//	** Return the depth of a tree comprising nPMA PMAs, assuming a fanout of
//	** SORTER_MAX_MERGE_COUNT. The returned value does not include leaf nodes.
//	**
//	** i.e.
//	**
//	**   nPMA<=16    -> TreeDepth() == 0
//	**   nPMA<=256   -> TreeDepth() == 1
//	**   nPMA<=65536 -> TreeDepth() == 2
//	*/
func _vdbeSorterTreeDepth(tls *libc.TLS, nPMA int32) (r int32) {
	var nDepth int32
	var nDiv Ti64
	_, _ = nDepth, nDiv
	nDepth = 0
	nDiv = int64(SORTER_MAX_MERGE_COUNT)
	for nDiv < int64(nPMA) {
		nDiv = nDiv * int64(SORTER_MAX_MERGE_COUNT)
		nDepth = nDepth + 1
	}
	return nDepth
}

// C documentation
//
//	/*
//	** Implementation of the sqlite_version() function.  The result is the version
//	** of the SQLite library that is running.
//	*/
func _versionFunc(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
	_ = NotUsed
	_ = NotUsed2
	/* IMP: R-48699-48617 This function is an SQL wrapper around the
	 ** sqlite3_libversion() C-interface. */
	Xsqlite3_result_text(tls, context, Xsqlite3_libversion(tls), -int32(1), libc.UintptrFromInt32(0))
}

var _vfsFlags = libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_EXCLUSIVE) | libc.Int32FromInt32(SQLITE_OPEN_DELETEONCLOSE) | libc.Int32FromInt32(SQLITE_OPEN_TRANSIENT_DB)

/************** End of vdbe.c ************************************************/
/************** Begin file vdbeblob.c ****************************************/
/*
** 2007 May 1
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains code used to implement incremental BLOB I/O.
 */

/* #include "sqliteInt.h" */
/* #include "vdbeInt.h" */

// C documentation
//
//	/*
//	** The list of all registered VFS implementations.
//	*/
var _vfsList = uintptr(0)

// C documentation
//
//	/*
//	** Unlink a VFS from the linked list
//	*/
func _vfsUnlink(tls *libc.TLS, pVfs uintptr) {
	var p uintptr
	_ = p
	if pVfs == uintptr(0) {
		/* No-op */
	} else {
		if _vfsList == pVfs {
			_vfsList = (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext
		} else {
			if _vfsList != 0 {
				p = _vfsList
				for (*Tsqlite3_vfs)(unsafe.Pointer(p)).FpNext != 0 && (*Tsqlite3_vfs)(unsafe.Pointer(p)).FpNext != pVfs {
					p = (*Tsqlite3_vfs)(unsafe.Pointer(p)).FpNext
				}
				if (*Tsqlite3_vfs)(unsafe.Pointer(p)).FpNext == pVfs {
					(*Tsqlite3_vfs)(unsafe.Pointer(p)).FpNext = (*Tsqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext
				}
			}
		}
	}
}

/* Template for VFS */
var _vfs_template = Tsqlite3_vfs{
	FiVersion: int32(1),
}

// C documentation
//
//	/*
//	** Attempt to obtain the exclusive WAL lock defined by parameters lockIdx and
//	** n. If the attempt fails and parameter xBusy is not NULL, then it is a
//	** busy-handler function. Invoke it and retry the lock until either the
//	** lock is successfully obtained or the busy-handler returns 0.
//	*/
func _walBusyLock(tls *libc.TLS, pWal uintptr, __ccgo_fp_xBusy uintptr, pBusyArg uintptr, lockIdx int32, n int32) (r int32) {
	var rc int32
	_ = rc
	for cond := true; cond; cond = __ccgo_fp_xBusy != 0 && rc == int32(SQLITE_BUSY) && (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xBusy})))(tls, pBusyArg) != 0 {
		rc = _walLockExclusive(tls, pWal, lockIdx, n)
	}
	return rc
}

// C documentation
//
//	/*
//	** Generate or extend an 8 byte checksum based on the data in
//	** array aByte[] and the initial values of aIn[0] and aIn[1] (or
//	** initial values of 0 and 0 if aIn==NULL).
//	**
//	** The checksum is written back into aOut[] before returning.
//	**
//	** nByte must be a positive multiple of 8.
//	*/
func _walChecksumBytes(tls *libc.TLS, nativeCksum int32, a uintptr, nByte int32, aIn uintptr, aOut uintptr) {
	var aData, aEnd, v2 uintptr
	var s1, s2, v1 Tu32
	_, _, _, _, _, _ = aData, aEnd, s1, s2, v1, v2
	aData = a
	aEnd = a + uintptr(nByte)
	if aIn != 0 {
		s1 = **(**Tu32)(__ccgo_up(aIn))
		s2 = **(**Tu32)(__ccgo_up(aIn + 1*4))
	} else {
		v1 = libc.Uint32FromInt32(0)
		s2 = v1
		s1 = v1
	}
	/* nByte is a multiple of 8 between 8 and 65536 */
	if !(nativeCksum != 0) {
		for cond := true; cond; cond = aData < aEnd {
			s1 = s1 + (**(**Tu32)(__ccgo_up(aData))&uint32(0x000000FF)<<int32(24) + **(**Tu32)(__ccgo_up(aData))&uint32(0x0000FF00)<<int32(8) + **(**Tu32)(__ccgo_up(aData))&uint32(0x00FF0000)>>int32(8) + **(**Tu32)(__ccgo_up(aData))&uint32(0xFF000000)>>int32(24) + s2)
			s2 = s2 + (**(**Tu32)(__ccgo_up(aData + 1*4))&uint32(0x000000FF)<<int32(24) + **(**Tu32)(__ccgo_up(aData + 1*4))&uint32(0x0000FF00)<<int32(8) + **(**Tu32)(__ccgo_up(aData + 1*4))&uint32(0x00FF0000)>>int32(8) + **(**Tu32)(__ccgo_up(aData + 1*4))&uint32(0xFF000000)>>int32(24) + s1)
			aData = aData + uintptr(2)*4
		}
	} else {
		if nByte%int32(64) == 0 {
			for cond := true; cond; cond = aData < aEnd {
				v2 = aData
				aData += 4
				s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2)
				v2 = aData
				aData += 4
				s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1)
				v2 = aData
				aData += 4
				s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2)
				v2 = aData
				aData += 4
				s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1)
				v2 = aData
				aData += 4
				s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2)
				v2 = aData
				aData += 4
				s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1)
				v2 = aData
				aData += 4
				s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2)
				v2 = aData
				aData += 4
				s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1)
				v2 = aData
				aData += 4
				s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2)
				v2 = aData
				aData += 4
				s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1)
				v2 = aData
				aData += 4
				s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2)
				v2 = aData
				aData += 4
				s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1)
				v2 = aData
				aData += 4
				s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2)
				v2 = aData
				aData += 4
				s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1)
				v2 = aData
				aData += 4
				s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2)
				v2 = aData
				aData += 4
				s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1)
			}
		} else {
			for cond := true; cond; cond = aData < aEnd {
				v2 = aData
				aData += 4
				s1 = s1 + (**(**Tu32)(__ccgo_up(v2)) + s2)
				v2 = aData
				aData += 4
				s2 = s2 + (**(**Tu32)(__ccgo_up(v2)) + s1)
			}
		}
	}
	**(**Tu32)(__ccgo_up(aOut)) = s1
	**(**Tu32)(__ccgo_up(aOut + 1*4)) = s2
}

// C documentation
//
//	/*
//	** Return a pointer to the WalIndexHdr structure in the wal-index.
//	*/
func _walIndexHdr(tls *libc.TLS, pWal uintptr) (r uintptr) {
	return **(**uintptr)(__ccgo_up((*TWal)(unsafe.Pointer(pWal)).FapWiData))
}

/*
** The argument to this macro must be of type u32. On a little-endian
** architecture, it returns the u32 value that results from interpreting
** the 4 bytes as a big-endian value. On a big-endian architecture, it
** returns the value that would be produced by interpreting the 4 bytes
** of the input value as a little-endian integer.
 */

// C documentation
//
//	/*
//	** Free an iterator allocated by walIteratorInit().
//	*/
func _walIteratorFree(tls *libc.TLS, p uintptr) {
	Xsqlite3_free(tls, p)
}

func _walLockExclusive(tls *libc.TLS, pWal uintptr, lockIdx int32, n int32) (r int32) {
	var rc int32
	_ = rc
	if (*TWal)(unsafe.Pointer(pWal)).FexclusiveMode != 0 {
		return SQLITE_OK
	}
	rc = _sqlite3OsShmLock(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, n, libc.Int32FromInt32(SQLITE_SHM_LOCK)|libc.Int32FromInt32(SQLITE_SHM_EXCLUSIVE))
	return rc
}

// C documentation
//
//	/*
//	** Set or release locks on the WAL.  Locks are either shared or exclusive.
//	** A lock cannot be moved directly between shared and exclusive - it must go
//	** through the unlocked state first.
//	**
//	** In locking_mode=EXCLUSIVE, all of these routines become no-ops.
//	*/
func _walLockShared(tls *libc.TLS, pWal uintptr, lockIdx int32) (r int32) {
	var rc int32
	_ = rc
	if (*TWal)(unsafe.Pointer(pWal)).FexclusiveMode != 0 {
		return SQLITE_OK
	}
	rc = _sqlite3OsShmLock(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, int32(1), libc.Int32FromInt32(SQLITE_SHM_LOCK)|libc.Int32FromInt32(SQLITE_SHM_SHARED))
	return rc
}

func _walNextHash(tls *libc.TLS, iPriorHash int32) (r int32) {
	return (iPriorHash + int32(1)) & (libc.Int32FromInt32(HASHTABLE_NPAGE)*libc.Int32FromInt32(2) - libc.Int32FromInt32(1))
}

// C documentation
//
//	/*
//	** This function is called just before writing a set of frames to the log
//	** file (see sqlite3WalFrames()). It checks to see if, instead of appending
//	** to the current log file, it is possible to overwrite the start of the
//	** existing log file with the new frames (i.e. "reset" the log). If so,
//	** it sets pWal->hdr.mxFrame to 0. Otherwise, pWal->hdr.mxFrame is left
//	** unchanged.
//	**
//	** SQLITE_OK is returned if no error is encountered (regardless of whether
//	** or not pWal->hdr.mxFrame is modified). An SQLite error code is returned
//	** if an error occurs.
//	*/
func _walRestartLog(tls *libc.TLS, pWal uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var pInfo uintptr
	var rc int32
	var _ /* cnt at bp+0 */ int32
	var _ /* notUsed at bp+8 */ int32
	var _ /* salt1 at bp+4 */ Tu32
	_, _ = pInfo, rc
	rc = SQLITE_OK
	if int32((*TWal)(unsafe.Pointer(pWal)).FreadLock) == 0 {
		pInfo = _walCkptInfo(tls, pWal)
		if (*TWalCkptInfo)(unsafe.Pointer(pInfo)).FnBackfill > uint32(0) {
			Xsqlite3_randomness(tls, int32(4), bp+4)
			rc = _walLockExclusive(tls, pWal, libc.Int32FromInt32(3)+libc.Int32FromInt32(1), libc.Int32FromInt32(SQLITE_SHM_NLOCK)-libc.Int32FromInt32(3)-libc.Int32FromInt32(1))
			if rc == SQLITE_OK {
				/* If all readers are using WAL_READ_LOCK(0) (in other words if no
				 ** readers are currently using the WAL), then the transactions
				 ** frames will overwrite the start of the existing log. Update the
				 ** wal-index header to reflect this.
				 **
				 ** In theory it would be Ok to update the cache of the header only
				 ** at this point. But updating the actual wal-index header is also
				 ** safe and means there is no special case for sqlite3WalUndo()
				 ** to handle if this transaction is rolled back.  */
				_walRestartHdr(tls, pWal, **(**Tu32)(__ccgo_up(bp + 4)))
				_walUnlockExclusive(tls, pWal, libc.Int32FromInt32(3)+libc.Int32FromInt32(1), libc.Int32FromInt32(SQLITE_SHM_NLOCK)-libc.Int32FromInt32(3)-libc.Int32FromInt32(1))
			} else {
				if rc != int32(SQLITE_BUSY) {
					return rc
				}
			}
		}
		_walUnlockShared(tls, pWal, libc.Int32FromInt32(3)+libc.Int32FromInt32(0))
		(*TWal)(unsafe.Pointer(pWal)).FreadLock = int16(-int32(1))
		**(**int32)(__ccgo_up(bp)) = 0
		for cond := true; cond; cond = rc == -int32(1) {
			rc = _walTryBeginRead(tls, pWal, bp+8, int32(1), bp)
		}
		/* BUSY not possible when useWal==1 */
	}
	return rc
}

func _walUnlockExclusive(tls *libc.TLS, pWal uintptr, lockIdx int32, n int32) {
	if (*TWal)(unsafe.Pointer(pWal)).FexclusiveMode != 0 {
		return
	}
	_sqlite3OsShmLock(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, n, libc.Int32FromInt32(SQLITE_SHM_UNLOCK)|libc.Int32FromInt32(SQLITE_SHM_EXCLUSIVE))
}

func _walUnlockShared(tls *libc.TLS, pWal uintptr, lockIdx int32) {
	if (*TWal)(unsafe.Pointer(pWal)).FexclusiveMode != 0 {
		return
	}
	_sqlite3OsShmLock(tls, (*TWal)(unsafe.Pointer(pWal)).FpDbFd, lockIdx, int32(1), libc.Int32FromInt32(SQLITE_SHM_UNLOCK)|libc.Int32FromInt32(SQLITE_SHM_SHARED))
}

// C documentation
//
//	/*
//	** Write iAmt bytes of content into the WAL file beginning at iOffset.
//	** Do a sync when crossing the p->iSyncPoint boundary.
//	**
//	** In other words, if iSyncPoint is in between iOffset and iOffset+iAmt,
//	** first write the part before iSyncPoint, then sync, then write the
//	** rest.
//	*/
func _walWriteToLog(tls *libc.TLS, p uintptr, pContent uintptr, iAmt int32, iOffset Tsqlite3_int64) (r int32) {
	var iFirstAmt, rc int32
	_, _ = iFirstAmt, rc
	if iOffset < (*TWalWriter)(unsafe.Pointer(p)).FiSyncPoint && iOffset+int64(iAmt) >= (*TWalWriter)(unsafe.Pointer(p)).FiSyncPoint {
		iFirstAmt = int32((*TWalWriter)(unsafe.Pointer(p)).FiSyncPoint - iOffset)
		rc = _sqlite3OsWrite(tls, (*TWalWriter)(unsafe.Pointer(p)).FpFd, pContent, iFirstAmt, iOffset)
		if rc != 0 {
			return rc
		}
		iOffset = iOffset + int64(iFirstAmt)
		iAmt = iAmt - iFirstAmt
		pContent = uintptr(iFirstAmt) + pContent
		rc = _sqlite3OsSync(tls, (*TWalWriter)(unsafe.Pointer(p)).FpFd, (*TWalWriter)(unsafe.Pointer(p)).FsyncFlags&int32(0x03))
		if iAmt == 0 || rc != 0 {
			return rc
		}
	}
	rc = _sqlite3OsWrite(tls, (*TWalWriter)(unsafe.Pointer(p)).FpFd, pContent, iAmt, iOffset)
	return rc
}

// C documentation
//
//	/*
//	** Walk all expressions linked into the list of Window objects passed
//	** as the second argument.
//	*/
func _walkWindowList(tls *libc.TLS, pWalker uintptr, pList uintptr, bOneOnly int32) (r int32) {
	var pWin uintptr
	var rc int32
	_, _ = pWin, rc
	pWin = pList
	for {
		if !(pWin != 0) {
			break
		}
		rc = _sqlite3WalkExprList(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy)
		if rc != 0 {
			return int32(WRC_Abort)
		}
		rc = _sqlite3WalkExprList(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpPartition)
		if rc != 0 {
			return int32(WRC_Abort)
		}
		rc = _sqlite3WalkExpr(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpFilter)
		if rc != 0 {
			return int32(WRC_Abort)
		}
		rc = _sqlite3WalkExpr(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpStart)
		if rc != 0 {
			return int32(WRC_Abort)
		}
		rc = _sqlite3WalkExpr(tls, pWalker, (*TWindow)(unsafe.Pointer(pWin)).FpEnd)
		if rc != 0 {
			return int32(WRC_Abort)
		}
		if bOneOnly != 0 {
			break
		}
		goto _1
	_1:
		;
		pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin
	}
	return WRC_Continue
}

// C documentation
//
//	/*
//	** Deallocate all memory associated with a WhereAndInfo object.
//	*/
func _whereAndInfoDelete(tls *libc.TLS, db uintptr, p uintptr) {
	_sqlite3WhereClauseClear(tls, p)
	_sqlite3DbFree(tls, db, p)
}

// C documentation
//
//	/*
//	** This is an sqlite3ParserAddCleanup() callback that is invoked to
//	** free the Parse->pIdxEpr list when the Parse object is destroyed.
//	*/
func _whereIndexedExprCleanup(tls *libc.TLS, db uintptr, pObject uintptr) {
	var p, pp uintptr
	_, _ = p, pp
	pp = pObject
	for **(**uintptr)(__ccgo_up(pp)) != uintptr(0) {
		p = **(**uintptr)(__ccgo_up(pp))
		**(**uintptr)(__ccgo_up(pp)) = (*TIndexedExpr)(unsafe.Pointer(p)).FpIENext
		_sqlite3ExprDelete(tls, db, (*TIndexedExpr)(unsafe.Pointer(p)).FpExpr)
		_sqlite3DbFreeNN(tls, db, p)
	}
}

// C documentation
//
//	/*
//	** Delete a WhereLoop object
//	*/
func _whereLoopDelete(tls *libc.TLS, db uintptr, p uintptr) {
	_whereLoopClear(tls, db, p)
	_sqlite3DbNNFreeNN(tls, db, p)
}

// C documentation
//
//	/*
//	** Two WhereLoop objects, pCandidate and pBaseline, are known to have the
//	** same cost.  Look deep into each to see if pCandidate is even slightly
//	** better than pBaseline.  Return false if it is, if pCandidate is is preferred.
//	** Return true if pBaseline is preferred or if we cannot tell the difference.
//	**
//	**    Result       Meaning
//	**    --------     ----------------------------------------------------------
//	**    true         We cannot tell the difference in pCandidate and pBaseline
//	**    false        pCandidate seems like a better choice than pBaseline
//	*/
func _whereLoopIsNoBetter(tls *libc.TLS, pCandidate uintptr, pBaseline uintptr) (r int32) {
	if (*TWhereLoop)(unsafe.Pointer(pCandidate)).FwsFlags&uint32(WHERE_INDEXED) == uint32(0) {
		return int32(1)
	}
	if (*TWhereLoop)(unsafe.Pointer(pBaseline)).FwsFlags&uint32(WHERE_INDEXED) == uint32(0) {
		return int32(1)
	}
	if int32((*TIndex)(unsafe.Pointer((*(*struct {
		FnEq          Tu16
		FnBtm         Tu16
		FnTop         Tu16
		FnDistinctCol Tu16
		FpIndex       uintptr
		FpOrderBy     uintptr
	})(unsafe.Pointer(pCandidate + 24))).FpIndex)).FszIdxRow) < int32((*TIndex)(unsafe.Pointer((*(*struct {
		FnEq          Tu16
		FnBtm         Tu16
		FnTop         Tu16
		FnDistinctCol Tu16
		FpIndex       uintptr
		FpOrderBy     uintptr
	})(unsafe.Pointer(pBaseline + 24))).FpIndex)).FszIdxRow) {
		return 0
	}
	return int32(1)
}

// C documentation
//
//	/*
//	** Deallocate all memory associated with a WhereOrInfo object.
//	*/
func _whereOrInfoDelete(tls *libc.TLS, db uintptr, p uintptr) {
	_sqlite3WhereClauseClear(tls, p)
	_sqlite3DbFree(tls, db, p)
}

// C documentation
//
//	/*
//	** This is whereScanInit() for the case of an index on an expression.
//	** It is factored out into a separate tail-recursion subroutine so that
//	** the normal whereScanInit() routine, which is a high-runner, does not
//	** need to push registers onto the stack as part of its prologue.
//	*/
func _whereScanInitIndexExpr(tls *libc.TLS, pScan uintptr) (r uintptr) {
	(*TWhereScan)(unsafe.Pointer(pScan)).Fidxaff = _sqlite3ExprAffinity(tls, (*TWhereScan)(unsafe.Pointer(pScan)).FpIdxExpr)
	return _whereScanNext(tls, pScan)
}

// C documentation
//
//	/*
//	** Return true if the current frame should be cached in the ephemeral table,
//	** even if there are no xInverse() calls required.
//	*/
func _windowCacheFrame(tls *libc.TLS, pMWin uintptr) (r int32) {
	var pFunc, pWin uintptr
	_, _ = pFunc, pWin
	if (*TWindow)(unsafe.Pointer(pMWin)).FregStartRowid != 0 {
		return int32(1)
	}
	pWin = pMWin
	for {
		if !(pWin != 0) {
			break
		}
		pFunc = (*TWindow)(unsafe.Pointer(pWin)).FpWFunc
		if (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_nth_valueName)) || (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_first_valueName)) || (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_leadName)) || (*TFuncDef)(unsafe.Pointer(pFunc)).FzName == uintptr(unsafe.Pointer(&_lagName)) {
			return int32(1)
		}
		goto _1
	_1:
		;
		pWin = (*TWindow)(unsafe.Pointer(pWin)).FpNextWin
	}
	return 0
}

// C documentation
//
//	/*
//	** Return true if it can be determined at compile time that expression
//	** pExpr evaluates to a value that, when cast to an integer, is greater
//	** than zero. False otherwise.
//	**
//	** If an OOM error occurs, this function sets the Parse.db.mallocFailed
//	** flag and returns zero.
//	*/
func _windowExprGtZero(tls *libc.TLS, pParse uintptr, pExpr uintptr) (r int32) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var db uintptr
	var ret int32
	var _ /* pVal at bp+0 */ uintptr
	_, _ = db, ret
	ret = 0
	db = (*TParse)(unsafe.Pointer(pParse)).Fdb
	**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
	_sqlite3ValueFromExpr(tls, db, pExpr, (*Tsqlite3)(unsafe.Pointer(db)).Fenc, uint8(SQLITE_AFF_NUMERIC), bp)
	if **(**uintptr)(__ccgo_up(bp)) != 0 && Xsqlite3_value_int(tls, **(**uintptr)(__ccgo_up(bp))) > 0 {
		ret = int32(1)
	}
	_sqlite3ValueFree(tls, **(**uintptr)(__ccgo_up(bp)))
	return ret
}

// C documentation
//
//	/*
//	** regOld and regNew are each the first register in an array of size
//	** pOrderBy->nExpr. This function generates code to compare the two
//	** arrays of registers using the collation sequences and other comparison
//	** parameters specified by pOrderBy.
//	**
//	** If the two arrays are not equal, the contents of regNew is copied to
//	** regOld and control falls through. Otherwise, if the contents of the arrays
//	** are equal, an OP_Goto is executed. The address of the OP_Goto is returned.
//	*/
func _windowIfNewPeer(tls *libc.TLS, pParse uintptr, pOrderBy uintptr, regNew int32, regOld int32, addr int32) {
	var nVal int32
	var pKeyInfo, v uintptr
	_, _, _ = nVal, pKeyInfo, v
	v = _sqlite3GetVdbe(tls, pParse)
	if pOrderBy != 0 {
		nVal = (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr
		pKeyInfo = _sqlite3KeyInfoFromExprList(tls, pParse, pOrderBy, 0, 0)
		_sqlite3VdbeAddOp3(tls, v, int32(OP_Compare), regOld, regNew, nVal)
		_sqlite3VdbeAppendP4(tls, v, pKeyInfo, -int32(9))
		_sqlite3VdbeAddOp3(tls, v, int32(OP_Jump), _sqlite3VdbeCurrentAddr(tls, v)+int32(1), addr, _sqlite3VdbeCurrentAddr(tls, v)+int32(1))
		_sqlite3VdbeAddOp3(tls, v, int32(OP_Copy), regNew, regOld, nVal-int32(1))
	} else {
		_sqlite3VdbeAddOp2(tls, v, int32(OP_Goto), 0, addr)
	}
}

// C documentation
//
//	/*
//	** Generate VM code to read the window frames peer values from cursor csr into
//	** an array of registers starting at reg.
//	*/
func _windowReadPeerValues(tls *libc.TLS, p uintptr, csr int32, reg int32) {
	var i, iColOff, v1 int32
	var pMWin, pOrderBy, pPart, v uintptr
	_, _, _, _, _, _, _ = i, iColOff, pMWin, pOrderBy, pPart, v, v1
	pMWin = (*TWindowCodeArg)(unsafe.Pointer(p)).FpMWin
	pOrderBy = (*TWindow)(unsafe.Pointer(pMWin)).FpOrderBy
	if pOrderBy != 0 {
		v = _sqlite3GetVdbe(tls, (*TWindowCodeArg)(unsafe.Pointer(p)).FpParse)
		pPart = (*TWindow)(unsafe.Pointer(pMWin)).FpPartition
		if pPart != 0 {
			v1 = (*TExprList)(unsafe.Pointer(pPart)).FnExpr
		} else {
			v1 = 0
		}
		iColOff = (*TWindow)(unsafe.Pointer(pMWin)).FnBufferCol + v1
		i = 0
		for {
			if !(i < (*TExprList)(unsafe.Pointer(pOrderBy)).FnExpr) {
				break
			}
			_sqlite3VdbeAddOp3(tls, v, int32(OP_Column), csr, iColOff+i, reg+i)
			goto _2
		_2:
			;
			i = i + 1
		}
	}
}

var _x = [32]uint8{
	0:  uint8(10),
	1:  uint8(10),
	2:  uint8(9),
	3:  uint8(9),
	4:  uint8(8),
	5:  uint8(8),
	6:  uint8(7),
	7:  uint8(7),
	8:  uint8(7),
	9:  uint8(6),
	10: uint8(6),
	11: uint8(6),
	12: uint8(5),
	13: uint8(5),
	14: uint8(5),
	15: uint8(4),
	16: uint8(4),
	17: uint8(4),
	18: uint8(4),
	19: uint8(3),
	20: uint8(3),
	21: uint8(3),
	22: uint8(3),
	23: uint8(3),
	24: uint8(3),
	25: uint8(2),
	26: uint8(2),
	27: uint8(2),
	28: uint8(2),
	29: uint8(2),
	30: uint8(2),
	31: uint8(2),
}

// C documentation
//
//	/*
//	** On some systems, ceil() and floor() are intrinsic function.  You are
//	** unable to take a pointer to these functions.  Hence, we here wrap them
//	** in our own actual functions.
//	*/
func _xCeil(tls *libc.TLS, x float64) (r float64) {
	return libc.Xceil(tls, x)
}

// C documentation
//
//	/*
//	** Default xRename callback for RBU.
//	*/
func _xDefaultRename(tls *libc.TLS, pArg uintptr, zOld uintptr, zNew uintptr) (r int32) {
	var rc, v1 int32
	_, _ = rc, v1
	rc = SQLITE_OK
	_ = pArg
	if libc.Xrename(tls, zOld, zNew) != 0 {
		v1 = int32(SQLITE_IOERR)
	} else {
		v1 = SQLITE_OK
	}
	rc = v1
	return rc
}

func _xFloor(tls *libc.TLS, x float64) (r float64) {
	return libc.Xfloor(tls, x)
}

/*
** Some systems do not have log2() and log10() in their standard math
** libraries.
 */

// C documentation
//
//	/*
//	** The 'pre-update' hook registered by this module with SQLite databases.
//	*/
func _xPreUpdate(tls *libc.TLS, pCtx uintptr, db uintptr, op int32, zDb uintptr, zName uintptr, iKey1 Tsqlite3_int64, iKey2 Tsqlite3_int64) {
	bp := tls.Alloc(16)
	defer tls.Free(16)
	var nDb int32
	var pSession uintptr
	var _ /* pTab at bp+0 */ uintptr
	_, _ = nDb, pSession
	nDb = _sqlite3Strlen30(tls, zDb)
	_ = iKey1
	_ = iKey2
	pSession = pCtx
	for {
		if !(pSession != 0) {
			break
		}
		/* If this session is attached to a different database ("main", "temp"
		 ** etc.), or if it is not currently enabled, there is nothing to do. Skip
		 ** to the next session object attached to this database. */
		if (*Tsqlite3_session)(unsafe.Pointer(pSession)).FbEnable == 0 {
			goto _1
		}
		if (*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc != 0 {
			goto _1
		}
		if Xsqlite3_strnicmp(tls, zDb, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb, nDb+int32(1)) != 0 {
			goto _1
		}
		(*Tsqlite3_session)(unsafe.Pointer(pSession)).Frc = _sessionFindTable(tls, pSession, zName, bp)
		if **(**uintptr)(__ccgo_up(bp)) != 0 {
			_sessionPreupdateOneChange(tls, op, iKey1, pSession, **(**uintptr)(__ccgo_up(bp)))
			if op == int32(SQLITE_UPDATE) {
				_sessionPreupdateOneChange(tls, int32(SQLITE_INSERT), iKey2, pSession, **(**uintptr)(__ccgo_up(bp)))
			}
		}
		goto _1
	_1:
		;
		pSession = (*Tsqlite3_session)(unsafe.Pointer(pSession)).FpNext
	}
}

// C documentation
//
//	/* The next table maps tokens (terminal symbols) into fallback tokens.
//	** If a construct like the following:
//	**
//	**      %fallback ID X Y Z.
//	**
//	** appears in the grammar, then ID becomes a fallback token for X, Y,
//	** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser
//	** but it does not parse, the type of the token is changed to ID and
//	** the parse is retried before an error is thrown.
//	**
//	** This feature can be used, for example, to cause some keywords in a language
//	** to revert to identifiers if they keyword does not apply in the context where
//	** it appears.
//	*/
var _yyFallback = [187]uint16{
	2:   uint16(60),
	3:   uint16(60),
	4:   uint16(60),
	5:   uint16(60),
	7:   uint16(60),
	8:   uint16(60),
	9:   uint16(60),
	11:  uint16(60),
	12:  uint16(60),
	13:  uint16(60),
	14:  uint16(60),
	18:  uint16(60),
	21:  uint16(60),
	26:  uint16(60),
	27:  uint16(60),
	28:  uint16(60),
	29:  uint16(60),
	30:  uint16(60),
	31:  uint16(60),
	32:  uint16(60),
	33:  uint16(60),
	34:  uint16(60),
	35:  uint16(60),
	36:  uint16(60),
	37:  uint16(60),
	38:  uint16(60),
	39:  uint16(60),
	40:  uint16(60),
	41:  uint16(60),
	42:  uint16(60),
	47:  uint16(60),
	48:  uint16(60),
	61:  uint16(60),
	62:  uint16(60),
	63:  uint16(60),
	64:  uint16(60),
	65:  uint16(60),
	66:  uint16(60),
	67:  uint16(60),
	68:  uint16(60),
	69:  uint16(60),
	70:  uint16(60),
	71:  uint16(60),
	72:  uint16(60),
	73:  uint16(60),
	74:  uint16(60),
	75:  uint16(60),
	76:  uint16(60),
	77:  uint16(60),
	78:  uint16(60),
	79:  uint16(60),
	80:  uint16(60),
	81:  uint16(60),
	82:  uint16(60),
	83:  uint16(60),
	84:  uint16(60),
	85:  uint16(60),
	86:  uint16(60),
	87:  uint16(60),
	88:  uint16(60),
	89:  uint16(60),
	90:  uint16(60),
	91:  uint16(60),
	92:  uint16(60),
	93:  uint16(60),
	94:  uint16(60),
	95:  uint16(60),
	96:  uint16(60),
	97:  uint16(60),
	98:  uint16(60),
	99:  uint16(60),
	100: uint16(60),
	101: uint16(60),
}

// C documentation
//
//	/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
//	** of that rule */
var _yyRuleInfoLhs = [412]uint16{
	0:   uint16(191),
	1:   uint16(191),
	2:   uint16(190),
	3:   uint16(192),
	4:   uint16(193),
	5:   uint16(193),
	6:   uint16(193),
	7:   uint16(193),
	8:   uint16(192),
	9:   uint16(192),
	10:  uint16(192),
	11:  uint16(192),
	12:  uint16(192),
	13:  uint16(197),
	14:  uint16(199),
	15:  uint16(201),
	16:  uint16(201),
	17:  uint16(200),
	18:  uint16(200),
	19:  uint16(198),
	20:  uint16(198),
	21:  uint16(205),
	22:  uint16(205),
	23:  uint16(207),
	24:  uint16(207),
	25:  uint16(208),
	26:  uint16(210),
	27:  uint16(210),
	28:  uint16(210),
	29:  uint16(211),
	30:  uint16(215),
	31:  uint16(216),
	32:  uint16(217),
	33:  uint16(217),
	34:  uint16(217),
	35:  uint16(217),
	36:  uint16(217),
	37:  uint16(217),
	38:  uint16(217),
	39:  uint16(217),
	40:  uint16(217),
	41:  uint16(217),
	42:  uint16(217),
	43:  uint16(217),
	44:  uint16(217),
	45:  uint16(226),
	46:  uint16(226),
	47:  uint16(222),
	48:  uint16(222),
	49:  uint16(224),
	50:  uint16(224),
	51:  uint16(227),
	52:  uint16(227),
	53:  uint16(227),
	54:  uint16(227),
	55:  uint16(228),
	56:  uint16(228),
	57:  uint16(228),
	58:  uint16(228),
	59:  uint16(228),
	60:  uint16(225),
	61:  uint16(225),
	62:  uint16(229),
	63:  uint16(229),
	64:  uint16(229),
	65:  uint16(204),
	66:  uint16(231),
	67:  uint16(232),
	68:  uint16(232),
	69:  uint16(232),
	70:  uint16(232),
	71:  uint16(232),
	72:  uint16(235),
	73:  uint16(220),
	74:  uint16(220),
	75:  uint16(236),
	76:  uint16(236),
	77:  uint16(237),
	78:  uint16(237),
	79:  uint16(192),
	80:  uint16(239),
	81:  uint16(239),
	82:  uint16(192),
	83:  uint16(192),
	84:  uint16(192),
	85:  uint16(206),
	86:  uint16(206),
	87:  uint16(206),
	88:  uint16(241),
	89:  uint16(244),
	90:  uint16(244),
	91:  uint16(244),
	92:  uint16(242),
	93:  uint16(242),
	94:  uint16(254),
	95:  uint16(242),
	96:  uint16(256),
	97:  uint16(256),
	98:  uint16(245),
	99:  uint16(245),
	100: uint16(245),
	101: uint16(257),
	102: uint16(246),
	103: uint16(246),
	104: uint16(246),
	105: uint16(258),
	106: uint16(258),
	107: uint16(247),
	108: uint16(247),
	109: uint16(260),
	110: uint16(260),
	111: uint16(259),
	112: uint16(259),
	113: uint16(259),
	114: uint16(259),
	115: uint16(259),
	116: uint16(202),
	117: uint16(202),
	118: uint16(240),
	119: uint16(240),
	120: uint16(265),
	121: uint16(265),
	122: uint16(265),
	123: uint16(265),
	124: uint16(261),
	125: uint16(261),
	126: uint16(261),
	127: uint16(261),
	128: uint16(262),
	129: uint16(262),
	130: uint16(262),
	131: uint16(267),
	132: uint16(263),
	133: uint16(263),
	134: uint16(251),
	135: uint16(251),
	136: uint16(233),
	137: uint16(233),
	138: uint16(221),
	139: uint16(221),
	140: uint16(221),
	141: uint16(268),
	142: uint16(268),
	143: uint16(268),
	144: uint16(249),
	145: uint16(249),
	146: uint16(250),
	147: uint16(250),
	148: uint16(252),
	149: uint16(252),
	150: uint16(252),
	151: uint16(252),
	152: uint16(192),
	153: uint16(248),
	154: uint16(248),
	155: uint16(270),
	156: uint16(270),
	157: uint16(270),
	158: uint16(270),
	159: uint16(192),
	160: uint16(271),
	161: uint16(271),
	162: uint16(271),
	163: uint16(271),
	164: uint16(192),
	165: uint16(192),
	166: uint16(274),
	167: uint16(274),
	168: uint16(274),
	169: uint16(274),
	170: uint16(274),
	171: uint16(274),
	172: uint16(275),
	173: uint16(272),
	174: uint16(272),
	175: uint16(273),
	176: uint16(273),
	177: uint16(266),
	178: uint16(266),
	179: uint16(219),
	180: uint16(219),
	181: uint16(219),
	182: uint16(219),
	183: uint16(218),
	184: uint16(218),
	185: uint16(218),
	186: uint16(219),
	187: uint16(219),
	188: uint16(219),
	189: uint16(219),
	190: uint16(219),
	191: uint16(219),
	192: uint16(219),
	193: uint16(219),
	194: uint16(219),
	195: uint16(218),
	196: uint16(219),
	197: uint16(219),
	198: uint16(219),
	199: uint16(219),
	200: uint16(219),
	201: uint16(219),
	202: uint16(219),
	203: uint16(219),
	204: uint16(219),
	205: uint16(277),
	206: uint16(219),
	207: uint16(219),
	208: uint16(219),
	209: uint16(219),
	210: uint16(219),
	211: uint16(219),
	212: uint16(219),
	213: uint16(219),
	214: uint16(219),
	215: uint16(219),
	216: uint16(219),
	217: uint16(219),
	218: uint16(278),
	219: uint16(278),
	220: uint16(219),
	221: uint16(279),
	222: uint16(279),
	223: uint16(219),
	224: uint16(219),
	225: uint16(219),
	226: uint16(219),
	227: uint16(219),
	228: uint16(219),
	229: uint16(282),
	230: uint16(282),
	231: uint16(283),
	232: uint16(283),
	233: uint16(281),
	234: uint16(264),
	235: uint16(255),
	236: uint16(255),
	237: uint16(280),
	238: uint16(280),
	239: uint16(192),
	240: uint16(284),
	241: uint16(284),
	242: uint16(223),
	243: uint16(223),
	244: uint16(234),
	245: uint16(234),
	246: uint16(285),
	247: uint16(285),
	248: uint16(192),
	249: uint16(192),
	250: uint16(192),
	251: uint16(286),
	252: uint16(286),
	253: uint16(192),
	254: uint16(192),
	255: uint16(192),
	256: uint16(192),
	257: uint16(192),
	258: uint16(213),
	259: uint16(214),
	260: uint16(192),
	261: uint16(288),
	262: uint16(290),
	263: uint16(290),
	264: uint16(290),
	265: uint16(291),
	266: uint16(291),
	267: uint16(291),
	268: uint16(293),
	269: uint16(293),
	270: uint16(289),
	271: uint16(289),
	272: uint16(295),
	273: uint16(295),
	274: uint16(294),
	275: uint16(294),
	276: uint16(294),
	277: uint16(294),
	278: uint16(219),
	279: uint16(219),
	280: uint16(238),
	281: uint16(238),
	282: uint16(238),
	283: uint16(192),
	284: uint16(192),
	285: uint16(192),
	286: uint16(297),
	287: uint16(297),
	288: uint16(192),
	289: uint16(192),
	290: uint16(192),
	291: uint16(192),
	292: uint16(192),
	293: uint16(192),
	294: uint16(298),
	295: uint16(192),
	296: uint16(192),
	297: uint16(192),
	298: uint16(192),
	299: uint16(192),
	300: uint16(192),
	301: uint16(192),
	302: uint16(192),
	303: uint16(192),
	304: uint16(300),
	305: uint16(302),
	306: uint16(303),
	307: uint16(303),
	308: uint16(304),
	309: uint16(269),
	310: uint16(269),
	311: uint16(307),
	312: uint16(307),
	313: uint16(307),
	314: uint16(306),
	315: uint16(308),
	316: uint16(243),
	317: uint16(243),
	318: uint16(309),
	319: uint16(310),
	320: uint16(311),
	321: uint16(311),
	322: uint16(311),
	323: uint16(311),
	324: uint16(311),
	325: uint16(312),
	326: uint16(312),
	327: uint16(312),
	328: uint16(316),
	329: uint16(318),
	330: uint16(318),
	331: uint16(319),
	332: uint16(319),
	333: uint16(317),
	334: uint16(317),
	335: uint16(320),
	336: uint16(320),
	337: uint16(321),
	338: uint16(321),
	339: uint16(321),
	340: uint16(253),
	341: uint16(276),
	342: uint16(276),
	343: uint16(276),
	344: uint16(315),
	345: uint16(315),
	346: uint16(314),
	347: uint16(218),
	348: uint16(187),
	349: uint16(188),
	350: uint16(188),
	351: uint16(189),
	352: uint16(189),
	353: uint16(189),
	354: uint16(194),
	355: uint16(194),
	356: uint16(194),
	357: uint16(196),
	358: uint16(196),
	359: uint16(192),
	360: uint16(205),
	361: uint16(203),
	362: uint16(203),
	363: uint16(195),
	364: uint16(195),
	365: uint16(210),
	366: uint16(211),
	367: uint16(212),
	368: uint16(212),
	369: uint16(209),
	370: uint16(209),
	371: uint16(217),
	372: uint16(217),
	373: uint16(217),
	374: uint16(204),
	375: uint16(230),
	376: uint16(230),
	377: uint16(231),
	378: uint16(235),
	379: uint16(237),
	380: uint16(241),
	381: uint16(242),
	382: uint16(257),
	383: uint16(258),
	384: uint16(267),
	385: uint16(275),
	386: uint16(219),
	387: uint16(277),
	388: uint16(281),
	389: uint16(264),
	390: uint16(287),
	391: uint16(287),
	392: uint16(287),
	393: uint16(287),
	394: uint16(287),
	395: uint16(213),
	396: uint16(292),
	397: uint16(292),
	398: uint16(295),
	399: uint16(296),
	400: uint16(296),
	401: uint16(299),
	402: uint16(299),
	403: uint16(301),
	404: uint16(301),
	405: uint16(302),
	406: uint16(305),
	407: uint16(305),
	408: uint16(305),
	409: uint16(269),
	410: uint16(309),
	411: uint16(311),
}

// C documentation
//
//	/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
//	** of symbols on the right-hand side of that rule. */
var _yyRuleInfoNRhs = [412]int8{
	0:   int8(-int32(1)),
	1:   int8(-int32(3)),
	2:   int8(-int32(1)),
	3:   int8(-int32(3)),
	5:   int8(-int32(1)),
	6:   int8(-int32(1)),
	7:   int8(-int32(1)),
	8:   int8(-int32(2)),
	9:   int8(-int32(2)),
	10:  int8(-int32(2)),
	11:  int8(-int32(3)),
	12:  int8(-int32(5)),
	13:  int8(-int32(6)),
	14:  int8(-int32(1)),
	16:  int8(-int32(3)),
	17:  int8(-int32(1)),
	19:  int8(-int32(5)),
	20:  int8(-int32(2)),
	22:  int8(-int32(3)),
	23:  int8(-int32(2)),
	24:  int8(-int32(1)),
	25:  int8(-int32(2)),
	27:  int8(-int32(4)),
	28:  int8(-int32(6)),
	29:  int8(-int32(2)),
	32:  int8(-int32(2)),
	33:  int8(-int32(3)),
	34:  int8(-int32(4)),
	35:  int8(-int32(4)),
	36:  int8(-int32(4)),
	37:  int8(-int32(3)),
	38:  int8(-int32(3)),
	39:  int8(-int32(5)),
	40:  int8(-int32(2)),
	41:  int8(-int32(4)),
	42:  int8(-int32(4)),
	43:  int8(-int32(1)),
	44:  int8(-int32(2)),
	45:  int8(-int32(3)),
	46:  int8(-int32(4)),
	48:  int8(-int32(1)),
	50:  int8(-int32(2)),
	51:  int8(-int32(2)),
	52:  int8(-int32(3)),
	53:  int8(-int32(3)),
	54:  int8(-int32(3)),
	55:  int8(-int32(2)),
	56:  int8(-int32(2)),
	57:  int8(-int32(1)),
	58:  int8(-int32(1)),
	59:  int8(-int32(2)),
	60:  int8(-int32(3)),
	61:  int8(-int32(2)),
	63:  int8(-int32(2)),
	64:  int8(-int32(2)),
	66:  int8(-int32(1)),
	67:  int8(-int32(2)),
	68:  int8(-int32(7)),
	69:  int8(-int32(5)),
	70:  int8(-int32(5)),
	71:  int8(-int32(10)),
	74:  int8(-int32(3)),
	76:  int8(-int32(2)),
	77:  int8(-int32(1)),
	78:  int8(-int32(1)),
	79:  int8(-int32(4)),
	80:  int8(-int32(2)),
	82:  int8(-int32(9)),
	83:  int8(-int32(4)),
	84:  int8(-int32(1)),
	85:  int8(-int32(3)),
	86:  int8(-int32(4)),
	87:  int8(-int32(1)),
	88:  int8(-int32(3)),
	89:  int8(-int32(1)),
	90:  int8(-int32(2)),
	91:  int8(-int32(1)),
	92:  int8(-int32(9)),
	93:  int8(-int32(10)),
	94:  int8(-int32(4)),
	95:  int8(-int32(1)),
	96:  int8(-int32(5)),
	97:  int8(-int32(5)),
	98:  int8(-int32(1)),
	99:  int8(-int32(1)),
	102: int8(-int32(5)),
	103: int8(-int32(3)),
	104: int8(-int32(5)),
	105: int8(-int32(2)),
	108: int8(-int32(2)),
	109: int8(-int32(2)),
	111: int8(-int32(5)),
	112: int8(-int32(6)),
	113: int8(-int32(8)),
	114: int8(-int32(6)),
	115: int8(-int32(6)),
	117: int8(-int32(2)),
	118: int8(-int32(1)),
	119: int8(-int32(3)),
	120: int8(-int32(1)),
	121: int8(-int32(3)),
	122: int8(-int32(3)),
	123: int8(-int32(5)),
	124: int8(-int32(1)),
	125: int8(-int32(2)),
	126: int8(-int32(3)),
	127: int8(-int32(4)),
	128: int8(-int32(2)),
	129: int8(-int32(4)),
	132: int8(-int32(3)),
	133: int8(-int32(2)),
	135: int8(-int32(3)),
	136: int8(-int32(5)),
	137: int8(-int32(3)),
	138: int8(-int32(1)),
	139: int8(-int32(1)),
	141: int8(-int32(2)),
	142: int8(-int32(2)),
	145: int8(-int32(3)),
	147: int8(-int32(2)),
	149: int8(-int32(2)),
	150: int8(-int32(4)),
	151: int8(-int32(4)),
	152: int8(-int32(6)),
	154: int8(-int32(2)),
	156: int8(-int32(2)),
	157: int8(-int32(2)),
	158: int8(-int32(4)),
	159: int8(-int32(9)),
	160: int8(-int32(5)),
	161: int8(-int32(7)),
	162: int8(-int32(3)),
	163: int8(-int32(5)),
	164: int8(-int32(7)),
	165: int8(-int32(8)),
	167: int8(-int32(2)),
	168: int8(-int32(12)),
	169: int8(-int32(9)),
	170: int8(-int32(5)),
	171: int8(-int32(8)),
	172: int8(-int32(2)),
	173: int8(-int32(2)),
	174: int8(-int32(1)),
	176: int8(-int32(3)),
	177: int8(-int32(3)),
	178: int8(-int32(1)),
	179: int8(-int32(3)),
	180: int8(-int32(1)),
	181: int8(-int32(3)),
	182: int8(-int32(5)),
	183: int8(-int32(1)),
	184: int8(-int32(1)),
	185: int8(-int32(1)),
	186: int8(-int32(1)),
	187: int8(-int32(3)),
	188: int8(-int32(6)),
	189: int8(-int32(5)),
	190: int8(-int32(8)),
	191: int8(-int32(4)),
	192: int8(-int32(6)),
	193: int8(-int32(9)),
	194: int8(-int32(5)),
	195: int8(-int32(1)),
	196: int8(-int32(5)),
	197: int8(-int32(3)),
	198: int8(-int32(3)),
	199: int8(-int32(3)),
	200: int8(-int32(3)),
	201: int8(-int32(3)),
	202: int8(-int32(3)),
	203: int8(-int32(3)),
	204: int8(-int32(3)),
	205: int8(-int32(2)),
	206: int8(-int32(3)),
	207: int8(-int32(5)),
	208: int8(-int32(2)),
	209: int8(-int32(3)),
	210: int8(-int32(3)),
	211: int8(-int32(4)),
	212: int8(-int32(6)),
	213: int8(-int32(5)),
	214: int8(-int32(2)),
	215: int8(-int32(2)),
	216: int8(-int32(2)),
	217: int8(-int32(3)),
	218: int8(-int32(1)),
	219: int8(-int32(2)),
	220: int8(-int32(5)),
	221: int8(-int32(1)),
	222: int8(-int32(2)),
	223: int8(-int32(5)),
	224: int8(-int32(3)),
	225: int8(-int32(5)),
	226: int8(-int32(5)),
	227: int8(-int32(4)),
	228: int8(-int32(5)),
	229: int8(-int32(5)),
	230: int8(-int32(4)),
	231: int8(-int32(2)),
	235: int8(-int32(3)),
	236: int8(-int32(1)),
	238: int8(-int32(3)),
	239: int8(-int32(12)),
	240: int8(-int32(1)),
	243: int8(-int32(3)),
	244: int8(-int32(5)),
	245: int8(-int32(3)),
	247: int8(-int32(2)),
	248: int8(-int32(4)),
	249: int8(-int32(2)),
	250: int8(-int32(3)),
	251: int8(-int32(2)),
	253: int8(-int32(3)),
	254: int8(-int32(5)),
	255: int8(-int32(6)),
	256: int8(-int32(5)),
	257: int8(-int32(6)),
	258: int8(-int32(2)),
	259: int8(-int32(2)),
	260: int8(-int32(5)),
	261: int8(-int32(11)),
	262: int8(-int32(1)),
	263: int8(-int32(2)),
	265: int8(-int32(1)),
	266: int8(-int32(1)),
	267: int8(-int32(3)),
	269: int8(-int32(2)),
	270: int8(-int32(3)),
	271: int8(-int32(2)),
	272: int8(-int32(3)),
	273: int8(-int32(2)),
	274: int8(-int32(9)),
	275: int8(-int32(8)),
	276: int8(-int32(6)),
	277: int8(-int32(3)),
	278: int8(-int32(4)),
	279: int8(-int32(6)),
	280: int8(-int32(1)),
	281: int8(-int32(1)),
	282: int8(-int32(1)),
	283: int8(-int32(4)),
	284: int8(-int32(6)),
	285: int8(-int32(3)),
	287: int8(-int32(2)),
	288: int8(-int32(1)),
	289: int8(-int32(3)),
	290: int8(-int32(1)),
	291: int8(-int32(3)),
	292: int8(-int32(6)),
	293: int8(-int32(2)),
	294: int8(-int32(7)),
	295: int8(-int32(6)),
	296: int8(-int32(8)),
	297: int8(-int32(6)),
	298: int8(-int32(9)),
	299: int8(-int32(10)),
	300: int8(-int32(11)),
	301: int8(-int32(9)),
	302: int8(-int32(1)),
	303: int8(-int32(4)),
	304: int8(-int32(8)),
	306: int8(-int32(1)),
	307: int8(-int32(3)),
	308: int8(-int32(1)),
	309: int8(-int32(2)),
	310: int8(-int32(3)),
	311: int8(-int32(1)),
	312: int8(-int32(2)),
	313: int8(-int32(3)),
	314: int8(-int32(6)),
	315: int8(-int32(1)),
	316: int8(-int32(1)),
	317: int8(-int32(3)),
	318: int8(-int32(3)),
	319: int8(-int32(5)),
	320: int8(-int32(5)),
	321: int8(-int32(6)),
	322: int8(-int32(4)),
	323: int8(-int32(5)),
	324: int8(-int32(2)),
	326: int8(-int32(3)),
	327: int8(-int32(6)),
	328: int8(-int32(1)),
	329: int8(-int32(1)),
	330: int8(-int32(2)),
	331: int8(-int32(1)),
	332: int8(-int32(2)),
	333: int8(-int32(2)),
	334: int8(-int32(2)),
	336: int8(-int32(2)),
	337: int8(-int32(2)),
	338: int8(-int32(2)),
	339: int8(-int32(1)),
	340: int8(-int32(2)),
	341: int8(-int32(2)),
	342: int8(-int32(1)),
	343: int8(-int32(1)),
	344: int8(-int32(4)),
	345: int8(-int32(2)),
	346: int8(-int32(5)),
	347: int8(-int32(1)),
	348: int8(-int32(1)),
	349: int8(-int32(2)),
	350: int8(-int32(1)),
	351: int8(-int32(1)),
	352: int8(-int32(2)),
	353: int8(-int32(3)),
	355: int8(-int32(1)),
	356: int8(-int32(2)),
	357: int8(-int32(1)),
	359: int8(-int32(2)),
	360: int8(-int32(1)),
	361: int8(-int32(4)),
	362: int8(-int32(2)),
	363: int8(-int32(1)),
	364: int8(-int32(1)),
	365: int8(-int32(1)),
	366: int8(-int32(1)),
	367: int8(-int32(1)),
	368: int8(-int32(1)),
	369: int8(-int32(2)),
	371: int8(-int32(2)),
	372: int8(-int32(4)),
	373: int8(-int32(2)),
	374: int8(-int32(2)),
	375: int8(-int32(3)),
	376: int8(-int32(1)),
	378: int8(-int32(1)),
	379: int8(-int32(1)),
	380: int8(-int32(1)),
	381: int8(-int32(1)),
	382: int8(-int32(2)),
	383: int8(-int32(1)),
	384: int8(-int32(1)),
	386: int8(-int32(1)),
	387: int8(-int32(1)),
	388: int8(-int32(1)),
	389: int8(-int32(1)),
	390: int8(-int32(1)),
	391: int8(-int32(1)),
	392: int8(-int32(1)),
	393: int8(-int32(1)),
	394: int8(-int32(1)),
	395: int8(-int32(1)),
	397: int8(-int32(3)),
	399: int8(-int32(1)),
	402: int8(-int32(1)),
	403: int8(-int32(1)),
	404: int8(-int32(3)),
	405: int8(-int32(2)),
	407: int8(-int32(4)),
	408: int8(-int32(2)),
	410: int8(-int32(1)),
	411: int8(-int32(1)),
}

// C documentation
//
//	/*
//	** The following is executed when the parser accepts
//	*/
func _yy_accept(tls *libc.TLS, yypParser uintptr) {
	var pParse uintptr
	_ = pParse
	pParse = (*TyyParser)(unsafe.Pointer(yypParser)).FpParse
	/* Here code is inserted which will be executed whenever the
	 ** parser accepts */
	/*********** Begin %parse_accept code *****************************************/
	/*********** End %parse_accept code *******************************************/
	/* Suppress warning about unused %extra_argument variable */
	(*TyyParser)(unsafe.Pointer(yypParser)).FpParse = pParse
}

// C documentation
//
//	/* Next are the tables used to determine what action to take based on the
//	** current state and lookahead token.  These tables are used to implement
//	** functions that take a state number and lookahead value and return an
//	** action integer.
//	**
//	** Suppose the action integer is N.  Then the action is determined as
//	** follows
//	**
//	**   0 <= N <= YY_MAX_SHIFT             Shift N.  That is, push the lookahead
//	**                                      token onto the stack and goto state N.
//	**
//	**   N between YY_MIN_SHIFTREDUCE       Shift to an arbitrary state then
//	**     and YY_MAX_SHIFTREDUCE           reduce by rule N-YY_MIN_SHIFTREDUCE.
//	**
//	**   N == YY_ERROR_ACTION               A syntax error has occurred.
//	**
//	**   N == YY_ACCEPT_ACTION              The parser accepts its input.
//	**
//	**   N == YY_NO_ACTION                  No such action.  Denotes unused
//	**                                      slots in the yy_action[] table.
//	**
//	**   N between YY_MIN_REDUCE            Reduce by rule N-YY_MIN_REDUCE
//	**     and YY_MAX_REDUCE
//	**
//	** The action table is constructed as a single large table named yy_action[].
//	** Given state S and lookahead X, the action is computed as either:
//	**
//	**    (A)   N = yy_action[ yy_shift_ofst[S] + X ]
//	**    (B)   N = yy_default[S]
//	**
//	** The (A) formula is preferred.  The B formula is used instead if
//	** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X.
//	**
//	** The formulas above are for computing the action when the lookahead is
//	** a terminal symbol.  If the lookahead is a non-terminal (as occurs after
//	** a reduce action) then the yy_reduce_ofst[] array is used in place of
//	** the yy_shift_ofst[] array.
//	**
//	** The following are the tables generated in this section:
//	**
//	**  yy_action[]        A single table containing all actions.
//	**  yy_lookahead[]     A table containing the lookahead for each entry in
//	**                     yy_action.  Used to detect hash collisions.
//	**  yy_shift_ofst[]    For each state, the offset into yy_action for
//	**                     shifting terminals.
//	**  yy_reduce_ofst[]   For each state, the offset into yy_action for
//	**                     shifting non-terminals after a reduce.
//	**  yy_default[]       Default action for each state.
//	**
//	*********** Begin parsing tables **********************************************/
var _yy_action = [2379]uint16{
	0:    uint16(134),
	1:    uint16(131),
	2:    uint16(238),
	3:    uint16(290),
	4:    uint16(290),
	5:    uint16(1353),
	6:    uint16(593),
	7:    uint16(1332),
	8:    uint16(478),
	9:    uint16(1606),
	10:   uint16(593),
	11:   uint16(1315),
	12:   uint16(593),
	13:   uint16(7),
	14:   uint16(593),
	15:   uint16(1353),
	16:   uint16(590),
	17:   uint16(593),
	18:   uint16(579),
	19:   uint16(424),
	20:   uint16(1566),
	21:   uint16(134),
	22:   uint16(131),
	23:   uint16(238),
	24:   uint16(1318),
	25:   uint16(541),
	26:   uint16(478),
	27:   uint16(477),
	28:   uint16(575),
	29:   uint16(84),
	30:   uint16(84),
	31:   uint16(1005),
	32:   uint16(303),
	33:   uint16(84),
	34:   uint16(84),
	35:   uint16(51),
	36:   uint16(51),
	37:   uint16(63),
	38:   uint16(63),
	39:   uint16(1006),
	40:   uint16(84),
	41:   uint16(84),
	42:   uint16(498),
	43:   uint16(141),
	44:   uint16(142),
	45:   uint16(93),
	46:   uint16(442),
	47:   uint16(1254),
	48:   uint16(1254),
	49:   uint16(1085),
	50:   uint16(1088),
	51:   uint16(1075),
	52:   uint16(1075),
	53:   uint16(139),
	54:   uint16(139),
	55:   uint16(140),
	56:   uint16(140),
	57:   uint16(140),
	58:   uint16(140),
	59:   uint16(424),
	60:   uint16(296),
	61:   uint16(296),
	62:   uint16(498),
	63:   uint16(296),
	64:   uint16(296),
	65:   uint16(567),
	66:   uint16(553),
	67:   uint16(296),
	68:   uint16(296),
	69:   uint16(1306),
	70:   uint16(574),
	71:   uint16(1358),
	72:   uint16(1358),
	73:   uint16(590),
	74:   uint16(542),
	75:   uint16(579),
	76:   uint16(590),
	77:   uint16(574),
	78:   uint16(579),
	79:   uint16(548),
	80:   uint16(590),
	81:   uint16(1304),
	82:   uint16(579),
	83:   uint16(141),
	84:   uint16(142),
	85:   uint16(93),
	86:   uint16(576),
	87:   uint16(1254),
	88:   uint16(1254),
	89:   uint16(1085),
	90:   uint16(1088),
	91:   uint16(1075),
	92:   uint16(1075),
	93:   uint16(139),
	94:   uint16(139),
	95:   uint16(140),
	96:   uint16(140),
	97:   uint16(140),
	98:   uint16(140),
	99:   uint16(399),
	100:  uint16(478),
	101:  uint16(395),
	102:  uint16(6),
	103:  uint16(138),
	104:  uint16(138),
	105:  uint16(138),
	106:  uint16(138),
	107:  uint16(137),
	108:  uint16(137),
	109:  uint16(136),
	110:  uint16(136),
	111:  uint16(136),
	112:  uint16(135),
	113:  uint16(132),
	114:  uint16(463),
	115:  uint16(44),
	116:  uint16(342),
	117:  uint16(593),
	118:  uint16(305),
	119:  uint16(1127),
	120:  uint16(1280),
	121:  uint16(1),
	122:  uint16(1),
	123:  uint16(599),
	124:  uint16(2),
	125:  uint16(1284),
	126:  uint16(598),
	127:  uint16(1200),
	128:  uint16(1284),
	129:  uint16(1200),
	130:  uint16(330),
	131:  uint16(424),
	132:  uint16(158),
	133:  uint16(330),
	134:  uint16(1613),
	135:  uint16(158),
	136:  uint16(390),
	137:  uint16(116),
	138:  uint16(308),
	139:  uint16(1366),
	140:  uint16(51),
	141:  uint16(51),
	142:  uint16(1366),
	143:  uint16(138),
	144:  uint16(138),
	145:  uint16(138),
	146:  uint16(138),
	147:  uint16(137),
	148:  uint16(137),
	149:  uint16(136),
	150:  uint16(136),
	151:  uint16(136),
	152:  uint16(135),
	153:  uint16(132),
	154:  uint16(463),
	155:  uint16(141),
	156:  uint16(142),
	157:  uint16(93),
	158:  uint16(515),
	159:  uint16(1254),
	160:  uint16(1254),
	161:  uint16(1085),
	162:  uint16(1088),
	163:  uint16(1075),
	164:  uint16(1075),
	165:  uint16(139),
	166:  uint16(139),
	167:  uint16(140),
	168:  uint16(140),
	169:  uint16(140),
	170:  uint16(140),
	171:  uint16(1230),
	172:  uint16(329),
	173:  uint16(584),
	174:  uint16(296),
	175:  uint16(296),
	176:  uint16(212),
	177:  uint16(296),
	178:  uint16(296),
	179:  uint16(568),
	180:  uint16(568),
	181:  uint16(488),
	182:  uint16(143),
	183:  uint16(1072),
	184:  uint16(1072),
	185:  uint16(1086),
	186:  uint16(1089),
	187:  uint16(590),
	188:  uint16(1195),
	189:  uint16(579),
	190:  uint16(590),
	191:  uint16(340),
	192:  uint16(579),
	193:  uint16(140),
	194:  uint16(140),
	195:  uint16(140),
	196:  uint16(140),
	197:  uint16(133),
	198:  uint16(392),
	199:  uint16(564),
	200:  uint16(536),
	201:  uint16(1195),
	202:  uint16(250),
	203:  uint16(425),
	204:  uint16(1195),
	205:  uint16(250),
	206:  uint16(137),
	207:  uint16(137),
	208:  uint16(136),
	209:  uint16(136),
	210:  uint16(136),
	211:  uint16(135),
	212:  uint16(132),
	213:  uint16(463),
	214:  uint16(291),
	215:  uint16(138),
	216:  uint16(138),
	217:  uint16(138),
	218:  uint16(138),
	219:  uint16(137),
	220:  uint16(137),
	221:  uint16(136),
	222:  uint16(136),
	223:  uint16(136),
	224:  uint16(135),
	225:  uint16(132),
	226:  uint16(463),
	227:  uint16(966),
	228:  uint16(1230),
	229:  uint16(1231),
	230:  uint16(1230),
	231:  uint16(412),
	232:  uint16(965),
	233:  uint16(467),
	234:  uint16(412),
	235:  uint16(424),
	236:  uint16(467),
	237:  uint16(489),
	238:  uint16(357),
	239:  uint16(1611),
	240:  uint16(391),
	241:  uint16(138),
	242:  uint16(138),
	243:  uint16(138),
	244:  uint16(138),
	245:  uint16(137),
	246:  uint16(137),
	247:  uint16(136),
	248:  uint16(136),
	249:  uint16(136),
	250:  uint16(135),
	251:  uint16(132),
	252:  uint16(463),
	253:  uint16(463),
	254:  uint16(134),
	255:  uint16(131),
	256:  uint16(238),
	257:  uint16(555),
	258:  uint16(1076),
	259:  uint16(141),
	260:  uint16(142),
	261:  uint16(93),
	262:  uint16(593),
	263:  uint16(1254),
	264:  uint16(1254),
	265:  uint16(1085),
	266:  uint16(1088),
	267:  uint16(1075),
	268:  uint16(1075),
	269:  uint16(139),
	270:  uint16(139),
	271:  uint16(140),
	272:  uint16(140),
	273:  uint16(140),
	274:  uint16(140),
	275:  uint16(1317),
	276:  uint16(134),
	277:  uint16(131),
	278:  uint16(238),
	279:  uint16(424),
	280:  uint16(549),
	281:  uint16(1597),
	282:  uint16(1531),
	283:  uint16(333),
	284:  uint16(97),
	285:  uint16(83),
	286:  uint16(83),
	287:  uint16(140),
	288:  uint16(140),
	289:  uint16(140),
	290:  uint16(140),
	291:  uint16(138),
	292:  uint16(138),
	293:  uint16(138),
	294:  uint16(138),
	295:  uint16(137),
	296:  uint16(137),
	297:  uint16(136),
	298:  uint16(136),
	299:  uint16(136),
	300:  uint16(135),
	301:  uint16(132),
	302:  uint16(463),
	303:  uint16(141),
	304:  uint16(142),
	305:  uint16(93),
	306:  uint16(1657),
	307:  uint16(1254),
	308:  uint16(1254),
	309:  uint16(1085),
	310:  uint16(1088),
	311:  uint16(1075),
	312:  uint16(1075),
	313:  uint16(139),
	314:  uint16(139),
	315:  uint16(140),
	316:  uint16(140),
	317:  uint16(140),
	318:  uint16(140),
	319:  uint16(138),
	320:  uint16(138),
	321:  uint16(138),
	322:  uint16(138),
	323:  uint16(137),
	324:  uint16(137),
	325:  uint16(136),
	326:  uint16(136),
	327:  uint16(136),
	328:  uint16(135),
	329:  uint16(132),
	330:  uint16(463),
	331:  uint16(591),
	332:  uint16(1230),
	333:  uint16(958),
	334:  uint16(958),
	335:  uint16(138),
	336:  uint16(138),
	337:  uint16(138),
	338:  uint16(138),
	339:  uint16(137),
	340:  uint16(137),
	341:  uint16(136),
	342:  uint16(136),
	343:  uint16(136),
	344:  uint16(135),
	345:  uint16(132),
	346:  uint16(463),
	347:  uint16(44),
	348:  uint16(398),
	349:  uint16(547),
	350:  uint16(1306),
	351:  uint16(136),
	352:  uint16(136),
	353:  uint16(136),
	354:  uint16(135),
	355:  uint16(132),
	356:  uint16(463),
	357:  uint16(386),
	358:  uint16(593),
	359:  uint16(442),
	360:  uint16(595),
	361:  uint16(145),
	362:  uint16(595),
	363:  uint16(138),
	364:  uint16(138),
	365:  uint16(138),
	366:  uint16(138),
	367:  uint16(137),
	368:  uint16(137),
	369:  uint16(136),
	370:  uint16(136),
	371:  uint16(136),
	372:  uint16(135),
	373:  uint16(132),
	374:  uint16(463),
	375:  uint16(500),
	376:  uint16(1230),
	377:  uint16(112),
	378:  uint16(550),
	379:  uint16(460),
	380:  uint16(459),
	381:  uint16(51),
	382:  uint16(51),
	383:  uint16(424),
	384:  uint16(296),
	385:  uint16(296),
	386:  uint16(479),
	387:  uint16(334),
	388:  uint16(1259),
	389:  uint16(1230),
	390:  uint16(1231),
	391:  uint16(1230),
	392:  uint16(1599),
	393:  uint16(1261),
	394:  uint16(388),
	395:  uint16(312),
	396:  uint16(444),
	397:  uint16(590),
	398:  uint16(246),
	399:  uint16(579),
	400:  uint16(546),
	401:  uint16(1260),
	402:  uint16(271),
	403:  uint16(235),
	404:  uint16(329),
	405:  uint16(584),
	406:  uint16(551),
	407:  uint16(141),
	408:  uint16(142),
	409:  uint16(93),
	410:  uint16(429),
	411:  uint16(1254),
	412:  uint16(1254),
	413:  uint16(1085),
	414:  uint16(1088),
	415:  uint16(1075),
	416:  uint16(1075),
	417:  uint16(139),
	418:  uint16(139),
	419:  uint16(140),
	420:  uint16(140),
	421:  uint16(140),
	422:  uint16(140),
	423:  uint16(22),
	424:  uint16(22),
	425:  uint16(1230),
	426:  uint16(1262),
	427:  uint16(424),
	428:  uint16(1262),
	429:  uint16(216),
	430:  uint16(296),
	431:  uint16(296),
	432:  uint16(98),
	433:  uint16(1230),
	434:  uint16(1231),
	435:  uint16(1230),
	436:  uint16(264),
	437:  uint16(884),
	438:  uint16(45),
	439:  uint16(528),
	440:  uint16(525),
	441:  uint16(524),
	442:  uint16(1041),
	443:  uint16(590),
	444:  uint16(1269),
	445:  uint16(579),
	446:  uint16(421),
	447:  uint16(420),
	448:  uint16(393),
	449:  uint16(523),
	450:  uint16(44),
	451:  uint16(141),
	452:  uint16(142),
	453:  uint16(93),
	454:  uint16(498),
	455:  uint16(1254),
	456:  uint16(1254),
	457:  uint16(1085),
	458:  uint16(1088),
	459:  uint16(1075),
	460:  uint16(1075),
	461:  uint16(139),
	462:  uint16(139),
	463:  uint16(140),
	464:  uint16(140),
	465:  uint16(140),
	466:  uint16(140),
	467:  uint16(138),
	468:  uint16(138),
	469:  uint16(138),
	470:  uint16(138),
	471:  uint16(137),
	472:  uint16(137),
	473:  uint16(136),
	474:  uint16(136),
	475:  uint16(136),
	476:  uint16(135),
	477:  uint16(132),
	478:  uint16(463),
	479:  uint16(593),
	480:  uint16(1611),
	481:  uint16(561),
	482:  uint16(1230),
	483:  uint16(1231),
	484:  uint16(1230),
	485:  uint16(23),
	486:  uint16(264),
	487:  uint16(515),
	488:  uint16(200),
	489:  uint16(528),
	490:  uint16(525),
	491:  uint16(524),
	492:  uint16(127),
	493:  uint16(585),
	494:  uint16(509),
	495:  uint16(4),
	496:  uint16(355),
	497:  uint16(487),
	498:  uint16(506),
	499:  uint16(523),
	500:  uint16(593),
	501:  uint16(498),
	502:  uint16(84),
	503:  uint16(84),
	504:  uint16(134),
	505:  uint16(131),
	506:  uint16(238),
	507:  uint16(329),
	508:  uint16(584),
	509:  uint16(588),
	510:  uint16(1627),
	511:  uint16(138),
	512:  uint16(138),
	513:  uint16(138),
	514:  uint16(138),
	515:  uint16(137),
	516:  uint16(137),
	517:  uint16(136),
	518:  uint16(136),
	519:  uint16(136),
	520:  uint16(135),
	521:  uint16(132),
	522:  uint16(463),
	523:  uint16(19),
	524:  uint16(19),
	525:  uint16(435),
	526:  uint16(1230),
	527:  uint16(1460),
	528:  uint16(297),
	529:  uint16(297),
	530:  uint16(311),
	531:  uint16(424),
	532:  uint16(1565),
	533:  uint16(464),
	534:  uint16(1631),
	535:  uint16(599),
	536:  uint16(2),
	537:  uint16(1284),
	538:  uint16(437),
	539:  uint16(574),
	540:  uint16(1107),
	541:  uint16(590),
	542:  uint16(330),
	543:  uint16(579),
	544:  uint16(158),
	545:  uint16(582),
	546:  uint16(489),
	547:  uint16(357),
	548:  uint16(573),
	549:  uint16(593),
	550:  uint16(592),
	551:  uint16(1366),
	552:  uint16(409),
	553:  uint16(1274),
	554:  uint16(1230),
	555:  uint16(141),
	556:  uint16(142),
	557:  uint16(93),
	558:  uint16(1364),
	559:  uint16(1254),
	560:  uint16(1254),
	561:  uint16(1085),
	562:  uint16(1088),
	563:  uint16(1075),
	564:  uint16(1075),
	565:  uint16(139),
	566:  uint16(139),
	567:  uint16(140),
	568:  uint16(140),
	569:  uint16(140),
	570:  uint16(140),
	571:  uint16(389),
	572:  uint16(84),
	573:  uint16(84),
	574:  uint16(1062),
	575:  uint16(567),
	576:  uint16(1230),
	577:  uint16(313),
	578:  uint16(1523),
	579:  uint16(593),
	580:  uint16(125),
	581:  uint16(125),
	582:  uint16(970),
	583:  uint16(1230),
	584:  uint16(1231),
	585:  uint16(1230),
	586:  uint16(296),
	587:  uint16(296),
	588:  uint16(126),
	589:  uint16(46),
	590:  uint16(464),
	591:  uint16(594),
	592:  uint16(464),
	593:  uint16(296),
	594:  uint16(296),
	595:  uint16(1050),
	596:  uint16(1230),
	597:  uint16(218),
	598:  uint16(439),
	599:  uint16(590),
	600:  uint16(1604),
	601:  uint16(579),
	602:  uint16(84),
	603:  uint16(84),
	604:  uint16(7),
	605:  uint16(403),
	606:  uint16(590),
	607:  uint16(515),
	608:  uint16(579),
	609:  uint16(325),
	610:  uint16(417),
	611:  uint16(1230),
	612:  uint16(1231),
	613:  uint16(1230),
	614:  uint16(250),
	615:  uint16(138),
	616:  uint16(138),
	617:  uint16(138),
	618:  uint16(138),
	619:  uint16(137),
	620:  uint16(137),
	621:  uint16(136),
	622:  uint16(136),
	623:  uint16(136),
	624:  uint16(135),
	625:  uint16(132),
	626:  uint16(463),
	627:  uint16(1050),
	628:  uint16(1050),
	629:  uint16(1052),
	630:  uint16(1053),
	631:  uint16(35),
	632:  uint16(1275),
	633:  uint16(1230),
	634:  uint16(1231),
	635:  uint16(1230),
	636:  uint16(424),
	637:  uint16(1370),
	638:  uint16(993),
	639:  uint16(574),
	640:  uint16(371),
	641:  uint16(414),
	642:  uint16(274),
	643:  uint16(412),
	644:  uint16(1597),
	645:  uint16(467),
	646:  uint16(1302),
	647:  uint16(552),
	648:  uint16(451),
	649:  uint16(590),
	650:  uint16(543),
	651:  uint16(579),
	652:  uint16(1530),
	653:  uint16(1230),
	654:  uint16(1231),
	655:  uint16(1230),
	656:  uint16(1214),
	657:  uint16(201),
	658:  uint16(409),
	659:  uint16(1174),
	660:  uint16(141),
	661:  uint16(142),
	662:  uint16(93),
	663:  uint16(223),
	664:  uint16(1254),
	665:  uint16(1254),
	666:  uint16(1085),
	667:  uint16(1088),
	668:  uint16(1075),
	669:  uint16(1075),
	670:  uint16(139),
	671:  uint16(139),
	672:  uint16(140),
	673:  uint16(140),
	674:  uint16(140),
	675:  uint16(140),
	676:  uint16(296),
	677:  uint16(296),
	678:  uint16(1250),
	679:  uint16(593),
	680:  uint16(424),
	681:  uint16(296),
	682:  uint16(296),
	683:  uint16(236),
	684:  uint16(529),
	685:  uint16(296),
	686:  uint16(296),
	687:  uint16(515),
	688:  uint16(100),
	689:  uint16(590),
	690:  uint16(1600),
	691:  uint16(579),
	692:  uint16(48),
	693:  uint16(1605),
	694:  uint16(590),
	695:  uint16(1230),
	696:  uint16(579),
	697:  uint16(7),
	698:  uint16(590),
	699:  uint16(577),
	700:  uint16(579),
	701:  uint16(904),
	702:  uint16(84),
	703:  uint16(84),
	704:  uint16(141),
	705:  uint16(142),
	706:  uint16(93),
	707:  uint16(496),
	708:  uint16(1254),
	709:  uint16(1254),
	710:  uint16(1085),
	711:  uint16(1088),
	712:  uint16(1075),
	713:  uint16(1075),
	714:  uint16(139),
	715:  uint16(139),
	716:  uint16(140),
	717:  uint16(140),
	718:  uint16(140),
	719:  uint16(140),
	720:  uint16(138),
	721:  uint16(138),
	722:  uint16(138),
	723:  uint16(138),
	724:  uint16(137),
	725:  uint16(137),
	726:  uint16(136),
	727:  uint16(136),
	728:  uint16(136),
	729:  uint16(135),
	730:  uint16(132),
	731:  uint16(463),
	732:  uint16(1365),
	733:  uint16(1230),
	734:  uint16(296),
	735:  uint16(296),
	736:  uint16(1250),
	737:  uint16(115),
	738:  uint16(1275),
	739:  uint16(326),
	740:  uint16(233),
	741:  uint16(539),
	742:  uint16(1062),
	743:  uint16(40),
	744:  uint16(282),
	745:  uint16(127),
	746:  uint16(585),
	747:  uint16(590),
	748:  uint16(4),
	749:  uint16(579),
	750:  uint16(329),
	751:  uint16(584),
	752:  uint16(1230),
	753:  uint16(1231),
	754:  uint16(1230),
	755:  uint16(1598),
	756:  uint16(593),
	757:  uint16(388),
	758:  uint16(904),
	759:  uint16(1051),
	760:  uint16(1356),
	761:  uint16(1356),
	762:  uint16(588),
	763:  uint16(1050),
	764:  uint16(138),
	765:  uint16(138),
	766:  uint16(138),
	767:  uint16(138),
	768:  uint16(137),
	769:  uint16(137),
	770:  uint16(136),
	771:  uint16(136),
	772:  uint16(136),
	773:  uint16(135),
	774:  uint16(132),
	775:  uint16(463),
	776:  uint16(185),
	777:  uint16(593),
	778:  uint16(1230),
	779:  uint16(19),
	780:  uint16(19),
	781:  uint16(1230),
	782:  uint16(971),
	783:  uint16(1597),
	784:  uint16(424),
	785:  uint16(1651),
	786:  uint16(464),
	787:  uint16(129),
	788:  uint16(908),
	789:  uint16(1195),
	790:  uint16(1230),
	791:  uint16(1231),
	792:  uint16(1230),
	793:  uint16(1325),
	794:  uint16(443),
	795:  uint16(1050),
	796:  uint16(1050),
	797:  uint16(1052),
	798:  uint16(582),
	799:  uint16(1603),
	800:  uint16(149),
	801:  uint16(149),
	802:  uint16(1195),
	803:  uint16(7),
	804:  uint16(5),
	805:  uint16(1195),
	806:  uint16(1687),
	807:  uint16(410),
	808:  uint16(141),
	809:  uint16(142),
	810:  uint16(93),
	811:  uint16(1536),
	812:  uint16(1254),
	813:  uint16(1254),
	814:  uint16(1085),
	815:  uint16(1088),
	816:  uint16(1075),
	817:  uint16(1075),
	818:  uint16(139),
	819:  uint16(139),
	820:  uint16(140),
	821:  uint16(140),
	822:  uint16(140),
	823:  uint16(140),
	824:  uint16(1214),
	825:  uint16(397),
	826:  uint16(593),
	827:  uint16(1062),
	828:  uint16(424),
	829:  uint16(1536),
	830:  uint16(1538),
	831:  uint16(50),
	832:  uint16(901),
	833:  uint16(125),
	834:  uint16(125),
	835:  uint16(1230),
	836:  uint16(1231),
	837:  uint16(1230),
	838:  uint16(1230),
	839:  uint16(1231),
	840:  uint16(1230),
	841:  uint16(126),
	842:  uint16(1230),
	843:  uint16(464),
	844:  uint16(594),
	845:  uint16(464),
	846:  uint16(515),
	847:  uint16(1230),
	848:  uint16(1050),
	849:  uint16(84),
	850:  uint16(84),
	851:  uint16(3),
	852:  uint16(141),
	853:  uint16(142),
	854:  uint16(93),
	855:  uint16(924),
	856:  uint16(1254),
	857:  uint16(1254),
	858:  uint16(1085),
	859:  uint16(1088),
	860:  uint16(1075),
	861:  uint16(1075),
	862:  uint16(139),
	863:  uint16(139),
	864:  uint16(140),
	865:  uint16(140),
	866:  uint16(140),
	867:  uint16(140),
	868:  uint16(138),
	869:  uint16(138),
	870:  uint16(138),
	871:  uint16(138),
	872:  uint16(137),
	873:  uint16(137),
	874:  uint16(136),
	875:  uint16(136),
	876:  uint16(136),
	877:  uint16(135),
	878:  uint16(132),
	879:  uint16(463),
	880:  uint16(1050),
	881:  uint16(1050),
	882:  uint16(1052),
	883:  uint16(1053),
	884:  uint16(35),
	885:  uint16(442),
	886:  uint16(457),
	887:  uint16(532),
	888:  uint16(433),
	889:  uint16(1230),
	890:  uint16(1062),
	891:  uint16(1361),
	892:  uint16(540),
	893:  uint16(540),
	894:  uint16(1598),
	895:  uint16(925),
	896:  uint16(388),
	897:  uint16(7),
	898:  uint16(1129),
	899:  uint16(1230),
	900:  uint16(1231),
	901:  uint16(1230),
	902:  uint16(1129),
	903:  uint16(1536),
	904:  uint16(1230),
	905:  uint16(1231),
	906:  uint16(1230),
	907:  uint16(1051),
	908:  uint16(570),
	909:  uint16(1214),
	910:  uint16(593),
	911:  uint16(1050),
	912:  uint16(138),
	913:  uint16(138),
	914:  uint16(138),
	915:  uint16(138),
	916:  uint16(137),
	917:  uint16(137),
	918:  uint16(136),
	919:  uint16(136),
	920:  uint16(136),
	921:  uint16(135),
	922:  uint16(132),
	923:  uint16(463),
	924:  uint16(6),
	925:  uint16(185),
	926:  uint16(1195),
	927:  uint16(1230),
	928:  uint16(231),
	929:  uint16(593),
	930:  uint16(382),
	931:  uint16(992),
	932:  uint16(424),
	933:  uint16(151),
	934:  uint16(151),
	935:  uint16(510),
	936:  uint16(1213),
	937:  uint16(557),
	938:  uint16(482),
	939:  uint16(1195),
	940:  uint16(381),
	941:  uint16(160),
	942:  uint16(1195),
	943:  uint16(1050),
	944:  uint16(1050),
	945:  uint16(1052),
	946:  uint16(1230),
	947:  uint16(1231),
	948:  uint16(1230),
	949:  uint16(422),
	950:  uint16(593),
	951:  uint16(447),
	952:  uint16(84),
	953:  uint16(84),
	954:  uint16(593),
	955:  uint16(217),
	956:  uint16(141),
	957:  uint16(142),
	958:  uint16(93),
	959:  uint16(593),
	960:  uint16(1254),
	961:  uint16(1254),
	962:  uint16(1085),
	963:  uint16(1088),
	964:  uint16(1075),
	965:  uint16(1075),
	966:  uint16(139),
	967:  uint16(139),
	968:  uint16(140),
	969:  uint16(140),
	970:  uint16(140),
	971:  uint16(140),
	972:  uint16(1214),
	973:  uint16(19),
	974:  uint16(19),
	975:  uint16(593),
	976:  uint16(424),
	977:  uint16(19),
	978:  uint16(19),
	979:  uint16(442),
	980:  uint16(1063),
	981:  uint16(442),
	982:  uint16(19),
	983:  uint16(19),
	984:  uint16(1230),
	985:  uint16(1231),
	986:  uint16(1230),
	987:  uint16(515),
	988:  uint16(445),
	989:  uint16(458),
	990:  uint16(1597),
	991:  uint16(386),
	992:  uint16(315),
	993:  uint16(1175),
	994:  uint16(1685),
	995:  uint16(556),
	996:  uint16(1685),
	997:  uint16(450),
	998:  uint16(84),
	999:  uint16(84),
	1000: uint16(141),
	1001: uint16(142),
	1002: uint16(93),
	1003: uint16(505),
	1004: uint16(1254),
	1005: uint16(1254),
	1006: uint16(1085),
	1007: uint16(1088),
	1008: uint16(1075),
	1009: uint16(1075),
	1010: uint16(139),
	1011: uint16(139),
	1012: uint16(140),
	1013: uint16(140),
	1014: uint16(140),
	1015: uint16(140),
	1016: uint16(138),
	1017: uint16(138),
	1018: uint16(138),
	1019: uint16(138),
	1020: uint16(137),
	1021: uint16(137),
	1022: uint16(136),
	1023: uint16(136),
	1024: uint16(136),
	1025: uint16(135),
	1026: uint16(132),
	1027: uint16(463),
	1028: uint16(442),
	1029: uint16(1147),
	1030: uint16(454),
	1031: uint16(1597),
	1032: uint16(362),
	1033: uint16(1041),
	1034: uint16(593),
	1035: uint16(462),
	1036: uint16(1460),
	1037: uint16(1233),
	1038: uint16(47),
	1039: uint16(1393),
	1040: uint16(324),
	1041: uint16(565),
	1042: uint16(565),
	1043: uint16(115),
	1044: uint16(1148),
	1045: uint16(449),
	1046: uint16(7),
	1047: uint16(460),
	1048: uint16(459),
	1049: uint16(307),
	1050: uint16(375),
	1051: uint16(354),
	1052: uint16(593),
	1053: uint16(113),
	1054: uint16(593),
	1055: uint16(329),
	1056: uint16(584),
	1057: uint16(19),
	1058: uint16(19),
	1059: uint16(1149),
	1060: uint16(138),
	1061: uint16(138),
	1062: uint16(138),
	1063: uint16(138),
	1064: uint16(137),
	1065: uint16(137),
	1066: uint16(136),
	1067: uint16(136),
	1068: uint16(136),
	1069: uint16(135),
	1070: uint16(132),
	1071: uint16(463),
	1072: uint16(209),
	1073: uint16(1173),
	1074: uint16(563),
	1075: uint16(19),
	1076: uint16(19),
	1077: uint16(19),
	1078: uint16(19),
	1079: uint16(49),
	1080: uint16(424),
	1081: uint16(944),
	1082: uint16(1175),
	1083: uint16(1686),
	1084: uint16(1046),
	1085: uint16(1686),
	1086: uint16(218),
	1087: uint16(355),
	1088: uint16(484),
	1089: uint16(343),
	1090: uint16(210),
	1091: uint16(945),
	1092: uint16(569),
	1093: uint16(562),
	1094: uint16(1262),
	1095: uint16(1233),
	1096: uint16(1262),
	1097: uint16(490),
	1098: uint16(314),
	1099: uint16(423),
	1100: uint16(424),
	1101: uint16(1598),
	1102: uint16(1206),
	1103: uint16(388),
	1104: uint16(141),
	1105: uint16(142),
	1106: uint16(93),
	1107: uint16(440),
	1108: uint16(1254),
	1109: uint16(1254),
	1110: uint16(1085),
	1111: uint16(1088),
	1112: uint16(1075),
	1113: uint16(1075),
	1114: uint16(139),
	1115: uint16(139),
	1116: uint16(140),
	1117: uint16(140),
	1118: uint16(140),
	1119: uint16(140),
	1120: uint16(352),
	1121: uint16(316),
	1122: uint16(531),
	1123: uint16(316),
	1124: uint16(141),
	1125: uint16(142),
	1126: uint16(93),
	1127: uint16(549),
	1128: uint16(1254),
	1129: uint16(1254),
	1130: uint16(1085),
	1131: uint16(1088),
	1132: uint16(1075),
	1133: uint16(1075),
	1134: uint16(139),
	1135: uint16(139),
	1136: uint16(140),
	1137: uint16(140),
	1138: uint16(140),
	1139: uint16(140),
	1140: uint16(446),
	1141: uint16(10),
	1142: uint16(1598),
	1143: uint16(274),
	1144: uint16(388),
	1145: uint16(915),
	1146: uint16(281),
	1147: uint16(299),
	1148: uint16(383),
	1149: uint16(534),
	1150: uint16(378),
	1151: uint16(533),
	1152: uint16(269),
	1153: uint16(593),
	1154: uint16(1206),
	1155: uint16(587),
	1156: uint16(587),
	1157: uint16(587),
	1158: uint16(374),
	1159: uint16(293),
	1160: uint16(1579),
	1161: uint16(991),
	1162: uint16(1173),
	1163: uint16(302),
	1164: uint16(138),
	1165: uint16(138),
	1166: uint16(138),
	1167: uint16(138),
	1168: uint16(137),
	1169: uint16(137),
	1170: uint16(136),
	1171: uint16(136),
	1172: uint16(136),
	1173: uint16(135),
	1174: uint16(132),
	1175: uint16(463),
	1176: uint16(53),
	1177: uint16(53),
	1178: uint16(520),
	1179: uint16(1250),
	1180: uint16(593),
	1181: uint16(1147),
	1182: uint16(1576),
	1183: uint16(431),
	1184: uint16(138),
	1185: uint16(138),
	1186: uint16(138),
	1187: uint16(138),
	1188: uint16(137),
	1189: uint16(137),
	1190: uint16(136),
	1191: uint16(136),
	1192: uint16(136),
	1193: uint16(135),
	1194: uint16(132),
	1195: uint16(463),
	1196: uint16(1148),
	1197: uint16(301),
	1198: uint16(593),
	1199: uint16(1577),
	1200: uint16(593),
	1201: uint16(1307),
	1202: uint16(431),
	1203: uint16(54),
	1204: uint16(54),
	1205: uint16(593),
	1206: uint16(268),
	1207: uint16(593),
	1208: uint16(461),
	1209: uint16(461),
	1210: uint16(461),
	1211: uint16(1149),
	1212: uint16(347),
	1213: uint16(492),
	1214: uint16(424),
	1215: uint16(135),
	1216: uint16(132),
	1217: uint16(463),
	1218: uint16(1146),
	1219: uint16(1195),
	1220: uint16(474),
	1221: uint16(68),
	1222: uint16(68),
	1223: uint16(69),
	1224: uint16(69),
	1225: uint16(550),
	1226: uint16(332),
	1227: uint16(287),
	1228: uint16(21),
	1229: uint16(21),
	1230: uint16(55),
	1231: uint16(55),
	1232: uint16(1195),
	1233: uint16(581),
	1234: uint16(424),
	1235: uint16(1195),
	1236: uint16(309),
	1237: uint16(1250),
	1238: uint16(141),
	1239: uint16(142),
	1240: uint16(93),
	1241: uint16(119),
	1242: uint16(1254),
	1243: uint16(1254),
	1244: uint16(1085),
	1245: uint16(1088),
	1246: uint16(1075),
	1247: uint16(1075),
	1248: uint16(139),
	1249: uint16(139),
	1250: uint16(140),
	1251: uint16(140),
	1252: uint16(140),
	1253: uint16(140),
	1254: uint16(593),
	1255: uint16(237),
	1256: uint16(480),
	1257: uint16(1476),
	1258: uint16(141),
	1259: uint16(142),
	1260: uint16(93),
	1261: uint16(593),
	1262: uint16(1254),
	1263: uint16(1254),
	1264: uint16(1085),
	1265: uint16(1088),
	1266: uint16(1075),
	1267: uint16(1075),
	1268: uint16(139),
	1269: uint16(139),
	1270: uint16(140),
	1271: uint16(140),
	1272: uint16(140),
	1273: uint16(140),
	1274: uint16(344),
	1275: uint16(430),
	1276: uint16(346),
	1277: uint16(70),
	1278: uint16(70),
	1279: uint16(494),
	1280: uint16(991),
	1281: uint16(1132),
	1282: uint16(1132),
	1283: uint16(512),
	1284: uint16(56),
	1285: uint16(56),
	1286: uint16(1269),
	1287: uint16(593),
	1288: uint16(268),
	1289: uint16(593),
	1290: uint16(369),
	1291: uint16(374),
	1292: uint16(593),
	1293: uint16(481),
	1294: uint16(215),
	1295: uint16(384),
	1296: uint16(1624),
	1297: uint16(481),
	1298: uint16(138),
	1299: uint16(138),
	1300: uint16(138),
	1301: uint16(138),
	1302: uint16(137),
	1303: uint16(137),
	1304: uint16(136),
	1305: uint16(136),
	1306: uint16(136),
	1307: uint16(135),
	1308: uint16(132),
	1309: uint16(463),
	1310: uint16(71),
	1311: uint16(71),
	1312: uint16(72),
	1313: uint16(72),
	1314: uint16(225),
	1315: uint16(73),
	1316: uint16(73),
	1317: uint16(593),
	1318: uint16(138),
	1319: uint16(138),
	1320: uint16(138),
	1321: uint16(138),
	1322: uint16(137),
	1323: uint16(137),
	1324: uint16(136),
	1325: uint16(136),
	1326: uint16(136),
	1327: uint16(135),
	1328: uint16(132),
	1329: uint16(463),
	1330: uint16(586),
	1331: uint16(431),
	1332: uint16(593),
	1333: uint16(872),
	1334: uint16(873),
	1335: uint16(874),
	1336: uint16(593),
	1337: uint16(911),
	1338: uint16(593),
	1339: uint16(1602),
	1340: uint16(74),
	1341: uint16(74),
	1342: uint16(593),
	1343: uint16(7),
	1344: uint16(1460),
	1345: uint16(242),
	1346: uint16(593),
	1347: uint16(306),
	1348: uint16(424),
	1349: uint16(1578),
	1350: uint16(472),
	1351: uint16(306),
	1352: uint16(364),
	1353: uint16(219),
	1354: uint16(367),
	1355: uint16(75),
	1356: uint16(75),
	1357: uint16(430),
	1358: uint16(345),
	1359: uint16(57),
	1360: uint16(57),
	1361: uint16(58),
	1362: uint16(58),
	1363: uint16(432),
	1364: uint16(187),
	1365: uint16(59),
	1366: uint16(59),
	1367: uint16(593),
	1368: uint16(424),
	1369: uint16(61),
	1370: uint16(61),
	1371: uint16(1475),
	1372: uint16(141),
	1373: uint16(142),
	1374: uint16(93),
	1375: uint16(123),
	1376: uint16(1254),
	1377: uint16(1254),
	1378: uint16(1085),
	1379: uint16(1088),
	1380: uint16(1075),
	1381: uint16(1075),
	1382: uint16(139),
	1383: uint16(139),
	1384: uint16(140),
	1385: uint16(140),
	1386: uint16(140),
	1387: uint16(140),
	1388: uint16(424),
	1389: uint16(570),
	1390: uint16(62),
	1391: uint16(62),
	1392: uint16(141),
	1393: uint16(142),
	1394: uint16(93),
	1395: uint16(911),
	1396: uint16(1254),
	1397: uint16(1254),
	1398: uint16(1085),
	1399: uint16(1088),
	1400: uint16(1075),
	1401: uint16(1075),
	1402: uint16(139),
	1403: uint16(139),
	1404: uint16(140),
	1405: uint16(140),
	1406: uint16(140),
	1407: uint16(140),
	1408: uint16(161),
	1409: uint16(384),
	1410: uint16(1624),
	1411: uint16(1474),
	1412: uint16(141),
	1413: uint16(130),
	1414: uint16(93),
	1415: uint16(441),
	1416: uint16(1254),
	1417: uint16(1254),
	1418: uint16(1085),
	1419: uint16(1088),
	1420: uint16(1075),
	1421: uint16(1075),
	1422: uint16(139),
	1423: uint16(139),
	1424: uint16(140),
	1425: uint16(140),
	1426: uint16(140),
	1427: uint16(140),
	1428: uint16(267),
	1429: uint16(266),
	1430: uint16(265),
	1431: uint16(1460),
	1432: uint16(138),
	1433: uint16(138),
	1434: uint16(138),
	1435: uint16(138),
	1436: uint16(137),
	1437: uint16(137),
	1438: uint16(136),
	1439: uint16(136),
	1440: uint16(136),
	1441: uint16(135),
	1442: uint16(132),
	1443: uint16(463),
	1444: uint16(593),
	1445: uint16(1336),
	1446: uint16(593),
	1447: uint16(1269),
	1448: uint16(1460),
	1449: uint16(384),
	1450: uint16(1624),
	1451: uint16(231),
	1452: uint16(138),
	1453: uint16(138),
	1454: uint16(138),
	1455: uint16(138),
	1456: uint16(137),
	1457: uint16(137),
	1458: uint16(136),
	1459: uint16(136),
	1460: uint16(136),
	1461: uint16(135),
	1462: uint16(132),
	1463: uint16(463),
	1464: uint16(593),
	1465: uint16(163),
	1466: uint16(593),
	1467: uint16(76),
	1468: uint16(76),
	1469: uint16(77),
	1470: uint16(77),
	1471: uint16(593),
	1472: uint16(138),
	1473: uint16(138),
	1474: uint16(138),
	1475: uint16(138),
	1476: uint16(137),
	1477: uint16(137),
	1478: uint16(136),
	1479: uint16(136),
	1480: uint16(136),
	1481: uint16(135),
	1482: uint16(132),
	1483: uint16(463),
	1484: uint16(475),
	1485: uint16(593),
	1486: uint16(483),
	1487: uint16(78),
	1488: uint16(78),
	1489: uint16(20),
	1490: uint16(20),
	1491: uint16(1249),
	1492: uint16(424),
	1493: uint16(491),
	1494: uint16(79),
	1495: uint16(79),
	1496: uint16(495),
	1497: uint16(422),
	1498: uint16(295),
	1499: uint16(235),
	1500: uint16(1574),
	1501: uint16(38),
	1502: uint16(511),
	1503: uint16(896),
	1504: uint16(422),
	1505: uint16(335),
	1506: uint16(240),
	1507: uint16(422),
	1508: uint16(147),
	1509: uint16(147),
	1510: uint16(112),
	1511: uint16(593),
	1512: uint16(424),
	1513: uint16(593),
	1514: uint16(101),
	1515: uint16(222),
	1516: uint16(991),
	1517: uint16(142),
	1518: uint16(93),
	1519: uint16(455),
	1520: uint16(1254),
	1521: uint16(1254),
	1522: uint16(1085),
	1523: uint16(1088),
	1524: uint16(1075),
	1525: uint16(1075),
	1526: uint16(139),
	1527: uint16(139),
	1528: uint16(140),
	1529: uint16(140),
	1530: uint16(140),
	1531: uint16(140),
	1532: uint16(593),
	1533: uint16(39),
	1534: uint16(148),
	1535: uint16(148),
	1536: uint16(80),
	1537: uint16(80),
	1538: uint16(93),
	1539: uint16(551),
	1540: uint16(1254),
	1541: uint16(1254),
	1542: uint16(1085),
	1543: uint16(1088),
	1544: uint16(1075),
	1545: uint16(1075),
	1546: uint16(139),
	1547: uint16(139),
	1548: uint16(140),
	1549: uint16(140),
	1550: uint16(140),
	1551: uint16(140),
	1552: uint16(328),
	1553: uint16(923),
	1554: uint16(922),
	1555: uint16(64),
	1556: uint16(64),
	1557: uint16(502),
	1558: uint16(1656),
	1559: uint16(1005),
	1560: uint16(933),
	1561: uint16(896),
	1562: uint16(124),
	1563: uint16(422),
	1564: uint16(121),
	1565: uint16(254),
	1566: uint16(593),
	1567: uint16(1006),
	1568: uint16(593),
	1569: uint16(226),
	1570: uint16(593),
	1571: uint16(127),
	1572: uint16(585),
	1573: uint16(164),
	1574: uint16(4),
	1575: uint16(16),
	1576: uint16(138),
	1577: uint16(138),
	1578: uint16(138),
	1579: uint16(138),
	1580: uint16(137),
	1581: uint16(137),
	1582: uint16(136),
	1583: uint16(136),
	1584: uint16(136),
	1585: uint16(135),
	1586: uint16(132),
	1587: uint16(463),
	1588: uint16(588),
	1589: uint16(81),
	1590: uint16(81),
	1591: uint16(65),
	1592: uint16(65),
	1593: uint16(82),
	1594: uint16(82),
	1595: uint16(593),
	1596: uint16(138),
	1597: uint16(138),
	1598: uint16(138),
	1599: uint16(138),
	1600: uint16(137),
	1601: uint16(137),
	1602: uint16(136),
	1603: uint16(136),
	1604: uint16(136),
	1605: uint16(135),
	1606: uint16(132),
	1607: uint16(463),
	1608: uint16(593),
	1609: uint16(226),
	1610: uint16(237),
	1611: uint16(966),
	1612: uint16(464),
	1613: uint16(593),
	1614: uint16(298),
	1615: uint16(593),
	1616: uint16(965),
	1617: uint16(593),
	1618: uint16(66),
	1619: uint16(66),
	1620: uint16(593),
	1621: uint16(1170),
	1622: uint16(593),
	1623: uint16(411),
	1624: uint16(582),
	1625: uint16(353),
	1626: uint16(469),
	1627: uint16(115),
	1628: uint16(593),
	1629: uint16(471),
	1630: uint16(169),
	1631: uint16(173),
	1632: uint16(173),
	1633: uint16(593),
	1634: uint16(44),
	1635: uint16(991),
	1636: uint16(174),
	1637: uint16(174),
	1638: uint16(89),
	1639: uint16(89),
	1640: uint16(67),
	1641: uint16(67),
	1642: uint16(593),
	1643: uint16(85),
	1644: uint16(85),
	1645: uint16(150),
	1646: uint16(150),
	1647: uint16(1114),
	1648: uint16(1043),
	1649: uint16(593),
	1650: uint16(273),
	1651: uint16(86),
	1652: uint16(86),
	1653: uint16(1062),
	1654: uint16(593),
	1655: uint16(503),
	1656: uint16(171),
	1657: uint16(171),
	1658: uint16(593),
	1659: uint16(125),
	1660: uint16(125),
	1661: uint16(497),
	1662: uint16(593),
	1663: uint16(273),
	1664: uint16(336),
	1665: uint16(152),
	1666: uint16(152),
	1667: uint16(126),
	1668: uint16(1335),
	1669: uint16(464),
	1670: uint16(594),
	1671: uint16(464),
	1672: uint16(146),
	1673: uint16(146),
	1674: uint16(1050),
	1675: uint16(593),
	1676: uint16(545),
	1677: uint16(172),
	1678: uint16(172),
	1679: uint16(593),
	1680: uint16(1054),
	1681: uint16(165),
	1682: uint16(165),
	1683: uint16(256),
	1684: uint16(339),
	1685: uint16(156),
	1686: uint16(156),
	1687: uint16(127),
	1688: uint16(585),
	1689: uint16(1586),
	1690: uint16(4),
	1691: uint16(329),
	1692: uint16(584),
	1693: uint16(499),
	1694: uint16(358),
	1695: uint16(273),
	1696: uint16(115),
	1697: uint16(348),
	1698: uint16(155),
	1699: uint16(155),
	1700: uint16(930),
	1701: uint16(931),
	1702: uint16(153),
	1703: uint16(153),
	1704: uint16(588),
	1705: uint16(1114),
	1706: uint16(1050),
	1707: uint16(1050),
	1708: uint16(1052),
	1709: uint16(1053),
	1710: uint16(35),
	1711: uint16(1554),
	1712: uint16(521),
	1713: uint16(593),
	1714: uint16(270),
	1715: uint16(1008),
	1716: uint16(1009),
	1717: uint16(9),
	1718: uint16(593),
	1719: uint16(372),
	1720: uint16(593),
	1721: uint16(115),
	1722: uint16(593),
	1723: uint16(168),
	1724: uint16(593),
	1725: uint16(115),
	1726: uint16(593),
	1727: uint16(1110),
	1728: uint16(464),
	1729: uint16(270),
	1730: uint16(996),
	1731: uint16(964),
	1732: uint16(273),
	1733: uint16(129),
	1734: uint16(1645),
	1735: uint16(1214),
	1736: uint16(154),
	1737: uint16(154),
	1738: uint16(1054),
	1739: uint16(1404),
	1740: uint16(582),
	1741: uint16(88),
	1742: uint16(88),
	1743: uint16(90),
	1744: uint16(90),
	1745: uint16(87),
	1746: uint16(87),
	1747: uint16(52),
	1748: uint16(52),
	1749: uint16(60),
	1750: uint16(60),
	1751: uint16(1405),
	1752: uint16(504),
	1753: uint16(537),
	1754: uint16(559),
	1755: uint16(1179),
	1756: uint16(961),
	1757: uint16(507),
	1758: uint16(129),
	1759: uint16(558),
	1760: uint16(127),
	1761: uint16(585),
	1762: uint16(1126),
	1763: uint16(4),
	1764: uint16(1126),
	1765: uint16(1125),
	1766: uint16(894),
	1767: uint16(1125),
	1768: uint16(162),
	1769: uint16(1062),
	1770: uint16(963),
	1771: uint16(359),
	1772: uint16(129),
	1773: uint16(1401),
	1774: uint16(363),
	1775: uint16(125),
	1776: uint16(125),
	1777: uint16(588),
	1778: uint16(366),
	1779: uint16(368),
	1780: uint16(370),
	1781: uint16(1349),
	1782: uint16(1334),
	1783: uint16(126),
	1784: uint16(1333),
	1785: uint16(464),
	1786: uint16(594),
	1787: uint16(464),
	1788: uint16(377),
	1789: uint16(387),
	1790: uint16(1050),
	1791: uint16(1391),
	1792: uint16(1414),
	1793: uint16(1618),
	1794: uint16(1459),
	1795: uint16(1387),
	1796: uint16(1399),
	1797: uint16(208),
	1798: uint16(580),
	1799: uint16(1464),
	1800: uint16(1314),
	1801: uint16(464),
	1802: uint16(243),
	1803: uint16(516),
	1804: uint16(1305),
	1805: uint16(1293),
	1806: uint16(1384),
	1807: uint16(1292),
	1808: uint16(1294),
	1809: uint16(1638),
	1810: uint16(288),
	1811: uint16(170),
	1812: uint16(228),
	1813: uint16(582),
	1814: uint16(12),
	1815: uint16(408),
	1816: uint16(321),
	1817: uint16(322),
	1818: uint16(241),
	1819: uint16(323),
	1820: uint16(245),
	1821: uint16(1446),
	1822: uint16(1050),
	1823: uint16(1050),
	1824: uint16(1052),
	1825: uint16(1053),
	1826: uint16(35),
	1827: uint16(559),
	1828: uint16(304),
	1829: uint16(350),
	1830: uint16(351),
	1831: uint16(501),
	1832: uint16(560),
	1833: uint16(127),
	1834: uint16(585),
	1835: uint16(1441),
	1836: uint16(4),
	1837: uint16(1451),
	1838: uint16(1434),
	1839: uint16(310),
	1840: uint16(1450),
	1841: uint16(526),
	1842: uint16(1062),
	1843: uint16(1332),
	1844: uint16(415),
	1845: uint16(380),
	1846: uint16(232),
	1847: uint16(1527),
	1848: uint16(125),
	1849: uint16(125),
	1850: uint16(588),
	1851: uint16(1214),
	1852: uint16(1396),
	1853: uint16(356),
	1854: uint16(1526),
	1855: uint16(583),
	1856: uint16(126),
	1857: uint16(1397),
	1858: uint16(464),
	1859: uint16(594),
	1860: uint16(464),
	1861: uint16(1641),
	1862: uint16(535),
	1863: uint16(1050),
	1864: uint16(1581),
	1865: uint16(1395),
	1866: uint16(1269),
	1867: uint16(1583),
	1868: uint16(1582),
	1869: uint16(213),
	1870: uint16(402),
	1871: uint16(277),
	1872: uint16(214),
	1873: uint16(227),
	1874: uint16(464),
	1875: uint16(1573),
	1876: uint16(239),
	1877: uint16(1571),
	1878: uint16(1266),
	1879: uint16(1394),
	1880: uint16(434),
	1881: uint16(198),
	1882: uint16(100),
	1883: uint16(224),
	1884: uint16(96),
	1885: uint16(183),
	1886: uint16(582),
	1887: uint16(191),
	1888: uint16(485),
	1889: uint16(193),
	1890: uint16(486),
	1891: uint16(194),
	1892: uint16(195),
	1893: uint16(196),
	1894: uint16(519),
	1895: uint16(1050),
	1896: uint16(1050),
	1897: uint16(1052),
	1898: uint16(1053),
	1899: uint16(35),
	1900: uint16(559),
	1901: uint16(113),
	1902: uint16(252),
	1903: uint16(413),
	1904: uint16(1447),
	1905: uint16(558),
	1906: uint16(493),
	1907: uint16(13),
	1908: uint16(1455),
	1909: uint16(416),
	1910: uint16(1453),
	1911: uint16(1452),
	1912: uint16(14),
	1913: uint16(202),
	1914: uint16(1521),
	1915: uint16(1062),
	1916: uint16(1532),
	1917: uint16(508),
	1918: uint16(258),
	1919: uint16(106),
	1920: uint16(514),
	1921: uint16(125),
	1922: uint16(125),
	1923: uint16(99),
	1924: uint16(1214),
	1925: uint16(1543),
	1926: uint16(289),
	1927: uint16(260),
	1928: uint16(206),
	1929: uint16(126),
	1930: uint16(365),
	1931: uint16(464),
	1932: uint16(594),
	1933: uint16(464),
	1934: uint16(361),
	1935: uint16(517),
	1936: uint16(1050),
	1937: uint16(261),
	1938: uint16(448),
	1939: uint16(1295),
	1940: uint16(262),
	1941: uint16(418),
	1942: uint16(1352),
	1943: uint16(1351),
	1944: uint16(108),
	1945: uint16(1350),
	1946: uint16(1655),
	1947: uint16(1654),
	1948: uint16(1343),
	1949: uint16(915),
	1950: uint16(419),
	1951: uint16(1322),
	1952: uint16(233),
	1953: uint16(452),
	1954: uint16(319),
	1955: uint16(379),
	1956: uint16(1321),
	1957: uint16(453),
	1958: uint16(1623),
	1959: uint16(320),
	1960: uint16(1320),
	1961: uint16(275),
	1962: uint16(1653),
	1963: uint16(544),
	1964: uint16(276),
	1965: uint16(1609),
	1966: uint16(1608),
	1967: uint16(1342),
	1968: uint16(1050),
	1969: uint16(1050),
	1970: uint16(1052),
	1971: uint16(1053),
	1972: uint16(35),
	1973: uint16(1630),
	1974: uint16(1218),
	1975: uint16(466),
	1976: uint16(385),
	1977: uint16(456),
	1978: uint16(300),
	1979: uint16(1419),
	1980: uint16(144),
	1981: uint16(1418),
	1982: uint16(570),
	1983: uint16(407),
	1984: uint16(407),
	1985: uint16(406),
	1986: uint16(284),
	1987: uint16(404),
	1988: uint16(11),
	1989: uint16(1508),
	1990: uint16(881),
	1991: uint16(396),
	1992: uint16(120),
	1993: uint16(127),
	1994: uint16(585),
	1995: uint16(394),
	1996: uint16(4),
	1997: uint16(1214),
	1998: uint16(327),
	1999: uint16(114),
	2000: uint16(1375),
	2001: uint16(1374),
	2002: uint16(220),
	2003: uint16(247),
	2004: uint16(400),
	2005: uint16(338),
	2006: uint16(401),
	2007: uint16(554),
	2008: uint16(42),
	2009: uint16(1224),
	2010: uint16(588),
	2011: uint16(596),
	2012: uint16(283),
	2013: uint16(337),
	2014: uint16(285),
	2015: uint16(286),
	2016: uint16(188),
	2017: uint16(597),
	2018: uint16(1290),
	2019: uint16(1285),
	2020: uint16(175),
	2021: uint16(1558),
	2022: uint16(176),
	2023: uint16(1559),
	2024: uint16(1557),
	2025: uint16(1556),
	2026: uint16(159),
	2027: uint16(317),
	2028: uint16(229),
	2029: uint16(177),
	2030: uint16(868),
	2031: uint16(230),
	2032: uint16(91),
	2033: uint16(465),
	2034: uint16(464),
	2035: uint16(221),
	2036: uint16(331),
	2037: uint16(468),
	2038: uint16(1165),
	2039: uint16(470),
	2040: uint16(473),
	2041: uint16(94),
	2042: uint16(244),
	2043: uint16(95),
	2044: uint16(249),
	2045: uint16(189),
	2046: uint16(582),
	2047: uint16(1124),
	2048: uint16(1122),
	2049: uint16(341),
	2050: uint16(427),
	2051: uint16(190),
	2052: uint16(178),
	2053: uint16(1249),
	2054: uint16(179),
	2055: uint16(43),
	2056: uint16(192),
	2057: uint16(947),
	2058: uint16(349),
	2059: uint16(428),
	2060: uint16(1138),
	2061: uint16(197),
	2062: uint16(251),
	2063: uint16(180),
	2064: uint16(181),
	2065: uint16(436),
	2066: uint16(102),
	2067: uint16(182),
	2068: uint16(438),
	2069: uint16(103),
	2070: uint16(104),
	2071: uint16(199),
	2072: uint16(248),
	2073: uint16(1140),
	2074: uint16(253),
	2075: uint16(1062),
	2076: uint16(105),
	2077: uint16(255),
	2078: uint16(1137),
	2079: uint16(166),
	2080: uint16(24),
	2081: uint16(125),
	2082: uint16(125),
	2083: uint16(257),
	2084: uint16(1264),
	2085: uint16(273),
	2086: uint16(360),
	2087: uint16(513),
	2088: uint16(259),
	2089: uint16(126),
	2090: uint16(15),
	2091: uint16(464),
	2092: uint16(594),
	2093: uint16(464),
	2094: uint16(204),
	2095: uint16(883),
	2096: uint16(1050),
	2097: uint16(518),
	2098: uint16(263),
	2099: uint16(373),
	2100: uint16(381),
	2101: uint16(92),
	2102: uint16(585),
	2103: uint16(1130),
	2104: uint16(4),
	2105: uint16(203),
	2106: uint16(205),
	2107: uint16(426),
	2108: uint16(107),
	2109: uint16(522),
	2110: uint16(25),
	2111: uint16(26),
	2112: uint16(329),
	2113: uint16(584),
	2114: uint16(913),
	2115: uint16(572),
	2116: uint16(527),
	2117: uint16(376),
	2118: uint16(588),
	2119: uint16(926),
	2120: uint16(530),
	2121: uint16(109),
	2122: uint16(184),
	2123: uint16(318),
	2124: uint16(167),
	2125: uint16(110),
	2126: uint16(27),
	2127: uint16(538),
	2128: uint16(1050),
	2129: uint16(1050),
	2130: uint16(1052),
	2131: uint16(1053),
	2132: uint16(35),
	2133: uint16(1211),
	2134: uint16(1091),
	2135: uint16(17),
	2136: uint16(476),
	2137: uint16(111),
	2138: uint16(1181),
	2139: uint16(234),
	2140: uint16(292),
	2141: uint16(1180),
	2142: uint16(464),
	2143: uint16(294),
	2144: uint16(207),
	2145: uint16(994),
	2146: uint16(129),
	2147: uint16(1201),
	2148: uint16(272),
	2149: uint16(1000),
	2150: uint16(28),
	2151: uint16(1197),
	2152: uint16(29),
	2153: uint16(30),
	2154: uint16(582),
	2155: uint16(1199),
	2156: uint16(1205),
	2157: uint16(1214),
	2158: uint16(31),
	2159: uint16(1204),
	2160: uint16(32),
	2161: uint16(1186),
	2162: uint16(41),
	2163: uint16(566),
	2164: uint16(33),
	2165: uint16(1105),
	2166: uint16(211),
	2167: uint16(8),
	2168: uint16(115),
	2169: uint16(1092),
	2170: uint16(1090),
	2171: uint16(1094),
	2172: uint16(34),
	2173: uint16(278),
	2174: uint16(578),
	2175: uint16(1095),
	2176: uint16(117),
	2177: uint16(122),
	2178: uint16(118),
	2179: uint16(1145),
	2180: uint16(36),
	2181: uint16(18),
	2182: uint16(128),
	2183: uint16(1062),
	2184: uint16(1055),
	2185: uint16(895),
	2186: uint16(957),
	2187: uint16(37),
	2188: uint16(589),
	2189: uint16(125),
	2190: uint16(125),
	2191: uint16(279),
	2192: uint16(186),
	2193: uint16(280),
	2194: uint16(1646),
	2195: uint16(157),
	2196: uint16(405),
	2197: uint16(126),
	2198: uint16(1220),
	2199: uint16(464),
	2200: uint16(594),
	2201: uint16(464),
	2202: uint16(1218),
	2203: uint16(466),
	2204: uint16(1050),
	2205: uint16(1219),
	2206: uint16(300),
	2207: uint16(1281),
	2208: uint16(1281),
	2209: uint16(1281),
	2210: uint16(1281),
	2211: uint16(407),
	2212: uint16(407),
	2213: uint16(406),
	2214: uint16(284),
	2215: uint16(404),
	2216: uint16(1281),
	2217: uint16(1281),
	2218: uint16(881),
	2219: uint16(1281),
	2220: uint16(300),
	2221: uint16(1281),
	2222: uint16(1281),
	2223: uint16(571),
	2224: uint16(1281),
	2225: uint16(407),
	2226: uint16(407),
	2227: uint16(406),
	2228: uint16(284),
	2229: uint16(404),
	2230: uint16(1281),
	2231: uint16(247),
	2232: uint16(881),
	2233: uint16(338),
	2234: uint16(1281),
	2235: uint16(1281),
	2236: uint16(1050),
	2237: uint16(1050),
	2238: uint16(1052),
	2239: uint16(1053),
	2240: uint16(35),
	2241: uint16(337),
	2242: uint16(1281),
	2243: uint16(1281),
	2244: uint16(1281),
	2245: uint16(247),
	2246: uint16(1281),
	2247: uint16(338),
	2248: uint16(1281),
	2249: uint16(1281),
	2250: uint16(1281),
	2251: uint16(1281),
	2252: uint16(1281),
	2253: uint16(1281),
	2254: uint16(1281),
	2255: uint16(337),
	2256: uint16(1281),
	2257: uint16(1281),
	2258: uint16(1281),
	2259: uint16(1281),
	2260: uint16(1281),
	2261: uint16(1281),
	2262: uint16(1281),
	2263: uint16(1281),
	2264: uint16(1281),
	2265: uint16(1214),
	2266: uint16(1281),
	2267: uint16(1281),
	2268: uint16(1281),
	2269: uint16(1281),
	2270: uint16(1281),
	2271: uint16(1281),
	2272: uint16(249),
	2273: uint16(1281),
	2274: uint16(1281),
	2275: uint16(1281),
	2276: uint16(1281),
	2277: uint16(1281),
	2278: uint16(1281),
	2279: uint16(1281),
	2280: uint16(178),
	2281: uint16(1281),
	2282: uint16(1281),
	2283: uint16(43),
	2284: uint16(1281),
	2285: uint16(1281),
	2286: uint16(249),
	2287: uint16(1281),
	2288: uint16(1281),
	2289: uint16(1281),
	2290: uint16(1281),
	2291: uint16(1281),
	2292: uint16(1281),
	2293: uint16(1281),
	2294: uint16(178),
	2295: uint16(1281),
	2296: uint16(1281),
	2297: uint16(43),
	2298: uint16(1281),
	2299: uint16(1281),
	2300: uint16(248),
	2301: uint16(1281),
	2302: uint16(1281),
	2303: uint16(1281),
	2304: uint16(1281),
	2305: uint16(1281),
	2306: uint16(1281),
	2307: uint16(1281),
	2308: uint16(1281),
	2309: uint16(1281),
	2310: uint16(1281),
	2311: uint16(1281),
	2312: uint16(1281),
	2313: uint16(1281),
	2314: uint16(248),
	2315: uint16(1281),
	2316: uint16(1281),
	2317: uint16(1281),
	2318: uint16(1281),
	2319: uint16(1281),
	2320: uint16(1281),
	2321: uint16(1281),
	2322: uint16(1281),
	2323: uint16(1281),
	2324: uint16(1281),
	2325: uint16(1281),
	2326: uint16(1281),
	2327: uint16(1281),
	2328: uint16(1281),
	2329: uint16(1281),
	2330: uint16(1281),
	2331: uint16(1281),
	2332: uint16(1281),
	2333: uint16(1281),
	2334: uint16(1281),
	2335: uint16(426),
	2336: uint16(1281),
	2337: uint16(1281),
	2338: uint16(1281),
	2339: uint16(1281),
	2340: uint16(329),
	2341: uint16(584),
	2342: uint16(1281),
	2343: uint16(1281),
	2344: uint16(1281),
	2345: uint16(1281),
	2346: uint16(1281),
	2347: uint16(1281),
	2348: uint16(1281),
	2349: uint16(426),
	2350: uint16(1281),
	2351: uint16(1281),
	2352: uint16(1281),
	2353: uint16(1281),
	2354: uint16(329),
	2355: uint16(584),
	2356: uint16(1281),
	2357: uint16(1281),
	2358: uint16(1281),
	2359: uint16(1281),
	2360: uint16(1281),
	2361: uint16(1281),
	2362: uint16(1281),
	2363: uint16(1281),
	2364: uint16(476),
	2365: uint16(1281),
	2366: uint16(1281),
	2367: uint16(1281),
	2368: uint16(1281),
	2369: uint16(1281),
	2370: uint16(1281),
	2371: uint16(1281),
	2372: uint16(1281),
	2373: uint16(1281),
	2374: uint16(1281),
	2375: uint16(1281),
	2376: uint16(1281),
	2377: uint16(1281),
	2378: uint16(476),
}

var _yy_default = [600]uint16{
	0:   uint16(1691),
	1:   uint16(1691),
	2:   uint16(1691),
	3:   uint16(1516),
	4:   uint16(1279),
	5:   uint16(1392),
	6:   uint16(1279),
	7:   uint16(1279),
	8:   uint16(1279),
	9:   uint16(1279),
	10:  uint16(1516),
	11:  uint16(1516),
	12:  uint16(1516),
	13:  uint16(1279),
	14:  uint16(1279),
	15:  uint16(1279),
	16:  uint16(1279),
	17:  uint16(1279),
	18:  uint16(1279),
	19:  uint16(1422),
	20:  uint16(1422),
	21:  uint16(1568),
	22:  uint16(1312),
	23:  uint16(1279),
	24:  uint16(1279),
	25:  uint16(1279),
	26:  uint16(1279),
	27:  uint16(1279),
	28:  uint16(1279),
	29:  uint16(1279),
	30:  uint16(1279),
	31:  uint16(1279),
	32:  uint16(1279),
	33:  uint16(1279),
	34:  uint16(1279),
	35:  uint16(1515),
	36:  uint16(1279),
	37:  uint16(1279),
	38:  uint16(1279),
	39:  uint16(1279),
	40:  uint16(1607),
	41:  uint16(1607),
	42:  uint16(1279),
	43:  uint16(1279),
	44:  uint16(1279),
	45:  uint16(1279),
	46:  uint16(1279),
	47:  uint16(1592),
	48:  uint16(1591),
	49:  uint16(1279),
	50:  uint16(1279),
	51:  uint16(1279),
	52:  uint16(1431),
	53:  uint16(1279),
	54:  uint16(1279),
	55:  uint16(1279),
	56:  uint16(1438),
	57:  uint16(1279),
	58:  uint16(1279),
	59:  uint16(1279),
	60:  uint16(1279),
	61:  uint16(1279),
	62:  uint16(1517),
	63:  uint16(1518),
	64:  uint16(1279),
	65:  uint16(1279),
	66:  uint16(1279),
	67:  uint16(1279),
	68:  uint16(1567),
	69:  uint16(1569),
	70:  uint16(1533),
	71:  uint16(1445),
	72:  uint16(1444),
	73:  uint16(1443),
	74:  uint16(1442),
	75:  uint16(1551),
	76:  uint16(1410),
	77:  uint16(1436),
	78:  uint16(1429),
	79:  uint16(1433),
	80:  uint16(1512),
	81:  uint16(1513),
	82:  uint16(1511),
	83:  uint16(1670),
	84:  uint16(1518),
	85:  uint16(1517),
	86:  uint16(1279),
	87:  uint16(1432),
	88:  uint16(1480),
	89:  uint16(1496),
	90:  uint16(1479),
	91:  uint16(1279),
	92:  uint16(1279),
	93:  uint16(1279),
	94:  uint16(1279),
	95:  uint16(1279),
	96:  uint16(1279),
	97:  uint16(1279),
	98:  uint16(1279),
	99:  uint16(1279),
	100: uint16(1279),
	101: uint16(1279),
	102: uint16(1279),
	103: uint16(1279),
	104: uint16(1279),
	105: uint16(1279),
	106: uint16(1279),
	107: uint16(1279),
	108: uint16(1279),
	109: uint16(1279),
	110: uint16(1279),
	111: uint16(1279),
	112: uint16(1279),
	113: uint16(1279),
	114: uint16(1279),
	115: uint16(1279),
	116: uint16(1279),
	117: uint16(1279),
	118: uint16(1279),
	119: uint16(1279),
	120: uint16(1279),
	121: uint16(1279),
	122: uint16(1279),
	123: uint16(1279),
	124: uint16(1279),
	125: uint16(1279),
	126: uint16(1279),
	127: uint16(1279),
	128: uint16(1279),
	129: uint16(1279),
	130: uint16(1279),
	131: uint16(1279),
	132: uint16(1279),
	133: uint16(1279),
	134: uint16(1279),
	135: uint16(1279),
	136: uint16(1279),
	137: uint16(1279),
	138: uint16(1279),
	139: uint16(1279),
	140: uint16(1279),
	141: uint16(1279),
	142: uint16(1279),
	143: uint16(1279),
	144: uint16(1279),
	145: uint16(1279),
	146: uint16(1488),
	147: uint16(1495),
	148: uint16(1494),
	149: uint16(1493),
	150: uint16(1502),
	151: uint16(1492),
	152: uint16(1489),
	153: uint16(1482),
	154: uint16(1481),
	155: uint16(1483),
	156: uint16(1484),
	157: uint16(1303),
	158: uint16(1300),
	159: uint16(1354),
	160: uint16(1279),
	161: uint16(1279),
	162: uint16(1279),
	163: uint16(1279),
	164: uint16(1279),
	165: uint16(1485),
	166: uint16(1312),
	167: uint16(1473),
	168: uint16(1472),
	169: uint16(1471),
	170: uint16(1279),
	171: uint16(1499),
	172: uint16(1486),
	173: uint16(1498),
	174: uint16(1497),
	175: uint16(1575),
	176: uint16(1644),
	177: uint16(1643),
	178: uint16(1534),
	179: uint16(1279),
	180: uint16(1279),
	181: uint16(1279),
	182: uint16(1279),
	183: uint16(1279),
	184: uint16(1279),
	185: uint16(1607),
	186: uint16(1279),
	187: uint16(1279),
	188: uint16(1279),
	189: uint16(1279),
	190: uint16(1279),
	191: uint16(1279),
	192: uint16(1279),
	193: uint16(1279),
	194: uint16(1279),
	195: uint16(1279),
	196: uint16(1279),
	197: uint16(1279),
	198: uint16(1279),
	199: uint16(1279),
	200: uint16(1279),
	201: uint16(1279),
	202: uint16(1279),
	203: uint16(1279),
	204: uint16(1279),
	205: uint16(1279),
	206: uint16(1279),
	207: uint16(1279),
	208: uint16(1412),
	209: uint16(1607),
	210: uint16(1607),
	211: uint16(1279),
	212: uint16(1312),
	213: uint16(1607),
	214: uint16(1607),
	215: uint16(1308),
	216: uint16(1413),
	217: uint16(1413),
	218: uint16(1308),
	219: uint16(1308),
	220: uint16(1416),
	221: uint16(1587),
	222: uint16(1383),
	223: uint16(1383),
	224: uint16(1383),
	225: uint16(1383),
	226: uint16(1392),
	227: uint16(1383),
	228: uint16(1279),
	229: uint16(1279),
	230: uint16(1279),
	231: uint16(1279),
	232: uint16(1279),
	233: uint16(1279),
	234: uint16(1279),
	235: uint16(1279),
	236: uint16(1279),
	237: uint16(1279),
	238: uint16(1279),
	239: uint16(1279),
	240: uint16(1279),
	241: uint16(1279),
	242: uint16(1279),
	243: uint16(1279),
	244: uint16(1279),
	245: uint16(1279),
	246: uint16(1279),
	247: uint16(1572),
	248: uint16(1570),
	249: uint16(1279),
	250: uint16(1279),
	251: uint16(1279),
	252: uint16(1279),
	253: uint16(1279),
	254: uint16(1279),
	255: uint16(1279),
	256: uint16(1279),
	257: uint16(1279),
	258: uint16(1279),
	259: uint16(1279),
	260: uint16(1279),
	261: uint16(1279),
	262: uint16(1279),
	263: uint16(1279),
	264: uint16(1279),
	265: uint16(1279),
	266: uint16(1279),
	267: uint16(1279),
	268: uint16(1279),
	269: uint16(1279),
	270: uint16(1279),
	271: uint16(1279),
	272: uint16(1279),
	273: uint16(1279),
	274: uint16(1279),
	275: uint16(1388),
	276: uint16(1279),
	277: uint16(1279),
	278: uint16(1279),
	279: uint16(1279),
	280: uint16(1279),
	281: uint16(1279),
	282: uint16(1279),
	283: uint16(1279),
	284: uint16(1279),
	285: uint16(1279),
	286: uint16(1637),
	287: uint16(1683),
	288: uint16(1279),
	289: uint16(1546),
	290: uint16(1368),
	291: uint16(1388),
	292: uint16(1388),
	293: uint16(1388),
	294: uint16(1388),
	295: uint16(1390),
	296: uint16(1369),
	297: uint16(1367),
	298: uint16(1382),
	299: uint16(1313),
	300: uint16(1286),
	301: uint16(1683),
	302: uint16(1683),
	303: uint16(1448),
	304: uint16(1437),
	305: uint16(1389),
	306: uint16(1437),
	307: uint16(1680),
	308: uint16(1435),
	309: uint16(1448),
	310: uint16(1448),
	311: uint16(1435),
	312: uint16(1448),
	313: uint16(1389),
	314: uint16(1680),
	315: uint16(1329),
	316: uint16(1659),
	317: uint16(1324),
	318: uint16(1422),
	319: uint16(1422),
	320: uint16(1422),
	321: uint16(1412),
	322: uint16(1412),
	323: uint16(1412),
	324: uint16(1412),
	325: uint16(1416),
	326: uint16(1416),
	327: uint16(1514),
	328: uint16(1389),
	329: uint16(1382),
	330: uint16(1279),
	331: uint16(1355),
	332: uint16(1683),
	333: uint16(1355),
	334: uint16(1355),
	335: uint16(1398),
	336: uint16(1398),
	337: uint16(1682),
	338: uint16(1682),
	339: uint16(1398),
	340: uint16(1534),
	341: uint16(1667),
	342: uint16(1457),
	343: uint16(1357),
	344: uint16(1363),
	345: uint16(1363),
	346: uint16(1363),
	347: uint16(1363),
	348: uint16(1398),
	349: uint16(1297),
	350: uint16(1435),
	351: uint16(1667),
	352: uint16(1667),
	353: uint16(1435),
	354: uint16(1457),
	355: uint16(1357),
	356: uint16(1435),
	357: uint16(1357),
	358: uint16(1435),
	359: uint16(1398),
	360: uint16(1297),
	361: uint16(1550),
	362: uint16(1678),
	363: uint16(1398),
	364: uint16(1297),
	365: uint16(1524),
	366: uint16(1398),
	367: uint16(1297),
	368: uint16(1398),
	369: uint16(1297),
	370: uint16(1524),
	371: uint16(1355),
	372: uint16(1355),
	373: uint16(1355),
	374: uint16(1344),
	375: uint16(1279),
	376: uint16(1279),
	377: uint16(1524),
	378: uint16(1355),
	379: uint16(1329),
	380: uint16(1355),
	381: uint16(1344),
	382: uint16(1355),
	383: uint16(1355),
	384: uint16(1625),
	385: uint16(1279),
	386: uint16(1528),
	387: uint16(1528),
	388: uint16(1524),
	389: uint16(1398),
	390: uint16(1617),
	391: uint16(1617),
	392: uint16(1425),
	393: uint16(1425),
	394: uint16(1430),
	395: uint16(1416),
	396: uint16(1519),
	397: uint16(1398),
	398: uint16(1279),
	399: uint16(1430),
	400: uint16(1428),
	401: uint16(1426),
	402: uint16(1435),
	403: uint16(1347),
	404: uint16(1640),
	405: uint16(1640),
	406: uint16(1636),
	407: uint16(1636),
	408: uint16(1636),
	409: uint16(1688),
	410: uint16(1688),
	411: uint16(1587),
	412: uint16(1652),
	413: uint16(1312),
	414: uint16(1312),
	415: uint16(1312),
	416: uint16(1312),
	417: uint16(1652),
	418: uint16(1331),
	419: uint16(1331),
	420: uint16(1313),
	421: uint16(1313),
	422: uint16(1312),
	423: uint16(1652),
	424: uint16(1279),
	425: uint16(1279),
	426: uint16(1279),
	427: uint16(1279),
	428: uint16(1279),
	429: uint16(1279),
	430: uint16(1279),
	431: uint16(1647),
	432: uint16(1279),
	433: uint16(1279),
	434: uint16(1535),
	435: uint16(1279),
	436: uint16(1279),
	437: uint16(1279),
	438: uint16(1279),
	439: uint16(1279),
	440: uint16(1279),
	441: uint16(1279),
	442: uint16(1402),
	443: uint16(1279),
	444: uint16(1279),
	445: uint16(1279),
	446: uint16(1279),
	447: uint16(1279),
	448: uint16(1279),
	449: uint16(1279),
	450: uint16(1279),
	451: uint16(1279),
	452: uint16(1593),
	453: uint16(1279),
	454: uint16(1279),
	455: uint16(1279),
	456: uint16(1279),
	457: uint16(1279),
	458: uint16(1279),
	459: uint16(1279),
	460: uint16(1279),
	461: uint16(1279),
	462: uint16(1279),
	463: uint16(1279),
	464: uint16(1462),
	465: uint16(1279),
	466: uint16(1282),
	467: uint16(1584),
	468: uint16(1279),
	469: uint16(1279),
	470: uint16(1279),
	471: uint16(1279),
	472: uint16(1279),
	473: uint16(1279),
	474: uint16(1279),
	475: uint16(1279),
	476: uint16(1279),
	477: uint16(1279),
	478: uint16(1279),
	479: uint16(1279),
	480: uint16(1279),
	481: uint16(1279),
	482: uint16(1439),
	483: uint16(1440),
	484: uint16(1279),
	485: uint16(1279),
	486: uint16(1279),
	487: uint16(1279),
	488: uint16(1279),
	489: uint16(1279),
	490: uint16(1279),
	491: uint16(1454),
	492: uint16(1279),
	493: uint16(1279),
	494: uint16(1279),
	495: uint16(1449),
	496: uint16(1279),
	497: uint16(1279),
	498: uint16(1279),
	499: uint16(1279),
	500: uint16(1279),
	501: uint16(1279),
	502: uint16(1279),
	503: uint16(1279),
	504: uint16(1403),
	505: uint16(1279),
	506: uint16(1279),
	507: uint16(1279),
	508: uint16(1279),
	509: uint16(1279),
	510: uint16(1279),
	511: uint16(1549),
	512: uint16(1548),
	513: uint16(1279),
	514: uint16(1279),
	515: uint16(1400),
	516: uint16(1279),
	517: uint16(1279),
	518: uint16(1279),
	519: uint16(1279),
	520: uint16(1279),
	521: uint16(1279),
	522: uint16(1279),
	523: uint16(1279),
	524: uint16(1279),
	525: uint16(1279),
	526: uint16(1279),
	527: uint16(1279),
	528: uint16(1279),
	529: uint16(1327),
	530: uint16(1279),
	531: uint16(1279),
	532: uint16(1279),
	533: uint16(1279),
	534: uint16(1279),
	535: uint16(1279),
	536: uint16(1279),
	537: uint16(1279),
	538: uint16(1279),
	539: uint16(1279),
	540: uint16(1279),
	541: uint16(1279),
	542: uint16(1279),
	543: uint16(1279),
	544: uint16(1279),
	545: uint16(1279),
	546: uint16(1279),
	547: uint16(1279),
	548: uint16(1279),
	549: uint16(1279),
	550: uint16(1279),
	551: uint16(1279),
	552: uint16(1279),
	553: uint16(1427),
	554: uint16(1279),
	555: uint16(1279),
	556: uint16(1279),
	557: uint16(1279),
	558: uint16(1279),
	559: uint16(1279),
	560: uint16(1279),
	561: uint16(1279),
	562: uint16(1279),
	563: uint16(1279),
	564: uint16(1279),
	565: uint16(1279),
	566: uint16(1279),
	567: uint16(1279),
	568: uint16(1622),
	569: uint16(1417),
	570: uint16(1279),
	571: uint16(1279),
	572: uint16(1279),
	573: uint16(1279),
	574: uint16(1671),
	575: uint16(1279),
	576: uint16(1279),
	577: uint16(1279),
	578: uint16(1279),
	579: uint16(1377),
	580: uint16(1279),
	581: uint16(1279),
	582: uint16(1279),
	583: uint16(1279),
	584: uint16(1279),
	585: uint16(1279),
	586: uint16(1279),
	587: uint16(1279),
	588: uint16(1279),
	589: uint16(1279),
	590: uint16(1663),
	591: uint16(1371),
	592: uint16(1463),
	593: uint16(1279),
	594: uint16(1466),
	595: uint16(1301),
	596: uint16(1279),
	597: uint16(1291),
	598: uint16(1279),
	599: uint16(1279),
}

/********** End of lemon-generated parsing tables *****************************/

var _yy_lookahead = [2566]uint16{
	0:    uint16(277),
	1:    uint16(278),
	2:    uint16(279),
	3:    uint16(241),
	4:    uint16(242),
	5:    uint16(225),
	6:    uint16(195),
	7:    uint16(227),
	8:    uint16(195),
	9:    uint16(312),
	10:   uint16(195),
	11:   uint16(218),
	12:   uint16(195),
	13:   uint16(316),
	14:   uint16(195),
	15:   uint16(235),
	16:   uint16(254),
	17:   uint16(195),
	18:   uint16(256),
	19:   uint16(19),
	20:   uint16(297),
	21:   uint16(277),
	22:   uint16(278),
	23:   uint16(279),
	24:   uint16(218),
	25:   uint16(206),
	26:   uint16(213),
	27:   uint16(214),
	28:   uint16(206),
	29:   uint16(218),
	30:   uint16(219),
	31:   uint16(31),
	32:   uint16(206),
	33:   uint16(218),
	34:   uint16(219),
	35:   uint16(218),
	36:   uint16(219),
	37:   uint16(218),
	38:   uint16(219),
	39:   uint16(39),
	40:   uint16(218),
	41:   uint16(219),
	42:   uint16(195),
	43:   uint16(43),
	44:   uint16(44),
	45:   uint16(45),
	46:   uint16(195),
	47:   uint16(47),
	48:   uint16(48),
	49:   uint16(49),
	50:   uint16(50),
	51:   uint16(51),
	52:   uint16(52),
	53:   uint16(53),
	54:   uint16(54),
	55:   uint16(55),
	56:   uint16(56),
	57:   uint16(57),
	58:   uint16(58),
	59:   uint16(19),
	60:   uint16(241),
	61:   uint16(242),
	62:   uint16(195),
	63:   uint16(241),
	64:   uint16(242),
	65:   uint16(195),
	66:   uint16(255),
	67:   uint16(241),
	68:   uint16(242),
	69:   uint16(195),
	70:   uint16(255),
	71:   uint16(237),
	72:   uint16(238),
	73:   uint16(254),
	74:   uint16(255),
	75:   uint16(256),
	76:   uint16(254),
	77:   uint16(255),
	78:   uint16(256),
	79:   uint16(264),
	80:   uint16(254),
	81:   uint16(207),
	82:   uint16(256),
	83:   uint16(43),
	84:   uint16(44),
	85:   uint16(45),
	86:   uint16(264),
	87:   uint16(47),
	88:   uint16(48),
	89:   uint16(49),
	90:   uint16(50),
	91:   uint16(51),
	92:   uint16(52),
	93:   uint16(53),
	94:   uint16(54),
	95:   uint16(55),
	96:   uint16(56),
	97:   uint16(57),
	98:   uint16(58),
	99:   uint16(251),
	100:  uint16(287),
	101:  uint16(253),
	102:  uint16(215),
	103:  uint16(103),
	104:  uint16(104),
	105:  uint16(105),
	106:  uint16(106),
	107:  uint16(107),
	108:  uint16(108),
	109:  uint16(109),
	110:  uint16(110),
	111:  uint16(111),
	112:  uint16(112),
	113:  uint16(113),
	114:  uint16(114),
	115:  uint16(82),
	116:  uint16(265),
	117:  uint16(195),
	118:  uint16(271),
	119:  uint16(11),
	120:  uint16(187),
	121:  uint16(188),
	122:  uint16(189),
	123:  uint16(190),
	124:  uint16(191),
	125:  uint16(192),
	126:  uint16(190),
	127:  uint16(87),
	128:  uint16(192),
	129:  uint16(89),
	130:  uint16(197),
	131:  uint16(19),
	132:  uint16(199),
	133:  uint16(197),
	134:  uint16(317),
	135:  uint16(199),
	136:  uint16(319),
	137:  uint16(25),
	138:  uint16(271),
	139:  uint16(206),
	140:  uint16(218),
	141:  uint16(219),
	142:  uint16(206),
	143:  uint16(103),
	144:  uint16(104),
	145:  uint16(105),
	146:  uint16(106),
	147:  uint16(107),
	148:  uint16(108),
	149:  uint16(109),
	150:  uint16(110),
	151:  uint16(111),
	152:  uint16(112),
	153:  uint16(113),
	154:  uint16(114),
	155:  uint16(43),
	156:  uint16(44),
	157:  uint16(45),
	158:  uint16(195),
	159:  uint16(47),
	160:  uint16(48),
	161:  uint16(49),
	162:  uint16(50),
	163:  uint16(51),
	164:  uint16(52),
	165:  uint16(53),
	166:  uint16(54),
	167:  uint16(55),
	168:  uint16(56),
	169:  uint16(57),
	170:  uint16(58),
	171:  uint16(60),
	172:  uint16(139),
	173:  uint16(140),
	174:  uint16(241),
	175:  uint16(242),
	176:  uint16(289),
	177:  uint16(241),
	178:  uint16(242),
	179:  uint16(309),
	180:  uint16(310),
	181:  uint16(294),
	182:  uint16(70),
	183:  uint16(47),
	184:  uint16(48),
	185:  uint16(49),
	186:  uint16(50),
	187:  uint16(254),
	188:  uint16(77),
	189:  uint16(256),
	190:  uint16(254),
	191:  uint16(195),
	192:  uint16(256),
	193:  uint16(55),
	194:  uint16(56),
	195:  uint16(57),
	196:  uint16(58),
	197:  uint16(59),
	198:  uint16(221),
	199:  uint16(88),
	200:  uint16(109),
	201:  uint16(90),
	202:  uint16(269),
	203:  uint16(240),
	204:  uint16(93),
	205:  uint16(269),
	206:  uint16(107),
	207:  uint16(108),
	208:  uint16(109),
	209:  uint16(110),
	210:  uint16(111),
	211:  uint16(112),
	212:  uint16(113),
	213:  uint16(114),
	214:  uint16(215),
	215:  uint16(103),
	216:  uint16(104),
	217:  uint16(105),
	218:  uint16(106),
	219:  uint16(107),
	220:  uint16(108),
	221:  uint16(109),
	222:  uint16(110),
	223:  uint16(111),
	224:  uint16(112),
	225:  uint16(113),
	226:  uint16(114),
	227:  uint16(136),
	228:  uint16(117),
	229:  uint16(118),
	230:  uint16(119),
	231:  uint16(298),
	232:  uint16(141),
	233:  uint16(300),
	234:  uint16(298),
	235:  uint16(19),
	236:  uint16(300),
	237:  uint16(129),
	238:  uint16(130),
	239:  uint16(317),
	240:  uint16(318),
	241:  uint16(103),
	242:  uint16(104),
	243:  uint16(105),
	244:  uint16(106),
	245:  uint16(107),
	246:  uint16(108),
	247:  uint16(109),
	248:  uint16(110),
	249:  uint16(111),
	250:  uint16(112),
	251:  uint16(113),
	252:  uint16(114),
	253:  uint16(114),
	254:  uint16(277),
	255:  uint16(278),
	256:  uint16(279),
	257:  uint16(146),
	258:  uint16(122),
	259:  uint16(43),
	260:  uint16(44),
	261:  uint16(45),
	262:  uint16(195),
	263:  uint16(47),
	264:  uint16(48),
	265:  uint16(49),
	266:  uint16(50),
	267:  uint16(51),
	268:  uint16(52),
	269:  uint16(53),
	270:  uint16(54),
	271:  uint16(55),
	272:  uint16(56),
	273:  uint16(57),
	274:  uint16(58),
	275:  uint16(218),
	276:  uint16(277),
	277:  uint16(278),
	278:  uint16(279),
	279:  uint16(19),
	280:  uint16(19),
	281:  uint16(195),
	282:  uint16(286),
	283:  uint16(23),
	284:  uint16(68),
	285:  uint16(218),
	286:  uint16(219),
	287:  uint16(55),
	288:  uint16(56),
	289:  uint16(57),
	290:  uint16(58),
	291:  uint16(103),
	292:  uint16(104),
	293:  uint16(105),
	294:  uint16(106),
	295:  uint16(107),
	296:  uint16(108),
	297:  uint16(109),
	298:  uint16(110),
	299:  uint16(111),
	300:  uint16(112),
	301:  uint16(113),
	302:  uint16(114),
	303:  uint16(43),
	304:  uint16(44),
	305:  uint16(45),
	306:  uint16(232),
	307:  uint16(47),
	308:  uint16(48),
	309:  uint16(49),
	310:  uint16(50),
	311:  uint16(51),
	312:  uint16(52),
	313:  uint16(53),
	314:  uint16(54),
	315:  uint16(55),
	316:  uint16(56),
	317:  uint16(57),
	318:  uint16(58),
	319:  uint16(103),
	320:  uint16(104),
	321:  uint16(105),
	322:  uint16(106),
	323:  uint16(107),
	324:  uint16(108),
	325:  uint16(109),
	326:  uint16(110),
	327:  uint16(111),
	328:  uint16(112),
	329:  uint16(113),
	330:  uint16(114),
	331:  uint16(135),
	332:  uint16(60),
	333:  uint16(137),
	334:  uint16(138),
	335:  uint16(103),
	336:  uint16(104),
	337:  uint16(105),
	338:  uint16(106),
	339:  uint16(107),
	340:  uint16(108),
	341:  uint16(109),
	342:  uint16(110),
	343:  uint16(111),
	344:  uint16(112),
	345:  uint16(113),
	346:  uint16(114),
	347:  uint16(82),
	348:  uint16(281),
	349:  uint16(206),
	350:  uint16(195),
	351:  uint16(109),
	352:  uint16(110),
	353:  uint16(111),
	354:  uint16(112),
	355:  uint16(113),
	356:  uint16(114),
	357:  uint16(195),
	358:  uint16(195),
	359:  uint16(195),
	360:  uint16(205),
	361:  uint16(22),
	362:  uint16(207),
	363:  uint16(103),
	364:  uint16(104),
	365:  uint16(105),
	366:  uint16(106),
	367:  uint16(107),
	368:  uint16(108),
	369:  uint16(109),
	370:  uint16(110),
	371:  uint16(111),
	372:  uint16(112),
	373:  uint16(113),
	374:  uint16(114),
	375:  uint16(195),
	376:  uint16(60),
	377:  uint16(116),
	378:  uint16(117),
	379:  uint16(107),
	380:  uint16(108),
	381:  uint16(218),
	382:  uint16(219),
	383:  uint16(19),
	384:  uint16(241),
	385:  uint16(242),
	386:  uint16(121),
	387:  uint16(23),
	388:  uint16(116),
	389:  uint16(117),
	390:  uint16(118),
	391:  uint16(119),
	392:  uint16(306),
	393:  uint16(121),
	394:  uint16(308),
	395:  uint16(206),
	396:  uint16(234),
	397:  uint16(254),
	398:  uint16(15),
	399:  uint16(256),
	400:  uint16(195),
	401:  uint16(129),
	402:  uint16(259),
	403:  uint16(260),
	404:  uint16(139),
	405:  uint16(140),
	406:  uint16(145),
	407:  uint16(43),
	408:  uint16(44),
	409:  uint16(45),
	410:  uint16(200),
	411:  uint16(47),
	412:  uint16(48),
	413:  uint16(49),
	414:  uint16(50),
	415:  uint16(51),
	416:  uint16(52),
	417:  uint16(53),
	418:  uint16(54),
	419:  uint16(55),
	420:  uint16(56),
	421:  uint16(57),
	422:  uint16(58),
	423:  uint16(218),
	424:  uint16(219),
	425:  uint16(60),
	426:  uint16(154),
	427:  uint16(19),
	428:  uint16(156),
	429:  uint16(265),
	430:  uint16(241),
	431:  uint16(242),
	432:  uint16(24),
	433:  uint16(117),
	434:  uint16(118),
	435:  uint16(119),
	436:  uint16(120),
	437:  uint16(21),
	438:  uint16(73),
	439:  uint16(123),
	440:  uint16(124),
	441:  uint16(125),
	442:  uint16(74),
	443:  uint16(254),
	444:  uint16(61),
	445:  uint16(256),
	446:  uint16(107),
	447:  uint16(108),
	448:  uint16(221),
	449:  uint16(133),
	450:  uint16(82),
	451:  uint16(43),
	452:  uint16(44),
	453:  uint16(45),
	454:  uint16(195),
	455:  uint16(47),
	456:  uint16(48),
	457:  uint16(49),
	458:  uint16(50),
	459:  uint16(51),
	460:  uint16(52),
	461:  uint16(53),
	462:  uint16(54),
	463:  uint16(55),
	464:  uint16(56),
	465:  uint16(57),
	466:  uint16(58),
	467:  uint16(103),
	468:  uint16(104),
	469:  uint16(105),
	470:  uint16(106),
	471:  uint16(107),
	472:  uint16(108),
	473:  uint16(109),
	474:  uint16(110),
	475:  uint16(111),
	476:  uint16(112),
	477:  uint16(113),
	478:  uint16(114),
	479:  uint16(195),
	480:  uint16(317),
	481:  uint16(318),
	482:  uint16(117),
	483:  uint16(118),
	484:  uint16(119),
	485:  uint16(22),
	486:  uint16(120),
	487:  uint16(195),
	488:  uint16(22),
	489:  uint16(123),
	490:  uint16(124),
	491:  uint16(125),
	492:  uint16(19),
	493:  uint16(20),
	494:  uint16(284),
	495:  uint16(22),
	496:  uint16(128),
	497:  uint16(81),
	498:  uint16(288),
	499:  uint16(133),
	500:  uint16(195),
	501:  uint16(195),
	502:  uint16(218),
	503:  uint16(219),
	504:  uint16(277),
	505:  uint16(278),
	506:  uint16(279),
	507:  uint16(139),
	508:  uint16(140),
	509:  uint16(36),
	510:  uint16(195),
	511:  uint16(103),
	512:  uint16(104),
	513:  uint16(105),
	514:  uint16(106),
	515:  uint16(107),
	516:  uint16(108),
	517:  uint16(109),
	518:  uint16(110),
	519:  uint16(111),
	520:  uint16(112),
	521:  uint16(113),
	522:  uint16(114),
	523:  uint16(218),
	524:  uint16(219),
	525:  uint16(62),
	526:  uint16(60),
	527:  uint16(195),
	528:  uint16(241),
	529:  uint16(242),
	530:  uint16(271),
	531:  uint16(19),
	532:  uint16(240),
	533:  uint16(60),
	534:  uint16(189),
	535:  uint16(190),
	536:  uint16(191),
	537:  uint16(192),
	538:  uint16(233),
	539:  uint16(255),
	540:  uint16(124),
	541:  uint16(254),
	542:  uint16(197),
	543:  uint16(256),
	544:  uint16(199),
	545:  uint16(72),
	546:  uint16(129),
	547:  uint16(130),
	548:  uint16(264),
	549:  uint16(195),
	550:  uint16(195),
	551:  uint16(206),
	552:  uint16(22),
	553:  uint16(23),
	554:  uint16(60),
	555:  uint16(43),
	556:  uint16(44),
	557:  uint16(45),
	558:  uint16(206),
	559:  uint16(47),
	560:  uint16(48),
	561:  uint16(49),
	562:  uint16(50),
	563:  uint16(51),
	564:  uint16(52),
	565:  uint16(53),
	566:  uint16(54),
	567:  uint16(55),
	568:  uint16(56),
	569:  uint16(57),
	570:  uint16(58),
	571:  uint16(195),
	572:  uint16(218),
	573:  uint16(219),
	574:  uint16(101),
	575:  uint16(195),
	576:  uint16(60),
	577:  uint16(271),
	578:  uint16(162),
	579:  uint16(195),
	580:  uint16(107),
	581:  uint16(108),
	582:  uint16(109),
	583:  uint16(117),
	584:  uint16(118),
	585:  uint16(119),
	586:  uint16(241),
	587:  uint16(242),
	588:  uint16(115),
	589:  uint16(73),
	590:  uint16(117),
	591:  uint16(118),
	592:  uint16(119),
	593:  uint16(241),
	594:  uint16(242),
	595:  uint16(122),
	596:  uint16(60),
	597:  uint16(195),
	598:  uint16(266),
	599:  uint16(254),
	600:  uint16(312),
	601:  uint16(256),
	602:  uint16(218),
	603:  uint16(219),
	604:  uint16(316),
	605:  uint16(203),
	606:  uint16(254),
	607:  uint16(195),
	608:  uint16(256),
	609:  uint16(255),
	610:  uint16(208),
	611:  uint16(117),
	612:  uint16(118),
	613:  uint16(119),
	614:  uint16(269),
	615:  uint16(103),
	616:  uint16(104),
	617:  uint16(105),
	618:  uint16(106),
	619:  uint16(107),
	620:  uint16(108),
	621:  uint16(109),
	622:  uint16(110),
	623:  uint16(111),
	624:  uint16(112),
	625:  uint16(113),
	626:  uint16(114),
	627:  uint16(154),
	628:  uint16(155),
	629:  uint16(156),
	630:  uint16(157),
	631:  uint16(158),
	632:  uint16(102),
	633:  uint16(117),
	634:  uint16(118),
	635:  uint16(119),
	636:  uint16(19),
	637:  uint16(242),
	638:  uint16(144),
	639:  uint16(255),
	640:  uint16(23),
	641:  uint16(206),
	642:  uint16(24),
	643:  uint16(298),
	644:  uint16(195),
	645:  uint16(300),
	646:  uint16(206),
	647:  uint16(195),
	648:  uint16(264),
	649:  uint16(254),
	650:  uint16(206),
	651:  uint16(256),
	652:  uint16(240),
	653:  uint16(117),
	654:  uint16(118),
	655:  uint16(119),
	656:  uint16(183),
	657:  uint16(22),
	658:  uint16(22),
	659:  uint16(23),
	660:  uint16(43),
	661:  uint16(44),
	662:  uint16(45),
	663:  uint16(151),
	664:  uint16(47),
	665:  uint16(48),
	666:  uint16(49),
	667:  uint16(50),
	668:  uint16(51),
	669:  uint16(52),
	670:  uint16(53),
	671:  uint16(54),
	672:  uint16(55),
	673:  uint16(56),
	674:  uint16(57),
	675:  uint16(58),
	676:  uint16(241),
	677:  uint16(242),
	678:  uint16(60),
	679:  uint16(195),
	680:  uint16(19),
	681:  uint16(241),
	682:  uint16(242),
	683:  uint16(195),
	684:  uint16(23),
	685:  uint16(241),
	686:  uint16(242),
	687:  uint16(195),
	688:  uint16(152),
	689:  uint16(254),
	690:  uint16(310),
	691:  uint16(256),
	692:  uint16(243),
	693:  uint16(312),
	694:  uint16(254),
	695:  uint16(60),
	696:  uint16(256),
	697:  uint16(316),
	698:  uint16(254),
	699:  uint16(206),
	700:  uint16(256),
	701:  uint16(60),
	702:  uint16(218),
	703:  uint16(219),
	704:  uint16(43),
	705:  uint16(44),
	706:  uint16(45),
	707:  uint16(272),
	708:  uint16(47),
	709:  uint16(48),
	710:  uint16(49),
	711:  uint16(50),
	712:  uint16(51),
	713:  uint16(52),
	714:  uint16(53),
	715:  uint16(54),
	716:  uint16(55),
	717:  uint16(56),
	718:  uint16(57),
	719:  uint16(58),
	720:  uint16(103),
	721:  uint16(104),
	722:  uint16(105),
	723:  uint16(106),
	724:  uint16(107),
	725:  uint16(108),
	726:  uint16(109),
	727:  uint16(110),
	728:  uint16(111),
	729:  uint16(112),
	730:  uint16(113),
	731:  uint16(114),
	732:  uint16(240),
	733:  uint16(60),
	734:  uint16(241),
	735:  uint16(242),
	736:  uint16(118),
	737:  uint16(25),
	738:  uint16(102),
	739:  uint16(255),
	740:  uint16(166),
	741:  uint16(167),
	742:  uint16(101),
	743:  uint16(22),
	744:  uint16(26),
	745:  uint16(19),
	746:  uint16(20),
	747:  uint16(254),
	748:  uint16(22),
	749:  uint16(256),
	750:  uint16(139),
	751:  uint16(140),
	752:  uint16(117),
	753:  uint16(118),
	754:  uint16(119),
	755:  uint16(306),
	756:  uint16(195),
	757:  uint16(308),
	758:  uint16(117),
	759:  uint16(118),
	760:  uint16(237),
	761:  uint16(238),
	762:  uint16(36),
	763:  uint16(122),
	764:  uint16(103),
	765:  uint16(104),
	766:  uint16(105),
	767:  uint16(106),
	768:  uint16(107),
	769:  uint16(108),
	770:  uint16(109),
	771:  uint16(110),
	772:  uint16(111),
	773:  uint16(112),
	774:  uint16(113),
	775:  uint16(114),
	776:  uint16(195),
	777:  uint16(195),
	778:  uint16(60),
	779:  uint16(218),
	780:  uint16(219),
	781:  uint16(60),
	782:  uint16(109),
	783:  uint16(195),
	784:  uint16(19),
	785:  uint16(217),
	786:  uint16(60),
	787:  uint16(25),
	788:  uint16(23),
	789:  uint16(77),
	790:  uint16(117),
	791:  uint16(118),
	792:  uint16(119),
	793:  uint16(225),
	794:  uint16(233),
	795:  uint16(154),
	796:  uint16(155),
	797:  uint16(156),
	798:  uint16(72),
	799:  uint16(312),
	800:  uint16(218),
	801:  uint16(219),
	802:  uint16(90),
	803:  uint16(316),
	804:  uint16(22),
	805:  uint16(93),
	806:  uint16(303),
	807:  uint16(304),
	808:  uint16(43),
	809:  uint16(44),
	810:  uint16(45),
	811:  uint16(195),
	812:  uint16(47),
	813:  uint16(48),
	814:  uint16(49),
	815:  uint16(50),
	816:  uint16(51),
	817:  uint16(52),
	818:  uint16(53),
	819:  uint16(54),
	820:  uint16(55),
	821:  uint16(56),
	822:  uint16(57),
	823:  uint16(58),
	824:  uint16(183),
	825:  uint16(195),
	826:  uint16(195),
	827:  uint16(101),
	828:  uint16(19),
	829:  uint16(213),
	830:  uint16(214),
	831:  uint16(243),
	832:  uint16(23),
	833:  uint16(107),
	834:  uint16(108),
	835:  uint16(117),
	836:  uint16(118),
	837:  uint16(119),
	838:  uint16(117),
	839:  uint16(118),
	840:  uint16(119),
	841:  uint16(115),
	842:  uint16(60),
	843:  uint16(117),
	844:  uint16(118),
	845:  uint16(119),
	846:  uint16(195),
	847:  uint16(60),
	848:  uint16(122),
	849:  uint16(218),
	850:  uint16(219),
	851:  uint16(22),
	852:  uint16(43),
	853:  uint16(44),
	854:  uint16(45),
	855:  uint16(35),
	856:  uint16(47),
	857:  uint16(48),
	858:  uint16(49),
	859:  uint16(50),
	860:  uint16(51),
	861:  uint16(52),
	862:  uint16(53),
	863:  uint16(54),
	864:  uint16(55),
	865:  uint16(56),
	866:  uint16(57),
	867:  uint16(58),
	868:  uint16(103),
	869:  uint16(104),
	870:  uint16(105),
	871:  uint16(106),
	872:  uint16(107),
	873:  uint16(108),
	874:  uint16(109),
	875:  uint16(110),
	876:  uint16(111),
	877:  uint16(112),
	878:  uint16(113),
	879:  uint16(114),
	880:  uint16(154),
	881:  uint16(155),
	882:  uint16(156),
	883:  uint16(157),
	884:  uint16(158),
	885:  uint16(195),
	886:  uint16(255),
	887:  uint16(67),
	888:  uint16(195),
	889:  uint16(60),
	890:  uint16(101),
	891:  uint16(240),
	892:  uint16(311),
	893:  uint16(312),
	894:  uint16(306),
	895:  uint16(75),
	896:  uint16(308),
	897:  uint16(316),
	898:  uint16(29),
	899:  uint16(117),
	900:  uint16(118),
	901:  uint16(119),
	902:  uint16(33),
	903:  uint16(287),
	904:  uint16(117),
	905:  uint16(118),
	906:  uint16(119),
	907:  uint16(118),
	908:  uint16(146),
	909:  uint16(183),
	910:  uint16(195),
	911:  uint16(122),
	912:  uint16(103),
	913:  uint16(104),
	914:  uint16(105),
	915:  uint16(106),
	916:  uint16(107),
	917:  uint16(108),
	918:  uint16(109),
	919:  uint16(110),
	920:  uint16(111),
	921:  uint16(112),
	922:  uint16(113),
	923:  uint16(114),
	924:  uint16(215),
	925:  uint16(195),
	926:  uint16(77),
	927:  uint16(60),
	928:  uint16(25),
	929:  uint16(195),
	930:  uint16(122),
	931:  uint16(144),
	932:  uint16(19),
	933:  uint16(218),
	934:  uint16(219),
	935:  uint16(66),
	936:  uint16(23),
	937:  uint16(88),
	938:  uint16(246),
	939:  uint16(90),
	940:  uint16(132),
	941:  uint16(25),
	942:  uint16(93),
	943:  uint16(154),
	944:  uint16(155),
	945:  uint16(156),
	946:  uint16(117),
	947:  uint16(118),
	948:  uint16(119),
	949:  uint16(257),
	950:  uint16(195),
	951:  uint16(131),
	952:  uint16(218),
	953:  uint16(219),
	954:  uint16(195),
	955:  uint16(265),
	956:  uint16(43),
	957:  uint16(44),
	958:  uint16(45),
	959:  uint16(195),
	960:  uint16(47),
	961:  uint16(48),
	962:  uint16(49),
	963:  uint16(50),
	964:  uint16(51),
	965:  uint16(52),
	966:  uint16(53),
	967:  uint16(54),
	968:  uint16(55),
	969:  uint16(56),
	970:  uint16(57),
	971:  uint16(58),
	972:  uint16(183),
	973:  uint16(218),
	974:  uint16(219),
	975:  uint16(195),
	976:  uint16(19),
	977:  uint16(218),
	978:  uint16(219),
	979:  uint16(195),
	980:  uint16(23),
	981:  uint16(195),
	982:  uint16(218),
	983:  uint16(219),
	984:  uint16(117),
	985:  uint16(118),
	986:  uint16(119),
	987:  uint16(195),
	988:  uint16(233),
	989:  uint16(255),
	990:  uint16(195),
	991:  uint16(195),
	992:  uint16(233),
	993:  uint16(22),
	994:  uint16(23),
	995:  uint16(146),
	996:  uint16(25),
	997:  uint16(233),
	998:  uint16(218),
	999:  uint16(219),
	1000: uint16(43),
	1001: uint16(44),
	1002: uint16(45),
	1003: uint16(294),
	1004: uint16(47),
	1005: uint16(48),
	1006: uint16(49),
	1007: uint16(50),
	1008: uint16(51),
	1009: uint16(52),
	1010: uint16(53),
	1011: uint16(54),
	1012: uint16(55),
	1013: uint16(56),
	1014: uint16(57),
	1015: uint16(58),
	1016: uint16(103),
	1017: uint16(104),
	1018: uint16(105),
	1019: uint16(106),
	1020: uint16(107),
	1021: uint16(108),
	1022: uint16(109),
	1023: uint16(110),
	1024: uint16(111),
	1025: uint16(112),
	1026: uint16(113),
	1027: uint16(114),
	1028: uint16(195),
	1029: uint16(12),
	1030: uint16(234),
	1031: uint16(195),
	1032: uint16(240),
	1033: uint16(74),
	1034: uint16(195),
	1035: uint16(255),
	1036: uint16(195),
	1037: uint16(60),
	1038: uint16(243),
	1039: uint16(262),
	1040: uint16(263),
	1041: uint16(311),
	1042: uint16(312),
	1043: uint16(25),
	1044: uint16(27),
	1045: uint16(19),
	1046: uint16(316),
	1047: uint16(107),
	1048: uint16(108),
	1049: uint16(265),
	1050: uint16(24),
	1051: uint16(265),
	1052: uint16(195),
	1053: uint16(150),
	1054: uint16(195),
	1055: uint16(139),
	1056: uint16(140),
	1057: uint16(218),
	1058: uint16(219),
	1059: uint16(42),
	1060: uint16(103),
	1061: uint16(104),
	1062: uint16(105),
	1063: uint16(106),
	1064: uint16(107),
	1065: uint16(108),
	1066: uint16(109),
	1067: uint16(110),
	1068: uint16(111),
	1069: uint16(112),
	1070: uint16(113),
	1071: uint16(114),
	1072: uint16(233),
	1073: uint16(102),
	1074: uint16(67),
	1075: uint16(218),
	1076: uint16(219),
	1077: uint16(218),
	1078: uint16(219),
	1079: uint16(243),
	1080: uint16(19),
	1081: uint16(64),
	1082: uint16(22),
	1083: uint16(23),
	1084: uint16(23),
	1085: uint16(25),
	1086: uint16(195),
	1087: uint16(128),
	1088: uint16(129),
	1089: uint16(130),
	1090: uint16(233),
	1091: uint16(74),
	1092: uint16(233),
	1093: uint16(86),
	1094: uint16(154),
	1095: uint16(118),
	1096: uint16(156),
	1097: uint16(130),
	1098: uint16(265),
	1099: uint16(208),
	1100: uint16(19),
	1101: uint16(306),
	1102: uint16(95),
	1103: uint16(308),
	1104: uint16(43),
	1105: uint16(44),
	1106: uint16(45),
	1107: uint16(266),
	1108: uint16(47),
	1109: uint16(48),
	1110: uint16(49),
	1111: uint16(50),
	1112: uint16(51),
	1113: uint16(52),
	1114: uint16(53),
	1115: uint16(54),
	1116: uint16(55),
	1117: uint16(56),
	1118: uint16(57),
	1119: uint16(58),
	1120: uint16(153),
	1121: uint16(230),
	1122: uint16(96),
	1123: uint16(232),
	1124: uint16(43),
	1125: uint16(44),
	1126: uint16(45),
	1127: uint16(19),
	1128: uint16(47),
	1129: uint16(48),
	1130: uint16(49),
	1131: uint16(50),
	1132: uint16(51),
	1133: uint16(52),
	1134: uint16(53),
	1135: uint16(54),
	1136: uint16(55),
	1137: uint16(56),
	1138: uint16(57),
	1139: uint16(58),
	1140: uint16(114),
	1141: uint16(22),
	1142: uint16(306),
	1143: uint16(24),
	1144: uint16(308),
	1145: uint16(127),
	1146: uint16(120),
	1147: uint16(121),
	1148: uint16(122),
	1149: uint16(123),
	1150: uint16(124),
	1151: uint16(125),
	1152: uint16(126),
	1153: uint16(195),
	1154: uint16(147),
	1155: uint16(212),
	1156: uint16(213),
	1157: uint16(214),
	1158: uint16(132),
	1159: uint16(23),
	1160: uint16(195),
	1161: uint16(25),
	1162: uint16(102),
	1163: uint16(100),
	1164: uint16(103),
	1165: uint16(104),
	1166: uint16(105),
	1167: uint16(106),
	1168: uint16(107),
	1169: uint16(108),
	1170: uint16(109),
	1171: uint16(110),
	1172: uint16(111),
	1173: uint16(112),
	1174: uint16(113),
	1175: uint16(114),
	1176: uint16(218),
	1177: uint16(219),
	1178: uint16(19),
	1179: uint16(60),
	1180: uint16(195),
	1181: uint16(12),
	1182: uint16(210),
	1183: uint16(211),
	1184: uint16(103),
	1185: uint16(104),
	1186: uint16(105),
	1187: uint16(106),
	1188: uint16(107),
	1189: uint16(108),
	1190: uint16(109),
	1191: uint16(110),
	1192: uint16(111),
	1193: uint16(112),
	1194: uint16(113),
	1195: uint16(114),
	1196: uint16(27),
	1197: uint16(134),
	1198: uint16(195),
	1199: uint16(195),
	1200: uint16(195),
	1201: uint16(210),
	1202: uint16(211),
	1203: uint16(218),
	1204: uint16(219),
	1205: uint16(195),
	1206: uint16(47),
	1207: uint16(195),
	1208: uint16(212),
	1209: uint16(213),
	1210: uint16(214),
	1211: uint16(42),
	1212: uint16(16),
	1213: uint16(130),
	1214: uint16(19),
	1215: uint16(112),
	1216: uint16(113),
	1217: uint16(114),
	1218: uint16(23),
	1219: uint16(77),
	1220: uint16(195),
	1221: uint16(218),
	1222: uint16(219),
	1223: uint16(218),
	1224: uint16(219),
	1225: uint16(117),
	1226: uint16(163),
	1227: uint16(164),
	1228: uint16(218),
	1229: uint16(219),
	1230: uint16(218),
	1231: uint16(219),
	1232: uint16(90),
	1233: uint16(64),
	1234: uint16(19),
	1235: uint16(93),
	1236: uint16(153),
	1237: uint16(118),
	1238: uint16(43),
	1239: uint16(44),
	1240: uint16(45),
	1241: uint16(160),
	1242: uint16(47),
	1243: uint16(48),
	1244: uint16(49),
	1245: uint16(50),
	1246: uint16(51),
	1247: uint16(52),
	1248: uint16(53),
	1249: uint16(54),
	1250: uint16(55),
	1251: uint16(56),
	1252: uint16(57),
	1253: uint16(58),
	1254: uint16(195),
	1255: uint16(119),
	1256: uint16(272),
	1257: uint16(276),
	1258: uint16(43),
	1259: uint16(44),
	1260: uint16(45),
	1261: uint16(195),
	1262: uint16(47),
	1263: uint16(48),
	1264: uint16(49),
	1265: uint16(50),
	1266: uint16(51),
	1267: uint16(52),
	1268: uint16(53),
	1269: uint16(54),
	1270: uint16(55),
	1271: uint16(56),
	1272: uint16(57),
	1273: uint16(58),
	1274: uint16(78),
	1275: uint16(116),
	1276: uint16(80),
	1277: uint16(218),
	1278: uint16(219),
	1279: uint16(116),
	1280: uint16(144),
	1281: uint16(128),
	1282: uint16(129),
	1283: uint16(130),
	1284: uint16(218),
	1285: uint16(219),
	1286: uint16(61),
	1287: uint16(195),
	1288: uint16(47),
	1289: uint16(195),
	1290: uint16(16),
	1291: uint16(132),
	1292: uint16(195),
	1293: uint16(263),
	1294: uint16(195),
	1295: uint16(314),
	1296: uint16(315),
	1297: uint16(267),
	1298: uint16(103),
	1299: uint16(104),
	1300: uint16(105),
	1301: uint16(106),
	1302: uint16(107),
	1303: uint16(108),
	1304: uint16(109),
	1305: uint16(110),
	1306: uint16(111),
	1307: uint16(112),
	1308: uint16(113),
	1309: uint16(114),
	1310: uint16(218),
	1311: uint16(219),
	1312: uint16(218),
	1313: uint16(219),
	1314: uint16(151),
	1315: uint16(218),
	1316: uint16(219),
	1317: uint16(195),
	1318: uint16(103),
	1319: uint16(104),
	1320: uint16(105),
	1321: uint16(106),
	1322: uint16(107),
	1323: uint16(108),
	1324: uint16(109),
	1325: uint16(110),
	1326: uint16(111),
	1327: uint16(112),
	1328: uint16(113),
	1329: uint16(114),
	1330: uint16(210),
	1331: uint16(211),
	1332: uint16(195),
	1333: uint16(7),
	1334: uint16(8),
	1335: uint16(9),
	1336: uint16(195),
	1337: uint16(60),
	1338: uint16(195),
	1339: uint16(312),
	1340: uint16(218),
	1341: uint16(219),
	1342: uint16(195),
	1343: uint16(316),
	1344: uint16(195),
	1345: uint16(120),
	1346: uint16(195),
	1347: uint16(263),
	1348: uint16(19),
	1349: uint16(195),
	1350: uint16(125),
	1351: uint16(267),
	1352: uint16(78),
	1353: uint16(24),
	1354: uint16(80),
	1355: uint16(218),
	1356: uint16(219),
	1357: uint16(116),
	1358: uint16(162),
	1359: uint16(218),
	1360: uint16(219),
	1361: uint16(218),
	1362: uint16(219),
	1363: uint16(301),
	1364: uint16(302),
	1365: uint16(218),
	1366: uint16(219),
	1367: uint16(195),
	1368: uint16(19),
	1369: uint16(218),
	1370: uint16(219),
	1371: uint16(276),
	1372: uint16(43),
	1373: uint16(44),
	1374: uint16(45),
	1375: uint16(160),
	1376: uint16(47),
	1377: uint16(48),
	1378: uint16(49),
	1379: uint16(50),
	1380: uint16(51),
	1381: uint16(52),
	1382: uint16(53),
	1383: uint16(54),
	1384: uint16(55),
	1385: uint16(56),
	1386: uint16(57),
	1387: uint16(58),
	1388: uint16(19),
	1389: uint16(146),
	1390: uint16(218),
	1391: uint16(219),
	1392: uint16(43),
	1393: uint16(44),
	1394: uint16(45),
	1395: uint16(118),
	1396: uint16(47),
	1397: uint16(48),
	1398: uint16(49),
	1399: uint16(50),
	1400: uint16(51),
	1401: uint16(52),
	1402: uint16(53),
	1403: uint16(54),
	1404: uint16(55),
	1405: uint16(56),
	1406: uint16(57),
	1407: uint16(58),
	1408: uint16(165),
	1409: uint16(314),
	1410: uint16(315),
	1411: uint16(276),
	1412: uint16(43),
	1413: uint16(44),
	1414: uint16(45),
	1415: uint16(266),
	1416: uint16(47),
	1417: uint16(48),
	1418: uint16(49),
	1419: uint16(50),
	1420: uint16(51),
	1421: uint16(52),
	1422: uint16(53),
	1423: uint16(54),
	1424: uint16(55),
	1425: uint16(56),
	1426: uint16(57),
	1427: uint16(58),
	1428: uint16(128),
	1429: uint16(129),
	1430: uint16(130),
	1431: uint16(195),
	1432: uint16(103),
	1433: uint16(104),
	1434: uint16(105),
	1435: uint16(106),
	1436: uint16(107),
	1437: uint16(108),
	1438: uint16(109),
	1439: uint16(110),
	1440: uint16(111),
	1441: uint16(112),
	1442: uint16(113),
	1443: uint16(114),
	1444: uint16(195),
	1445: uint16(228),
	1446: uint16(195),
	1447: uint16(61),
	1448: uint16(195),
	1449: uint16(314),
	1450: uint16(315),
	1451: uint16(25),
	1452: uint16(103),
	1453: uint16(104),
	1454: uint16(105),
	1455: uint16(106),
	1456: uint16(107),
	1457: uint16(108),
	1458: uint16(109),
	1459: uint16(110),
	1460: uint16(111),
	1461: uint16(112),
	1462: uint16(113),
	1463: uint16(114),
	1464: uint16(195),
	1465: uint16(22),
	1466: uint16(195),
	1467: uint16(218),
	1468: uint16(219),
	1469: uint16(218),
	1470: uint16(219),
	1471: uint16(195),
	1472: uint16(103),
	1473: uint16(104),
	1474: uint16(105),
	1475: uint16(106),
	1476: uint16(107),
	1477: uint16(108),
	1478: uint16(109),
	1479: uint16(110),
	1480: uint16(111),
	1481: uint16(112),
	1482: uint16(113),
	1483: uint16(114),
	1484: uint16(195),
	1485: uint16(195),
	1486: uint16(246),
	1487: uint16(218),
	1488: uint16(219),
	1489: uint16(218),
	1490: uint16(219),
	1491: uint16(25),
	1492: uint16(19),
	1493: uint16(246),
	1494: uint16(218),
	1495: uint16(219),
	1496: uint16(246),
	1497: uint16(257),
	1498: uint16(259),
	1499: uint16(260),
	1500: uint16(195),
	1501: uint16(22),
	1502: uint16(266),
	1503: uint16(60),
	1504: uint16(257),
	1505: uint16(195),
	1506: uint16(120),
	1507: uint16(257),
	1508: uint16(218),
	1509: uint16(219),
	1510: uint16(116),
	1511: uint16(195),
	1512: uint16(19),
	1513: uint16(195),
	1514: uint16(150),
	1515: uint16(151),
	1516: uint16(25),
	1517: uint16(44),
	1518: uint16(45),
	1519: uint16(266),
	1520: uint16(47),
	1521: uint16(48),
	1522: uint16(49),
	1523: uint16(50),
	1524: uint16(51),
	1525: uint16(52),
	1526: uint16(53),
	1527: uint16(54),
	1528: uint16(55),
	1529: uint16(56),
	1530: uint16(57),
	1531: uint16(58),
	1532: uint16(195),
	1533: uint16(54),
	1534: uint16(218),
	1535: uint16(219),
	1536: uint16(218),
	1537: uint16(219),
	1538: uint16(45),
	1539: uint16(145),
	1540: uint16(47),
	1541: uint16(48),
	1542: uint16(49),
	1543: uint16(50),
	1544: uint16(51),
	1545: uint16(52),
	1546: uint16(53),
	1547: uint16(54),
	1548: uint16(55),
	1549: uint16(56),
	1550: uint16(57),
	1551: uint16(58),
	1552: uint16(246),
	1553: uint16(121),
	1554: uint16(122),
	1555: uint16(218),
	1556: uint16(219),
	1557: uint16(19),
	1558: uint16(23),
	1559: uint16(31),
	1560: uint16(25),
	1561: uint16(118),
	1562: uint16(159),
	1563: uint16(257),
	1564: uint16(161),
	1565: uint16(24),
	1566: uint16(195),
	1567: uint16(39),
	1568: uint16(195),
	1569: uint16(143),
	1570: uint16(195),
	1571: uint16(19),
	1572: uint16(20),
	1573: uint16(22),
	1574: uint16(22),
	1575: uint16(24),
	1576: uint16(103),
	1577: uint16(104),
	1578: uint16(105),
	1579: uint16(106),
	1580: uint16(107),
	1581: uint16(108),
	1582: uint16(109),
	1583: uint16(110),
	1584: uint16(111),
	1585: uint16(112),
	1586: uint16(113),
	1587: uint16(114),
	1588: uint16(36),
	1589: uint16(218),
	1590: uint16(219),
	1591: uint16(218),
	1592: uint16(219),
	1593: uint16(218),
	1594: uint16(219),
	1595: uint16(195),
	1596: uint16(103),
	1597: uint16(104),
	1598: uint16(105),
	1599: uint16(106),
	1600: uint16(107),
	1601: uint16(108),
	1602: uint16(109),
	1603: uint16(110),
	1604: uint16(111),
	1605: uint16(112),
	1606: uint16(113),
	1607: uint16(114),
	1608: uint16(195),
	1609: uint16(143),
	1610: uint16(119),
	1611: uint16(136),
	1612: uint16(60),
	1613: uint16(195),
	1614: uint16(22),
	1615: uint16(195),
	1616: uint16(141),
	1617: uint16(195),
	1618: uint16(218),
	1619: uint16(219),
	1620: uint16(195),
	1621: uint16(23),
	1622: uint16(195),
	1623: uint16(25),
	1624: uint16(72),
	1625: uint16(23),
	1626: uint16(131),
	1627: uint16(25),
	1628: uint16(195),
	1629: uint16(134),
	1630: uint16(23),
	1631: uint16(218),
	1632: uint16(219),
	1633: uint16(195),
	1634: uint16(82),
	1635: uint16(144),
	1636: uint16(218),
	1637: uint16(219),
	1638: uint16(218),
	1639: uint16(219),
	1640: uint16(218),
	1641: uint16(219),
	1642: uint16(195),
	1643: uint16(218),
	1644: uint16(219),
	1645: uint16(218),
	1646: uint16(219),
	1647: uint16(60),
	1648: uint16(23),
	1649: uint16(195),
	1650: uint16(25),
	1651: uint16(218),
	1652: uint16(219),
	1653: uint16(101),
	1654: uint16(195),
	1655: uint16(117),
	1656: uint16(218),
	1657: uint16(219),
	1658: uint16(195),
	1659: uint16(107),
	1660: uint16(108),
	1661: uint16(23),
	1662: uint16(195),
	1663: uint16(25),
	1664: uint16(195),
	1665: uint16(218),
	1666: uint16(219),
	1667: uint16(115),
	1668: uint16(228),
	1669: uint16(117),
	1670: uint16(118),
	1671: uint16(119),
	1672: uint16(218),
	1673: uint16(219),
	1674: uint16(122),
	1675: uint16(195),
	1676: uint16(19),
	1677: uint16(218),
	1678: uint16(219),
	1679: uint16(195),
	1680: uint16(60),
	1681: uint16(218),
	1682: uint16(219),
	1683: uint16(142),
	1684: uint16(195),
	1685: uint16(218),
	1686: uint16(219),
	1687: uint16(19),
	1688: uint16(20),
	1689: uint16(195),
	1690: uint16(22),
	1691: uint16(139),
	1692: uint16(140),
	1693: uint16(23),
	1694: uint16(23),
	1695: uint16(25),
	1696: uint16(25),
	1697: uint16(195),
	1698: uint16(218),
	1699: uint16(219),
	1700: uint16(7),
	1701: uint16(8),
	1702: uint16(218),
	1703: uint16(219),
	1704: uint16(36),
	1705: uint16(118),
	1706: uint16(154),
	1707: uint16(155),
	1708: uint16(156),
	1709: uint16(157),
	1710: uint16(158),
	1711: uint16(195),
	1712: uint16(23),
	1713: uint16(195),
	1714: uint16(25),
	1715: uint16(84),
	1716: uint16(85),
	1717: uint16(49),
	1718: uint16(195),
	1719: uint16(23),
	1720: uint16(195),
	1721: uint16(25),
	1722: uint16(195),
	1723: uint16(23),
	1724: uint16(195),
	1725: uint16(25),
	1726: uint16(195),
	1727: uint16(23),
	1728: uint16(60),
	1729: uint16(25),
	1730: uint16(23),
	1731: uint16(23),
	1732: uint16(25),
	1733: uint16(25),
	1734: uint16(142),
	1735: uint16(183),
	1736: uint16(218),
	1737: uint16(219),
	1738: uint16(118),
	1739: uint16(195),
	1740: uint16(72),
	1741: uint16(218),
	1742: uint16(219),
	1743: uint16(218),
	1744: uint16(219),
	1745: uint16(218),
	1746: uint16(219),
	1747: uint16(218),
	1748: uint16(219),
	1749: uint16(218),
	1750: uint16(219),
	1751: uint16(195),
	1752: uint16(195),
	1753: uint16(146),
	1754: uint16(86),
	1755: uint16(98),
	1756: uint16(23),
	1757: uint16(195),
	1758: uint16(25),
	1759: uint16(91),
	1760: uint16(19),
	1761: uint16(20),
	1762: uint16(154),
	1763: uint16(22),
	1764: uint16(156),
	1765: uint16(154),
	1766: uint16(23),
	1767: uint16(156),
	1768: uint16(25),
	1769: uint16(101),
	1770: uint16(23),
	1771: uint16(195),
	1772: uint16(25),
	1773: uint16(195),
	1774: uint16(195),
	1775: uint16(107),
	1776: uint16(108),
	1777: uint16(36),
	1778: uint16(195),
	1779: uint16(195),
	1780: uint16(195),
	1781: uint16(195),
	1782: uint16(228),
	1783: uint16(115),
	1784: uint16(195),
	1785: uint16(117),
	1786: uint16(118),
	1787: uint16(119),
	1788: uint16(195),
	1789: uint16(195),
	1790: uint16(122),
	1791: uint16(261),
	1792: uint16(195),
	1793: uint16(321),
	1794: uint16(195),
	1795: uint16(195),
	1796: uint16(195),
	1797: uint16(258),
	1798: uint16(238),
	1799: uint16(195),
	1800: uint16(195),
	1801: uint16(60),
	1802: uint16(299),
	1803: uint16(291),
	1804: uint16(195),
	1805: uint16(195),
	1806: uint16(258),
	1807: uint16(195),
	1808: uint16(195),
	1809: uint16(195),
	1810: uint16(290),
	1811: uint16(244),
	1812: uint16(216),
	1813: uint16(72),
	1814: uint16(245),
	1815: uint16(193),
	1816: uint16(258),
	1817: uint16(258),
	1818: uint16(299),
	1819: uint16(258),
	1820: uint16(299),
	1821: uint16(274),
	1822: uint16(154),
	1823: uint16(155),
	1824: uint16(156),
	1825: uint16(157),
	1826: uint16(158),
	1827: uint16(86),
	1828: uint16(247),
	1829: uint16(295),
	1830: uint16(248),
	1831: uint16(295),
	1832: uint16(91),
	1833: uint16(19),
	1834: uint16(20),
	1835: uint16(270),
	1836: uint16(22),
	1837: uint16(274),
	1838: uint16(270),
	1839: uint16(248),
	1840: uint16(274),
	1841: uint16(222),
	1842: uint16(101),
	1843: uint16(227),
	1844: uint16(274),
	1845: uint16(221),
	1846: uint16(231),
	1847: uint16(221),
	1848: uint16(107),
	1849: uint16(108),
	1850: uint16(36),
	1851: uint16(183),
	1852: uint16(262),
	1853: uint16(247),
	1854: uint16(221),
	1855: uint16(283),
	1856: uint16(115),
	1857: uint16(262),
	1858: uint16(117),
	1859: uint16(118),
	1860: uint16(119),
	1861: uint16(198),
	1862: uint16(116),
	1863: uint16(122),
	1864: uint16(220),
	1865: uint16(262),
	1866: uint16(61),
	1867: uint16(220),
	1868: uint16(220),
	1869: uint16(251),
	1870: uint16(247),
	1871: uint16(142),
	1872: uint16(251),
	1873: uint16(245),
	1874: uint16(60),
	1875: uint16(202),
	1876: uint16(299),
	1877: uint16(202),
	1878: uint16(38),
	1879: uint16(262),
	1880: uint16(202),
	1881: uint16(22),
	1882: uint16(152),
	1883: uint16(151),
	1884: uint16(296),
	1885: uint16(43),
	1886: uint16(72),
	1887: uint16(236),
	1888: uint16(18),
	1889: uint16(239),
	1890: uint16(202),
	1891: uint16(239),
	1892: uint16(239),
	1893: uint16(239),
	1894: uint16(18),
	1895: uint16(154),
	1896: uint16(155),
	1897: uint16(156),
	1898: uint16(157),
	1899: uint16(158),
	1900: uint16(86),
	1901: uint16(150),
	1902: uint16(201),
	1903: uint16(248),
	1904: uint16(275),
	1905: uint16(91),
	1906: uint16(248),
	1907: uint16(273),
	1908: uint16(236),
	1909: uint16(248),
	1910: uint16(275),
	1911: uint16(275),
	1912: uint16(273),
	1913: uint16(236),
	1914: uint16(248),
	1915: uint16(101),
	1916: uint16(286),
	1917: uint16(202),
	1918: uint16(201),
	1919: uint16(159),
	1920: uint16(63),
	1921: uint16(107),
	1922: uint16(108),
	1923: uint16(296),
	1924: uint16(183),
	1925: uint16(293),
	1926: uint16(202),
	1927: uint16(201),
	1928: uint16(22),
	1929: uint16(115),
	1930: uint16(202),
	1931: uint16(117),
	1932: uint16(118),
	1933: uint16(119),
	1934: uint16(292),
	1935: uint16(223),
	1936: uint16(122),
	1937: uint16(201),
	1938: uint16(65),
	1939: uint16(202),
	1940: uint16(201),
	1941: uint16(223),
	1942: uint16(220),
	1943: uint16(220),
	1944: uint16(22),
	1945: uint16(220),
	1946: uint16(226),
	1947: uint16(226),
	1948: uint16(229),
	1949: uint16(127),
	1950: uint16(223),
	1951: uint16(220),
	1952: uint16(166),
	1953: uint16(24),
	1954: uint16(285),
	1955: uint16(220),
	1956: uint16(222),
	1957: uint16(114),
	1958: uint16(315),
	1959: uint16(285),
	1960: uint16(220),
	1961: uint16(202),
	1962: uint16(220),
	1963: uint16(307),
	1964: uint16(92),
	1965: uint16(320),
	1966: uint16(320),
	1967: uint16(229),
	1968: uint16(154),
	1969: uint16(155),
	1970: uint16(156),
	1971: uint16(157),
	1972: uint16(158),
	1974: uint16(1),
	1975: uint16(2),
	1976: uint16(223),
	1977: uint16(83),
	1978: uint16(5),
	1979: uint16(268),
	1980: uint16(149),
	1981: uint16(268),
	1982: uint16(146),
	1983: uint16(10),
	1984: uint16(11),
	1985: uint16(12),
	1986: uint16(13),
	1987: uint16(14),
	1988: uint16(22),
	1989: uint16(280),
	1990: uint16(17),
	1991: uint16(202),
	1992: uint16(159),
	1993: uint16(19),
	1994: uint16(20),
	1995: uint16(251),
	1996: uint16(22),
	1997: uint16(183),
	1998: uint16(282),
	1999: uint16(148),
	2000: uint16(252),
	2001: uint16(252),
	2002: uint16(250),
	2003: uint16(30),
	2004: uint16(249),
	2005: uint16(32),
	2006: uint16(248),
	2007: uint16(147),
	2008: uint16(25),
	2009: uint16(13),
	2010: uint16(36),
	2011: uint16(204),
	2012: uint16(196),
	2013: uint16(40),
	2014: uint16(196),
	2015: uint16(6),
	2016: uint16(302),
	2017: uint16(194),
	2018: uint16(194),
	2019: uint16(194),
	2020: uint16(209),
	2021: uint16(215),
	2022: uint16(209),
	2023: uint16(215),
	2024: uint16(215),
	2025: uint16(215),
	2026: uint16(224),
	2027: uint16(224),
	2028: uint16(216),
	2029: uint16(209),
	2030: uint16(4),
	2031: uint16(216),
	2032: uint16(215),
	2033: uint16(3),
	2034: uint16(60),
	2035: uint16(22),
	2036: uint16(122),
	2037: uint16(19),
	2038: uint16(122),
	2039: uint16(19),
	2040: uint16(125),
	2041: uint16(22),
	2042: uint16(15),
	2043: uint16(22),
	2044: uint16(71),
	2045: uint16(16),
	2046: uint16(72),
	2047: uint16(23),
	2048: uint16(23),
	2049: uint16(140),
	2050: uint16(305),
	2051: uint16(152),
	2052: uint16(79),
	2053: uint16(25),
	2054: uint16(131),
	2055: uint16(82),
	2056: uint16(143),
	2057: uint16(20),
	2058: uint16(16),
	2059: uint16(305),
	2060: uint16(1),
	2061: uint16(143),
	2062: uint16(145),
	2063: uint16(131),
	2064: uint16(131),
	2065: uint16(62),
	2066: uint16(54),
	2067: uint16(131),
	2068: uint16(37),
	2069: uint16(54),
	2070: uint16(54),
	2071: uint16(152),
	2072: uint16(99),
	2073: uint16(117),
	2074: uint16(34),
	2075: uint16(101),
	2076: uint16(54),
	2077: uint16(24),
	2078: uint16(1),
	2079: uint16(5),
	2080: uint16(22),
	2081: uint16(107),
	2082: uint16(108),
	2083: uint16(116),
	2084: uint16(76),
	2085: uint16(25),
	2086: uint16(162),
	2087: uint16(41),
	2088: uint16(142),
	2089: uint16(115),
	2090: uint16(24),
	2091: uint16(117),
	2092: uint16(118),
	2093: uint16(119),
	2094: uint16(116),
	2095: uint16(20),
	2096: uint16(122),
	2097: uint16(19),
	2098: uint16(126),
	2099: uint16(23),
	2100: uint16(132),
	2101: uint16(19),
	2102: uint16(20),
	2103: uint16(69),
	2104: uint16(22),
	2105: uint16(69),
	2106: uint16(22),
	2107: uint16(134),
	2108: uint16(22),
	2109: uint16(68),
	2110: uint16(22),
	2111: uint16(22),
	2112: uint16(139),
	2113: uint16(140),
	2114: uint16(60),
	2115: uint16(141),
	2116: uint16(68),
	2117: uint16(24),
	2118: uint16(36),
	2119: uint16(28),
	2120: uint16(97),
	2121: uint16(22),
	2122: uint16(37),
	2123: uint16(68),
	2124: uint16(23),
	2125: uint16(150),
	2126: uint16(34),
	2127: uint16(22),
	2128: uint16(154),
	2129: uint16(155),
	2130: uint16(156),
	2131: uint16(157),
	2132: uint16(158),
	2133: uint16(23),
	2134: uint16(23),
	2135: uint16(22),
	2136: uint16(163),
	2137: uint16(25),
	2138: uint16(23),
	2139: uint16(142),
	2140: uint16(23),
	2141: uint16(98),
	2142: uint16(60),
	2143: uint16(23),
	2144: uint16(22),
	2145: uint16(144),
	2146: uint16(25),
	2147: uint16(76),
	2148: uint16(34),
	2149: uint16(117),
	2150: uint16(34),
	2151: uint16(89),
	2152: uint16(34),
	2153: uint16(34),
	2154: uint16(72),
	2155: uint16(87),
	2156: uint16(76),
	2157: uint16(183),
	2158: uint16(34),
	2159: uint16(94),
	2160: uint16(34),
	2161: uint16(23),
	2162: uint16(22),
	2163: uint16(24),
	2164: uint16(34),
	2165: uint16(23),
	2166: uint16(25),
	2167: uint16(44),
	2168: uint16(25),
	2169: uint16(23),
	2170: uint16(23),
	2171: uint16(23),
	2172: uint16(22),
	2173: uint16(22),
	2174: uint16(25),
	2175: uint16(11),
	2176: uint16(143),
	2177: uint16(25),
	2178: uint16(143),
	2179: uint16(23),
	2180: uint16(22),
	2181: uint16(22),
	2182: uint16(22),
	2183: uint16(101),
	2184: uint16(23),
	2185: uint16(23),
	2186: uint16(136),
	2187: uint16(22),
	2188: uint16(25),
	2189: uint16(107),
	2190: uint16(108),
	2191: uint16(142),
	2192: uint16(25),
	2193: uint16(142),
	2194: uint16(142),
	2195: uint16(23),
	2196: uint16(15),
	2197: uint16(115),
	2198: uint16(1),
	2199: uint16(117),
	2200: uint16(118),
	2201: uint16(119),
	2202: uint16(1),
	2203: uint16(2),
	2204: uint16(122),
	2205: uint16(1),
	2206: uint16(5),
	2207: uint16(322),
	2208: uint16(322),
	2209: uint16(322),
	2210: uint16(322),
	2211: uint16(10),
	2212: uint16(11),
	2213: uint16(12),
	2214: uint16(13),
	2215: uint16(14),
	2216: uint16(322),
	2217: uint16(322),
	2218: uint16(17),
	2219: uint16(322),
	2220: uint16(5),
	2221: uint16(322),
	2222: uint16(322),
	2223: uint16(141),
	2224: uint16(322),
	2225: uint16(10),
	2226: uint16(11),
	2227: uint16(12),
	2228: uint16(13),
	2229: uint16(14),
	2230: uint16(322),
	2231: uint16(30),
	2232: uint16(17),
	2233: uint16(32),
	2234: uint16(322),
	2235: uint16(322),
	2236: uint16(154),
	2237: uint16(155),
	2238: uint16(156),
	2239: uint16(157),
	2240: uint16(158),
	2241: uint16(40),
	2242: uint16(322),
	2243: uint16(322),
	2244: uint16(322),
	2245: uint16(30),
	2246: uint16(322),
	2247: uint16(32),
	2248: uint16(322),
	2249: uint16(322),
	2250: uint16(322),
	2251: uint16(322),
	2252: uint16(322),
	2253: uint16(322),
	2254: uint16(322),
	2255: uint16(40),
	2256: uint16(322),
	2257: uint16(322),
	2258: uint16(322),
	2259: uint16(322),
	2260: uint16(322),
	2261: uint16(322),
	2262: uint16(322),
	2263: uint16(322),
	2264: uint16(322),
	2265: uint16(183),
	2266: uint16(322),
	2267: uint16(322),
	2268: uint16(322),
	2269: uint16(322),
	2270: uint16(322),
	2271: uint16(322),
	2272: uint16(71),
	2273: uint16(322),
	2274: uint16(322),
	2275: uint16(322),
	2276: uint16(322),
	2277: uint16(322),
	2278: uint16(322),
	2279: uint16(322),
	2280: uint16(79),
	2281: uint16(322),
	2282: uint16(322),
	2283: uint16(82),
	2284: uint16(322),
	2285: uint16(322),
	2286: uint16(71),
	2287: uint16(322),
	2288: uint16(322),
	2289: uint16(322),
	2290: uint16(322),
	2291: uint16(322),
	2292: uint16(322),
	2293: uint16(322),
	2294: uint16(79),
	2295: uint16(322),
	2296: uint16(322),
	2297: uint16(82),
	2298: uint16(322),
	2299: uint16(322),
	2300: uint16(99),
	2301: uint16(322),
	2302: uint16(322),
	2303: uint16(322),
	2304: uint16(322),
	2305: uint16(322),
	2306: uint16(322),
	2307: uint16(322),
	2308: uint16(322),
	2309: uint16(322),
	2310: uint16(322),
	2311: uint16(322),
	2312: uint16(322),
	2313: uint16(322),
	2314: uint16(99),
	2315: uint16(322),
	2316: uint16(322),
	2317: uint16(322),
	2318: uint16(322),
	2319: uint16(322),
	2320: uint16(322),
	2321: uint16(322),
	2322: uint16(322),
	2323: uint16(322),
	2324: uint16(322),
	2325: uint16(322),
	2326: uint16(322),
	2327: uint16(322),
	2328: uint16(322),
	2329: uint16(322),
	2330: uint16(322),
	2331: uint16(322),
	2332: uint16(322),
	2333: uint16(322),
	2334: uint16(322),
	2335: uint16(134),
	2336: uint16(322),
	2337: uint16(322),
	2338: uint16(322),
	2339: uint16(322),
	2340: uint16(139),
	2341: uint16(140),
	2342: uint16(322),
	2343: uint16(322),
	2344: uint16(322),
	2345: uint16(322),
	2346: uint16(322),
	2347: uint16(322),
	2348: uint16(322),
	2349: uint16(134),
	2350: uint16(322),
	2351: uint16(322),
	2352: uint16(322),
	2353: uint16(322),
	2354: uint16(139),
	2355: uint16(140),
	2356: uint16(322),
	2357: uint16(322),
	2358: uint16(322),
	2359: uint16(322),
	2360: uint16(322),
	2361: uint16(322),
	2362: uint16(322),
	2363: uint16(322),
	2364: uint16(163),
	2365: uint16(322),
	2366: uint16(322),
	2367: uint16(322),
	2368: uint16(322),
	2369: uint16(322),
	2370: uint16(322),
	2371: uint16(322),
	2372: uint16(322),
	2373: uint16(322),
	2374: uint16(322),
	2375: uint16(322),
	2376: uint16(322),
	2377: uint16(322),
	2378: uint16(163),
	2379: uint16(322),
	2380: uint16(322),
	2381: uint16(322),
	2382: uint16(322),
	2383: uint16(322),
	2384: uint16(322),
	2385: uint16(322),
	2386: uint16(322),
	2387: uint16(322),
	2388: uint16(322),
	2389: uint16(322),
	2390: uint16(322),
	2391: uint16(322),
	2392: uint16(322),
	2393: uint16(322),
	2394: uint16(322),
	2395: uint16(322),
	2396: uint16(322),
	2397: uint16(322),
	2398: uint16(322),
	2399: uint16(322),
	2400: uint16(322),
	2401: uint16(322),
	2402: uint16(322),
	2403: uint16(322),
	2404: uint16(322),
	2405: uint16(322),
	2406: uint16(322),
	2407: uint16(322),
	2408: uint16(187),
	2409: uint16(187),
	2410: uint16(187),
	2411: uint16(187),
	2412: uint16(187),
	2413: uint16(187),
	2414: uint16(187),
	2415: uint16(187),
	2416: uint16(187),
	2417: uint16(187),
	2418: uint16(187),
	2419: uint16(187),
	2420: uint16(187),
	2421: uint16(187),
	2422: uint16(187),
	2423: uint16(187),
	2424: uint16(187),
	2425: uint16(187),
	2426: uint16(187),
	2427: uint16(187),
	2428: uint16(187),
	2429: uint16(187),
	2430: uint16(187),
	2431: uint16(187),
	2432: uint16(187),
	2433: uint16(187),
	2434: uint16(187),
	2435: uint16(187),
	2436: uint16(187),
	2437: uint16(187),
	2438: uint16(187),
	2439: uint16(187),
	2440: uint16(187),
	2441: uint16(187),
	2442: uint16(187),
	2443: uint16(187),
	2444: uint16(187),
	2445: uint16(187),
	2446: uint16(187),
	2447: uint16(187),
	2448: uint16(187),
	2449: uint16(187),
	2450: uint16(187),
	2451: uint16(187),
	2452: uint16(187),
	2453: uint16(187),
	2454: uint16(187),
	2455: uint16(187),
	2456: uint16(187),
	2457: uint16(187),
	2458: uint16(187),
	2459: uint16(187),
	2460: uint16(187),
	2461: uint16(187),
	2462: uint16(187),
	2463: uint16(187),
	2464: uint16(187),
	2465: uint16(187),
	2466: uint16(187),
	2467: uint16(187),
	2468: uint16(187),
	2469: uint16(187),
	2470: uint16(187),
	2471: uint16(187),
	2472: uint16(187),
	2473: uint16(187),
	2474: uint16(187),
	2475: uint16(187),
	2476: uint16(187),
	2477: uint16(187),
	2478: uint16(187),
	2479: uint16(187),
	2480: uint16(187),
	2481: uint16(187),
	2482: uint16(187),
	2483: uint16(187),
	2484: uint16(187),
	2485: uint16(187),
	2486: uint16(187),
	2487: uint16(187),
	2488: uint16(187),
	2489: uint16(187),
	2490: uint16(187),
	2491: uint16(187),
	2492: uint16(187),
	2493: uint16(187),
	2494: uint16(187),
	2495: uint16(187),
	2496: uint16(187),
	2497: uint16(187),
	2498: uint16(187),
	2499: uint16(187),
	2500: uint16(187),
	2501: uint16(187),
	2502: uint16(187),
	2503: uint16(187),
	2504: uint16(187),
	2505: uint16(187),
	2506: uint16(187),
	2507: uint16(187),
	2508: uint16(187),
	2509: uint16(187),
	2510: uint16(187),
	2511: uint16(187),
	2512: uint16(187),
	2513: uint16(187),
	2514: uint16(187),
	2515: uint16(187),
	2516: uint16(187),
	2517: uint16(187),
	2518: uint16(187),
	2519: uint16(187),
	2520: uint16(187),
	2521: uint16(187),
	2522: uint16(187),
	2523: uint16(187),
	2524: uint16(187),
	2525: uint16(187),
	2526: uint16(187),
	2527: uint16(187),
	2528: uint16(187),
	2529: uint16(187),
	2530: uint16(187),
	2531: uint16(187),
	2532: uint16(187),
	2533: uint16(187),
	2534: uint16(187),
	2535: uint16(187),
	2536: uint16(187),
	2537: uint16(187),
	2538: uint16(187),
	2539: uint16(187),
	2540: uint16(187),
	2541: uint16(187),
	2542: uint16(187),
	2543: uint16(187),
	2544: uint16(187),
	2545: uint16(187),
	2546: uint16(187),
	2547: uint16(187),
	2548: uint16(187),
	2549: uint16(187),
	2550: uint16(187),
	2551: uint16(187),
	2552: uint16(187),
	2553: uint16(187),
	2554: uint16(187),
	2555: uint16(187),
	2556: uint16(187),
	2557: uint16(187),
	2558: uint16(187),
	2559: uint16(187),
	2560: uint16(187),
	2561: uint16(187),
	2562: uint16(187),
	2563: uint16(187),
	2564: uint16(187),
	2565: uint16(187),
}

var _yy_reduce_ofst = [424]int16{
	0:   int16(-int32(67)),
	1:   int16(345),
	2:   int16(-int32(64)),
	3:   int16(-int32(178)),
	4:   int16(-int32(181)),
	5:   int16(143),
	6:   int16(435),
	7:   int16(-int32(78)),
	8:   int16(-int32(183)),
	9:   int16(163),
	10:  int16(-int32(185)),
	11:  int16(284),
	12:  int16(384),
	13:  int16(-int32(174)),
	14:  int16(189),
	15:  int16(352),
	16:  int16(440),
	17:  int16(444),
	18:  int16(493),
	19:  int16(-int32(23)),
	20:  int16(227),
	21:  int16(-int32(277)),
	22:  int16(-int32(1)),
	23:  int16(305),
	24:  int16(561),
	25:  int16(755),
	26:  int16(759),
	27:  int16(764),
	28:  int16(-int32(189)),
	29:  int16(839),
	30:  int16(857),
	31:  int16(354),
	32:  int16(484),
	33:  int16(859),
	34:  int16(631),
	35:  int16(67),
	36:  int16(734),
	37:  int16(780),
	38:  int16(-int32(187)),
	39:  int16(616),
	40:  int16(581),
	41:  int16(730),
	42:  int16(891),
	43:  int16(449),
	44:  int16(588),
	45:  int16(795),
	46:  int16(836),
	47:  int16(-int32(238)),
	48:  int16(287),
	49:  int16(-int32(238)),
	50:  int16(287),
	51:  int16(-int32(256)),
	52:  int16(-int32(256)),
	53:  int16(-int32(256)),
	54:  int16(-int32(256)),
	55:  int16(-int32(256)),
	56:  int16(-int32(256)),
	57:  int16(-int32(256)),
	58:  int16(-int32(256)),
	59:  int16(-int32(256)),
	60:  int16(-int32(256)),
	61:  int16(-int32(256)),
	62:  int16(-int32(256)),
	63:  int16(-int32(256)),
	64:  int16(-int32(256)),
	65:  int16(-int32(256)),
	66:  int16(-int32(256)),
	67:  int16(-int32(256)),
	68:  int16(-int32(256)),
	69:  int16(-int32(256)),
	70:  int16(-int32(256)),
	71:  int16(-int32(256)),
	72:  int16(-int32(256)),
	73:  int16(-int32(256)),
	74:  int16(-int32(256)),
	75:  int16(-int32(256)),
	76:  int16(-int32(256)),
	77:  int16(-int32(256)),
	78:  int16(-int32(256)),
	79:  int16(-int32(256)),
	80:  int16(-int32(256)),
	81:  int16(-int32(256)),
	82:  int16(-int32(256)),
	83:  int16(-int32(256)),
	84:  int16(-int32(256)),
	85:  int16(-int32(256)),
	86:  int16(-int32(256)),
	87:  int16(-int32(256)),
	88:  int16(-int32(256)),
	89:  int16(-int32(256)),
	90:  int16(-int32(256)),
	91:  int16(205),
	92:  int16(582),
	93:  int16(715),
	94:  int16(958),
	95:  int16(985),
	96:  int16(1003),
	97:  int16(1005),
	98:  int16(1010),
	99:  int16(1012),
	100: int16(1059),
	101: int16(1066),
	102: int16(1092),
	103: int16(1094),
	104: int16(1097),
	105: int16(1122),
	106: int16(1137),
	107: int16(1141),
	108: int16(1143),
	109: int16(1147),
	110: int16(1151),
	111: int16(1172),
	112: int16(1249),
	113: int16(1251),
	114: int16(1269),
	115: int16(1271),
	116: int16(1276),
	117: int16(1290),
	118: int16(1316),
	119: int16(1318),
	120: int16(1337),
	121: int16(1371),
	122: int16(1373),
	123: int16(1375),
	124: int16(1400),
	125: int16(1413),
	126: int16(1418),
	127: int16(1420),
	128: int16(1422),
	129: int16(1425),
	130: int16(1427),
	131: int16(1433),
	132: int16(1438),
	133: int16(1447),
	134: int16(1454),
	135: int16(1459),
	136: int16(1463),
	137: int16(1467),
	138: int16(1480),
	139: int16(1484),
	140: int16(1518),
	141: int16(1523),
	142: int16(1525),
	143: int16(1527),
	144: int16(1529),
	145: int16(1531),
	146: int16(-int32(256)),
	147: int16(-int32(256)),
	148: int16(-int32(256)),
	149: int16(-int32(256)),
	150: int16(-int32(256)),
	151: int16(-int32(256)),
	152: int16(-int32(256)),
	153: int16(-int32(256)),
	154: int16(-int32(256)),
	155: int16(-int32(256)),
	156: int16(-int32(256)),
	157: int16(155),
	158: int16(210),
	159: int16(-int32(220)),
	160: int16(86),
	161: int16(-int32(130)),
	162: int16(943),
	163: int16(996),
	164: int16(402),
	165: int16(-int32(256)),
	166: int16(-int32(113)),
	167: int16(981),
	168: int16(1095),
	169: int16(1135),
	170: int16(395),
	171: int16(-int32(256)),
	172: int16(-int32(256)),
	173: int16(-int32(256)),
	174: int16(-int32(256)),
	175: int16(568),
	176: int16(568),
	177: int16(568),
	178: int16(-int32(4)),
	179: int16(-int32(153)),
	180: int16(-int32(133)),
	181: int16(259),
	182: int16(306),
	183: int16(-int32(166)),
	184: int16(523),
	185: int16(-int32(303)),
	186: int16(-int32(126)),
	187: int16(503),
	188: int16(503),
	189: int16(-int32(37)),
	190: int16(-int32(149)),
	191: int16(164),
	192: int16(690),
	193: int16(292),
	194: int16(412),
	195: int16(492),
	196: int16(651),
	197: int16(784),
	198: int16(332),
	199: int16(786),
	200: int16(841),
	201: int16(1149),
	202: int16(833),
	203: int16(1236),
	204: int16(792),
	205: int16(162),
	206: int16(796),
	207: int16(1253),
	208: int16(777),
	209: int16(288),
	210: int16(381),
	211: int16(380),
	212: int16(709),
	213: int16(487),
	214: int16(1027),
	215: int16(972),
	216: int16(1030),
	217: int16(1084),
	218: int16(991),
	219: int16(1120),
	220: int16(-int32(152)),
	221: int16(1062),
	222: int16(692),
	223: int16(1240),
	224: int16(1247),
	225: int16(1250),
	226: int16(1239),
	227: int16(1306),
	228: int16(-int32(207)),
	229: int16(-int32(194)),
	230: int16(57),
	231: int16(180),
	232: int16(74),
	233: int16(315),
	234: int16(355),
	235: int16(376),
	236: int16(452),
	237: int16(488),
	238: int16(630),
	239: int16(693),
	240: int16(965),
	241: int16(1004),
	242: int16(1025),
	243: int16(1099),
	244: int16(1154),
	245: int16(1289),
	246: int16(1305),
	247: int16(1310),
	248: int16(1469),
	249: int16(1489),
	250: int16(984),
	251: int16(1494),
	252: int16(1502),
	253: int16(1516),
	254: int16(1544),
	255: int16(1556),
	256: int16(1557),
	257: int16(1562),
	258: int16(1576),
	259: int16(1578),
	260: int16(1579),
	261: int16(1583),
	262: int16(1584),
	263: int16(1585),
	264: int16(1586),
	265: int16(1217),
	266: int16(1440),
	267: int16(1554),
	268: int16(1589),
	269: int16(1593),
	270: int16(1594),
	271: int16(1530),
	272: int16(1597),
	273: int16(1599),
	274: int16(1600),
	275: int16(1539),
	276: int16(1472),
	277: int16(1601),
	278: int16(1560),
	279: int16(1604),
	280: int16(355),
	281: int16(1605),
	282: int16(1609),
	283: int16(1610),
	284: int16(1612),
	285: int16(1613),
	286: int16(1614),
	287: int16(1503),
	288: int16(1512),
	289: int16(1520),
	290: int16(1567),
	291: int16(1548),
	292: int16(1558),
	293: int16(1559),
	294: int16(1561),
	295: int16(1530),
	296: int16(1567),
	297: int16(1567),
	298: int16(1569),
	299: int16(1596),
	300: int16(1622),
	301: int16(1519),
	302: int16(1521),
	303: int16(1547),
	304: int16(1565),
	305: int16(1581),
	306: int16(1568),
	307: int16(1534),
	308: int16(1582),
	309: int16(1563),
	310: int16(1566),
	311: int16(1591),
	312: int16(1570),
	313: int16(1606),
	314: int16(1536),
	315: int16(1619),
	316: int16(1615),
	317: int16(1616),
	318: int16(1624),
	319: int16(1626),
	320: int16(1633),
	321: int16(1590),
	322: int16(1595),
	323: int16(1603),
	324: int16(1617),
	325: int16(1618),
	326: int16(1621),
	327: int16(1572),
	328: int16(1623),
	329: int16(1628),
	330: int16(1663),
	331: int16(1644),
	332: int16(1577),
	333: int16(1647),
	334: int16(1648),
	335: int16(1673),
	336: int16(1675),
	337: int16(1588),
	338: int16(1627),
	339: int16(1678),
	340: int16(1630),
	341: int16(1629),
	342: int16(1634),
	343: int16(1651),
	344: int16(1650),
	345: int16(1652),
	346: int16(1653),
	347: int16(1654),
	348: int16(1688),
	349: int16(1701),
	350: int16(1655),
	351: int16(1635),
	352: int16(1636),
	353: int16(1658),
	354: int16(1639),
	355: int16(1672),
	356: int16(1661),
	357: int16(1677),
	358: int16(1666),
	359: int16(1715),
	360: int16(1717),
	361: int16(1632),
	362: int16(1642),
	363: int16(1724),
	364: int16(1726),
	365: int16(1712),
	366: int16(1728),
	367: int16(1736),
	368: int16(1737),
	369: int16(1739),
	370: int16(1718),
	371: int16(1722),
	372: int16(1723),
	373: int16(1725),
	374: int16(1719),
	375: int16(1720),
	376: int16(1721),
	377: int16(1727),
	378: int16(1731),
	379: int16(1734),
	380: int16(1735),
	381: int16(1738),
	382: int16(1740),
	383: int16(1742),
	384: int16(1643),
	385: int16(1656),
	386: int16(1669),
	387: int16(1674),
	388: int16(1753),
	389: int16(1759),
	390: int16(1645),
	391: int16(1646),
	392: int16(1711),
	393: int16(1713),
	394: int16(1748),
	395: int16(1744),
	396: int16(1709),
	397: int16(1789),
	398: int16(1716),
	399: int16(1749),
	400: int16(1752),
	401: int16(1755),
	402: int16(1758),
	403: int16(1807),
	404: int16(1816),
	405: int16(1818),
	406: int16(1823),
	407: int16(1824),
	408: int16(1825),
	409: int16(1745),
	410: int16(1754),
	411: int16(1714),
	412: int16(1811),
	413: int16(1806),
	414: int16(1808),
	415: int16(1809),
	416: int16(1810),
	417: int16(1813),
	418: int16(1802),
	419: int16(1803),
	420: int16(1812),
	421: int16(1815),
	422: int16(1817),
	423: int16(1820),
}

var _yy_shift_ofst = [600]uint16{
	0:   uint16(2201),
	1:   uint16(1973),
	2:   uint16(2215),
	3:   uint16(1552),
	4:   uint16(1552),
	5:   uint16(33),
	6:   uint16(368),
	7:   uint16(1668),
	8:   uint16(1741),
	9:   uint16(1814),
	10:  uint16(726),
	11:  uint16(726),
	12:  uint16(726),
	13:  uint16(265),
	14:  uint16(33),
	15:  uint16(33),
	16:  uint16(33),
	17:  uint16(33),
	18:  uint16(33),
	21:  uint16(216),
	22:  uint16(1349),
	23:  uint16(726),
	24:  uint16(726),
	25:  uint16(726),
	26:  uint16(726),
	27:  uint16(726),
	28:  uint16(726),
	29:  uint16(726),
	30:  uint16(726),
	31:  uint16(726),
	32:  uint16(726),
	33:  uint16(726),
	34:  uint16(726),
	35:  uint16(726),
	36:  uint16(726),
	37:  uint16(726),
	38:  uint16(272),
	39:  uint16(272),
	40:  uint16(111),
	41:  uint16(111),
	42:  uint16(316),
	43:  uint16(365),
	44:  uint16(516),
	45:  uint16(867),
	46:  uint16(867),
	47:  uint16(916),
	48:  uint16(916),
	49:  uint16(916),
	50:  uint16(916),
	51:  uint16(40),
	52:  uint16(112),
	53:  uint16(260),
	54:  uint16(364),
	55:  uint16(408),
	56:  uint16(512),
	57:  uint16(617),
	58:  uint16(661),
	59:  uint16(765),
	60:  uint16(809),
	61:  uint16(913),
	62:  uint16(957),
	63:  uint16(1061),
	64:  uint16(1081),
	65:  uint16(1195),
	66:  uint16(1215),
	67:  uint16(1329),
	68:  uint16(1349),
	69:  uint16(1349),
	70:  uint16(1349),
	71:  uint16(1349),
	72:  uint16(1349),
	73:  uint16(1349),
	74:  uint16(1349),
	75:  uint16(1349),
	76:  uint16(1349),
	77:  uint16(1349),
	78:  uint16(1349),
	79:  uint16(1349),
	80:  uint16(1349),
	81:  uint16(1349),
	82:  uint16(1349),
	83:  uint16(1349),
	84:  uint16(1349),
	85:  uint16(1349),
	86:  uint16(1369),
	87:  uint16(1349),
	88:  uint16(1473),
	89:  uint16(1493),
	90:  uint16(1493),
	91:  uint16(473),
	92:  uint16(1974),
	93:  uint16(2082),
	94:  uint16(726),
	95:  uint16(726),
	96:  uint16(726),
	97:  uint16(726),
	98:  uint16(726),
	99:  uint16(726),
	100: uint16(726),
	101: uint16(726),
	102: uint16(726),
	103: uint16(726),
	104: uint16(726),
	105: uint16(726),
	106: uint16(726),
	107: uint16(726),
	108: uint16(726),
	109: uint16(726),
	110: uint16(726),
	111: uint16(726),
	112: uint16(726),
	113: uint16(726),
	114: uint16(726),
	115: uint16(726),
	116: uint16(726),
	117: uint16(726),
	118: uint16(726),
	119: uint16(726),
	120: uint16(726),
	121: uint16(726),
	122: uint16(726),
	123: uint16(726),
	124: uint16(726),
	125: uint16(726),
	126: uint16(726),
	127: uint16(726),
	128: uint16(726),
	129: uint16(726),
	130: uint16(726),
	131: uint16(726),
	132: uint16(726),
	133: uint16(726),
	134: uint16(726),
	135: uint16(726),
	136: uint16(726),
	137: uint16(726),
	138: uint16(726),
	139: uint16(726),
	140: uint16(726),
	141: uint16(726),
	142: uint16(726),
	143: uint16(726),
	144: uint16(726),
	145: uint16(726),
	146: uint16(138),
	147: uint16(232),
	148: uint16(232),
	149: uint16(232),
	150: uint16(232),
	151: uint16(232),
	152: uint16(232),
	153: uint16(232),
	154: uint16(188),
	155: uint16(99),
	156: uint16(242),
	157: uint16(718),
	158: uint16(416),
	159: uint16(1159),
	160: uint16(867),
	161: uint16(867),
	162: uint16(940),
	163: uint16(940),
	164: uint16(867),
	165: uint16(1103),
	166: uint16(417),
	167: uint16(574),
	168: uint16(574),
	169: uint16(574),
	170: uint16(611),
	171: uint16(139),
	172: uint16(139),
	173: uint16(2379),
	174: uint16(2379),
	175: uint16(1026),
	176: uint16(1026),
	177: uint16(1026),
	178: uint16(536),
	179: uint16(466),
	180: uint16(466),
	181: uint16(466),
	182: uint16(466),
	183: uint16(1017),
	184: uint16(1017),
	185: uint16(849),
	186: uint16(718),
	187: uint16(971),
	188: uint16(1060),
	189: uint16(867),
	190: uint16(867),
	191: uint16(867),
	192: uint16(867),
	193: uint16(867),
	194: uint16(867),
	195: uint16(867),
	196: uint16(867),
	197: uint16(867),
	198: uint16(867),
	199: uint16(867),
	200: uint16(867),
	201: uint16(867),
	202: uint16(867),
	203: uint16(867),
	204: uint16(867),
	205: uint16(867),
	206: uint16(867),
	207: uint16(867),
	208: uint16(261),
	209: uint16(712),
	210: uint16(712),
	211: uint16(867),
	212: uint16(108),
	213: uint16(1142),
	214: uint16(1142),
	215: uint16(977),
	216: uint16(1108),
	217: uint16(1108),
	218: uint16(977),
	219: uint16(977),
	220: uint16(1243),
	221: uint16(2379),
	222: uint16(2379),
	223: uint16(2379),
	224: uint16(2379),
	225: uint16(2379),
	226: uint16(2379),
	227: uint16(2379),
	228: uint16(641),
	229: uint16(789),
	230: uint16(789),
	231: uint16(635),
	232: uint16(366),
	233: uint16(721),
	234: uint16(673),
	235: uint16(782),
	236: uint16(494),
	237: uint16(787),
	238: uint16(829),
	239: uint16(867),
	240: uint16(867),
	241: uint16(867),
	242: uint16(867),
	243: uint16(867),
	244: uint16(867),
	245: uint16(867),
	246: uint16(867),
	247: uint16(867),
	248: uint16(867),
	249: uint16(867),
	250: uint16(959),
	251: uint16(867),
	252: uint16(867),
	253: uint16(867),
	254: uint16(867),
	255: uint16(867),
	256: uint16(867),
	257: uint16(867),
	258: uint16(867),
	259: uint16(867),
	260: uint16(867),
	261: uint16(867),
	262: uint16(867),
	263: uint16(867),
	264: uint16(867),
	265: uint16(820),
	266: uint16(820),
	267: uint16(820),
	268: uint16(867),
	269: uint16(867),
	270: uint16(867),
	271: uint16(1136),
	272: uint16(867),
	273: uint16(867),
	274: uint16(867),
	275: uint16(1119),
	276: uint16(1007),
	277: uint16(867),
	278: uint16(1169),
	279: uint16(867),
	280: uint16(867),
	281: uint16(867),
	282: uint16(867),
	283: uint16(867),
	284: uint16(867),
	285: uint16(867),
	286: uint16(867),
	287: uint16(1225),
	288: uint16(1153),
	289: uint16(869),
	290: uint16(196),
	291: uint16(618),
	292: uint16(618),
	293: uint16(618),
	294: uint16(618),
	295: uint16(1491),
	296: uint16(196),
	297: uint16(196),
	298: uint16(91),
	299: uint16(339),
	300: uint16(1326),
	301: uint16(1386),
	302: uint16(383),
	303: uint16(1163),
	304: uint16(1364),
	305: uint16(1426),
	306: uint16(1364),
	307: uint16(1538),
	308: uint16(903),
	309: uint16(1163),
	310: uint16(1163),
	311: uint16(903),
	312: uint16(1163),
	313: uint16(1426),
	314: uint16(1538),
	315: uint16(1018),
	316: uint16(1535),
	317: uint16(1241),
	318: uint16(1528),
	319: uint16(1528),
	320: uint16(1528),
	321: uint16(1394),
	322: uint16(1394),
	323: uint16(1394),
	324: uint16(1394),
	325: uint16(762),
	326: uint16(762),
	327: uint16(1403),
	328: uint16(1466),
	329: uint16(1475),
	330: uint16(1551),
	331: uint16(1746),
	332: uint16(1805),
	333: uint16(1746),
	334: uint16(1746),
	335: uint16(1729),
	336: uint16(1729),
	337: uint16(1840),
	338: uint16(1840),
	339: uint16(1729),
	340: uint16(1730),
	341: uint16(1732),
	342: uint16(1859),
	343: uint16(1842),
	344: uint16(1870),
	345: uint16(1870),
	346: uint16(1870),
	347: uint16(1870),
	348: uint16(1729),
	349: uint16(1876),
	350: uint16(1751),
	351: uint16(1732),
	352: uint16(1732),
	353: uint16(1751),
	354: uint16(1859),
	355: uint16(1842),
	356: uint16(1751),
	357: uint16(1842),
	358: uint16(1751),
	359: uint16(1729),
	360: uint16(1876),
	361: uint16(1760),
	362: uint16(1857),
	363: uint16(1729),
	364: uint16(1876),
	365: uint16(1906),
	366: uint16(1729),
	367: uint16(1876),
	368: uint16(1729),
	369: uint16(1876),
	370: uint16(1906),
	371: uint16(1746),
	372: uint16(1746),
	373: uint16(1746),
	374: uint16(1873),
	375: uint16(1922),
	376: uint16(1922),
	377: uint16(1906),
	378: uint16(1746),
	379: uint16(1822),
	380: uint16(1746),
	381: uint16(1873),
	382: uint16(1746),
	383: uint16(1746),
	384: uint16(1786),
	385: uint16(1929),
	386: uint16(1843),
	387: uint16(1843),
	388: uint16(1906),
	389: uint16(1729),
	390: uint16(1872),
	391: uint16(1872),
	392: uint16(1894),
	393: uint16(1894),
	394: uint16(1831),
	395: uint16(1836),
	396: uint16(1966),
	397: uint16(1729),
	398: uint16(1833),
	399: uint16(1831),
	400: uint16(1851),
	401: uint16(1860),
	402: uint16(1751),
	403: uint16(1983),
	404: uint16(1996),
	405: uint16(1996),
	406: uint16(2009),
	407: uint16(2009),
	408: uint16(2009),
	409: uint16(2379),
	410: uint16(2379),
	411: uint16(2379),
	412: uint16(2379),
	413: uint16(2379),
	414: uint16(2379),
	415: uint16(2379),
	416: uint16(2379),
	417: uint16(2379),
	418: uint16(2379),
	419: uint16(2379),
	420: uint16(2379),
	421: uint16(2379),
	422: uint16(2379),
	423: uint16(2379),
	424: uint16(136),
	425: uint16(1063),
	426: uint16(1196),
	427: uint16(530),
	428: uint16(636),
	429: uint16(1274),
	430: uint16(1300),
	431: uint16(1443),
	432: uint16(1598),
	433: uint16(1495),
	434: uint16(1479),
	435: uint16(967),
	436: uint16(1083),
	437: uint16(1602),
	438: uint16(463),
	439: uint16(1625),
	440: uint16(1638),
	441: uint16(1670),
	442: uint16(1541),
	443: uint16(1671),
	444: uint16(1689),
	445: uint16(1696),
	446: uint16(1277),
	447: uint16(1432),
	448: uint16(1693),
	449: uint16(808),
	450: uint16(1700),
	451: uint16(1607),
	452: uint16(1657),
	453: uint16(1587),
	454: uint16(1704),
	455: uint16(1707),
	456: uint16(1631),
	457: uint16(1708),
	458: uint16(1733),
	459: uint16(1608),
	460: uint16(1611),
	461: uint16(1743),
	462: uint16(1747),
	463: uint16(1620),
	464: uint16(1592),
	465: uint16(2026),
	466: uint16(2030),
	467: uint16(2013),
	468: uint16(1914),
	469: uint16(2018),
	470: uint16(1916),
	471: uint16(2020),
	472: uint16(2019),
	473: uint16(2021),
	474: uint16(1915),
	475: uint16(2027),
	476: uint16(2029),
	477: uint16(2024),
	478: uint16(2025),
	479: uint16(1909),
	480: uint16(1899),
	481: uint16(1923),
	482: uint16(2028),
	483: uint16(2028),
	484: uint16(1913),
	485: uint16(2037),
	486: uint16(1917),
	487: uint16(2042),
	488: uint16(2059),
	489: uint16(1918),
	490: uint16(1932),
	491: uint16(2028),
	492: uint16(1933),
	493: uint16(2003),
	494: uint16(2031),
	495: uint16(2028),
	496: uint16(1919),
	497: uint16(2012),
	498: uint16(2015),
	499: uint16(2016),
	500: uint16(2022),
	501: uint16(1936),
	502: uint16(1956),
	503: uint16(2040),
	504: uint16(2053),
	505: uint16(2077),
	506: uint16(2074),
	507: uint16(2058),
	508: uint16(1967),
	509: uint16(1924),
	510: uint16(2034),
	511: uint16(2060),
	512: uint16(2036),
	513: uint16(2008),
	514: uint16(2046),
	515: uint16(1946),
	516: uint16(1978),
	517: uint16(2066),
	518: uint16(2075),
	519: uint16(2078),
	520: uint16(1968),
	521: uint16(1972),
	522: uint16(2084),
	523: uint16(2041),
	524: uint16(2086),
	525: uint16(2088),
	526: uint16(2076),
	527: uint16(2089),
	528: uint16(2048),
	529: uint16(2054),
	530: uint16(2093),
	531: uint16(2023),
	532: uint16(2091),
	533: uint16(2099),
	534: uint16(2055),
	535: uint16(2085),
	536: uint16(2101),
	537: uint16(2092),
	538: uint16(1975),
	539: uint16(2105),
	540: uint16(2110),
	541: uint16(2111),
	542: uint16(2112),
	543: uint16(2115),
	544: uint16(2113),
	545: uint16(2043),
	546: uint16(1997),
	547: uint16(2117),
	548: uint16(2120),
	549: uint16(2032),
	550: uint16(2114),
	551: uint16(2122),
	552: uint16(2001),
	553: uint16(2121),
	554: uint16(2116),
	555: uint16(2118),
	556: uint16(2119),
	557: uint16(2124),
	558: uint16(2062),
	559: uint16(2071),
	560: uint16(2068),
	561: uint16(2123),
	562: uint16(2080),
	563: uint16(2065),
	564: uint16(2126),
	565: uint16(2138),
	566: uint16(2140),
	567: uint16(2139),
	568: uint16(2141),
	569: uint16(2143),
	570: uint16(2130),
	571: uint16(2033),
	572: uint16(2035),
	573: uint16(2142),
	574: uint16(2121),
	575: uint16(2146),
	576: uint16(2147),
	577: uint16(2148),
	578: uint16(2150),
	579: uint16(2149),
	580: uint16(2152),
	581: uint16(2156),
	582: uint16(2151),
	583: uint16(2164),
	584: uint16(2158),
	585: uint16(2159),
	586: uint16(2161),
	587: uint16(2162),
	588: uint16(2160),
	589: uint16(2165),
	590: uint16(2163),
	591: uint16(2050),
	592: uint16(2049),
	593: uint16(2051),
	594: uint16(2052),
	595: uint16(2167),
	596: uint16(2172),
	597: uint16(2181),
	598: uint16(2197),
	599: uint16(2204),
}

var _zValue = [256]int8{
	0:   int8(-int32(1)),
	1:   int8(-int32(1)),
	2:   int8(-int32(1)),
	3:   int8(-int32(1)),
	4:   int8(-int32(1)),
	5:   int8(-int32(1)),
	6:   int8(-int32(1)),
	7:   int8(-int32(1)),
	8:   int8(-int32(1)),
	9:   int8(-int32(1)),
	10:  int8(-int32(1)),
	11:  int8(-int32(1)),
	12:  int8(-int32(1)),
	13:  int8(-int32(1)),
	14:  int8(-int32(1)),
	15:  int8(-int32(1)),
	16:  int8(-int32(1)),
	17:  int8(-int32(1)),
	18:  int8(-int32(1)),
	19:  int8(-int32(1)),
	20:  int8(-int32(1)),
	21:  int8(-int32(1)),
	22:  int8(-int32(1)),
	23:  int8(-int32(1)),
	24:  int8(-int32(1)),
	25:  int8(-int32(1)),
	26:  int8(-int32(1)),
	27:  int8(-int32(1)),
	28:  int8(-int32(1)),
	29:  int8(-int32(1)),
	30:  int8(-int32(1)),
	31:  int8(-int32(1)),
	32:  int8(-int32(1)),
	33:  int8(-int32(1)),
	34:  int8(-int32(1)),
	35:  int8(-int32(1)),
	36:  int8(-int32(1)),
	37:  int8(-int32(1)),
	38:  int8(-int32(1)),
	39:  int8(-int32(1)),
	40:  int8(-int32(1)),
	41:  int8(-int32(1)),
	42:  int8(-int32(1)),
	43:  int8(-int32(1)),
	44:  int8(-int32(1)),
	45:  int8(-int32(1)),
	46:  int8(-int32(1)),
	47:  int8(-int32(1)),
	49:  int8(1),
	50:  int8(2),
	51:  int8(3),
	52:  int8(4),
	53:  int8(5),
	54:  int8(6),
	55:  int8(7),
	56:  int8(8),
	57:  int8(9),
	58:  int8(-int32(1)),
	59:  int8(-int32(1)),
	60:  int8(-int32(1)),
	61:  int8(-int32(1)),
	62:  int8(-int32(1)),
	63:  int8(-int32(1)),
	64:  int8(-int32(1)),
	65:  int8(10),
	66:  int8(11),
	67:  int8(12),
	68:  int8(13),
	69:  int8(14),
	70:  int8(15),
	71:  int8(16),
	72:  int8(17),
	73:  int8(18),
	74:  int8(19),
	75:  int8(20),
	76:  int8(21),
	77:  int8(22),
	78:  int8(23),
	79:  int8(24),
	80:  int8(25),
	81:  int8(26),
	82:  int8(27),
	83:  int8(28),
	84:  int8(29),
	85:  int8(30),
	86:  int8(31),
	87:  int8(32),
	88:  int8(33),
	89:  int8(34),
	90:  int8(35),
	91:  int8(-int32(1)),
	92:  int8(-int32(1)),
	93:  int8(-int32(1)),
	94:  int8(-int32(1)),
	95:  int8(36),
	96:  int8(-int32(1)),
	97:  int8(37),
	98:  int8(38),
	99:  int8(39),
	100: int8(40),
	101: int8(41),
	102: int8(42),
	103: int8(43),
	104: int8(44),
	105: int8(45),
	106: int8(46),
	107: int8(47),
	108: int8(48),
	109: int8(49),
	110: int8(50),
	111: int8(51),
	112: int8(52),
	113: int8(53),
	114: int8(54),
	115: int8(55),
	116: int8(56),
	117: int8(57),
	118: int8(58),
	119: int8(59),
	120: int8(60),
	121: int8(61),
	122: int8(62),
	123: int8(-int32(1)),
	124: int8(-int32(1)),
	125: int8(-int32(1)),
	126: int8(63),
	127: int8(-int32(1)),
	128: int8(-int32(1)),
	129: int8(-int32(1)),
	130: int8(-int32(1)),
	131: int8(-int32(1)),
	132: int8(-int32(1)),
	133: int8(-int32(1)),
	134: int8(-int32(1)),
	135: int8(-int32(1)),
	136: int8(-int32(1)),
	137: int8(-int32(1)),
	138: int8(-int32(1)),
	139: int8(-int32(1)),
	140: int8(-int32(1)),
	141: int8(-int32(1)),
	142: int8(-int32(1)),
	143: int8(-int32(1)),
	144: int8(-int32(1)),
	145: int8(-int32(1)),
	146: int8(-int32(1)),
	147: int8(-int32(1)),
	148: int8(-int32(1)),
	149: int8(-int32(1)),
	150: int8(-int32(1)),
	151: int8(-int32(1)),
	152: int8(-int32(1)),
	153: int8(-int32(1)),
	154: int8(-int32(1)),
	155: int8(-int32(1)),
	156: int8(-int32(1)),
	157: int8(-int32(1)),
	158: int8(-int32(1)),
	159: int8(-int32(1)),
	160: int8(-int32(1)),
	161: int8(-int32(1)),
	162: int8(-int32(1)),
	163: int8(-int32(1)),
	164: int8(-int32(1)),
	165: int8(-int32(1)),
	166: int8(-int32(1)),
	167: int8(-int32(1)),
	168: int8(-int32(1)),
	169: int8(-int32(1)),
	170: int8(-int32(1)),
	171: int8(-int32(1)),
	172: int8(-int32(1)),
	173: int8(-int32(1)),
	174: int8(-int32(1)),
	175: int8(-int32(1)),
	176: int8(-int32(1)),
	177: int8(-int32(1)),
	178: int8(-int32(1)),
	179: int8(-int32(1)),
	180: int8(-int32(1)),
	181: int8(-int32(1)),
	182: int8(-int32(1)),
	183: int8(-int32(1)),
	184: int8(-int32(1)),
	185: int8(-int32(1)),
	186: int8(-int32(1)),
	187: int8(-int32(1)),
	188: int8(-int32(1)),
	189: int8(-int32(1)),
	190: int8(-int32(1)),
	191: int8(-int32(1)),
	192: int8(-int32(1)),
	193: int8(-int32(1)),
	194: int8(-int32(1)),
	195: int8(-int32(1)),
	196: int8(-int32(1)),
	197: int8(-int32(1)),
	198: int8(-int32(1)),
	199: int8(-int32(1)),
	200: int8(-int32(1)),
	201: int8(-int32(1)),
	202: int8(-int32(1)),
	203: int8(-int32(1)),
	204: int8(-int32(1)),
	205: int8(-int32(1)),
	206: int8(-int32(1)),
	207: int8(-int32(1)),
	208: int8(-int32(1)),
	209: int8(-int32(1)),
	210: int8(-int32(1)),
	211: int8(-int32(1)),
	212: int8(-int32(1)),
	213: int8(-int32(1)),
	214: int8(-int32(1)),
	215: int8(-int32(1)),
	216: int8(-int32(1)),
	217: int8(-int32(1)),
	218: int8(-int32(1)),
	219: int8(-int32(1)),
	220: int8(-int32(1)),
	221: int8(-int32(1)),
	222: int8(-int32(1)),
	223: int8(-int32(1)),
	224: int8(-int32(1)),
	225: int8(-int32(1)),
	226: int8(-int32(1)),
	227: int8(-int32(1)),
	228: int8(-int32(1)),
	229: int8(-int32(1)),
	230: int8(-int32(1)),
	231: int8(-int32(1)),
	232: int8(-int32(1)),
	233: int8(-int32(1)),
	234: int8(-int32(1)),
	235: int8(-int32(1)),
	236: int8(-int32(1)),
	237: int8(-int32(1)),
	238: int8(-int32(1)),
	239: int8(-int32(1)),
	240: int8(-int32(1)),
	241: int8(-int32(1)),
	242: int8(-int32(1)),
	243: int8(-int32(1)),
	244: int8(-int32(1)),
	245: int8(-int32(1)),
	246: int8(-int32(1)),
	247: int8(-int32(1)),
	248: int8(-int32(1)),
	249: int8(-int32(1)),
	250: int8(-int32(1)),
	251: int8(-int32(1)),
	252: int8(-int32(1)),
	253: int8(-int32(1)),
	254: int8(-int32(1)),
	255: int8(-int32(1)),
}

var _zero = [4]Tu8{}

// C documentation
//
//	/*
//	** Add a new element to the end of an expression list.  If pList is
//	** initially NULL, then create a new expression list.
//	**
//	** The pList argument must be either NULL or a pointer to an ExprList
//	** obtained from a prior call to sqlite3ExprListAppend().
//	**
//	** If a memory allocation error occurs, the entire list is freed and
//	** NULL is returned.  If non-NULL is returned, then it is guaranteed
//	** that the new entry was successfully appended.
//	*/
var _zeroItem = TExprList_item{}

var _zerobyte Tu8

type analysisInfo = TanalysisInfo

const bBatch = 0

type bft = Tbft

/* Bit Field Type */

/*
** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value
** that can be stored in a u32 without loss of data.  The value
** is 0x00000000ffffffff.  But because of quirks of some compilers, we
** have to specify the value in the less intuitive manner shown:
 */

type clock_t = Tclock_t

type compareInfo = TcompareInfo

/*
** For LIKE and GLOB matching on EBCDIC machines, assume that every
** character is exactly one byte in size.  Also, provide the Utf8Read()
** macro for fast reading of the next character in the common case where
** the next character is ASCII.
 */

const cume_distFinalizeFunc = 0

type dev_t = Tdev_t

type div_t = Tdiv_t

const errno = 0

const etBUFSIZE = 70

type etByte = TetByte

const etCHARX = 8

const etDECIMAL = 16

const etDYNSTRING = 6

const etESCAPE_Q = 10

const etESCAPE_q = 9

const etESCAPE_w = 14

const etEXP = 2

const etFLOAT = 1

const etGENERIC = 3

const etINVALID = 17

const etORDINAL = 15

const etPERCENT = 7

const etPOINTER = 13

const etRADIX = 0

const etSIZE = 4

const etSRCITEM = 12

const etSTRING = 5

const etTOKEN = 11

type et_info = Tet_info

/*
** Allowed values for et_info.flags
 */

/*
** The table is searched by hash.  In the case of %C where C is the character
** and that character has ASCII value j, then the hash is j%23.
**
** The order of the entries in fmtinfo[] and the hash chain was entered
** manually, but based on the output of the following TCL script:
 */

type fd_set = Tfd_set

const first_valueInvFunc = 0

const first_valueValueFunc = 0

type float_t = Tfloat_t

type fpos_t = Tfpos_t

const fts5GetVarint = 0

const fts5YYGROWABLESTACK = 0

const fts5YYMALLOCARGTYPE = 0

type fts5YYMINORTYPE = Tfts5YYMINORTYPE

/************* End control #defines *******************************************/

/* Define the fts5yytestcase() macro to be a no-op if is not already defined
** otherwise.
**
** Applications can choose to define fts5yytestcase() in the %include section
** to a macro that can assist in verifying code coverage.  For production
** code the fts5yytestcase() macro should be turned off.  But it is useful
** for testing.
 */

/* Macro to determine if stack space has the ability to grow using
** heap memory.
 */

/* Guarantee a minimum number of initial stack slots.
 */

const fts5YYNFTS5TOKEN = 16

const fts5YYNOCODE = 27

const fts5YYNOERRORRECOVERY = 1

const fts5YYNRULE = 28

const fts5YYNRULE_WITH_ACTION = 28

const fts5YYNSTATE = 35

const fts5YYPARSEFREENOTNULL = 1

const fts5YYSTACKDEPTH = 100

const fts5YY_ACCEPT_ACTION = 81

const fts5YY_ACTTAB_COUNT = 105

const fts5YY_ERROR_ACTION = 80

const fts5YY_MAX_DSTRCTR = 24

const fts5YY_MAX_REDUCE = 110

const fts5YY_MAX_SHIFT = 34

const fts5YY_MAX_SHIFTREDUCE = 79

const fts5YY_MIN_DSTRCTR = 16

const fts5YY_MIN_REDUCE = 83

const fts5YY_MIN_SHIFTREDUCE = 52

const fts5YY_NO_ACTION = 82

const fts5YY_REDUCE_COUNT = 17

const fts5YY_REDUCE_MAX = 67

const fts5YY_REDUCE_MIN = -17

const fts5YY_SHIFT_COUNT = 34

const fts5YY_SHIFT_MAX = 93

const fts5YY_SHIFT_MIN = 0

type fts5_api = Tfts5_api

type fts5_extension_function = Tfts5_extension_function

type fts5_tokenizer = Tfts5_tokenizer

/* Flags that may be passed as the third argument to xTokenize() */

/* Flags that may be passed by the tokenizer implementation back to FTS5
** as the third argument to the supplied xToken callback. */

/*
** END OF CUSTOM TOKENIZERS
*************************************************************************/

type fts5_tokenizer_v2 = Tfts5_tokenizer_v2

type fts5yyParser = Tfts5yyParser

/* #include <assert.h> */

/* For builds that do no have a growable stack, fts5yyGrowStack always
** returns an error.
 */

/* Datatype of the argument to the memory allocated passed as the
** second argument to sqlite3Fts5ParserAlloc() below.  This can be changed by
** putting an appropriate #define in the %include section of the input
** grammar.
 */

type fts5yyStackEntry = Tfts5yyStackEntry

const get4byte = 0

const getVarint = 0

type ht_slot = Tht_slot

/* Size (in bytes) of a WalIterator object suitable for N or fewer segments */

/*
** Define the parameters of the hash tables in the wal-index file. There
** is a hash-table following every HASHTABLE_NPAGE page numbers in the
** wal-index.
**
** Changing any of these constants will alter the wal-index format and
** create incompatibilities.
 */

/*
** The block of page numbers associated with the first hash-table in a
** wal-index is smaller than usual. This is so that there is a complete
** hash-table on each aligned 32KB page of the wal-index.
 */

/* The wal-index is divided into pages of WALINDEX_PGSZ bytes each. */

/*
** Structured Exception Handling (SEH) is a Windows-specific technique
** for catching exceptions raised while accessing memory-mapped files.
**
** The -DSQLITE_USE_SEH compile-time option means to use SEH to catch and
** deal with system-level errors that arise during WAL -shm file processing.
** Without this compile-time option, any system-level faults that appear
** while accessing the memory-mapped -shm file will cause a process-wide
** signal to be deliver, which will more than likely cause the entire
** process to exit.
 */

type i16 = Ti16

type i64 = Ti64

type i8 = Ti8

/* 1-byte signed integer */

type ino_t = Tino_t

type int16_t = Tint16_t

type int32_t = Tint32_t

type int64_t = Tint64_t

type int8_t = Tint8_t

type int_fast16_t = Tint_fast16_t

type int_fast32_t = Tint_fast32_t

type int_fast64_t = Tint_fast64_t

type int_fast8_t = Tint_fast8_t

type int_least16_t = Tint_least16_t

type int_least32_t = Tint_least32_t

type int_least64_t = Tint_least64_t

type int_least8_t = Tint_least8_t

type intmax_t = Tintmax_t

type intptr_t = Tintptr_t

type ldiv_t = Tldiv_t

type lldiv_t = Tlldiv_t

const mem0 = 0

// C documentation
//
//	/*
//	** Initialize the mutex system.
//	*/
var mu sync.Mutex

const noopFunc = 0

const nth_valueInvFunc = 0

const nth_valueValueFunc = 0

const ntileFinalizeFunc = 0

type p4union = Tp4union

const pcache1 = 0

const percent_rankFinalizeFunc = 0

const put4byte = 0

const putVarint = 0

type rbu_file = Trbu_file

type rbu_vfs = Trbu_vfs

type sColMap = TsColMap

type size_t = Tsize_t

type sqlite3 = Tsqlite3

type sqlite3AutoExtList = Tsqlite3AutoExtList

const sqlite3Fts5ParserARG_PARAM = 0

const sqlite3Fts5ParserARG_PDECL = 0

const sqlite3Fts5ParserFTS5TOKENTYPE = 0

const sqlite3GlobalConfig = 0

type sqlite3InitInfo = Tsqlite3InitInfo

const sqlite3ParserCTX_PARAM = 0

const sqlite3ParserCTX_PDECL = 0

const sqlite3ParserTOKENTYPE = 0

const sqlite3Parser_ENGINEALWAYSONSTACK = 1

type sqlite3PrngType = Tsqlite3PrngType

/************** End of printf.c **********************************************/
/************** Begin file treeview.c ****************************************/
/*
** 2015-06-08
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains C code to implement the TreeView debugging routines.
** These routines print a parse tree to standard output for debugging and
** analysis.
**
** The interfaces in this file is only available when compiling
** with SQLITE_DEBUG.
 */
/* #include "sqliteInt.h" */

/************** End of treeview.c ********************************************/
/************** Begin file random.c ******************************************/
/*
** 2001 September 15
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code to implement a pseudo-random number
** generator (PRNG) for SQLite.
**
** Random numbers are used by some of the database backends in order
** to generate random integer keys for tables or random filenames.
 */
/* #include "sqliteInt.h" */

type sqlite3StatType = Tsqlite3StatType

type sqlite3StatValueType = Tsqlite3StatValueType

const sqlite3StrNICmp = 0

type sqlite3_api_routines = Tsqlite3_api_routines

type sqlite3_backup = Tsqlite3_backup

type sqlite3_callback = Tsqlite3_callback

/*
** CAPI3REF: Result Codes
** KEYWORDS: {result code definitions}
**
** Many SQLite functions return an integer result code from the set shown
** here in order to indicate success or failure.
**
** New error codes may be added in future versions of SQLite.
**
** See also: [extended result code definitions]
 */
/* beginning-of-error-codes */
/* end-of-error-codes */

/*
** CAPI3REF: Extended Result Codes
** KEYWORDS: {extended result code definitions}
**
** In its default configuration, SQLite API routines return one of 30 integer
** [result codes].  However, experience has shown that many of
** these result codes are too coarse-grained.  They do not provide as
** much information about problems as programmers might like.  In an effort to
** address this, newer versions of SQLite (version 3.3.8 [dateof:3.3.8]
** and later) include
** support for additional result codes that provide more detailed information
** about errors. These [extended result codes] are enabled or disabled
** on a per database connection basis using the
** [sqlite3_extended_result_codes()] API.  Or, the extended code for
** the most recent error can be obtained using
** [sqlite3_extended_errcode()].
 */

/*
** CAPI3REF: Flags For File Open Operations
**
** These bit values are intended for use in the
** 3rd parameter to the [sqlite3_open_v2()] interface and
** in the 4th parameter to the [sqlite3_vfs.xOpen] method.
**
** Only those flags marked as "Ok for sqlite3_open_v2()" may be
** used as the third argument to the [sqlite3_open_v2()] interface.
** The other flags have historically been ignored by sqlite3_open_v2(),
** though future versions of SQLite might change so that an error is
** raised if any of the disallowed bits are passed into sqlite3_open_v2().
** Applications should not depend on the historical behavior.
**
** Note in particular that passing the SQLITE_OPEN_EXCLUSIVE flag into
** [sqlite3_open_v2()] does *not* cause the underlying database file
** to be opened using O_EXCL.  Passing SQLITE_OPEN_EXCLUSIVE into
** [sqlite3_open_v2()] has historically been a no-op and might become an
** error in future versions of SQLite.
 */

/* Reserved:                         0x00F00000 */
/* Legacy compatibility: */

/*
** CAPI3REF: Device Characteristics
**
** The xDeviceCharacteristics method of the [sqlite3_io_methods]
** object returns an integer which is a vector of these
** bit values expressing I/O characteristics of the mass storage
** device that holds the file that the [sqlite3_io_methods]
** refers to.
**
** The SQLITE_IOCAP_ATOMIC property means that all writes of
** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values
** mean that writes of blocks that are nnn bytes in size and
** are aligned to an address which is an integer multiple of
** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means
** that when data is appended to a file, the data is appended
** first then the size of the file is extended, never the other
** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that
** information is written to disk in the same order as calls
** to xWrite().  The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
** after reboot following a crash or power loss, the only bytes in a
** file that were written at the application level might have changed
** and that adjacent bytes, even bytes within the same sector are
** guaranteed to be unchanged.  The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN
** flag indicates that a file cannot be deleted when open.  The
** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on
** read-only media and cannot be changed even by processes with
** elevated privileges.
**
** The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying
** filesystem supports doing multiple write operations atomically when those
** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and
** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].
**
** The SQLITE_IOCAP_SUBPAGE_READ property means that it is ok to read
** from the database file in amounts that are not a multiple of the
** page size and that do not begin at a page boundary.  Without this
** property, SQLite is careful to only do full-page reads and write
** on aligned pages, with the one exception that it will do a sub-page
** read of the first page to access the database header.
 */

/*
** CAPI3REF: File Locking Levels
**
** SQLite uses one of these integer values as the second
** argument to calls it makes to the xLock() and xUnlock() methods
** of an [sqlite3_io_methods] object.  These values are ordered from
** least restrictive to most restrictive.
**
** The argument to xLock() is always SHARED or higher.  The argument to
** xUnlock is either SHARED or NONE.
 */

/*
** CAPI3REF: Synchronization Type Flags
**
** When SQLite invokes the xSync() method of an
** [sqlite3_io_methods] object it uses a combination of
** these integer values as the second argument.
**
** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
** sync operation only needs to flush data to mass storage.  Inode
** information need not be flushed. If the lower four bits of the flag
** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.
** If the lower four bits equal SQLITE_SYNC_FULL, that means
** to use Mac OS X style fullsync instead of fsync().
**
** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags
** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL
** settings.  The [synchronous pragma] determines when calls to the
** xSync VFS method occur and applies uniformly across all platforms.
** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how
** energetic or rigorous or forceful the sync operations are and
** only make a difference on Mac OSX for the default SQLite code.
** (Third-party VFS implementations might also make the distinction
** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the
** operating systems natively supported by SQLite, only Mac OSX
** cares about the difference.)
 */

type sqlite3_changegroup = Tsqlite3_changegroup

/*
** CAPI3REF: Flags for sqlite3changeset_apply_v2
**
** The following flags may passed via the 9th parameter to
** [sqlite3changeset_apply_v2] and [sqlite3changeset_apply_v2_strm]:
**
** <dl>
** <dt>SQLITE_CHANGESETAPPLY_NOSAVEPOINT <dd>
**   Usually, the sessions module encloses all operations performed by
**   a single call to apply_v2() or apply_v2_strm() in a [SAVEPOINT]. The
**   SAVEPOINT is committed if the changeset or patchset is successfully
**   applied, or rolled back if an error occurs. Specifying this flag
**   causes the sessions module to omit this savepoint. In this case, if the
**   caller has an open transaction or savepoint when apply_v2() is called,
**   it may revert the partially applied changeset by rolling it back.
**
** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>
**   Invert the changeset before applying it. This is equivalent to inverting
**   a changeset using sqlite3changeset_invert() before applying it. It is
**   an error to specify this flag with a patchset.
**
** <dt>SQLITE_CHANGESETAPPLY_IGNORENOOP <dd>
**   Do not invoke the conflict handler callback for any changes that
**   would not actually modify the database even if they were applied.
**   Specifically, this means that the conflict handler is not invoked
**   for:
**    <ul>
**    <li>a delete change if the row being deleted cannot be found,
**    <li>an update change if the modified fields are already set to
**        their new values in the conflicting row, or
**    <li>an insert change if all fields of the conflicting row match
**        the row being inserted.
**    </ul>
**
** <dt>SQLITE_CHANGESETAPPLY_FKNOACTION <dd>
**   If this flag it set, then all foreign key constraints in the target
**   database behave as if they were declared with "ON UPDATE NO ACTION ON
**   DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL
**   or SET DEFAULT.
**
** <dt>SQLITE_CHANGESETAPPLY_NOUPDATELOOP <dd>
**   Sometimes, a changeset contains two or more update statements such that
**   although after applying all updates the database will contain no
**   constraint violations, no single update can be applied before the others.
**   The simplest example of this is a pair of UPDATEs that have "swapped"
**   two column values with a UNIQUE constraint.
**   <p>
**   Usually, sqlite3changeset_apply() and similar functions work hard to try
**   to find a way to apply such a changeset. However, if this flag is set,
**   then all such updates are considered CONSTRAINT conflicts.
 */

/*
** CAPI3REF: Constants Passed To The Conflict Handler
**
** Values that may be passed as the second argument to a conflict-handler.
**
** <dl>
** <dt>SQLITE_CHANGESET_DATA<dd>
**   The conflict handler is invoked with CHANGESET_DATA as the second argument
**   when processing a DELETE or UPDATE change if a row with the required
**   PRIMARY KEY fields is present in the database, but one or more other
**   (non primary-key) fields modified by the update do not contain the
**   expected "before" values.
**
**   The conflicting row, in this case, is the database row with the matching
**   primary key.
**
** <dt>SQLITE_CHANGESET_NOTFOUND<dd>
**   The conflict handler is invoked with CHANGESET_NOTFOUND as the second
**   argument when processing a DELETE or UPDATE change if a row with the
**   required PRIMARY KEY fields is not present in the database.
**
**   There is no conflicting row in this case. The results of invoking the
**   sqlite3changeset_conflict() API are undefined.
**
** <dt>SQLITE_CHANGESET_CONFLICT<dd>
**   CHANGESET_CONFLICT is passed as the second argument to the conflict
**   handler while processing an INSERT change if the operation would result
**   in duplicate primary key values.
**
**   The conflicting row in this case is the database row with the matching
**   primary key.
**
** <dt>SQLITE_CHANGESET_FOREIGN_KEY<dd>
**   If foreign key handling is enabled, and applying a changeset leaves the
**   database in a state containing foreign key violations, the conflict
**   handler is invoked with CHANGESET_FOREIGN_KEY as the second argument
**   exactly once before the changeset is committed. If the conflict handler
**   returns CHANGESET_OMIT, the changes, including those that caused the
**   foreign key constraint violation, are committed. Or, if it returns
**   CHANGESET_ABORT, the changeset is rolled back.
**
**   No current or conflicting row information is provided. The only function
**   it is possible to call on the supplied sqlite3_changeset_iter handle
**   is sqlite3changeset_fk_conflicts().
**
** <dt>SQLITE_CHANGESET_CONSTRAINT<dd>
**   If any other constraint violation occurs while applying a change (i.e.
**   a UNIQUE, CHECK or NOT NULL constraint), the conflict handler is
**   invoked with CHANGESET_CONSTRAINT as the second argument.
**
**   There is no conflicting row in this case. The results of invoking the
**   sqlite3changeset_conflict() API are undefined.
**
** </dl>
 */

/*
** CAPI3REF: Constants Returned By The Conflict Handler
**
** A conflict handler callback must return one of the following three values.
**
** <dl>
** <dt>SQLITE_CHANGESET_OMIT<dd>
**   If a conflict handler returns this value no special action is taken. The
**   change that caused the conflict is not applied. The session module
**   continues to the next change in the changeset.
**
** <dt>SQLITE_CHANGESET_REPLACE<dd>
**   This value may only be returned if the second argument to the conflict
**   handler was SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If this
**   is not the case, any changes applied so far are rolled back and the
**   call to sqlite3changeset_apply() returns SQLITE_MISUSE.
**
**   If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_DATA conflict
**   handler, then the conflicting row is either updated or deleted, depending
**   on the type of change.
**
**   If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_CONFLICT conflict
**   handler, then the conflicting row is removed from the database and a
**   second attempt to apply the change is made. If this second attempt fails,
**   the original row is restored to the database before continuing.
**
** <dt>SQLITE_CHANGESET_ABORT<dd>
**   If this value is returned, any changes applied so far are rolled back
**   and the call to sqlite3changeset_apply() returns SQLITE_ABORT.
** </dl>
 */

type sqlite3_changeset_iter = Tsqlite3_changeset_iter

type sqlite3_context = Tsqlite3_context

type sqlite3_destructor_type = Tsqlite3_destructor_type

type sqlite3_file = Tsqlite3_file

type sqlite3_filename = Tsqlite3_filename

type sqlite3_index_constraint = Tsqlite3_index_constraint

type sqlite3_index_constraint_usage = Tsqlite3_index_constraint_usage

type sqlite3_index_info = Tsqlite3_index_info

type sqlite3_index_orderby = Tsqlite3_index_orderby

type sqlite3_int64 = Tsqlite3_int64

type sqlite3_loadext_entry = Tsqlite3_loadext_entry

/*
** The following macros redefine the API routines so that they are
** redirected through the global sqlite3_api structure.
**
** This header file is also used by the loadext.c source file
** (part of the main SQLite library - not an extension) so that
** it can get access to the sqlite3_api_routines structure
** definition.  But the main library does not want to redefine
** the API.  So the redefinition macros are only valid if the
** SQLITE_CORE macros is undefined.
 */

/* This case when the file is being statically linked into the
 ** application */

/************** End of sqlite3ext.h ******************************************/
/************** Continuing where we left off in loadext.c ********************/
/* #include "sqliteInt.h" */

/*
** Some API routines are omitted when various features are
** excluded from a build of SQLite.  Substitute a NULL pointer
** for any missing APIs.
 */

type sqlite3_mem_methods = Tsqlite3_mem_methods

type sqlite3_module = Tsqlite3_module

type sqlite3_mutex_methods = Tsqlite3_mutex_methods

type sqlite3_pcache_methods = Tsqlite3_pcache_methods

type sqlite3_pcache_methods2 = Tsqlite3_pcache_methods2

type sqlite3_pcache_page = Tsqlite3_pcache_page

type sqlite3_rebaser = Tsqlite3_rebaser

/*
** Make sure we can call this stuff from C++.
 */

/******** End of sqlite3session.h *********/
/******** Begin file fts5.h *********/
/*
** 2014 May 31
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
******************************************************************************
**
** Interfaces to extend FTS5. Using the interfaces defined in this file,
** FTS5 may be extended with:
**
**     * custom tokenizers, and
**     * custom auxiliary functions.
 */

/*************************************************************************
** CUSTOM AUXILIARY FUNCTIONS
**
** Virtual table implementations may overload SQL functions by implementing
** the sqlite3_module.xFindFunction() method.
 */

type sqlite3_rtree_dbl = Tsqlite3_rtree_dbl

/*
** Allowed values for sqlite3_rtree_query.eWithin and .eParentWithin.
 */

/******** End of sqlite3rtree.h *********/
/******** Begin file sqlite3session.h *********/

/*
** Make sure we can call this stuff from C++.
 */

type sqlite3_rtree_geometry = Tsqlite3_rtree_geometry

type sqlite3_rtree_query_info = Tsqlite3_rtree_query_info

type sqlite3_session = Tsqlite3_session

type sqlite3_snapshot = Tsqlite3_snapshot

/*
** CAPI3REF: Datatypes for the CARRAY table-valued function
**
** The fifth argument to the [sqlite3_carray_bind()] interface musts be
** one of the following constants, to specify the datatype of the array
** that is being bound into the [carray table-valued function].
 */

/*
** Versions of the above #defines that omit the initial SQLITE_, for
** legacy compatibility.
 */

/*
** Undo the hack that converts floating point types to integer for
** builds on processors without floating point support.
 */

/* #endif for SQLITE3_H will be added by mksqlite3.tcl */

/******** Begin file sqlite3rtree.h *********/
/*
** 2010 August 30
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
 */

type sqlite3_str = Tsqlite3_str

type sqlite3_syscall_ptr = Tsqlite3_syscall_ptr

type sqlite3_uint64 = Tsqlite3_uint64

type sqlite3_value = Tsqlite3_value

type sqlite3_vfs = Tsqlite3_vfs

type sqlite3_vtab = Tsqlite3_vtab

type sqlite3_vtab_cursor = Tsqlite3_vtab_cursor

type sqlite3_xauth = Tsqlite3_xauth

/*
** Macros to compute aCol[] and aFunc[] register numbers.
**
** These macros should not be used prior to the call to
** assignAggregateRegisters() that computes the value of pAggInfo->iFirstReg.
** The assert()s that are part of this macro verify that constraint.
 */

type sqlite3rbu = Tsqlite3rbu

/************** End of sqlite3rbu.h ******************************************/
/************** Continuing where we left off in sqlite3rbu.c *****************/

/* Maximum number of prepared UPDATE statements held by this module */

/* Delta checksums disabled by default.  Compile with -DRBU_ENABLE_DELTA_CKSUM
** to enable checksum verification.
 */

/*
** Swap two objects of type TYPE.
 */

/*
** Name of the URI option that causes RBU to take an exclusive lock as
** part of the incremental checkpoint operation.
 */

/*
** The rbu_state table is used to save the state of a partially applied
** update so that it can be resumed later. The table consists of integer
** keys mapped to values as follows:
**
** RBU_STATE_STAGE:
**   May be set to integer values 1, 2, 4 or 5. As follows:
**       1: the *-rbu file is currently under construction.
**       2: the *-rbu file has been constructed, but not yet moved
**          to the *-wal path.
**       4: the checkpoint is underway.
**       5: the rbu update has been checkpointed.
**
** RBU_STATE_TBL:
**   Only valid if STAGE==1. The target database name of the table
**   currently being written.
**
** RBU_STATE_IDX:
**   Only valid if STAGE==1. The target database name of the index
**   currently being written, or NULL if the main table is currently being
**   updated.
**
** RBU_STATE_ROW:
**   Only valid if STAGE==1. Number of rows already processed for the current
**   table/index.
**
** RBU_STATE_PROGRESS:
**   Trbul number of sqlite3rbu_step() calls made so far as part of this
**   rbu update.
**
** RBU_STATE_CKPT:
**   Valid if STAGE==4. The 64-bit checksum associated with the wal-index
**   header created by recovering the *-wal file. This is used to detect
**   cases when another client appends frames to the *-wal file in the
**   middle of an incremental checkpoint (an incremental checkpoint cannot
**   be continued if this happens).
**
** RBU_STATE_COOKIE:
**   Valid if STAGE==1. The current change-counter cookie value in the
**   target db file.
**
** RBU_STATE_OALSZ:
**   Valid if STAGE==1. The size in bytes of the *-oal file.
**
** RBU_STATE_DATATBL:
**   Only valid if STAGE==1. The RBU database name of the table
**   currently being read.
 */

type sqlite_int64 = Tsqlite_int64

type sqlite_uint64 = Tsqlite_uint64

type ssize_t = Tssize_t

type tRowcnt = TtRowcnt

type t__builtin_va_list = uintptr

type t__ccgo_fp__Xsqlite3_auto_extension_0 = func(*libc.TLS)

/* The "wsdAutoext" macro will resolve to the autoextension
** state vector.  If writable static data is unsupported on the target,
** we have to locate the state vector at run-time.  In the more common
** case where writable static data is supported, wsdStat can refer directly
** to the "sqlite3Autoext" state vector declared above.
 */

type t__ccgo_fp__Xsqlite3_autovacuum_pages_1 = func(*libc.TLS, uintptr, uintptr, uint32, uint32, uint32) uint32

type t__ccgo_fp__Xsqlite3_autovacuum_pages_3 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_bind_blob64_4 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_bind_blob_4 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_bind_pointer_4 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_bind_text16_4 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_bind_text64_4 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_bind_text_4 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_busy_handler_1 = func(*libc.TLS, uintptr, int32) int32

type t__ccgo_fp__Xsqlite3_cancel_auto_extension_0 = func(*libc.TLS)

type t__ccgo_fp__Xsqlite3_collation_needed16_2 = func(*libc.TLS, uintptr, uintptr, int32, uintptr)

type t__ccgo_fp__Xsqlite3_collation_needed_2 = func(*libc.TLS, uintptr, uintptr, int32, uintptr)

type t__ccgo_fp__Xsqlite3_commit_hook_1 = func(*libc.TLS, uintptr) int32

type t__ccgo_fp__Xsqlite3_create_collation16_4 = func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32

type t__ccgo_fp__Xsqlite3_create_collation_4 = func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32

type t__ccgo_fp__Xsqlite3_create_collation_v2_4 = func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32

type t__ccgo_fp__Xsqlite3_create_collation_v2_5 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_create_function16_5 = func(*libc.TLS, uintptr, int32, uintptr)

type t__ccgo_fp__Xsqlite3_create_function16_6 = func(*libc.TLS, uintptr, int32, uintptr)

type t__ccgo_fp__Xsqlite3_create_function16_7 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_create_function_5 = func(*libc.TLS, uintptr, int32, uintptr)

type t__ccgo_fp__Xsqlite3_create_function_6 = func(*libc.TLS, uintptr, int32, uintptr)

type t__ccgo_fp__Xsqlite3_create_function_7 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_create_function_v2_5 = func(*libc.TLS, uintptr, int32, uintptr)

type t__ccgo_fp__Xsqlite3_create_function_v2_6 = func(*libc.TLS, uintptr, int32, uintptr)

type t__ccgo_fp__Xsqlite3_create_function_v2_7 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_create_function_v2_8 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_create_module_v2_4 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_create_window_function_5 = func(*libc.TLS, uintptr, int32, uintptr)

type t__ccgo_fp__Xsqlite3_create_window_function_6 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_create_window_function_7 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_create_window_function_8 = func(*libc.TLS, uintptr, int32, uintptr)

type t__ccgo_fp__Xsqlite3_create_window_function_9 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_exec_2 = func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32

/************** End of insert.c **********************************************/
/************** Begin file legacy.c ******************************************/
/*
** 2001 September 15
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Main file for the SQLite library.  The routines in this file
** implement the programmer interface to the library.  Routines in
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
 */

/* #include "sqliteInt.h" */

type t__ccgo_fp__Xsqlite3_memory_alarm_0 = func(*libc.TLS, uintptr, int64, int32)

type t__ccgo_fp__Xsqlite3_preupdate_hook_1 = func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, int64, int64)

type t__ccgo_fp__Xsqlite3_profile_1 = func(*libc.TLS, uintptr, uintptr, uint64)

type t__ccgo_fp__Xsqlite3_progress_handler_2 = func(*libc.TLS, uintptr) int32

type t__ccgo_fp__Xsqlite3_result_blob64_3 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_result_blob_3 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_result_pointer_3 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_result_text16_3 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_result_text16be_3 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_result_text16le_3 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_result_text64_3 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_result_text_3 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_rollback_hook_1 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_rtree_geometry_callback_2 = func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3_rtree_query_callback_2 = func(*libc.TLS, uintptr) int32

type t__ccgo_fp__Xsqlite3_rtree_query_callback_4 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_set_authorizer_1 = func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32

/************** End of attach.c **********************************************/
/************** Begin file auth.c ********************************************/
/*
** 2003 January 11
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code used to implement the sqlite3_set_authorizer()
** API.  This facility is an optional feature of the library.  Embedded
** systems that do not need this facility may omit it by recompiling
** the library with -DSQLITE_OMIT_AUTHORIZATION=1
 */
/* #include "sqliteInt.h" */

/*
** All of the code in this file may be omitted by defining a single
** macro.
 */

type t__ccgo_fp__Xsqlite3_set_auxdata_3 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_set_clientdata_3 = func(*libc.TLS, uintptr)

type t__ccgo_fp__Xsqlite3_trace_1 = func(*libc.TLS, uintptr, uintptr)

type t__ccgo_fp__Xsqlite3_trace_v2_2 = func(*libc.TLS, uint32, uintptr, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3_unlock_notify_1 = func(*libc.TLS, uintptr, int32)

type t__ccgo_fp__Xsqlite3_update_hook_1 = func(*libc.TLS, uintptr, int32, uintptr, uintptr, int64)

type t__ccgo_fp__Xsqlite3_wal_hook_1 = func(*libc.TLS, uintptr, uintptr, uintptr, int32) int32

type t__ccgo_fp__Xsqlite3changegroup_add_strm_1 = func(*libc.TLS, uintptr, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3changegroup_output_strm_1 = func(*libc.TLS, uintptr, uintptr, int32) int32

type t__ccgo_fp__Xsqlite3changeset_apply_3 = func(*libc.TLS, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_apply_4 = func(*libc.TLS, uintptr, int32, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_apply_strm_1 = func(*libc.TLS, uintptr, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_apply_strm_3 = func(*libc.TLS, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_apply_strm_4 = func(*libc.TLS, uintptr, int32, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_apply_v2_3 = func(*libc.TLS, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_apply_v2_4 = func(*libc.TLS, uintptr, int32, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_apply_v2_strm_1 = func(*libc.TLS, uintptr, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_apply_v2_strm_3 = func(*libc.TLS, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_apply_v2_strm_4 = func(*libc.TLS, uintptr, int32, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_apply_v3_3 = func(*libc.TLS, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_apply_v3_4 = func(*libc.TLS, uintptr, int32, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_apply_v3_strm_1 = func(*libc.TLS, uintptr, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_apply_v3_strm_3 = func(*libc.TLS, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_apply_v3_strm_4 = func(*libc.TLS, uintptr, int32, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_concat_strm_0 = func(*libc.TLS, uintptr, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_concat_strm_2 = func(*libc.TLS, uintptr, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_concat_strm_4 = func(*libc.TLS, uintptr, uintptr, int32) int32

type t__ccgo_fp__Xsqlite3changeset_invert_strm_0 = func(*libc.TLS, uintptr, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_invert_strm_2 = func(*libc.TLS, uintptr, uintptr, int32) int32

type t__ccgo_fp__Xsqlite3changeset_start_strm_1 = func(*libc.TLS, uintptr, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3changeset_start_v2_strm_1 = func(*libc.TLS, uintptr, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3rbu_rename_handler_2 = func(*libc.TLS, uintptr, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3rebaser_rebase_strm_1 = func(*libc.TLS, uintptr, uintptr, uintptr) int32

type t__ccgo_fp__Xsqlite3rebaser_rebase_strm_3 = func(*libc.TLS, uintptr, uintptr, int32) int32

type t__ccgo_fp__Xsqlite3session_changeset_strm_1 = func(*libc.TLS, uintptr, uintptr, int32) int32

type t__ccgo_fp__Xsqlite3session_patchset_strm_1 = func(*libc.TLS, uintptr, uintptr, int32) int32

type t__ccgo_fp__Xsqlite3session_table_filter_1 = func(*libc.TLS, uintptr, uintptr) int32

type time_t = Ttime_t

type timespec = Ttimespec

type timeval = Ttimeval

const tkCREATE = 4

const tkEND = 7

const tkEXPLAIN = 3

const tkOTHER = 2

const tkSEMI = 0

const tkTEMP = 5

const tkTRIGGER = 6

const tkWS = 1

type u16 = Tu16

type u32 = Tu32

type u64 = Tu64

type u8 = Tu8

type u_char = Tu_char

type u_int = Tu_int

type u_long = Tu_long

type u_short = Tu_short

type uint16_t = Tuint16_t

type uint32_t = Tuint32_t

type uint64_t = Tuint64_t

type uint8_t = Tuint8_t

type uint_fast16_t = Tuint_fast16_t

type uint_fast8_t = Tuint_fast8_t

type uint_least16_t = Tuint_least16_t

type uint_least32_t = Tuint_least32_t

type uint_least64_t = Tuint_least64_t

type uint_least8_t = Tuint_least8_t

type uintptr_t = Tuintptr_t

type uptr = Tuptr

/*
** Bits for the sqlite3WhereTrace mask:
**
** (---any--)   Top-level block structure
** 0x-------F   High-level debug messages
** 0x----FFF-   More detail
** 0xFFFF----   Low-level debug messages
**
** 0x00000001   Code generation
** 0x00000002   Solver (Use 0x40000 for less detail)
** 0x00000004   Solver costs
** 0x00000008   WhereLoop inserts
**
** 0x00000010   Display sqlite3_index_info xBestIndex calls
** 0x00000020   Range an equality scan metrics
** 0x00000040   IN operator decisions
** 0x00000080   WhereLoop cost adjustments
** 0x00000100
** 0x00000200   Covering index decisions
** 0x00000400   OR optimization
** 0x00000800   Index scanner
** 0x00001000   More details associated with code generation
** 0x00002000
** 0x00004000   Show all WHERE terms at key points
** 0x00008000   Show the full SELECT statement at key places
**
** 0x00010000   Show more detail when printing WHERE terms
** 0x00020000   Show WHERE terms returned from whereScanNext()
** 0x00040000   Solver overview messages
** 0x00080000   Star-query heuristic
** 0x00100000   Pointers are all shown as zero
 */

type useconds_t = Tuseconds_t

type va_list = Tva_list

const vfsList = 0

type wchar_t = Twchar_t

const wsdAutoext = 0

const wsdHooks = 0

const wsdPrng = 0

const wsdStat = 0

type yDbMask = TyDbMask

type ynVar = TynVar

type yyParser = TyyParser

/* #include <assert.h> */

type yyStackEntry = TyyStackEntry
